diff --git a/headers/private/kernel/arch/m68k/arch_config.h b/headers/private/kernel/arch/m68k/arch_config.h new file mode 100644 index 0000000000..af17b83634 --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_config.h @@ -0,0 +1,17 @@ +/* + * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_M68K_CONFIG_H +#define _KERNEL_ARCH_M68K_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 /* _KERNEL_ARCH_M68K_CONFIG_H */ diff --git a/headers/private/kernel/arch/m68k/arch_cpu.h b/headers/private/kernel/arch/m68k/arch_cpu.h new file mode 100644 index 0000000000..e99f71bb95 --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_cpu.h @@ -0,0 +1,258 @@ +/* +** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. +*/ +#ifndef _KERNEL_ARCH_M68K_CPU_H +#define _KERNEL_ARCH_M68K_CPU_H + + +#include +#include + + +#define PAGE_SIZE 4096 + +struct iframe { + uint32 d7; + /* XXX: order depends on movem */ + uint32 a0; + /* 030 ex frame: */ + uint16 sr; + uint32 pc; + uint16 vector; /* [12:15] frame type */ + /* other stuff depending on frame type... do we really need that ? */ + union { + struct { + uint32 inst; + } format2 _PACKED; + struct { + uint32 inst; + uint16 intregs[4]; + } format9 _PACKED; + struct { + uint16 intregs[1]; + uint16 ssw; + uint16 instpipe_c; + uint16 instpipe_b; + uint32 faultaddr; + uint16 intregs2[2]; + uint32 dataout; + uint16 intregs3[2]; + } formata _PACKED; + struct { + uint16 intregs[1]; + uint16 ssw; + uint16 instpipe_c; + uint16 instpipe_b; + uint32 faultaddr; + uint16 intregs2[2]; + uint32 dataout; + uint16 intregs3[4]; + uint32 stbaddr; + uint16 intregs4[2]; + uint32 datain; + uint16 intregs5[3]; + uint16 intinfo; + uint16 intregs6[18]; + } formatb _PACKED; + }; +/* uint32 vector; + uint32 srr0; + uint32 srr1; + uint32 dar; + uint32 dsisr; + uint32 lr; + uint32 cr; + uint32 xer; + uint32 ctr; + uint32 fpscr; + 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; + double f31; + double f30; + double f29; + double f28; + double f27; + double f26; + double f25; + double f24; + double f23; + double f22; + double f21; + double f20; + double f19; + double f18; + double f17; + double f16; + double f15; + double f14; + double f13; + double f12; + double f11; + double f10; + double f9; + double f8; + double f7; + double f6; + double f5; + double f4; + double f3; + double f2; + double f1; + double f0;*/ +} _PACKED; + +enum machine_state { + MSR_EXCEPTIONS_ENABLED = 1L << 15, // EE + MSR_PRIVILEGE_LEVEL = 1L << 14, // PR + MSR_FP_AVAILABLE = 1L << 13, // FP + MSR_MACHINE_CHECK_ENABLED = 1L << 12, // ME + MSR_EXCEPTION_PREFIX = 1L << 6, // IP + MSR_INST_ADDRESS_TRANSLATION = 1L << 5, // IR + MSR_DATA_ADDRESS_TRANSLATION = 1L << 4, // DR +}; + +struct block_address_translation; + +typedef struct arch_cpu_info { + int null; +} arch_cpu_info; + + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32 get_sdr1(void); +extern void set_sdr1(uint32 value); +extern uint32 get_sr(void *virtualAddress); +extern void set_sr(void *virtualAddress, uint32 value); +extern uint32 get_msr(void); +extern uint32 set_msr(uint32 value); +extern uint32 get_pvr(void); + +extern void set_ibat0(struct block_address_translation *bat); +extern void set_ibat1(struct block_address_translation *bat); +extern void set_ibat2(struct block_address_translation *bat); +extern void set_ibat3(struct block_address_translation *bat); +extern void set_dbat0(struct block_address_translation *bat); +extern void set_dbat1(struct block_address_translation *bat); +extern void set_dbat2(struct block_address_translation *bat); +extern void set_dbat3(struct block_address_translation *bat); + +extern void get_ibat0(struct block_address_translation *bat); +extern void get_ibat1(struct block_address_translation *bat); +extern void get_ibat2(struct block_address_translation *bat); +extern void get_ibat3(struct block_address_translation *bat); +extern void get_dbat0(struct block_address_translation *bat); +extern void get_dbat1(struct block_address_translation *bat); +extern void get_dbat2(struct block_address_translation *bat); +extern void get_dbat3(struct block_address_translation *bat); + +extern void reset_ibats(void); +extern void reset_dbats(void); + +//extern void sethid0(unsigned int val); +//extern unsigned int getl2cr(void); +//extern void setl2cr(unsigned int val); +extern long long get_time_base(void); + +void __m68k_setup_system_time(vint32 *cvFactor); + // defined in libroot: os/arch/system_time.c +int64 __m68k_get_time_base(void); + // defined in libroot: os/arch/system_time_asm.S + +extern void m68k_context_switch(void **_oldStackPointer, void *newStackPointer); + +extern bool m68k_set_fault_handler(addr_t *handlerLocation, addr_t handler) + __attribute__((noinline)); + +#ifdef __cplusplus +} +#endif + +#define eieio() asm volatile("eieio") +#define isync() asm volatile("isync") +#define tlbsync() asm volatile("tlbsync") +#define ppc_sync() asm volatile("sync") +#define tlbia() asm volatile("tlbia") +#define tlbie(addr) asm volatile("tlbie %0" :: "r" (addr)) + + +// PowerPC processor version (the upper 16 bits of the PVR). +enum m68k_processor_version { + MPC601 = 0x0001, + MPC603 = 0x0003, + MPC604 = 0x0004, + MPC602 = 0x0005, + MPC603e = 0x0006, + MPC603ev = 0x0007, + MPC750 = 0x0008, + MPC604ev = 0x0009, + MPC7400 = 0x000c, + MPC620 = 0x0014, + IBM403 = 0x0020, + IBM401A1 = 0x0021, + IBM401B2 = 0x0022, + IBM401C2 = 0x0023, + IBM401D2 = 0x0024, + IBM401E2 = 0x0025, + IBM401F2 = 0x0026, + IBM401G2 = 0x0027, + IBMPOWER3 = 0x0041, + MPC860 = 0x0050, + MPC8240 = 0x0081, + IBM405GP = 0x4011, + IBM405L = 0x4161, + IBM750FX = 0x7000, + MPC7450 = 0x8000, + MPC7455 = 0x8001, + MPC7457 = 0x8002, + MPC7447A = 0x8003, + MPC7448 = 0x8004, + MPC7410 = 0x800c, + MPC8245 = 0x8081, +}; + + +/* + Use of (some) special purpose registers. + + SPRG0: per CPU physical address pointer to an ppc_cpu_exception_context + structure + SPRG1: scratch + SPRG2: current struct thread* + SPRG3: TLS base pointer (only for userland threads) +*/ + +#endif /* _KERNEL_ARCH_PPC_CPU_H */ diff --git a/headers/private/kernel/arch/m68k/arch_elf.h b/headers/private/kernel/arch/m68k/arch_elf.h new file mode 100644 index 0000000000..56ce6d009c --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_elf.h @@ -0,0 +1,49 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef _KERNEL_ARCH_M68K_ELF_H +#define _KERNEL_ARCH_M68K_ELF_H + +/* relocation types */ + +#define R_PPC_NONE 0 +#define R_PPC_ADDR32 1 +#define R_PPC_ADDR24 2 +#define R_PPC_ADDR16 3 +#define R_PPC_ADDR16_LO 4 +#define R_PPC_ADDR16_HI 5 +#define R_PPC_ADDR16_HA 6 +#define R_PPC_ADDR14 7 +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 +#define R_PPC_REL14 11 +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 +#define R_PPC_ADDR30 37 + +#endif /* _KERNEL_ARCH_M68K_ELF_H */ diff --git a/headers/private/kernel/arch/m68k/arch_int.h b/headers/private/kernel/arch/m68k/arch_int.h new file mode 100644 index 0000000000..be7741abf2 --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_int.h @@ -0,0 +1,46 @@ +/* + * Copyright 2005-2006, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel Dörfler + * Ingo Weinhold + */ +#ifndef _KERNEL_ARCH_M68K_INT_H +#define _KERNEL_ARCH_M68K_INT_H + +#include + +#define NUM_IO_VECTORS 256 + +/* The sprg0 register of each CPU points to the physical address of such + a structure. So it is at hand in the early exception handling code. +*/ +struct m68k_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 m68k_cpu_exception_context *m68k_get_cpu_exception_context(int cpu); + +void m68k_set_current_cpu_exception_context( + struct m68k_cpu_exception_context *context); + // only called once per CPU + + +#ifdef __cplusplus +} +#endif + +#endif /* _KERNEL_ARCH_M68K_INT_H */ diff --git a/headers/private/kernel/arch/m68k/arch_kernel.h b/headers/private/kernel/arch/m68k/arch_kernel.h new file mode 100644 index 0000000000..1c8886a509 --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_kernel.h @@ -0,0 +1,30 @@ +/* +** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. +** Distributed under the terms of the NewOS License. +*/ +#ifndef _KERNEL_ARCH_M68K_KERNEL_H +#define _KERNEL_ARCH_M68K_KERNEL_H + +#include + +// 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_SIZE (0x80000000 - (0x10000 + 0x100000)) +#define USER_TOP (USER_BASE + USER_SIZE) + +#define USER_STACK_REGION 0x70000000 +#define USER_STACK_REGION_SIZE (USER_BASE + (USER_SIZE - USER_STACK_REGION)) + +#endif /* _KERNEL_ARCH_M68K_KERNEL_H */ diff --git a/headers/private/kernel/arch/m68k/arch_kernel_args.h b/headers/private/kernel/arch/m68k/arch_kernel_args.h new file mode 100644 index 0000000000..294a63ea65 --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_kernel_args.h @@ -0,0 +1,34 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef KERNEL_ARCH_M68K_KERNEL_ARGS_H +#define KERNEL_ARCH_M68K_KERNEL_ARGS_H + +#ifndef KERNEL_BOOT_KERNEL_ARGS_H +# error This file is included from only +#endif + +#define _PACKED __attribute__((packed)) + +//#define MAX_VIRTUAL_RANGES_TO_KEEP 32 + +// kernel args +typedef struct { + // architecture specific + uint64 cpu_frequency; + uint64 bus_frequency; + uint64 time_base_frequency; + + addr_range page_table; // virtual address and size of the page table + addr_range exception_handlers; + addr_range framebuffer; // maps where the framebuffer is located, in physical memory + int screen_x, screen_y, screen_depth; + + // The virtual ranges we want to keep in the kernel. E.g. those belonging + // to the Open Firmware. +// uint32 num_virtual_ranges_to_keep; +// addr_range virtual_ranges_to_keep[MAX_VIRTUAL_RANGES_TO_KEEP]; +} arch_kernel_args; + +#endif /* KERNEL_ARCH_M68K_KERNEL_ARGS_H */ diff --git a/headers/private/kernel/arch/m68k/arch_mmu.h b/headers/private/kernel/arch/m68k/arch_mmu.h new file mode 100644 index 0000000000..a02bd9b59f --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_mmu.h @@ -0,0 +1,149 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef _KERNEL_ARCH_M68K_MMU_H +#define _KERNEL_ARCH_M68K_MMU_H + + +#include +#include + +#include + + +/*** BAT - block address translation ***/ + +enum bat_length { + BAT_LENGTH_128kB = 0x0000, + BAT_LENGTH_256kB = 0x0001, + BAT_LENGTH_512kB = 0x0003, + BAT_LENGTH_1MB = 0x0007, + BAT_LENGTH_2MB = 0x000f, + BAT_LENGTH_4MB = 0x001f, + BAT_LENGTH_8MB = 0x003f, + BAT_LENGTH_16MB = 0x007f, + BAT_LENGTH_32MB = 0x00ff, + BAT_LENGTH_64MB = 0x01ff, + BAT_LENGTH_128MB = 0x03ff, + BAT_LENGTH_256MB = 0x07ff, +}; + +enum bat_protection { + BAT_READ_ONLY = 1, + BAT_READ_WRITE = 2, +}; + +struct block_address_translation { + // upper 32 bit + uint32 page_index : 15; // BEPI, block effective page index + uint32 _reserved0 : 4; + uint32 length : 11; + uint32 kernel_valid : 1; // Vs, Supervisor-state valid + uint32 user_valid : 1; // Vp, User-state valid + // lower 32 bit + uint32 physical_block_number : 15; // BPRN + uint32 write_through : 1; // WIMG + uint32 caching_inhibited : 1; + uint32 memory_coherent : 1; + uint32 guarded : 1; + uint32 _reserved1 : 1; + uint32 protection : 2; + + block_address_translation() + { + Clear(); + } + + void SetVirtualAddress(void *address) + { + page_index = uint32(address) >> 17; + } + + void SetPhysicalAddress(void *address) + { + physical_block_number = uint32(address) >> 17; + } + + void Clear() + { + memset((void *)this, 0, sizeof(block_address_translation)); + } +}; + +struct segment_descriptor { + uint32 type : 1; // 0 for page translation descriptors + uint32 kernel_protection_key : 1; // Ks, Supervisor-state protection key + uint32 user_protection_key : 1; // Kp, User-state protection key + uint32 no_execute_protection : 1; + uint32 _reserved : 4; + uint32 virtual_segment_id : 24; + + segment_descriptor() + { + Clear(); + } + + segment_descriptor(uint32 value) + { + *((uint32 *)this) = value; + } + + void Clear() + { + memset((void *)this, 0, sizeof(segment_descriptor)); + } +}; + + +/*** PTE - page table entry ***/ + +enum pte_protection { + PTE_READ_ONLY = 3, + PTE_READ_WRITE = 2, +}; + +struct page_table_entry { + // upper 32 bit + uint32 valid : 1; + uint32 virtual_segment_id : 24; + uint32 secondary_hash : 1; + uint32 abbr_page_index : 6; + // lower 32 bit + uint32 physical_page_number : 20; + uint32 _reserved0 : 3; + uint32 referenced : 1; + uint32 changed : 1; + uint32 write_through : 1; // WIMG + uint32 caching_inhibited : 1; + uint32 memory_coherent : 1; + uint32 guarded : 1; + uint32 _reserved1 : 1; + uint32 page_protection : 2; + + static uint32 PrimaryHash(uint32 virtualSegmentID, uint32 virtualAddress); + static uint32 SecondaryHash(uint32 virtualSegmentID, uint32 virtualAddress); + static uint32 SecondaryHash(uint32 primaryHash); +}; + +struct page_table_entry_group { + struct page_table_entry entry[8]; +}; + +extern void m68k_get_page_table(page_table_entry_group **_pageTable, size_t *_size); +extern void m68k_set_page_table(page_table_entry_group *pageTable, size_t size); + +static inline segment_descriptor +m68k_get_segment_register(void *virtualAddress) +{ + return (segment_descriptor)get_sr(virtualAddress); +} + + +static inline void +m68k_set_segment_register(void *virtualAddress, segment_descriptor segment) +{ + set_sr(virtualAddress, *(uint32 *)&segment); +} + +#endif /* _KERNEL_ARCH_M68K_MMU_H */ diff --git a/headers/private/kernel/arch/m68k/arch_platform.h b/headers/private/kernel/arch/m68k/arch_platform.h new file mode 100644 index 0000000000..4914f9b9f9 --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_platform.h @@ -0,0 +1,52 @@ +/* + * Copyright 2006, Ingo Weinhold . + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_M68K_ARCH_PLATFORM_H +#define _KERNEL_M68K_ARCH_PLATFORM_H + +#include + +struct real_time_data; + +enum m68k_platform_type { + M68K_PLATFORM_AMIGA = 0, + M68K_PLATFORM_APPLE, + M68K_PLATFORM_ATARI /* Falcon */ +}; + +namespace BPrivate { + +class M68KPlatform { +public: + M68KPlatform(m68k_platform_type platformType); + virtual ~M68KPlatform(); + + static M68KPlatform *Default(); + + inline m68k_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: + m68k_platform_type fPlatformType; +}; + +} // namespace BPrivate + +using BPrivate::M68KPlatform; + + +#endif // _KERNEL_M68K_ARCH_PLATFORM_H diff --git a/headers/private/kernel/arch/m68k/arch_real_time_data.h b/headers/private/kernel/arch/m68k/arch_real_time_data.h new file mode 100644 index 0000000000..d3d2f07d7c --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_real_time_data.h @@ -0,0 +1,36 @@ +/* + * Copyright 2006, Ingo Weinhold . + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_REAL_TIME_DATA_H +#define _KERNEL_ARCH_REAL_TIME_DATA_H + +#include +#include + + +struct ppc_real_time_data { + vint64 system_time_offset; +}; + +struct arch_real_time_data { + struct ppc_real_time_data data[2]; + vint32 system_time_conversion_factor; + vint32 version; + // Since there're no cheap atomic_{set,get,add}64() on PPC 32 (i.e. one + // that doesn't involve a syscall), we can't have just a single + // system_time_offset and set/get it atomically. + // That's why have our data twice. One set is current (indexed by + // version % 2). When setting the offset, we do that with disabled + // interrupts and protected by a spinlock. We write the new values + // into the other array element and increment the version. + // A reader first reads the version, then the date of interest, and + // finally rechecks the version. If it hasn't changed in the meantime, + // the read value is fine, otherwise it runs the whole procedure again. + // + // system_time_conversion_factor is currently consider constant, + // although that is not necessarily true. We simply don't support + // changing conversion factors at the moment. +}; + +#endif /* _KERNEL_ARCH_REAL_TIME_DATA_H */ diff --git a/headers/private/kernel/arch/m68k/arch_system_info.h b/headers/private/kernel/arch/m68k/arch_system_info.h new file mode 100644 index 0000000000..9474aca50a --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_system_info.h @@ -0,0 +1,12 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_M68K_SYSTEM_INFO_H +#define _KERNEL_ARCH_M68K_SYSTEM_INFO_H + + +/* nothing to be seen here yet */ + + +#endif /* _KRENEL_ARCH_M68K_SYSTEM_INFO_H */ diff --git a/headers/private/kernel/arch/m68k/arch_thread.h b/headers/private/kernel/arch/m68k/arch_thread.h new file mode 100644 index 0000000000..6a79fc5160 --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_thread.h @@ -0,0 +1,44 @@ +/* + * Copyright 2003-2006, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel Dörfler + * Ingo Weinhold + */ +#ifndef _KERNEL_ARCH_M68K_THREAD_H +#define _KERNEL_ARCH_M68K_THREAD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void m68k_push_iframe(struct iframe_stack *stack, struct iframe *frame); +void m68k_pop_iframe(struct iframe_stack *stack); +struct iframe *m68k_get_user_iframe(void); + + +extern inline struct thread * +arch_thread_get_current_thread(void) +{ + struct thread *t; + asm volatile("mfsprg2 %0" : "=r"(t)); + return t; +} + + +extern inline void +arch_thread_set_current_thread(struct thread *t) +{ + asm volatile("mtsprg2 %0" : : "r"(t)); +} + + +#ifdef __cplusplus +} +#endif + + +#endif /* _KERNEL_ARCH_M68K_THREAD_H */ diff --git a/headers/private/kernel/arch/m68k/arch_thread_types.h b/headers/private/kernel/arch/m68k/arch_thread_types.h new file mode 100644 index 0000000000..1723fbba26 --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_thread_types.h @@ -0,0 +1,38 @@ +/* +** Copyright 2001, Travis Geiselbrecht. All rights reserved. +** Distributed under the terms of the NewOS License. +*/ +#ifndef KERNEL_ARCH_M68K_THREAD_TYPES_H +#define KERNEL_ARCH_M68K_THREAD_TYPES_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_M68K_THREAD_TYPES_H */ diff --git a/headers/private/kernel/arch/m68k/arch_user_debugger.h b/headers/private/kernel/arch/m68k/arch_user_debugger.h new file mode 100644 index 0000000000..765dbca178 --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_user_debugger.h @@ -0,0 +1,17 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_M68K_USER_DEBUGGER_H +#define _KERNEL_ARCH_M68K_USER_DEBUGGER_H + + +struct arch_team_debug_info { + uint32 dummy; +}; + +struct arch_thread_debug_info { + uint32 dummy; +}; + +#endif // _KERNEL_ARCH_M68K_USER_DEBUGGER_H diff --git a/headers/private/kernel/arch/m68k/arch_vm.h b/headers/private/kernel/arch/m68k/arch_vm.h new file mode 100644 index 0000000000..2b2ecd0d45 --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_vm.h @@ -0,0 +1,15 @@ +/* + * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef ARCH_M68K_VM_H +#define ARCH_M68K_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 /* ARCH_M68K_VM_H */ diff --git a/headers/private/kernel/arch/m68k/arch_vm_translation_map.h b/headers/private/kernel/arch/m68k/arch_vm_translation_map.h new file mode 100644 index 0000000000..f78a686dc6 --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_vm_translation_map.h @@ -0,0 +1,26 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef _KERNEL_ARCH_M68K_VM_TRANSLATION_MAP_H +#define _KERNEL_ARCH_M68K_VM_TRANSLATION_MAP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void m68k_translation_map_change_asid(vm_translation_map *map); + +status_t m68k_map_address_range(addr_t virtualAddress, addr_t physicalAddress, + size_t size); +void m68k_unmap_address_range(addr_t virtualAddress, size_t size); +status_t m68k_remap_address_range(addr_t *virtualAddress, size_t size, + bool unmap); + +#ifdef __cplusplus +} +#endif + +#endif /* _KERNEL_ARCH_M68K_VM_TRANSLATION_MAP_H */ diff --git a/headers/private/kernel/arch/m68k/arch_vm_types.h b/headers/private/kernel/arch/m68k/arch_vm_types.h new file mode 100644 index 0000000000..3ca6344470 --- /dev/null +++ b/headers/private/kernel/arch/m68k/arch_vm_types.h @@ -0,0 +1,8 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_M68K_VM_TYPES_H +#define _KERNEL_ARCH_M68K_VM_TYPES_H + +#endif /* _KERNEL_ARCH_M68K_VM_TYPES_H */ diff --git a/headers/private/kernel/arch/m68k/cpu.h b/headers/private/kernel/arch/m68k/cpu.h new file mode 100644 index 0000000000..6414589249 --- /dev/null +++ b/headers/private/kernel/arch/m68k/cpu.h @@ -0,0 +1,11 @@ +/* +** Copyright 2001, Travis Geiselbrecht. All rights reserved. +** Distributed under the terms of the NewOS License. +*/ +#ifndef _M68K_CPU_H +#define _M68K_CPU_H + +#define PAGE_SIZE 4096 + +#endif + diff --git a/headers/private/kernel/arch/m68k/ktypes.h b/headers/private/kernel/arch/m68k/ktypes.h new file mode 100644 index 0000000000..c5a876c2f3 --- /dev/null +++ b/headers/private/kernel/arch/m68k/ktypes.h @@ -0,0 +1,11 @@ +/* +** Copyright 2001, Travis Geiselbrecht. All rights reserved. +** Distributed under the terms of the NewOS License. +*/ +#ifndef _M68K_KTYPES_H +#define _M68K_KTYPES_H + +typedef unsigned long addr; + +#endif + diff --git a/headers/private/kernel/arch/m68k/stage2_priv.h b/headers/private/kernel/arch/m68k/stage2_priv.h new file mode 100644 index 0000000000..605ad5a733 --- /dev/null +++ b/headers/private/kernel/arch/m68k/stage2_priv.h @@ -0,0 +1,43 @@ +/* +** Copyright 2001, Travis Geiselbrecht. All rights reserved. +** Distributed under the terms of the NewOS License. +*/ +#ifndef _STAGE2_PRIV_H +#define _STAGE2_PRIV_H + +#define LOAD_ADDR 0x100000 +#define BOOTDIR_ADDR 0x101000 + +int s2_text_init(); +void s2_change_framebuffer_addr(unsigned int address); +void putchar(char c); +void puts(char *str); +int printf(const char *fmt, ...); + +int of_init(void *of_entry); +int of_open(const char *node_name); +int of_finddevice(const char *dev); +int of_instance_to_package(int in_handle); +int of_getprop(int handle, const char *prop, void *buf, int buf_len); +int of_setprop(int handle, const char *prop, const void *buf, int buf_len); +int of_read(int handle, void *buf, int buf_len); +int of_write(int handle, void *buf, int buf_len); +int of_seek(int handle, long long pos); + +int s2_mmu_init(); +void mmu_map_page(unsigned int vsid, unsigned long pa, unsigned long va);; +void syncicache(void *address, int len); + +void s2_faults_init(kernel_args *ka); + +void getibats(int bats[8]); +void setibats(int bats[8]); +void getdbats(int bats[8]); +void setdbats(int bats[8]); +unsigned int *getsdr1(); +void setsdr1(unsigned int sdr); +unsigned int getsr(int sr); +unsigned int getmsr(); +void setmsr(unsigned int msr); + +#endif diff --git a/headers/private/kernel/arch/m68k/types.h b/headers/private/kernel/arch/m68k/types.h new file mode 100644 index 0000000000..09de5553c3 --- /dev/null +++ b/headers/private/kernel/arch/m68k/types.h @@ -0,0 +1,18 @@ +/* +** Copyright 2001, Travis Geiselbrecht. All rights reserved. +** Distributed under the terms of the NewOS License. +*/ +#ifndef _M68K_TYPES_H +#define _M68K_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 +