From 57c324a753e3d6b54728b520588373184f7237c2 Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Sun, 1 Apr 2012 13:59:42 +0200 Subject: [PATCH] arm: added some missing arch bits and changed asm section for arm compat. --- build/jam/HaikuImage | 2 + .../system/arch/arm/arch_real_time_data.h | 5 ++ src/system/glue/arch/arm/Jamfile | 7 ++ src/system/glue/arch/arm/crti.S | 30 +++++++ src/system/glue/arch/arm/crtn.S | 19 ++++ src/system/libroot/os/arch/arm/Jamfile | 17 ++++ src/system/libroot/os/arch/arm/syscalls.inc | 88 +++++++++++++++++++ src/system/libroot/os/arch/arm/thread.c | 9 ++ src/system/libroot/os/arch/arm/time.c | 42 +++++++++ src/system/libroot/os/arch/arm/tls.c | 53 +++++++++++ src/system/libroot/os/syscalls.S | 3 + .../posix/glibc/include/libc-symbols.h | 2 +- .../libroot/posix/string/arch/arm/Jamfile | 10 +++ 13 files changed, 286 insertions(+), 1 deletion(-) create mode 100644 src/system/glue/arch/arm/Jamfile create mode 100644 src/system/glue/arch/arm/crti.S create mode 100644 src/system/glue/arch/arm/crtn.S create mode 100644 src/system/libroot/os/arch/arm/Jamfile create mode 100644 src/system/libroot/os/arch/arm/syscalls.inc create mode 100644 src/system/libroot/os/arch/arm/thread.c create mode 100644 src/system/libroot/os/arch/arm/time.c create mode 100644 src/system/libroot/os/arch/arm/tls.c create mode 100644 src/system/libroot/posix/string/arch/arm/Jamfile diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage index 8647168c73..354f601d93 100644 --- a/build/jam/HaikuImage +++ b/build/jam/HaikuImage @@ -11,6 +11,8 @@ if $(TARGET_ARCH) = x86 { PPC_ONLY = "" ; } else if $(TARGET_ARCH) = m68k { M68K_ONLY = "" ; +} else if $(TARGET_ARCH) = arm { + ARM_ONLY = "" ; } local GPL_ONLY = ; diff --git a/headers/private/system/arch/arm/arch_real_time_data.h b/headers/private/system/arch/arm/arch_real_time_data.h index de1ebf7148..149b8332b8 100644 --- a/headers/private/system/arch/arm/arch_real_time_data.h +++ b/headers/private/system/arch/arm/arch_real_time_data.h @@ -10,7 +10,12 @@ #warning ARM: fix system_time() +struct arm_real_time_data { + vint64 system_time_offset; +}; + struct arch_real_time_data { + struct arm_real_time_data data[2]; vint32 system_time_conversion_factor; vint32 version; }; diff --git a/src/system/glue/arch/arm/Jamfile b/src/system/glue/arch/arm/Jamfile new file mode 100644 index 0000000000..3d54e9408b --- /dev/null +++ b/src/system/glue/arch/arm/Jamfile @@ -0,0 +1,7 @@ +SubDir HAIKU_TOP src system glue arch arm ; + +KernelObjects + crti.S + crtn.S + ; + diff --git a/src/system/glue/arch/arm/crti.S b/src/system/glue/arch/arm/crti.S new file mode 100644 index 0000000000..337c772ec2 --- /dev/null +++ b/src/system/glue/arch/arm/crti.S @@ -0,0 +1,30 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + +/** This file contains the first part of the ".init" and ".fini" sections in + * the ELF executable. + * The functions defined here will be called during initialization/termination + * of the loaded executable/library. The ".init" and ".fini" sections are + * stacked together like this: + * + * crti.S entry point + * call to _init_before/_term_before + * crtbegin.S GCC specific: constructors/destructors are called, ... + * crtend.S + * crtn.S call to _init_after/_term_after + * exit + */ + +#define FUNCTION(x) .global x; .type x,%function; x + +.section .init +FUNCTION(_init): + bl __haiku_init_before + // crtbegin.o stuff comes here + +.section .fini +FUNCTION(_fini): + bl __haiku_term_before + // crtbegin.o stuff comes here diff --git a/src/system/glue/arch/arm/crtn.S b/src/system/glue/arch/arm/crtn.S new file mode 100644 index 0000000000..125022e37d --- /dev/null +++ b/src/system/glue/arch/arm/crtn.S @@ -0,0 +1,19 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + +/** This file contains the final part of the ".init" and ".fini" sections in + * the ELF executable. It is tightly connected to crti.S. + * Have a look at crti.S to find a description of what happens here. + */ + +.section .init + // the image ID and program args are still on the stack + bl __haiku_init_after + + +.section .fini + // the image ID and program args are still on the stack + bl __haiku_term_after + diff --git a/src/system/libroot/os/arch/arm/Jamfile b/src/system/libroot/os/arch/arm/Jamfile new file mode 100644 index 0000000000..52b5f241fb --- /dev/null +++ b/src/system/libroot/os/arch/arm/Jamfile @@ -0,0 +1,17 @@ +SubDir HAIKU_TOP src system libroot os arch arm ; + +UsePrivateKernelHeaders ; +UsePrivateSystemHeaders ; + +SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; + +MergeObject os_arch_$(TARGET_ARCH).o : + atomic.S + byteorder.S + system_time.c + thread.c + time.c + tls.c + + generic_system_time_nsecs.cpp +; diff --git a/src/system/libroot/os/arch/arm/syscalls.inc b/src/system/libroot/os/arch/arm/syscalls.inc new file mode 100644 index 0000000000..1e691f2416 --- /dev/null +++ b/src/system/libroot/os/arch/arm/syscalls.inc @@ -0,0 +1,88 @@ +/* +** Copyright 2001, Travis Geiselbrecht. All rights reserved. +** Distributed under the terms of the NewOS License. +*/ +#define SYSCALL0(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL1(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL2(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL3(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL4(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL5(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL6(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL7(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL8(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL9(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL10(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL11(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL12(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + +#define SYSCALL13(name, n) \ +.globl name; \ +.type name,%function; \ +.align 4; \ +name: + diff --git a/src/system/libroot/os/arch/arm/thread.c b/src/system/libroot/os/arch/arm/thread.c new file mode 100644 index 0000000000..df90b6ad6a --- /dev/null +++ b/src/system/libroot/os/arch/arm/thread.c @@ -0,0 +1,9 @@ +#include +#include "syscalls.h" + + +thread_id +find_thread(const char *name) +{ + return _kern_find_thread(name); +} diff --git a/src/system/libroot/os/arch/arm/time.c b/src/system/libroot/os/arch/arm/time.c new file mode 100644 index 0000000000..9a16dedd15 --- /dev/null +++ b/src/system/libroot/os/arch/arm/time.c @@ -0,0 +1,42 @@ +/* + * Copyright 2006, Ingo Weinhold . + * Distributed under the terms of the MIT License. + */ + +#include + +#include +#include +#include + + +static struct arch_real_time_data *sRealTimeData; + +void +__arch_init_time(struct real_time_data *data, bool setDefaults) +{ + sRealTimeData = &data->arch_data; + + if (setDefaults) { + sRealTimeData->data[0].system_time_offset = 0; + sRealTimeData->system_time_conversion_factor = 1000000000LL; + sRealTimeData->version = 0; + } + + __arm_setup_system_time(&sRealTimeData->system_time_conversion_factor); +} + + +bigtime_t +__arch_get_system_time_offset(struct real_time_data *data) +{ + int32 version; + bigtime_t offset; + do { + version = sRealTimeData->version; + offset = sRealTimeData->data[version % 2].system_time_offset; + } while (version != sRealTimeData->version); + + return offset; +} + diff --git a/src/system/libroot/os/arch/arm/tls.c b/src/system/libroot/os/arch/arm/tls.c new file mode 100644 index 0000000000..4ffd760532 --- /dev/null +++ b/src/system/libroot/os/arch/arm/tls.c @@ -0,0 +1,53 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + +// ToDo: this is a dummy implementation - I've not yet gained enough knowledge +// to decide how this should be done, so it's just broken now (okay for single +// threaded apps, though). + +// we don't want to have the inline assembly included here +#ifndef _NO_INLINE_ASM +# define _NO_INLINE_ASM 1 +#endif + +#include "support/TLS.h" +#include "tls.h" + + +static int32 gNextSlot = TLS_FIRST_FREE_SLOT; +static void *gSlots[TLS_MAX_KEYS]; + + +int32 +tls_allocate(void) +{ + int32 next = atomic_add(&gNextSlot, 1); + if (next >= TLS_MAX_KEYS) + return B_NO_MEMORY; + + return next; +} + + +void * +tls_get(int32 index) +{ + return gSlots[index]; +} + + +void ** +tls_address(int32 index) +{ + return &gSlots[index]; +} + + +void +tls_set(int32 index, void *value) +{ + gSlots[index] = value; +} + diff --git a/src/system/libroot/os/syscalls.S b/src/system/libroot/os/syscalls.S index e54624dae7..770da146bc 100644 --- a/src/system/libroot/os/syscalls.S +++ b/src/system/libroot/os/syscalls.S @@ -22,6 +22,9 @@ #ifdef ARCH_ppc # include "arch/ppc/syscalls.inc" #endif +#ifdef ARCH_arm +# include "arch/arm/syscalls.inc" +#endif #ifdef ARCH_m68k # include "arch/m68k/syscalls.inc" #endif diff --git a/src/system/libroot/posix/glibc/include/libc-symbols.h b/src/system/libroot/posix/glibc/include/libc-symbols.h index ecea00687e..d0de8f91bb 100644 --- a/src/system/libroot/posix/glibc/include/libc-symbols.h +++ b/src/system/libroot/posix/glibc/include/libc-symbols.h @@ -247,7 +247,7 @@ __attribute__ ((unused, section (".gnu.warning." #symbol __sec_comment))) \ = msg; # define libc_freeres_ptr(decl) \ - __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", @nobits") \ + __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \ decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment))) # define __libc_freeres_fn_section \ __attribute__ ((section ("__libc_freeres_fn"))) diff --git a/src/system/libroot/posix/string/arch/arm/Jamfile b/src/system/libroot/posix/string/arch/arm/Jamfile new file mode 100644 index 0000000000..6d67684cff --- /dev/null +++ b/src/system/libroot/posix/string/arch/arm/Jamfile @@ -0,0 +1,10 @@ +SubDir HAIKU_TOP src system libroot posix string arch arm ; + +UsePrivateSystemHeaders ; + +SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; + +MergeObject posix_string_arch_$(TARGET_ARCH).o : + memcpy.c + memset.c +;