diff --git a/headers/private/kernel/arch/mipsel/arch_cpu.h b/headers/private/kernel/arch/mipsel/arch_cpu.h new file mode 100644 index 0000000000..19c5952da6 --- /dev/null +++ b/headers/private/kernel/arch/mipsel/arch_cpu.h @@ -0,0 +1,90 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_MIPSEL_CPU_H +#define _KERNEL_ARCH_MIPSEL_CPU_H + + +#warning IMPLEMENT arch_cpu.h + + +#include +#include + + +struct iframe { +#warning struct iframe + uint32 r31; + uint32 r30; + uint32 r29; + uint32 r28; + uint32 r27; + uint32 r26; + uint32 r25; + uint32 r24; + uint32 r23; + uint32 r22; + uint32 r21; + uint32 r20; + uint32 r19; + uint32 r18; + uint32 r17; + uint32 r16; + uint32 r15; + uint32 r14; + uint32 r13; + uint32 r12; + uint32 r11; + uint32 r10; + uint32 r9; + uint32 r8; + uint32 r7; + uint32 r6; + uint32 r5; + uint32 r4; + uint32 r3; + uint32 r2; + uint32 r1; + uint32 r0; +}; + +typedef struct arch_cpu_info { + int null; +} arch_cpu_info; + + +#ifdef __cplusplus +extern "C" { +#endif + + +extern long long get_time_base(void); + +void __mipsel_setup_system_time(vint32 *cvFactor); + // defined in libroot: os/arch/system_time.c + +int64 __mipsel_get_time_base(void); + // defined in libroot: os/arch/system_time_asm.S + +extern void mipsel_context_switch(void **_oldStackPointer, + void *newStackPointer); + +extern bool mipsel_set_fault_handler(addr_t *handlerLocation, addr_t handler) + __attribute__((noinline)); + +#ifdef __cplusplus +} +#endif + + +/* TODO */ +enum mipsel_processor_version { + FAKE1 = 0x0001, + FAKE2 = 0x0002, + FAKE3 = 0x0003, +}; + + +#endif /* _KERNEL_ARCH_MIPSEL_CPU_H */ + diff --git a/headers/private/kernel/arch/mipsel/arch_int.h b/headers/private/kernel/arch/mipsel/arch_int.h new file mode 100644 index 0000000000..de1e99cb4f --- /dev/null +++ b/headers/private/kernel/arch/mipsel/arch_int.h @@ -0,0 +1,48 @@ +/* + * Copyright 2005-2009, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel Dörfler + * Ingo Weinhold + */ +#ifndef _KERNEL_ARCH_MIPSEL_INT_H +#define _KERNEL_ARCH_MIPSEL_INT_H + + +#include + + +#warning IMPLEMENT arch_int.h + + +#define NUM_IO_VECTORS 256 + + +struct mipsel_cpu_exception_context { + void *kernel_handle_exception; // exception handler routine in the + // kernel + void *exception_context; // the virtual address of this + // structure + void *kernel_stack; // kernel stack for the current thread + + uint32 scratch[8]; // scratch memory for free use in the + // early exception handling code +}; + +#ifdef __cplusplus +extern "C" { +#endif + +struct mipsel_cpu_exception_context* mipsel_get_cpu_exception_context(int cpu); + +void mipsel_set_current_cpu_exception_context( + struct mipsel_cpu_exception_context *context); + // only called once per CPU + +#ifdef __cplusplus +} +#endif + +#endif /* _KERNEL_ARCH_MIPSEL_INT_H */ + diff --git a/headers/private/kernel/arch/mipsel/arch_kernel.h b/headers/private/kernel/arch/mipsel/arch_kernel.h new file mode 100644 index 0000000000..6eea165c55 --- /dev/null +++ b/headers/private/kernel/arch/mipsel/arch_kernel.h @@ -0,0 +1,36 @@ +/* + * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. + */ +#ifndef _KERNEL_ARCH_MIPSEL_KERNEL_H +#define _KERNEL_ARCH_MIPSEL_KERNEL_H + +#include + +#warning IMPLEMENT arch_kernel.h + +// memory layout +#define KERNEL_BASE 0x80000000 +#define KERNEL_SIZE 0x80000000 +#define KERNEL_TOP (KERNEL_BASE + (KERNEL_SIZE - 1)) + +/* + * User space layout is a little special: + * The user space does not completely cover the space not covered by the kernel. + * This is accomplished by starting user space at 1Mb and running to 64kb short + * of kernel space. The lower 1Mb reserved spot makes it easy to find null + * pointer references and guarantees a region wont be placed there. The 64kb + * region assures a user space thread cannot pass a buffer into the kernel as + * part of a syscall that would cross into kernel space. + */ +#define USER_BASE 0x100000 +#define USER_BASE_ANY USER_BASE +#define USER_SIZE (0x80000000 - (0x10000 + 0x100000)) +#define USER_TOP (USER_BASE + USER_SIZE) + +#define KERNEL_USER_DATA_BASE 0x6fff0000 +#define USER_STACK_REGION 0x70000000 +#define USER_STACK_REGION_SIZE (USER_TOP - USER_STACK_REGION) + +#endif /* _KERNEL_ARCH_MIPSEL_KERNEL_H */ + diff --git a/headers/private/kernel/arch/mipsel/arch_kernel_args.h b/headers/private/kernel/arch/mipsel/arch_kernel_args.h new file mode 100644 index 0000000000..29c310276c --- /dev/null +++ b/headers/private/kernel/arch/mipsel/arch_kernel_args.h @@ -0,0 +1,31 @@ +/* + * Copyright 2009, Axel Dörfler, axeld@pinc-software.de. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_MIPSEL_KERNEL_ARGS_H +#define _KERNEL_ARCH_MIPSEL_KERNEL_ARGS_H + +#ifndef KERNEL_BOOT_KERNEL_ARGS_H +# error This file is included from only +#endif + +#warning IMPLEMENT arch_kernel_args.h + +#define _PACKED __attribute__((packed)) + +// kernel args +typedef struct { + int cpu_type; + int fpu_type; + int mmu_type; + int platform; + int machine; + + // architecture specific + uint64 cpu_frequency; + uint64 bus_frequency; + uint64 time_base_frequency; +} arch_kernel_args; + +#endif /* _KERNEL_ARCH_MIPSEL_KERNEL_ARGS_H */ + diff --git a/headers/private/kernel/arch/mipsel/arch_mmu.h b/headers/private/kernel/arch/mipsel/arch_mmu.h new file mode 100644 index 0000000000..6a225508b6 --- /dev/null +++ b/headers/private/kernel/arch/mipsel/arch_mmu.h @@ -0,0 +1,14 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_MIPSEL_MMU_H +#define _KERNEL_ARCH_MIPSEL_MMU_H + +#include + +#warning IMPLEMENT arch_mmu.h + + +#endif /* _KERNEL_ARCH_MIPSEL_MMU_H */ + diff --git a/headers/private/kernel/arch/mipsel/arch_platform.h b/headers/private/kernel/arch/mipsel/arch_platform.h new file mode 100644 index 0000000000..db15b3b30c --- /dev/null +++ b/headers/private/kernel/arch/mipsel/arch_platform.h @@ -0,0 +1,53 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_MIPSEL_PLATFORM_H +#define _KERNEL_ARCH_MIPSEL_PLATFORM_H + +#include + +#warning IMPLEMENT arch_platform.h + +struct real_time_data; + +enum mipsel_platform_type { + MIPSEL_PLATFORM_ROUTERBOARD = 0, +}; + +namespace BPrivate { + +class MipselPlatform { +public: + MipselPlatform(mipsel_platform_type platformType); + virtual ~MipselPlatform(); + + static MipselPlatform* Default(); + + inline mipsel_platform_type PlatformType() const { return fPlatformType; } + + virtual status_t Init(struct kernel_args* kernelArgs) = 0; + virtual status_t InitSerialDebug(struct kernel_args* kernelArgs) = 0; + virtual status_t InitPostVM(struct kernel_args* kernelArgs) = 0; + virtual status_t InitRTC(struct kernel_args* kernelArgs, + struct real_time_data* data) = 0; + + virtual char SerialDebugGetChar() = 0; + virtual void SerialDebugPutChar(char c) = 0; + + virtual void SetHardwareRTC(uint32 seconds) = 0; + virtual uint32 GetHardwareRTC() = 0; + + virtual void ShutDown(bool reboot) = 0; + +private: + mipsel_platform_type fPlatformType; +}; + +} // namespace BPrivate + +using BPrivate::MipselPlatform; + + +#endif /* _KERNEL_ARCH_MIPSEL_PLATFORM_H */ + diff --git a/headers/private/kernel/arch/mipsel/arch_system_info.h b/headers/private/kernel/arch/mipsel/arch_system_info.h new file mode 100644 index 0000000000..2eac80a2f5 --- /dev/null +++ b/headers/private/kernel/arch/mipsel/arch_system_info.h @@ -0,0 +1,14 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_MIPSEL_SYSTEM_INFO_H +#define _KERNEL_ARCH_MIPSEL_SYSTEM_INFO_H + +#warning IMPLEMENT arch_system_info.h + +/* nothing to be seen here yet */ + + +#endif /* _KERNEL_ARCH_MIPSEL_SYSTEM_INFO_H */ + diff --git a/headers/private/kernel/arch/mipsel/arch_thread.h b/headers/private/kernel/arch/mipsel/arch_thread.h new file mode 100644 index 0000000000..ae16ff84b2 --- /dev/null +++ b/headers/private/kernel/arch/mipsel/arch_thread.h @@ -0,0 +1,47 @@ +/* + * Copyright 2003-2009, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold + * Jonas Sundström + */ +#ifndef _KERNEL_ARCH_MIPSEL_THREAD_H +#define _KERNEL_ARCH_MIPSEL_THREAD_H + +#include + +#warning IMPLEMENT arch_thread.h + +#ifdef __cplusplus +extern "C" { +#endif + +void mipsel_push_iframe(struct iframe_stack* stack, struct iframe* frame); +void mipsel_pop_iframe(struct iframe_stack* stack); +struct iframe* mipsel_get_user_iframe(void); + + +static inline struct thread* +arch_thread_get_current_thread(void) +{ +#warning IMPLEMENT arch_thread_get_current_thread + struct thread* t; + return t; +} + + +static inline void +arch_thread_set_current_thread(struct thread* t) +{ +#warning IMPLEMENT arch_thread_set_current_thread +} + + +#ifdef __cplusplus +} +#endif + + +#endif /* _KERNEL_ARCH_MIPSEL_THREAD_H */ + diff --git a/headers/private/kernel/arch/mipsel/arch_thread_types.h b/headers/private/kernel/arch/mipsel/arch_thread_types.h new file mode 100644 index 0000000000..cc5413b657 --- /dev/null +++ b/headers/private/kernel/arch/mipsel/arch_thread_types.h @@ -0,0 +1,41 @@ +/* +** Copyright 2001, Travis Geiselbrecht. All rights reserved. +** Distributed under the terms of the NewOS License. +*/ +#ifndef _KERNEL_ARCH_MIPSEL_THREAD_TYPES_H +#define _KERNEL_ARCH_MIPSEL_THREAD_TYPES_H + +#include + +#define IFRAME_TRACE_DEPTH 4 + +struct iframe_stack { + struct iframe *frames[IFRAME_TRACE_DEPTH]; + int32 index; +}; + +// architecture specific thread info +struct arch_thread { + void *sp; // stack pointer + void *interrupt_stack; + + // used to track interrupts on this thread + struct iframe_stack iframes; +}; + +struct arch_team { + // gcc treats empty structures as zero-length in C, but as if they contain + // a char in C++. So we have to put a dummy in to be able to use the struct + // from both in a consistent way. + char dummy; +}; + +struct arch_fork_arg { + // gcc treats empty structures as zero-length in C, but as if they contain + // a char in C++. So we have to put a dummy in to be able to use the struct + // from both in a consistent way. + char dummy; +}; + +#endif /* _KERNEL_ARCH_MIPSEL_THREAD_TYPES_H */ + diff --git a/headers/private/kernel/arch/mipsel/arch_user_debugger.h b/headers/private/kernel/arch/mipsel/arch_user_debugger.h new file mode 100644 index 0000000000..0eec54bb1d --- /dev/null +++ b/headers/private/kernel/arch/mipsel/arch_user_debugger.h @@ -0,0 +1,17 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_MIPSEL_USER_DEBUGGER_H +#define _KERNEL_ARCH_MIPSEL_USER_DEBUGGER_H + +struct arch_team_debug_info { + uint32 dummy; +}; + +struct arch_thread_debug_info { + uint32 dummy; +}; + +#endif /* _KERNEL_ARCH_MIPSEL_USER_DEBUGGER_H */ + diff --git a/headers/private/kernel/arch/mipsel/arch_vm.h b/headers/private/kernel/arch/mipsel/arch_vm.h new file mode 100644 index 0000000000..0f0e901cdc --- /dev/null +++ b/headers/private/kernel/arch/mipsel/arch_vm.h @@ -0,0 +1,16 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_MIPSEL_VM_H +#define _KERNEL_ARCH_MIPSEL_VM_H + +/* This many pages will be read/written on I/O if possible */ + +#define NUM_IO_PAGES 4 + /* 16 kB */ + +#define PAGE_SHIFT 12 + +#endif /* _KERNEL_ARCH_MIPSEL_VM_H */ + diff --git a/headers/private/kernel/arch/mipsel/arch_vm_translation_map.h b/headers/private/kernel/arch/mipsel/arch_vm_translation_map.h new file mode 100644 index 0000000000..3782b45ab3 --- /dev/null +++ b/headers/private/kernel/arch/mipsel/arch_vm_translation_map.h @@ -0,0 +1,27 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_MIPSEL_VM_TRANSLATION_MAP_H +#define _KERNEL_ARCH_MIPSEL_VM_TRANSLATION_MAP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +status_t mipsel_map_address_range(addr_t virtualAddress, addr_t physicalAddress, + size_t size); + +void mipsel_unmap_address_range(addr_t virtualAddress, size_t size); + +status_t mipsel_remap_address_range(addr_t *virtualAddress, size_t size, + bool unmap); + +#ifdef __cplusplus +} +#endif + +#endif /* _KERNEL_ARCH_MIPSEL_VM_TRANSLATION_MAP_H */ + diff --git a/headers/private/kernel/arch/mipsel/arch_vm_types.h b/headers/private/kernel/arch/mipsel/arch_vm_types.h new file mode 100644 index 0000000000..2d61a9dec5 --- /dev/null +++ b/headers/private/kernel/arch/mipsel/arch_vm_types.h @@ -0,0 +1,9 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_MIPSEL_VM_TYPES_H +#define _KERNEL_ARCH_MIPSEL_VM_TYPES_H + +#endif /* _KERNEL_ARCH_MIPSEL_VM_TYPES_H */ + diff --git a/headers/private/kernel/arch/mipsel/cpu.h b/headers/private/kernel/arch/mipsel/cpu.h new file mode 100644 index 0000000000..06fe7d2b0d --- /dev/null +++ b/headers/private/kernel/arch/mipsel/cpu.h @@ -0,0 +1,11 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_MIPSEL_CPU_H +#define _KERNEL_ARCH_MIPSEL_CPU_H + +#define PAGE_SIZE 4096 + +#endif /* _KERNEL_ARCH_MIPSEL_CPU_H */ + diff --git a/headers/private/kernel/arch/mipsel/ktypes.h b/headers/private/kernel/arch/mipsel/ktypes.h new file mode 100644 index 0000000000..74ffccd773 --- /dev/null +++ b/headers/private/kernel/arch/mipsel/ktypes.h @@ -0,0 +1,11 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_MIPSEL_KTYPES_H +#define _KERNEL_ARCH_MIPSEL_KTYPES_H + +typedef unsigned long addr; + +#endif /* _KERNEL_ARCH_MIPSEL_KTYPES_H */ + diff --git a/headers/private/kernel/arch/mipsel/types.h b/headers/private/kernel/arch/mipsel/types.h new file mode 100644 index 0000000000..92798b048b --- /dev/null +++ b/headers/private/kernel/arch/mipsel/types.h @@ -0,0 +1,18 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_MIPSEL_TYPES_H +#define _KERNEL_ARCH_MIPSEL_TYPES_H + +typedef unsigned long long uint64; +typedef long long int64; +typedef unsigned int uint32; +typedef int int32; +typedef unsigned short uint16; +typedef short int16; +typedef unsigned char uint8; +typedef char int8; + +#endif /* _KERNEL_ARCH_MIPSEL_TYPES_H */ + diff --git a/headers/private/system/arch/mipsel/arch_commpage_defs.h b/headers/private/system/arch/mipsel/arch_commpage_defs.h new file mode 100644 index 0000000000..64320ef662 --- /dev/null +++ b/headers/private/system/arch/mipsel/arch_commpage_defs.h @@ -0,0 +1,20 @@ +/* + * Copyright 2007, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_ARCH_MIPSEL_COMMPAGE_DEFS_H +#define _SYSTEM_ARCH_MIPSEL_COMMPAGE_DEFS_H + +#warning IMPLEMENT COMMPAGE + +#ifndef _SYSTEM_COMMPAGE_DEFS_H +# error Must not be included directly. Include instead! +#endif + +#define COMMPAGE_ENTRY_MIPSEL_SYSCALL (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 0) +#define COMMPAGE_ENTRY_MIPSEL_MEMCPY (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 1) + +#define ARCH_USER_COMMPAGE_ADDR (0xffff0000) + +#endif /* _SYSTEM_ARCH_MIPSEL_COMMPAGE_DEFS_H */ + diff --git a/headers/private/system/arch/mipsel/arch_config.h b/headers/private/system/arch/mipsel/arch_config.h new file mode 100644 index 0000000000..80cc93b210 --- /dev/null +++ b/headers/private/system/arch/mipsel/arch_config.h @@ -0,0 +1,19 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_ARCH_MIPSEL_CONFIG_H +#define _SYSTEM_ARCH_MIPSEL_CONFIG_H + +#warning IMPLEMENT _SYSTEM_ARCH_MIPSEL_CONFIG_H + +#define FUNCTION_CALL_PARAMETER_ALIGNMENT_TYPE unsigned int + +#define STACK_GROWS_DOWNWARDS + +//#define ATOMIC_FUNCS_ARE_SYSCALLS +#define ATOMIC64_FUNCS_ARE_SYSCALLS + + +#endif /* _SYSTEM_ARCH_MIPSEL_CONFIG_H */ + diff --git a/headers/private/system/arch/mipsel/arch_elf.h b/headers/private/system/arch/mipsel/arch_elf.h new file mode 100644 index 0000000000..7e44f36fe6 --- /dev/null +++ b/headers/private/system/arch/mipsel/arch_elf.h @@ -0,0 +1,53 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_ARCH_MIPSEL_ELF_H +#define _SYSTEM_ARCH_MIPSEL_ELF_H + + +#warning DEFINE mipsel relocation types + + +/* relocation types */ +#define R_MIPSEL_NONE 0 +#define R_MIPSEL_ADDR32 1 +#define R_MIPSEL_ADDR24 2 +#define R_MIPSEL_ADDR16 3 +#define R_MIPSEL_ADDR16_LO 4 +#define R_MIPSEL_ADDR16_HI 5 +#define R_MIPSEL_ADDR16_HA 6 +#define R_MIPSEL_ADDR14 7 +#define R_MIPSEL_ADDR14_BRTAKEN 8 +#define R_MIPSEL_ADDR14_BRNTAKEN 9 +#define R_MIPSEL_REL24 10 +#define R_MIPSEL_REL14 11 +#define R_MIPSEL_REL14_BRTAKEN 12 +#define R_MIPSEL_REL14_BRNTAKEN 13 +#define R_MIPSEL_GOT16 14 +#define R_MIPSEL_GOT16_LO 15 +#define R_MIPSEL_GOT16_HI 16 +#define R_MIPSEL_GOT16_HA 17 +#define R_MIPSEL_PLTREL24 18 +#define R_MIPSEL_COPY 19 +#define R_MIPSEL_GLOB_DAT 20 +#define R_MIPSEL_JMP_SLOT 21 +#define R_MIPSEL_RELATIVE 22 +#define R_MIPSEL_LOCAL24PC 23 +#define R_MIPSEL_UADDR32 24 +#define R_MIPSEL_UADDR16 25 +#define R_MIPSEL_REL32 26 +#define R_MIPSEL_PLT32 27 +#define R_MIPSEL_PLTREL32 28 +#define R_MIPSEL_PLT16_LO 29 +#define R_MIPSEL_PLT16_HI 30 +#define R_MIPSEL_PLT16_HA 31 +#define R_MIPSEL_SDAREL16 32 +#define R_MIPSEL_SECTOFF 33 +#define R_MIPSEL_SECTOFF_LO 34 +#define R_MIPSEL_SECTOFF_HI 35 +#define R_MIPSEL_SECTOFF_HA 36 +#define R_MIPSEL_ADDR30 37 + +#endif /* _SYSTEM_ARCH_MIPSEL_ELF_H */ + diff --git a/headers/private/system/arch/mipsel/arch_real_time_data.h b/headers/private/system/arch/mipsel/arch_real_time_data.h new file mode 100644 index 0000000000..8d5cc0f2a2 --- /dev/null +++ b/headers/private/system/arch/mipsel/arch_real_time_data.h @@ -0,0 +1,18 @@ +/* + * Copyright 2006-2009, Ingo Weinhold . + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_ARCH_REAL_TIME_DATA_H +#define _SYSTEM_ARCH_REAL_TIME_DATA_H + + +#include + + +struct arch_real_time_data { + bigtime_t system_time_offset; + uint32 system_time_conversion_factor; +}; + +#endif /* _SYSTEM_ARCH_REAL_TIME_DATA_H */ + diff --git a/headers/private/system/arch/mipsel/asm_defs.h b/headers/private/system/arch/mipsel/asm_defs.h new file mode 100644 index 0000000000..ac0868d2f8 --- /dev/null +++ b/headers/private/system/arch/mipsel/asm_defs.h @@ -0,0 +1,17 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef SYSTEM_ARCH_MIPSEL_ASM_DEFS_H +#define SYSTEM_ARCH_MIPSEL_ASM_DEFS_H + + +#define SYMBOL(name) .global name; name +#define SYMBOL_END(name) 1: .size name, 1b - name +#define STATIC_FUNCTION(name) .type name, @function; name +#define FUNCTION(name) .global name; .type name, @function; name +#define FUNCTION_END(name) 1: .size name, 1b - name + + +#endif /* SYSTEM_ARCH_MIPSEL_ASM_DEFS_H */ + diff --git a/src/system/kernel/arch/mipsel/Jamfile b/src/system/kernel/arch/mipsel/Jamfile index 9987e86466..30c4659faf 100644 --- a/src/system/kernel/arch/mipsel/Jamfile +++ b/src/system/kernel/arch/mipsel/Jamfile @@ -6,16 +6,15 @@ UsePrivateKernelHeaders ; SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; -KernelMergeObject kernel_arch_arm.o : +KernelMergeObject kernel_arch_mipsel.o : arch_asm.S -# arch_atomic.c + arch_atomic.c arch_commpage.cpp arch_cpu.cpp -# arch_cpu_asm.S arch_debug_console.cpp arch_debug.cpp arch_elf.cpp -# arch_exceptions.S + arch_exceptions.S arch_int.cpp arch_platform.cpp arch_real_time_clock.cpp diff --git a/src/system/kernel/arch/mipsel/arch_asm.S b/src/system/kernel/arch/mipsel/arch_asm.S index 165b31cbae..bb89c2cb17 100644 --- a/src/system/kernel/arch/mipsel/arch_asm.S +++ b/src/system/kernel/arch/mipsel/arch_asm.S @@ -7,9 +7,9 @@ * Distributed under the terms of the NewOS License. */ -#include #include + .text @@ -39,3 +39,8 @@ FUNCTION(arch_int_are_interrupts_enabled): nop FUNCTION_END(arch_int_are_interrupts_enabled) +/* void mipsel_context_switch(addr_t* old_sp, addr_t new_sp); */ +FUNCTION(mipsel_context_switch): + nop +FUNCTION_END(mipsel_context_switch) + diff --git a/src/system/kernel/arch/mipsel/arch_atomic.c b/src/system/kernel/arch/mipsel/arch_atomic.c new file mode 100644 index 0000000000..0d635121cd --- /dev/null +++ b/src/system/kernel/arch/mipsel/arch_atomic.c @@ -0,0 +1,238 @@ +/* + * Copyright 2003, Marcus Overhagen. All rights reserved. + * Distributed under the terms of the OpenBeOS License. + */ + +#include + +#include +#include + +/* + * Emulation of 64 bit atomic functions. + * Slow, using spinlocks... + */ + +static spinlock atomic_lock = 0; + +int64 +atomic_set64(vint64 *value, int64 newValue) +{ + cpu_status status; + int64 oldValue; + status = disable_interrupts(); + acquire_spinlock(&atomic_lock); + oldValue = *value; + *value = newValue; + release_spinlock(&atomic_lock); + restore_interrupts(status); + return oldValue; +} + +int64 +atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst) +{ + cpu_status status; + int64 oldValue; + status = disable_interrupts(); + acquire_spinlock(&atomic_lock); + oldValue = *value; + if (oldValue == testAgainst) + *value = newValue; + release_spinlock(&atomic_lock); + restore_interrupts(status); + return oldValue; +} + +int64 +atomic_add64(vint64 *value, int64 addValue) +{ + cpu_status status; + int64 oldValue; + status = disable_interrupts(); + acquire_spinlock(&atomic_lock); + oldValue = *value; + *value += addValue; + release_spinlock(&atomic_lock); + restore_interrupts(status); + return oldValue; +} + +int64 +atomic_and64(vint64 *value, int64 andValue) +{ + cpu_status status; + int64 oldValue; + status = disable_interrupts(); + acquire_spinlock(&atomic_lock); + oldValue = *value; + *value &= andValue; + release_spinlock(&atomic_lock); + restore_interrupts(status); + return oldValue; +} + +int64 +atomic_or64(vint64 *value, int64 orValue) +{ + cpu_status status; + int64 oldValue; + status = disable_interrupts(); + acquire_spinlock(&atomic_lock); + oldValue = *value; + *value |= orValue; + release_spinlock(&atomic_lock); + restore_interrupts(status); + return oldValue; +} + +int64 +atomic_get64(vint64 *value) +{ + cpu_status status; + int64 oldValue; + status = disable_interrupts(); + acquire_spinlock(&atomic_lock); + oldValue = *value; + release_spinlock(&atomic_lock); + restore_interrupts(status); + return oldValue; +} + +int64 +_user_atomic_set64(vint64 *value, int64 newValue) +{ + cpu_status status; + int64 oldValue; + if (!IS_USER_ADDRESS(value) + || lock_memory((void *)value, 8, B_READ_DEVICE) != B_OK) + goto access_violation; + + status = disable_interrupts(); + acquire_spinlock(&atomic_lock); + oldValue = *value; + *value = newValue; + release_spinlock(&atomic_lock); + restore_interrupts(status); + unlock_memory((void *)value, 8, B_READ_DEVICE); + return oldValue; + +access_violation: + // XXX kill application + return -1; +} + +int64 +_user_atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst) +{ + cpu_status status; + int64 oldValue; + if (!IS_USER_ADDRESS(value) + || lock_memory((void *)value, 8, B_READ_DEVICE) != B_OK) + goto access_violation; + + status = disable_interrupts(); + acquire_spinlock(&atomic_lock); + oldValue = *value; + if (oldValue == testAgainst) + *value = newValue; + release_spinlock(&atomic_lock); + restore_interrupts(status); + unlock_memory((void *)value, 8, B_READ_DEVICE); + return oldValue; + +access_violation: + // XXX kill application + return -1; +} + +int64 +_user_atomic_add64(vint64 *value, int64 addValue) +{ + cpu_status status; + int64 oldValue; + if (!IS_USER_ADDRESS(value) + || lock_memory((void *)value, 8, B_READ_DEVICE) != B_OK) + goto access_violation; + + status = disable_interrupts(); + acquire_spinlock(&atomic_lock); + oldValue = *value; + *value += addValue; + release_spinlock(&atomic_lock); + restore_interrupts(status); + unlock_memory((void *)value, 8, B_READ_DEVICE); + return oldValue; + +access_violation: + // XXX kill application + return -1; +} + +int64 +_user_atomic_and64(vint64 *value, int64 andValue) +{ + cpu_status status; + int64 oldValue; + if (!IS_USER_ADDRESS(value) + || lock_memory((void *)value, 8, B_READ_DEVICE) != B_OK) + goto access_violation; + + status = disable_interrupts(); + acquire_spinlock(&atomic_lock); + oldValue = *value; + *value &= andValue; + release_spinlock(&atomic_lock); + restore_interrupts(status); + unlock_memory((void *)value, 8, B_READ_DEVICE); + return oldValue; + +access_violation: + // XXX kill application + return -1; +} + +int64 +_user_atomic_or64(vint64 *value, int64 orValue) +{ + cpu_status status; + int64 oldValue; + if (!IS_USER_ADDRESS(value) + || lock_memory((void *)value, 8, B_READ_DEVICE) != B_OK) + goto access_violation; + + status = disable_interrupts(); + acquire_spinlock(&atomic_lock); + oldValue = *value; + *value |= orValue; + release_spinlock(&atomic_lock); + restore_interrupts(status); + unlock_memory((void *)value, 8, B_READ_DEVICE); + return oldValue; +access_violation: + // XXX kill application + return -1; +} + +int64 +_user_atomic_get64(vint64 *value) +{ + cpu_status status; + int64 oldValue; + if (!IS_USER_ADDRESS(value) + || lock_memory((void *)value, 8, B_READ_DEVICE) != B_OK) + goto access_violation; + + status = disable_interrupts(); + acquire_spinlock(&atomic_lock); + oldValue = *value; + release_spinlock(&atomic_lock); + restore_interrupts(status); + unlock_memory((void *)value, 8, B_READ_DEVICE); + return oldValue; + +access_violation: + // XXX kill application + return -1; +} + diff --git a/src/system/kernel/arch/mipsel/arch_cpu.cpp b/src/system/kernel/arch/mipsel/arch_cpu.cpp index 92d8e10422..160c82c0e5 100644 --- a/src/system/kernel/arch/mipsel/arch_cpu.cpp +++ b/src/system/kernel/arch/mipsel/arch_cpu.cpp @@ -10,7 +10,6 @@ #include -//#include #include #include #include @@ -168,3 +167,24 @@ arch_cpu_idle(void) #warning IMPLEMENT arch_cpu_idle } +// The purpose of this function is to trick the compiler. When setting the +// page_handler to a label that is obviously (to the compiler) never used, +// it may reorganize the control flow, so that the labeled part is optimized +// away. +// By invoking the function like this +// +// if (mipsel_set_fault_handler(faultHandler, (addr_t)&&error)) +// goto error; +// +// the compiler has to keep the labeled code, since it can't guess the return +// value of this (non-inlinable) function. At least in my tests it worked that +// way, and I hope it will continue to work like this in the future. +// +bool +mipsel_set_fault_handler(addr_t *handlerLocation, addr_t handler) +{ +// TODO: This doesn't work correctly with gcc 4 anymore! + *handlerLocation = handler; + return false; +} + diff --git a/src/system/kernel/arch/mipsel/arch_debug_console.cpp b/src/system/kernel/arch/mipsel/arch_debug_console.cpp index 8c32072b49..d94900d810 100644 --- a/src/system/kernel/arch/mipsel/arch_debug_console.cpp +++ b/src/system/kernel/arch/mipsel/arch_debug_console.cpp @@ -51,7 +51,6 @@ void arch_debug_serial_putchar(const char c) { #warning IMPLEMENT arch_debug_serial_putchar - return 0; } diff --git a/src/system/kernel/arch/mipsel/arch_exceptions.S b/src/system/kernel/arch/mipsel/arch_exceptions.S new file mode 100644 index 0000000000..83326dc325 --- /dev/null +++ b/src/system/kernel/arch/mipsel/arch_exceptions.S @@ -0,0 +1,18 @@ +/* + * Copyright 2009 Haiku Inc. + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include + + +FUNCTION(__mipsel_exception_noop): + nop +FUNCTION_END(__mipsel_exception_noop) + + +FUNCTION(__mipsel_exception_common): + nop +FUNCTION_END(__mipsel_exception_common) + diff --git a/src/system/kernel/arch/mipsel/arch_int.cpp b/src/system/kernel/arch/mipsel/arch_int.cpp index bf948b3a17..b264784b58 100644 --- a/src/system/kernel/arch/mipsel/arch_int.cpp +++ b/src/system/kernel/arch/mipsel/arch_int.cpp @@ -87,3 +87,19 @@ arch_int_init_post_device_manager(struct kernel_args* args) return B_ENTRY_NOT_FOUND; } + +void +mipsel_get_current_cpu_exception_context( + struct mipsel_cpu_exception_context *context) +{ +#warning mipsel_get_current_cpu_exception_context +} + + +void +mipsel_set_current_cpu_exception_context( + struct mipsel_cpu_exception_context *context) +{ +#warning mipsel_set_current_cpu_exception_context +} + diff --git a/src/system/kernel/arch/mipsel/arch_platform.cpp b/src/system/kernel/arch/mipsel/arch_platform.cpp index 1939f18caf..24a3613392 100644 --- a/src/system/kernel/arch/mipsel/arch_platform.cpp +++ b/src/system/kernel/arch/mipsel/arch_platform.cpp @@ -5,16 +5,167 @@ * All rights reserved. Distributed under the terms of the MIT License. */ -//#include -#include +#include + +#include + +#include + +#include +#include +#include + + +static MipselPlatform *sMipselPlatform; + + +MipselPlatform::MipselPlatform(mipsel_platform_type platformType) + : + fPlatformType(platformType) +{ +#warning IMPLEMENT MipselPlatform +} + +MipselPlatform::~MipselPlatform() +{ +#warning IMPLEMENT ~MipselPlatform +} + +MipselPlatform* +MipselPlatform::Default() +{ + return sMipselPlatform; +} + + +// #pragma mark - Routerboard + + +namespace BPrivate { + +class Routerboard : public MipselPlatform { +public: + Routerboard(); + virtual ~Routerboard(); + + virtual status_t Init(struct kernel_args *kernelArgs); + virtual status_t InitSerialDebug(struct kernel_args *kernelArgs); + virtual status_t InitPostVM(struct kernel_args *kernelArgs); + virtual status_t InitRTC(struct kernel_args *kernelArgs, + struct real_time_data *data); + + virtual char SerialDebugGetChar(); + virtual void SerialDebugPutChar(char c); + + virtual void SetHardwareRTC(uint32 seconds); + virtual uint32 GetHardwareRTC(); + + virtual void ShutDown(bool reboot); + +private: + int fInput; + int fOutput; + int fRTC; +}; + +} // namespace BPrivate + +using BPrivate::Routerboard; -#include -#include -#include -#include -#include + +Routerboard::Routerboard() + : MipselPlatform(MIPSEL_PLATFORM_ROUTERBOARD), + fInput(-1), + fOutput(-1), + fRTC(-1) +{ +#warning IMPLEMENT Routerboard +} + + +Routerboard::~Routerboard() +{ +#warning IMPLEMENT ~Routerboard +} + +status_t +Routerboard::Init(struct kernel_args *kernelArgs) +{ +#warning IMPLEMENT Init + return B_ERROR; +} + + +status_t +Routerboard::InitSerialDebug(struct kernel_args *kernelArgs) +{ +#warning IMPLEMENT InitSerialDebug + return B_ERROR; +} + + +status_t +Routerboard::InitPostVM(struct kernel_args *kernelArgs) +{ +#warning IMPLEMENT InitPostVM + return B_ERROR; +} + + +status_t +Routerboard::InitRTC(struct kernel_args *kernelArgs, + struct real_time_data *data) +{ +#warning IMPLEMENT InitRTC + return B_ERROR; +} + + +char +Routerboard::SerialDebugGetChar() +{ +#warning IMPLEMENT SerialDebugGetChar + return 0; +} + + +void +Routerboard::SerialDebugPutChar(char c) +{ +#warning IMPLEMENT SerialDebugPutChar +} + + +void +Routerboard::SetHardwareRTC(uint32 seconds) +{ +#warning IMPLEMENT SetHardwareRTC +} + + +uint32 +Routerboard::GetHardwareRTC() +{ +#warning IMPLEMENT GetHardwareRTC + return 0; +} + + +void +Routerboard::ShutDown(bool reboot) +{ +#warning IMPLEMENT ShutDown +} + + +// # pragma mark - + + +// static buffer for constructing the actual MipselPlatform +static char *sMipselPlatformBuffer[sizeof(Routerboard)]; + status_t arch_platform_init(struct kernel_args* kernelArgs) diff --git a/src/system/kernel/arch/mipsel/arch_real_time_clock.cpp b/src/system/kernel/arch/mipsel/arch_real_time_clock.cpp index fffe9d8ba9..3875b603d9 100644 --- a/src/system/kernel/arch/mipsel/arch_real_time_clock.cpp +++ b/src/system/kernel/arch/mipsel/arch_real_time_clock.cpp @@ -7,6 +7,7 @@ * Distributed under the terms of the MIT License. */ + #include diff --git a/src/system/kernel/arch/mipsel/arch_system_info.cpp b/src/system/kernel/arch/mipsel/arch_system_info.cpp index 00af8b92d6..32ec1db47a 100644 --- a/src/system/kernel/arch/mipsel/arch_system_info.cpp +++ b/src/system/kernel/arch/mipsel/arch_system_info.cpp @@ -10,6 +10,7 @@ * All rights reserved. Distributed under the terms of the MIT License. */ + #include #include @@ -17,31 +18,18 @@ #include -static uint64 sCPUClockFrequency; -static uint64 sBusClockFrequency; -static enum cpu_types sCPUType; -static uint16 sCPURevision; - status_t arch_get_system_info(system_info *info, size_t size) { - info->cpu_type = sCPUType; - info->cpu_revision = sCPURevision; - - info->cpu_clock_speed = sCPUClockFrequency; - info->bus_clock_speed = sBusClockFrequency; - - return B_OK; +#warning IMPLEMENT arch_get_system_info + return B_ERROR; } status_t arch_system_info_init(struct kernel_args *args) { - sCPUClockFrequency = args->arch_args.cpu_frequency; - sBusClockFrequency = args->arch_args.bus_frequency; - sCPUType = args->arch_args.cpu_type; - sCPURevision = args->arch_args.cpu_revision; - - return B_OK; +#warning IMPLEMENT arch_system_info_init + return B_ERROR; } + diff --git a/src/system/kernel/arch/mipsel/arch_thread.c b/src/system/kernel/arch/mipsel/arch_thread.c index 06a4f4a14a..6327e21e28 100644 --- a/src/system/kernel/arch/mipsel/arch_thread.c +++ b/src/system/kernel/arch/mipsel/arch_thread.c @@ -11,6 +11,7 @@ * Distributed under the terms of the NewOS License. */ + #include #include @@ -28,6 +29,39 @@ static struct arch_thread sInitialState; +void +mipsel_push_iframe(struct iframe_stack *stack, struct iframe *frame) +{ +#warning IMPLEMENT mipsel_push_iframe +} + + +void +mipsel_pop_iframe(struct iframe_stack *stack) +{ +#warning IMPLEMENT mipsel_pop_iframe +} + + +static struct iframe * +mipsel_get_current_iframe(void) +{ +#warning IMPLEMENT mipsel_get_current_iframe + return NULL; +} + + +struct iframe * +mipsel_get_user_iframe(void) +{ +#warning IMPLEMENT mipsel_get_user_iframe + return NULL; +} + + +// #pragma mark - + + status_t arch_thread_init(struct kernel_args *args) { diff --git a/src/system/kernel/arch/mipsel/arch_vm.cpp b/src/system/kernel/arch/mipsel/arch_vm.cpp index 1e8324e60e..167a472ef4 100644 --- a/src/system/kernel/arch/mipsel/arch_vm.cpp +++ b/src/system/kernel/arch/mipsel/arch_vm.cpp @@ -7,6 +7,7 @@ * Distributed under the terms of the NewOS License. */ + #include #include diff --git a/src/system/kernel/arch/mipsel/arch_vm_translation_map.cpp b/src/system/kernel/arch/mipsel/arch_vm_translation_map.cpp index 5249bd8412..5a7eb8bd78 100644 --- a/src/system/kernel/arch/mipsel/arch_vm_translation_map.cpp +++ b/src/system/kernel/arch/mipsel/arch_vm_translation_map.cpp @@ -7,6 +7,7 @@ * Distributed under the terms of the NewOS License. */ + #include #include #include @@ -91,3 +92,30 @@ arch_vm_translation_map_is_kernel_page_accessible(addr_t virtualAddress, return TRUE; } + +// #pragma mark - + + +status_t +mipsel_map_address_range(addr_t virtualAddress, addr_t physicalAddress, + size_t size) +{ +#warning IMPLEMENT mipsel_map_address_range + return B_OK; +} + + +void +mipsel_unmap_address_range(addr_t virtualAddress, size_t size) +{ +#warning IMPLEMENT mipsel_unmap_address_range +} + + +status_t +mipsel_remap_address_range(addr_t *_virtualAddress, size_t size, bool unmap) +{ +#warning IMPLEMENT mipsel_remap_address_range + return B_OK; +} + diff --git a/src/system/kernel/lib/arch/mipsel/Jamfile b/src/system/kernel/lib/arch/mipsel/Jamfile new file mode 100644 index 0000000000..86c3cdb16a --- /dev/null +++ b/src/system/kernel/lib/arch/mipsel/Jamfile @@ -0,0 +1,32 @@ +SubDir HAIKU_TOP src system kernel lib arch mipsel ; + +SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; + +local librootSources = [ FDirName $(HAIKU_TOP) src system libroot ] ; +local posixSources = [ FDirName $(librootSources) posix ] ; + +SEARCH_SOURCE += [ FDirName $(librootSources) os arch $(TARGET_ARCH) ] ; + +KernelMergeObject kernel_os_arch_$(TARGET_ARCH).o : + atomic.S + byteorder.S + system_time_asm.S + system_time.c + + : $(TARGET_KERNEL_PIC_CCFLAGS) +; + +SEARCH_SOURCE += [ FDirName $(posixSources) arch $(TARGET_ARCH) ] ; +SEARCH_SOURCE += [ FDirName $(posixSources) string arch generic ] ; + +KernelMergeObject kernel_lib_posix_arch_$(TARGET_ARCH).o : + siglongjmp.S + sigsetjmp.S + kernel_longjmp_return.c + kernel_setjmp_save_sigs.c + + memcpy.c + memset.c + + : $(TARGET_KERNEL_PIC_CCFLAGS) +;