Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / ppc-chrp / efika / kernel / kernel_intern.h
blob4f6d1348ee5a053bbb7b7fb604790ffc758d4b81
1 #ifndef KERNEL_INTERN_H_
2 #define KERNEL_INTERN_H_
4 #include <asm/mpc5200b.h>
5 #include <aros/libcall.h>
6 #include <inttypes.h>
7 #include <exec/lists.h>
8 #include <exec/execbase.h>
9 #include <exec/memory.h>
10 #include <utility/tagitem.h>
11 #include <stdio.h>
12 #include <stdarg.h>
14 #include "syscall.h"
16 #define KERNEL_PHYS_BASE 0x07800000
17 #define KERNEL_VIRT_BASE 0xff800000
19 #define STACK_SIZE 4096
21 struct KernelBase {
22 struct Node kb_Node;
23 void * kb_MemPool;
24 struct List kb_Exceptions[21];
25 struct List kb_Interrupts[64];
26 struct MemHeader *kb_SupervisorMem;
27 struct MinList kb_Modules;
28 context_t *kb_FPUOwner;
29 struct List kb_DeadTasks;
30 struct Task *kb_LastDeadTask;
33 struct OFWNode {
34 struct MinNode on_node;
35 char *on_name;
36 struct MinList on_children;
37 struct MinList on_properties;
39 uint8_t on_storage[];
42 struct OFWProperty {
43 struct MinNode op_node;
44 char *op_name;
45 uint32_t op_length;
46 void *op_value;
48 uint8_t op_storage[];
51 struct KernelBSS {
52 void *addr;
53 uint32_t len;
56 enum intr_types {
57 it_exception = 0xe0,
58 it_interrupt = 0xf0
61 struct IntrNode {
62 struct MinNode in_Node;
63 void (*in_Handler)(void *, void *);
64 void *in_HandlerData;
65 void *in_HandlerData2;
66 uint8_t in_type;
67 uint8_t in_nr;
71 * Exception handler differs a bit. It is suppost to have access to the CPU
72 * context...
74 struct ExceptNode {
75 struct MinNode in_Node;
76 int (*in_Handler)(regs_t *, void *, void *);
77 void *in_HandlerData;
78 void *in_HandlerData2;
79 uint8_t in_type;
80 uint8_t in_nr;
83 typedef struct {
84 struct MinNode m_node;
85 char *m_name;
86 char *m_str;
87 intptr_t m_lowest;
88 intptr_t m_highest;
89 struct MinList m_symbols;
90 } module_t;
92 typedef struct {
93 struct MinNode s_node;
94 char *s_name;
95 intptr_t s_lowest;
96 intptr_t s_highest;
97 } symbol_t;
99 static inline uint32_t goSuper() {
100 register uint32_t oldmsr asm("r3");
101 asm volatile("li %0,%1; sc":"=r"(oldmsr):"i"(SC_SUPERSTATE):"memory");
102 return oldmsr;
105 static inline void goUser() {
106 wrmsr(rdmsr() | (MSR_PR));
109 static inline uint64_t mftbu()
111 uint32_t lo,hi,tmp;
113 do {
114 asm volatile("mftbu %0; mftb %1; mftbu %2":"=r"(hi),"=r"(lo),"=r"(tmp));
115 } while(tmp != hi);
117 return (((uint64_t)hi) << 32) | ((uint64_t)lo);
120 intptr_t krnGetTagData(Tag tagValue, intptr_t defaultVal, const struct TagItem *tagList);
121 struct TagItem *krnFindTagItem(Tag tagValue, const struct TagItem *tagList);
122 struct TagItem *krnNextTagItem(const struct TagItem **tagListPtr);
124 void core_LeaveInterrupt(regs_t *regs) __attribute__((noreturn));
125 void core_Switch(regs_t *regs) __attribute__((noreturn));
126 void core_Schedule(regs_t *regs) __attribute__((noreturn));
127 void core_Dispatch(regs_t *regs) __attribute__((noreturn));
128 void core_ExitInterrupt(regs_t *regs) __attribute__((noreturn));
129 void core_Cause(struct ExecBase *SysBase);
130 int32_t core_Rtas(intptr_t rtas_args, intptr_t rtas_base, intptr_t rtas_entry);
131 void intr_init();
132 void mmu_init(char *mmu_dir, uint32_t mmu_size);
133 void ictl_init(void *);
134 void ictl_enable_irq(uint8_t irqnum);
135 void ictl_disable_irq(uint8_t irqnum);
136 void __attribute__((noreturn)) syscall_handler(regs_t *ctx, uint8_t exception, void *self);
137 void __attribute__((noreturn)) ictl_handler(regs_t *ctx, uint8_t exception, void *self);
138 void __attribute__((noreturn)) mmu_handler(regs_t *ctx, uint8_t exception, void *self);
140 int mmu_map_area(uint64_t virt, uint32_t phys, uint32_t length, uint32_t prot);
141 int mmu_map_page(uint64_t virt, uint32_t phys, uint32_t prot);
144 #ifdef bug
145 #undef bug
146 #endif
147 #ifdef D
148 #undef D
149 #endif
150 #define D(x) x
152 #define __STR(x) #x
153 #define STR(x) __STR(x)
155 AROS_LD2(int, KrnBug,
156 AROS_LDA(const char *, format, A0),
157 AROS_LDA(va_list, args, A1),
158 struct KernelBase *, KernelBase, 11, Kernel);
160 static inline void bug(const char *format, ...)
162 struct KernelBase *kbase = getKernelBase();
163 va_list args;
164 va_start(args, format);
165 AROS_SLIB_ENTRY(KrnBug, Kernel)(format, args, kbase);
166 va_end(args);
169 uint32_t findNames(intptr_t addr, char **module, char **function);
171 #endif /*KERNEL_INTERN_H_*/