1 /* 2 ** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 ** Distributed under the terms of the Haiku License. 4 */ 5 #ifndef _KERNEL_ARCH_PPC_CPU_H 6 #define _KERNEL_ARCH_PPC_CPU_H 7 8 9 #include <arch/ppc/thread_struct.h> 10 #include <kernel.h> 11 12 13 #define PAGE_SIZE 4096 14 15 struct iframe { 16 uint32 srr0; 17 uint32 srr1; 18 uint32 dar; 19 uint32 dsisr; 20 uint32 lr; 21 uint32 cr; 22 uint32 xer; 23 uint32 ctr; 24 uint32 r31; 25 uint32 r30; 26 uint32 r29; 27 uint32 r28; 28 uint32 r27; 29 uint32 r26; 30 uint32 r25; 31 uint32 r24; 32 uint32 r23; 33 uint32 r22; 34 uint32 r21; 35 uint32 r20; 36 uint32 r19; 37 uint32 r18; 38 uint32 r17; 39 uint32 r16; 40 uint32 r15; 41 uint32 r14; 42 uint32 r13; 43 uint32 r12; 44 uint32 r11; 45 uint32 r10; 46 uint32 r9; 47 uint32 r8; 48 uint32 r7; 49 uint32 r6; 50 uint32 r5; 51 uint32 r4; 52 uint32 r3; 53 uint32 r2; 54 uint32 r1; 55 uint32 r0; 56 }; 57 58 enum machine_state { 59 MSR_EXCEPTIONS_ENABLED = 1L << 15, // EE 60 MSR_PRIVILEGE_LEVEL = 1L << 14, // PR 61 MSR_FP_AVAILABLE = 1L << 13, // FP 62 MSR_MACHINE_CHECK_ENABLED = 1L << 12, // ME 63 MSR_EXCEPTION_PREFIX = 1L << 6, // IP 64 MSR_INST_ADDRESS_TRANSLATION = 1L << 5, // IR 65 MSR_DATA_ADDRESS_TRANSLATION = 1L << 4, // DR 66 }; 67 68 struct block_address_translation; 69 70 #ifdef __cplusplus 71 extern "C" { 72 #endif 73 74 extern uint32 get_sdr1(void); 75 extern void set_sdr1(uint32 value); 76 extern uint32 get_sr(void *virtualAddress); 77 extern void set_sr(void *virtualAddress, uint32 value); 78 extern uint32 get_msr(void); 79 extern uint32 set_msr(uint32 value); 80 81 extern void set_ibat0(struct block_address_translation *bat); 82 extern void set_ibat1(struct block_address_translation *bat); 83 extern void set_ibat2(struct block_address_translation *bat); 84 extern void set_ibat3(struct block_address_translation *bat); 85 extern void set_dbat0(struct block_address_translation *bat); 86 extern void set_dbat1(struct block_address_translation *bat); 87 extern void set_dbat2(struct block_address_translation *bat); 88 extern void set_dbat3(struct block_address_translation *bat); 89 90 extern void get_ibat0(struct block_address_translation *bat); 91 extern void get_ibat1(struct block_address_translation *bat); 92 extern void get_ibat2(struct block_address_translation *bat); 93 extern void get_ibat3(struct block_address_translation *bat); 94 extern void get_dbat0(struct block_address_translation *bat); 95 extern void get_dbat1(struct block_address_translation *bat); 96 extern void get_dbat2(struct block_address_translation *bat); 97 extern void get_dbat3(struct block_address_translation *bat); 98 99 extern void reset_ibats(void); 100 extern void reset_dbats(void); 101 102 //extern void sethid0(unsigned int val); 103 //extern unsigned int getl2cr(void); 104 //extern void setl2cr(unsigned int val); 105 extern long long get_time_base(void); 106 107 extern void ppc_context_switch(void **_oldStackPointer, void *newStackPointer); 108 109 #ifdef __cplusplus 110 } 111 #endif 112 113 #define eieio() asm volatile("eieio") 114 #define isync() asm volatile("isync") 115 #define tlbsync() asm volatile("tlbsync") 116 117 #endif /* _KERNEL_ARCH_PPC_CPU_H */ 118