diff --git a/headers/private/kernel/arch/ppc/arch_cpu.h b/headers/private/kernel/arch/ppc/arch_cpu.h index f3f979ae2c..f352f38403 100644 --- a/headers/private/kernel/arch/ppc/arch_cpu.h +++ b/headers/private/kernel/arch/ppc/arch_cpu.h @@ -5,7 +5,9 @@ #ifndef _KERNEL_ARCH_PPC_CPU_H #define _KERNEL_ARCH_PPC_CPU_H + #include +#include #define PAGE_SIZE 4096 @@ -15,8 +17,52 @@ #define ATOMIC64_FUNCS_ARE_SYSCALLS 1 struct iframe { + uint32 srr0; + uint32 srr1; + uint32 dar; + uint32 dsisr; + uint32 lr; + uint32 cr; + uint32 xer; + uint32 ctr; + 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; }; +#define MSR_IP (1L << 6) + +struct block_address_translation; + #ifdef __cplusplus extern "C" { #endif @@ -28,10 +74,27 @@ extern void set_sr(void *virtualAddress, uint32 value); extern uint32 get_msr(void); extern uint32 set_msr(uint32 value); +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 sethid0(unsigned int val); +//extern unsigned int getl2cr(void); +//extern void setl2cr(unsigned int val); +extern long long get_time_base(void); + +extern void ppc_context_switch(void **_oldStackPointer, void *newStackPointer); + #ifdef __cplusplus } #endif #define eieio() asm volatile("eieio") +#define isync() asm volatile("isync") #endif /* _KERNEL_ARCH_PPC_CPU_H */ diff --git a/headers/private/kernel/arch/ppc/arch_kernel_args.h b/headers/private/kernel/arch/ppc/arch_kernel_args.h index 44725c0603..b1e12e2fa5 100644 --- a/headers/private/kernel/arch/ppc/arch_kernel_args.h +++ b/headers/private/kernel/arch/ppc/arch_kernel_args.h @@ -14,8 +14,9 @@ // kernel args typedef struct { // architecture specific - addr_range page_table; // maps where the page table is located, in physical memory - addr_range framebuffer; // maps where the framebuffer is located, in physical memory + 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; } arch_kernel_args; diff --git a/headers/private/kernel/arch/ppc/arch_mmu.h b/headers/private/kernel/arch/ppc/arch_mmu.h index c343c3ef76..c441c5e087 100644 --- a/headers/private/kernel/arch/ppc/arch_mmu.h +++ b/headers/private/kernel/arch/ppc/arch_mmu.h @@ -7,8 +7,11 @@ #include +#include +/*** BAT - block address translation ***/ + enum bat_length { BAT_LENGTH_128kB = 0x0000, BAT_LENGTH_256kB = 0x0001, @@ -32,11 +35,12 @@ enum bat_protection { struct block_address_translation { // upper 32 bit uint32 page_index : 15; // BEPI, block effective page index - uint32 _reserved0 : 3; - uint32 length : 10; - uint32 kernel_valid : 1; - uint32 user_valid : 1; + 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; @@ -44,9 +48,19 @@ struct block_address_translation { uint32 _reserved1 : 1; uint32 protection : 2; - void Reset() + void SetVirtualAddress(void *address) { - *((uint32 *)this) = 0; + 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)); } }; @@ -59,11 +73,19 @@ struct segment_descriptor { uint32 virtual_segment_id : 24; }; + +/*** 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 hash : 1; + uint32 secondary_hash : 1; uint32 abbr_page_index : 6; // lower 32 bit uint32 physical_page_number : 20; @@ -86,7 +108,7 @@ struct page_table_entry_group { struct page_table_entry entry[8]; }; -extern void ppc_get_page_table(void **_pageTable, size_t *_size); -extern void ppc_set_page_table(void *pageTable, size_t size); +extern void ppc_get_page_table(page_table_entry_group **_pageTable, size_t *_size); +extern void ppc_set_page_table(page_table_entry_group *pageTable, size_t size); #endif /* _KERNEL_ARCH_PPC_MMU_H */ diff --git a/headers/private/kernel/arch/ppc/arch_vm_translation_map.h b/headers/private/kernel/arch/ppc/arch_vm_translation_map.h new file mode 100644 index 0000000000..452c86d69e --- /dev/null +++ b/headers/private/kernel/arch/ppc/arch_vm_translation_map.h @@ -0,0 +1,15 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef _KERNEL_ARCH_PPC_VM_TRANSLATION_MAP_H +#define _KERNEL_ARCH_PPC_VM_TRANSLATION_MAP_H + +#include + +#ifdef __cplusplus +extern "C" +#endif +void ppc_translation_map_change_asid(vm_translation_map *map); + +#endif /* _KERNEL_ARCH_PPC_VM_TRANSLATION_MAP_H */ diff --git a/headers/private/kernel/arch/ppc/thread_struct.h b/headers/private/kernel/arch/ppc/thread_struct.h index 66c721a615..4113b4851a 100644 --- a/headers/private/kernel/arch/ppc/thread_struct.h +++ b/headers/private/kernel/arch/ppc/thread_struct.h @@ -7,7 +7,7 @@ // architecture specific thread info struct arch_thread { - // stack pointer + void *sp; // stack pointer }; struct arch_team {