1 #ifndef KERNEL_INTERN_H_
2 #define KERNEL_INTERN_H_
4 #include <asm/mpc5200b.h>
5 #include <aros/libcall.h>
7 #include <exec/lists.h>
8 #include <exec/execbase.h>
9 #include <exec/memory.h>
10 #include <utility/tagitem.h>
16 #define KERNEL_PHYS_BASE 0x07800000
17 #define KERNEL_VIRT_BASE 0xff800000
19 #define STACK_SIZE 4096
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
;
34 struct MinNode on_node
;
36 struct MinList on_children
;
37 struct MinList on_properties
;
43 struct MinNode op_node
;
62 struct MinNode in_Node
;
63 void (*in_Handler
)(void *, void *);
65 void *in_HandlerData2
;
71 * Exception handler differs a bit. It is suppost to have access to the CPU
75 struct MinNode in_Node
;
76 int (*in_Handler
)(regs_t
*, void *, void *);
78 void *in_HandlerData2
;
84 struct MinNode m_node
;
89 struct MinList m_symbols
;
93 struct MinNode s_node
;
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");
105 static inline void goUser() {
106 wrmsr(rdmsr() | (MSR_PR
));
109 static inline uint64_t mftbu()
114 asm volatile("mftbu %0; mftb %1; mftbu %2":"=r"(hi
),"=r"(lo
),"=r"(tmp
));
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
);
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
);
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();
164 va_start(args
, format
);
165 AROS_SLIB_ENTRY(KrnBug
, Kernel
)(format
, args
, kbase
);
169 uint32_t findNames(intptr_t addr
, char **module
, char **function
);
171 #endif /*KERNEL_INTERN_H_*/