diff --git a/src/system/boot/arch/mipsel/Jamfile b/src/system/boot/arch/mipsel/Jamfile new file mode 100644 index 0000000000..55f63e6d73 --- /dev/null +++ b/src/system/boot/arch/mipsel/Jamfile @@ -0,0 +1,21 @@ +SubDir HAIKU_TOP src system boot arch mipsel ; + +DEFINES += _BOOT_MODE ; + +local kernelLibArchObjects = + byteorder.o + memcpy.o + memset.o +; + +KernelMergeObject boot_arch_$(TARGET_ARCH).o : + arch_elf.cpp + : # additional flags + : + $(kernelArchObjects) + $(kernelLibArchObjects) +; + +SEARCH on [ FGristFiles arch_elf.cpp ] + = [ FDirName $(HAIKU_TOP) src system kernel arch $(TARGET_ARCH) ] ; + diff --git a/src/system/libroot/os/arch/mipsel/Jamfile b/src/system/libroot/os/arch/mipsel/Jamfile new file mode 100644 index 0000000000..b3260f6962 --- /dev/null +++ b/src/system/libroot/os/arch/mipsel/Jamfile @@ -0,0 +1,20 @@ +SubDir HAIKU_TOP src system libroot os arch mipsel ; + +UsePrivateKernelHeaders ; + # TODO: Replace by "UsePrivateHeaders libroot" after resolving the TODO in + # time.c! +UsePrivateSystemHeaders ; + +MergeObject os_arch_$(TARGET_ARCH).o : + atomic.S + byteorder.S + compatibility.c # only here until the places where those functions are used + # are fixed + stack_frame.c +# systeminfo.c + system_time.c + system_time_asm.S + thread.c + time.c + tls.c +; diff --git a/src/system/libroot/os/arch/mipsel/atomic.S b/src/system/libroot/os/arch/mipsel/atomic.S new file mode 100644 index 0000000000..8270007bcf --- /dev/null +++ b/src/system/libroot/os/arch/mipsel/atomic.S @@ -0,0 +1,46 @@ +/* + * Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ + +#define FUNCTION(x) .global x; .type x,@function; x + +#warning MIPSEL: fixme + +.text + +/* int atomic_add(int *value, int increment) + * (r3) r3 r4 + */ +FUNCTION(atomic_add): +lost1: jr $ra + +/* int atomic_and(int *value, int andValue) + * (r3) r3 r4 + */ +FUNCTION(atomic_and): +lost2: jr $ra + +/* int atomic_or(int *value, int orValue) + * (r3) r3 r4 + */ +FUNCTION(atomic_or): +lost3: jr $ra + +/* int atomic_set(int *value, int setTo) + * (r3) r3 r4 + */ +FUNCTION(atomic_set): +lost4: jr $ra + +/* int atomic_test_and_set(int *value, int setTo, int testValue) + * (r3) r3 r4 r5 + */ +FUNCTION(atomic_test_and_set): +lost5: jr $ra + +/* int atomic_get(int *value) + * (r3) r3 + */ +FUNCTION(atomic_get): +lost6: jr $ra diff --git a/src/system/libroot/os/arch/mipsel/byteorder.S b/src/system/libroot/os/arch/mipsel/byteorder.S new file mode 100644 index 0000000000..2072b78f5f --- /dev/null +++ b/src/system/libroot/os/arch/mipsel/byteorder.S @@ -0,0 +1,49 @@ +/* + * Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the OpenBeOS License. + */ + +#define FUNCTION(x) .global x; .type x,@function; x + +#warning MIPSEL: fixme + +.text + +/* uint16 __swap_int16(uint16 value) + * r3 + */ +FUNCTION(__swap_int16): + jr $ra + + +/* uint32 __swap_int32(uint32 value) + * r3 + */ +FUNCTION(__swap_int32): + jr $ra + + +/* uint64 __swap_int64(uint64 value) + * r3/r4 + */ +FUNCTION(__swap_int64): + jr $ra + + +/* TODO: The following functions can surely be optimized. A simple optimization + * would be to define macros with the contents of the __swap_int{32,64} + * functions and use those instead of calling the functions. + */ + +/* float __swap_float(float value) + * f1 + */ +FUNCTION(__swap_float): + jr $ra + +/* double __swap_double(double value) + * f1 + */ +FUNCTION(__swap_double): + jr $ra + diff --git a/src/system/libroot/os/arch/mipsel/compatibility.c b/src/system/libroot/os/arch/mipsel/compatibility.c new file mode 100644 index 0000000000..1411ca6560 --- /dev/null +++ b/src/system/libroot/os/arch/mipsel/compatibility.c @@ -0,0 +1,44 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +// This file includes some known R5 syscalls +// ToDo: maybe they should indeed do something... + +#include + + +int _kset_mon_limit_(int num); +int _kset_fd_limit_(int num); +int _kget_cpu_state_(int cpuNum); +int _kset_cpu_state_(int cpuNum, int state); + + +int +_kset_mon_limit_(int num) +{ + return B_ERROR; +} + + +int +_kset_fd_limit_(int num) +{ + return B_ERROR; +} + + +int +_kget_cpu_state_(int cpuNum) +{ + return 1; +} + + +int +_kset_cpu_state_(int cpuNum, int state) +{ + return state ? B_OK : B_ERROR; +} + diff --git a/src/system/libroot/os/arch/mipsel/stack_frame.c b/src/system/libroot/os/arch/mipsel/stack_frame.c new file mode 100644 index 0000000000..c52213a61c --- /dev/null +++ b/src/system/libroot/os/arch/mipsel/stack_frame.c @@ -0,0 +1,24 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include + +#include + + +void* +get_stack_frame(void) +{ + // TODO: Implement! + return NULL; +} + + +void* +__arch_get_caller(void) +{ + // TODO: Implement! + return NULL; +} diff --git a/src/system/libroot/os/arch/mipsel/syscalls.inc b/src/system/libroot/os/arch/mipsel/syscalls.inc new file mode 100644 index 0000000000..c3e49ca6bb --- /dev/null +++ b/src/system/libroot/os/arch/mipsel/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/mipsel/system_time.c b/src/system/libroot/os/arch/mipsel/system_time.c new file mode 100644 index 0000000000..3bc6e2cb2e --- /dev/null +++ b/src/system/libroot/os/arch/mipsel/system_time.c @@ -0,0 +1,29 @@ +/* + * Copyright 2006, Ingo Weinhold . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include + +#include +#include +#include + + +static vint32 *sConversionFactor; + +void +__mipsel_setup_system_time(vint32 *cvFactor) +{ + sConversionFactor = cvFactor; +} + + +bigtime_t +system_time(void) +{ + uint64 timeBase = __mipsel_get_time_base(); + + uint32 cv = *sConversionFactor; + return (timeBase >> 32) * cv + (((timeBase & 0xffffffff) * cv) >> 32); +} diff --git a/src/system/libroot/os/arch/mipsel/system_time_asm.S b/src/system/libroot/os/arch/mipsel/system_time_asm.S new file mode 100644 index 0000000000..569c941a87 --- /dev/null +++ b/src/system/libroot/os/arch/mipsel/system_time_asm.S @@ -0,0 +1,18 @@ +/* + * Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the OpenBeOS License. + */ + +#define FUNCTION(x) .global x; .type x,@function; x + +#warning MIPSEL: fixme + +.text + +/* int64 __mipsel_get_time_base(void) + * r3/r4 + */ +FUNCTION(__mipsel_get_time_base): + /* get TB (time base) register */ +carry: jr $ra + diff --git a/src/system/libroot/os/arch/mipsel/thread.c b/src/system/libroot/os/arch/mipsel/thread.c new file mode 100644 index 0000000000..df90b6ad6a --- /dev/null +++ b/src/system/libroot/os/arch/mipsel/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/mipsel/time.c b/src/system/libroot/os/arch/mipsel/time.c new file mode 100644 index 0000000000..ca534debbf --- /dev/null +++ b/src/system/libroot/os/arch/mipsel/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; + } + + __mipsel_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/mipsel/tls.c b/src/system/libroot/os/arch/mipsel/tls.c new file mode 100644 index 0000000000..4ffd760532 --- /dev/null +++ b/src/system/libroot/os/arch/mipsel/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/posix/arch/mipsel/Jamfile b/src/system/libroot/posix/arch/mipsel/Jamfile new file mode 100644 index 0000000000..c1200bf8dc --- /dev/null +++ b/src/system/libroot/posix/arch/mipsel/Jamfile @@ -0,0 +1,16 @@ +SubDir HAIKU_TOP src system libroot posix arch mipsel ; + +local genericSources = + setjmp_save_sigs.c + longjmp_return.c +; + +MergeObject posix_arch_$(TARGET_ARCH).o : + sigsetjmp.S + siglongjmp.S + + $(genericSources) +; + +SEARCH on [ FGristFiles $(genericSources) ] + = [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; diff --git a/src/system/libroot/posix/arch/mipsel/setjmp_internal.h b/src/system/libroot/posix/arch/mipsel/setjmp_internal.h new file mode 100644 index 0000000000..4cffd9f27a --- /dev/null +++ b/src/system/libroot/posix/arch/mipsel/setjmp_internal.h @@ -0,0 +1,49 @@ +/* + * Copyright 2005, Ingo Weinhold . All rights + * reserved. Distributed under the terms of the Haiku License. + */ +#ifndef SETJMP_INTERNAL_H +#define SETJMP_INTERNAL_H + +#error MIPSEL: fixme + +/* PPC function call ABI register use: + r0 - volatile + r1 - stack frame + r2 - reserved + r3-r4 - param passing, return values + r5-r10 - param passing + r11-r12 - volatile + r13 - small data pointer + r14-r30 - local vars + r31 - local vars/environment +*/ + +/* These are the fields of the __jmp_regs structure */ +#define JMP_REGS_R1 0 +#define JMP_REGS_R2 4 +#define JMP_REGS_R13 8 +#define JMP_REGS_R14 12 +#define JMP_REGS_R15 16 +#define JMP_REGS_R16 20 +#define JMP_REGS_R17 24 +#define JMP_REGS_R18 28 +#define JMP_REGS_R19 32 +#define JMP_REGS_R20 36 +#define JMP_REGS_R21 40 +#define JMP_REGS_R22 44 +#define JMP_REGS_R23 48 +#define JMP_REGS_R24 52 +#define JMP_REGS_R25 56 +#define JMP_REGS_R26 60 +#define JMP_REGS_R27 64 +#define JMP_REGS_R28 68 +#define JMP_REGS_R29 72 +#define JMP_REGS_R30 76 +#define JMP_REGS_R31 80 +#define JMP_REGS_LR 84 +#define JMP_REGS_CR 88 + +#define FUNCTION(x) .global x; .type x,@function; x + +#endif /* SETJMP_INTERNAL_H */ diff --git a/src/system/libroot/posix/arch/mipsel/siglongjmp.S b/src/system/libroot/posix/arch/mipsel/siglongjmp.S new file mode 100644 index 0000000000..580fc570dd --- /dev/null +++ b/src/system/libroot/posix/arch/mipsel/siglongjmp.S @@ -0,0 +1,48 @@ +#error XXX +/* + * Copyright 2005, Ingo Weinhold . All rights + * reserved. Distributed under the terms of the Haiku License. + */ + +#include "setjmp_internal.h" + +#error MIPSEL: fixme + +/* int __siglongjmp(jmp_buf buffer, int value) */ +FUNCTION(siglongjmp): +FUNCTION(longjmp): +FUNCTION(_longjmp): + // r3: buffer, r4: saveMask + + // restore non-volatile general purpose registers + lwz %r1, JMP_REGS_R1(3) + lwz %r2, JMP_REGS_R2(3) + lwz %r13, JMP_REGS_R13(3) + lwz %r14, JMP_REGS_R14(3) + lwz %r15, JMP_REGS_R15(3) + lwz %r16, JMP_REGS_R16(3) + lwz %r17, JMP_REGS_R17(3) + lwz %r18, JMP_REGS_R18(3) + lwz %r19, JMP_REGS_R19(3) + lwz %r20, JMP_REGS_R20(3) + lwz %r21, JMP_REGS_R21(3) + lwz %r22, JMP_REGS_R22(3) + lwz %r23, JMP_REGS_R23(3) + lwz %r24, JMP_REGS_R24(3) + lwz %r25, JMP_REGS_R25(3) + lwz %r26, JMP_REGS_R26(3) + lwz %r27, JMP_REGS_R27(3) + lwz %r28, JMP_REGS_R28(3) + lwz %r29, JMP_REGS_R29(3) + lwz %r30, JMP_REGS_R30(3) + lwz %r31, JMP_REGS_R31(3) + + // restore special registers (link, condition) + lwz %r0, JMP_REGS_LR(3) + mtlr %r0 + lwz %r0, JMP_REGS_CR(3) + mtcr %r0 + + b __longjmp_return + +#pragma weak longjmp=siglongjmp diff --git a/src/system/libroot/posix/arch/mipsel/sigsetjmp.S b/src/system/libroot/posix/arch/mipsel/sigsetjmp.S new file mode 100644 index 0000000000..8edd1cc340 --- /dev/null +++ b/src/system/libroot/posix/arch/mipsel/sigsetjmp.S @@ -0,0 +1,54 @@ +#error XXX +/* + * Copyright 2005, Ingo Weinhold . All rights + * reserved. Distributed under the terms of the Haiku License. + */ + +#include "setjmp_internal.h" + +#error MIPSEL: fixme + +/* int sigsetjmp(jmp_buf buffer, int saveMask) */ +FUNCTION(__sigsetjmp): +FUNCTION(sigsetjmp): + // r3: buffer, r4: saveMask + + // store non-volatile general purpose registers + stw %r1, JMP_REGS_R1(3) + stw %r2, JMP_REGS_R2(3) + stw %r13, JMP_REGS_R13(3) + stw %r14, JMP_REGS_R14(3) + stw %r15, JMP_REGS_R15(3) + stw %r16, JMP_REGS_R16(3) + stw %r17, JMP_REGS_R17(3) + stw %r18, JMP_REGS_R18(3) + stw %r19, JMP_REGS_R19(3) + stw %r20, JMP_REGS_R20(3) + stw %r21, JMP_REGS_R21(3) + stw %r22, JMP_REGS_R22(3) + stw %r23, JMP_REGS_R23(3) + stw %r24, JMP_REGS_R24(3) + stw %r25, JMP_REGS_R25(3) + stw %r26, JMP_REGS_R26(3) + stw %r27, JMP_REGS_R27(3) + stw %r28, JMP_REGS_R28(3) + stw %r29, JMP_REGS_R29(3) + stw %r30, JMP_REGS_R30(3) + stw %r31, JMP_REGS_R31(3) + + // store special registers (link, condition) + mflr %r0 + stw %r0, JMP_REGS_LR(3) + mfcr %r0 + stw %r0, JMP_REGS_CR(3) + + b __setjmp_save_sigs + + +/* int setjmp(jmp_buf buffer) */ +FUNCTION(setjmp): + // call __sigsetjmp with saveMask = 0 + addi %r4, 0, 0 + b __sigsetjmp + +#pragma weak _setjmp=setjmp