ARM: Add ARMv6 or older __sync_synchronize built-in

* On ARMv6 or older, we do a simulated dsb.
* Move __sync_synchronize into thread.c in libroot
  and use the new arch_atomic.h dsb/dmb defines.
* Gets arm @bootstrap-raw to end of bootstrap.
This commit is contained in:
Alexander von Gluck IV 2014-02-26 12:49:38 -06:00
parent cb7de03cca
commit a21611e439
3 changed files with 41 additions and 16 deletions

View File

@ -9,29 +9,41 @@
#define _KERNEL_ARCH_ARM_ATOMIC_H
#if __ARM_ARCH__ <= 6
#define dsb() __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4" \
: : "r" (0) : "memory")
#define dmb() __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4" \
: : "r" (0) : "memory")
#else
#define dsb() __asm__ __volatile__("dsb" : : : "memory")
#define dmb() __asm__ __volatile__("dmb" : : : "memory")
#endif
static inline void
memory_read_barrier_inline(void)
{
asm volatile ("":::"memory");
dmb();
}
static inline void
memory_write_barrier_inline(void)
{
asm volatile ("":::"memory");
dmb();
}
static inline void
memory_full_barrier_inline(void)
{
asm volatile ("":::"memory");
dmb();
}
#define memory_read_barrier memory_read_barrier_inline
#define memory_write_barrier memory_write_barrier_inline
#define memory_full_barrier memory_full_barrier_inline
#define memory_read_barrier memory_read_barrier_inline
#define memory_write_barrier memory_write_barrier_inline
#define memory_full_barrier memory_full_barrier_inline
#endif // _KERNEL_ARCH_ARM_ATOMIC_H

View File

@ -6,6 +6,7 @@
#include <asm_defs.h>
#include <arch_config.h>
.text
#ifndef ATOMIC_FUNCS_ARE_SYSCALLS
@ -22,9 +23,6 @@ miss1: ldrex r12, [r0]
bx lr
FUNCTION_END(atomic_add)
/* int atomic_and(int *value, int andValue)
*/
FUNCTION(atomic_and):
@ -88,13 +86,6 @@ FUNCTION(atomic_get):
bx lr
FUNCTION_END(atomic_get)
/* void __sync_synchronize(void)
*/
FUNCTION(__sync_synchronize):
dmb
bx lr
FUNCTION_END(__sync_synchronize)
#endif /* ATOMIC_FUNCS_ARE_SYSCALLS */
#ifndef ATOMIC64_FUNCS_ARE_SYSCALLS

View File

@ -1,4 +1,16 @@
/*
* Copyright 2012-2014, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Jerome Duval <jerome.duval@free.fr>
* Alexander von Gluck IV <kallisti5@unixzen.com>
*/
#include <OS.h>
#include <arch_atomic.h>
#include "syscalls.h"
@ -7,3 +19,13 @@ find_thread(const char *name)
{
return _kern_find_thread(name);
}
/*
* Fill out gcc __sync_synchronize built-in for ARM
*/
void
__sync_synchronize(void)
{
dsb();
}