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