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 <hardware/openfirmware.h>
11 #include <utility/tagitem.h>
19 #define KERNEL_PHYS_BASE 0x07800000
20 #define KERNEL_VIRT_BASE 0xff800000
22 #define STACK_SIZE 4096
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
;
42 struct MinNode in_Node
;
43 void (*in_Handler
)(void *, void *);
45 void *in_HandlerData2
;
51 * Exception handler differs a bit. It is suppost to have access to the CPU
55 struct MinNode in_Node
;
56 int (*in_Handler
)(regs_t
*, void *, void *);
58 void *in_HandlerData2
;
64 struct MinNode m_node
;
69 struct MinList m_symbols
;
73 struct MinNode s_node
;
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");
85 static inline void goUser() {
86 wrmsr(rdmsr() | (MSR_PR
));
89 static inline uint64_t mftbu()
94 asm volatile("mftbu %0; mftb %1; mftbu %2":"=r"(hi
),"=r"(lo
),"=r"(tmp
));
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
);
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
);
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();
144 va_start(args
, format
);
145 AROS_SLIB_ENTRY(KrnBug
, Kernel
, 12)(format
, args
, kbase
);
149 uint32_t findNames(intptr_t addr
, char **module
, char **function
);
151 #endif /*KERNEL_INTERN_H_*/