revert between 56095 -> 55830 in arch
[AROS.git] / arch / ppc-chrp / efika / kernel / kernel_intern.h
blob5c748cc45fbb91f82a2bce8a13e0c8e3e10d163c
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 <hardware/openfirmware.h>
11 #include <utility/tagitem.h>
12 #include <stdio.h>
13 #include <stdarg.h>
15 #include "syscall.h"
17 #undef KernelBase
19 #define KERNEL_PHYS_BASE 0x07800000
20 #define KERNEL_VIRT_BASE 0xff800000
22 #define STACK_SIZE 4096
24 struct KernelBase {
25 struct Node kb_Node;
26 void * kb_MemPool;
27 struct List kb_Exceptions[21];
28 struct List kb_Interrupts[64];
29 struct MemHeader *kb_SupervisorMem;
30 struct MinList kb_Modules;
31 context_t *kb_FPUOwner;
32 struct List kb_DeadTasks;
33 struct Task *kb_LastDeadTask;
36 enum intr_types {
37 it_exception = 0xe0,
38 it_interrupt = 0xf0
41 struct IntrNode {
42 struct MinNode in_Node;
43 void (*in_Handler)(void *, void *);
44 void *in_HandlerData;
45 void *in_HandlerData2;
46 uint8_t in_type;
47 uint8_t in_nr;
51 * Exception handler differs a bit. It is suppost to have access to the CPU
52 * context...
54 struct ExceptNode {
55 struct MinNode in_Node;
56 int (*in_Handler)(regs_t *, void *, void *);
57 void *in_HandlerData;
58 void *in_HandlerData2;
59 uint8_t in_type;
60 uint8_t in_nr;
63 typedef struct {
64 struct MinNode m_node;
65 char *m_name;
66 char *m_str;
67 intptr_t m_lowest;
68 intptr_t m_highest;
69 struct MinList m_symbols;
70 } module_t;
72 typedef struct {
73 struct MinNode s_node;
74 char *s_name;
75 intptr_t s_lowest;
76 intptr_t s_highest;
77 } symbol_t;
79 static inline uint32_t goSuper() {
80 register uint32_t oldmsr asm("r3");
81 asm volatile("li %0,%1; sc":"=r"(oldmsr):"i"(SC_SUPERSTATE):"memory");
82 return oldmsr;
85 static inline void goUser() {
86 wrmsr(rdmsr() | (MSR_PR));
89 static inline uint64_t mftbu()
91 uint32_t lo,hi,tmp;
93 do {
94 asm volatile("mftbu %0; mftb %1; mftbu %2":"=r"(hi),"=r"(lo),"=r"(tmp));
95 } while(tmp != hi);
97 return (((uint64_t)hi) << 32) | ((uint64_t)lo);
100 intptr_t krnGetTagData(Tag tagValue, intptr_t defaultVal, const struct TagItem *tagList);
101 struct TagItem *krnFindTagItem(Tag tagValue, const struct TagItem *tagList);
102 struct TagItem *krnNextTagItem(const struct TagItem **tagListPtr);
104 void core_LeaveInterrupt(regs_t *regs) __attribute__((noreturn));
105 void core_Switch(regs_t *regs) __attribute__((noreturn));
106 void core_Schedule(regs_t *regs) __attribute__((noreturn));
107 void core_Dispatch(regs_t *regs) __attribute__((noreturn));
108 void core_ExitInterrupt(regs_t *regs) __attribute__((noreturn));
109 void core_Cause(struct ExecBase *SysBase);
110 int32_t core_Rtas(intptr_t rtas_args, intptr_t rtas_base, intptr_t rtas_entry);
111 void intr_init();
112 void mmu_init(char *mmu_dir, uint32_t mmu_size);
113 void ictl_init(void *);
114 void ictl_enable_irq(uint8_t irqnum);
115 void ictl_disable_irq(uint8_t irqnum);
116 void __attribute__((noreturn)) syscall_handler(regs_t *ctx, uint8_t exception, void *self);
117 void __attribute__((noreturn)) ictl_handler(regs_t *ctx, uint8_t exception, void *self);
118 void __attribute__((noreturn)) mmu_handler(regs_t *ctx, uint8_t exception, void *self);
120 int mmu_map_area(uint64_t virt, uint32_t phys, uint32_t length, uint32_t prot);
121 int mmu_map_page(uint64_t virt, uint32_t phys, uint32_t prot);
124 #ifdef bug
125 #undef bug
126 #endif
127 #ifdef D
128 #undef D
129 #endif
130 #define D(x) x
132 #define __STR(x) #x
133 #define STR(x) __STR(x)
135 AROS_LD2(int, KrnBug,
136 AROS_LDA(const char *, format, A0),
137 AROS_LDA(va_list, args, A1),
138 struct KernelBase *, KernelBase, 12, Kernel);
140 static inline void bug(const char *format, ...)
142 struct KernelBase *kbase = getKernelBase();
143 va_list args;
144 va_start(args, format);
145 AROS_SLIB_ENTRY(KrnBug, Kernel, 12)(format, args, kbase);
146 va_end(args);
149 uint32_t findNames(intptr_t addr, char **module, char **function);
151 #endif /*KERNEL_INTERN_H_*/