Added and modified kernel stubs and headers for arch mipsel. Correctness not included.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32621 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jonas Sundström
2009-08-23 02:52:09 +00:00
parent 080f08465b
commit 893988af82
35 changed files with 1172 additions and 32 deletions
@@ -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 <arch/mipsel/arch_thread_types.h>
#include <kernel.h>
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 */
@@ -0,0 +1,48 @@
/*
* Copyright 2005-2009, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Axel Dörfler <[email protected]>
* Ingo Weinhold <[email protected]>
*/
#ifndef _KERNEL_ARCH_MIPSEL_INT_H
#define _KERNEL_ARCH_MIPSEL_INT_H
#include <SupportDefs.h>
#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 */
@@ -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 <arch/cpu.h>
#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 */
@@ -0,0 +1,31 @@
/*
* Copyright 2009, Axel Dörfler, [email protected].
* 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 <boot/kernel_args.h> 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 */
@@ -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 <arch_cpu.h>
#warning IMPLEMENT arch_mmu.h
#endif /* _KERNEL_ARCH_MIPSEL_MMU_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 <arch/platform.h>
#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 */
@@ -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 */
@@ -0,0 +1,47 @@
/*
* Copyright 2003-2009, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Ingo Weinhold <[email protected]>
* Jonas Sundström <[email protected]>
*/
#ifndef _KERNEL_ARCH_MIPSEL_THREAD_H
#define _KERNEL_ARCH_MIPSEL_THREAD_H
#include <arch/cpu.h>
#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 */
@@ -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 <arch_cpu.h>
#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 */
@@ -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 */
@@ -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 */
@@ -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 <arch/vm_translation_map.h>
#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 */
@@ -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 */
+11
View File
@@ -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 */
@@ -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 */
@@ -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 */
@@ -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 <commpage_defs.h> 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 */
@@ -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 */
@@ -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 */
@@ -0,0 +1,18 @@
/*
* Copyright 2006-2009, Ingo Weinhold <[email protected]>.
* 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 <SupportDefs.h>
struct arch_real_time_data {
bigtime_t system_time_offset;
uint32 system_time_conversion_factor;
};
#endif /* _SYSTEM_ARCH_REAL_TIME_DATA_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 */
+3 -4
View File
@@ -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
+6 -1
View File
@@ -7,9 +7,9 @@
* Distributed under the terms of the NewOS License.
*/
#include <arch/mipsel/arch_cpu.h>
#include <asm_defs.h>
.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)
+238
View File
@@ -0,0 +1,238 @@
/*
* Copyright 2003, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the OpenBeOS License.
*/
#include <KernelExport.h>
#include <kernel.h>
#include <user_atomic.h>
/*
* 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;
}
+21 -1
View File
@@ -10,7 +10,6 @@
#include <KernelExport.h>
//#include <arch_platform.h>
#include <arch_thread.h>
#include <arch/cpu.h>
#include <boot/kernel_args.h>
@@ -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;
}
@@ -51,7 +51,6 @@ void
arch_debug_serial_putchar(const char c)
{
#warning IMPLEMENT arch_debug_serial_putchar
return 0;
}
@@ -0,0 +1,18 @@
/*
* Copyright 2009 Haiku Inc.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <asm_defs.h>
FUNCTION(__mipsel_exception_noop):
nop
FUNCTION_END(__mipsel_exception_noop)
FUNCTION(__mipsel_exception_common):
nop
FUNCTION_END(__mipsel_exception_common)
@@ -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
}
+158 -7
View File
@@ -5,16 +5,167 @@
* All rights reserved. Distributed under the terms of the MIT License.
*/
//#include <arch_platform.h>
#include <new>
#include <arch_platform.h>
#include <new>
#include <KernelExport.h>
#include <boot/kernel_args.h>
#include <real_time_clock.h>
#include <util/kernel_cpp.h>
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 <KernelExport.h>
#include <arch/platform.h>
#include <boot/kernel_args.h>
#include <real_time_clock.h>
#include <util/kernel_cpp.h>
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)
@@ -7,6 +7,7 @@
* Distributed under the terms of the MIT License.
*/
#include <arch/real_time_clock.h>
@@ -10,6 +10,7 @@
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include <OS.h>
#include <arch_cpu.h>
@@ -17,31 +18,18 @@
#include <boot/kernel_args.h>
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;
}
@@ -11,6 +11,7 @@
* Distributed under the terms of the NewOS License.
*/
#include <arch_thread.h>
#include <arch_cpu.h>
@@ -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)
{
@@ -7,6 +7,7 @@
* Distributed under the terms of the NewOS License.
*/
#include <KernelExport.h>
#include <kernel.h>
@@ -7,6 +7,7 @@
* Distributed under the terms of the NewOS License.
*/
#include <KernelExport.h>
#include <kernel.h>
#include <vm.h>
@@ -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;
}
+32
View File
@@ -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)
;