add missing STACKED's
[AROS.git] / arch / ppc-sam440 / kernel / kernel_intern.h
blob555fdfce96416b4ff5e1a3c5d33ae59a185394a6
1 #ifndef KERNEL_INTERN_H_
2 #define KERNEL_INTERN_H_
4 #include <aros/libcall.h>
5 #include <inttypes.h>
6 #include <exec/lists.h>
7 #include <exec/execbase.h>
8 #include <exec/memory.h>
9 #include <utility/tagitem.h>
10 #include <asm/amcc440.h>
11 #include <stdio.h>
12 #include <stdarg.h>
14 #if defined(DEBUG) && DEBUG
15 #include <aros/debug.h>
16 struct KernelBase;
17 #include "kernel_debug.h"
19 /* Early definition of 'bug'
21 #undef bug
22 static inline void bug(const char *fmt, ...)
24 va_list args;
25 va_start(args, fmt);
26 krnBug(fmt, args, NULL);
27 va_end(args);
29 #endif
31 #define KERNEL_PHYS_BASE 0x00800000
32 #define KERNEL_VIRT_BASE 0xff800000
34 #define STACK_SIZE 4096
36 struct PlatformData {
37 context_t * pd_FPUOwner;
38 uint32_t pd_CPUUsage;
40 uint32_t pd_CPUFreq;
41 uint32_t pd_PLBFreq;
42 uint32_t pd_OPBFreq;
43 uint32_t pd_PCIFreq;
44 uint32_t pd_EPBFreq;
46 uint32_t pd_PVR; /* Cache of the PVR SPR */
48 struct MinList *pd_DebugInfo; /* List of struct Parthenope_DebugInfo */
51 static inline BOOL krnIsPPC440(uint32_t pvr)
53 return (pvr == PVR_PPC440EP_B || pvr == PVR_PPC440EP_C);
56 static inline BOOL krnIsPPC460(uint32_t pvr)
58 return (pvr == PVR_PPC460EX_B);
61 typedef struct {
62 struct MinNode m_node;
63 char * m_name;
64 char * m_str;
65 intptr_t m_lowest;
66 intptr_t m_highest;
67 struct MinList m_symbols;
68 } module_t;
70 typedef struct {
71 struct MinNode s_node;
72 char * s_name;
73 intptr_t s_lowest;
74 intptr_t s_highest;
75 } symbol_t;
77 static inline uint64_t mftbu()
79 uint32_t lo,hi,tmp;
81 do {
82 asm volatile("mftbu %0; mftb %1; mftbu %2":"=r"(hi),"=r"(lo),"=r"(tmp));
83 } while(tmp != hi);
85 return (((uint64_t)hi) << 32) | ((uint64_t)lo);
88 intptr_t krnGetTagData(Tag tagValue, intptr_t defaultVal, struct TagItem *tagList);
89 struct TagItem *krnFindTagItem(Tag tagValue, struct TagItem *tagList);
90 struct TagItem *krnNextTagItem(struct TagItem **tagListPtr);
92 void core_ExitInterrupt(context_t *ctx);
93 void dumpregs(context_t *ctx, uint8_t exception);
95 void mmu_init(struct TagItem *tags);
96 void intr_init();
98 extern ULONG uic_er[4];
100 void uic_init(void);
101 void uic_enable(int irq);
102 void uic_disable(int irq);
104 static inline void ExitInterrupt(context_t *ctx)
106 /* As per the documentation of core_ExitInterrupt,
107 * only call this if we are returning to user mode!
109 if (ctx->cpu.srr1 & MSR_PR)
110 core_ExitInterrupt(ctx);
113 typedef void exception_handler(context_t *ctx, uint8_t exception);
115 extern exception_handler generic_handler;
116 extern exception_handler uic_handler;
117 extern exception_handler alignment_handler;
118 extern exception_handler syscall_handler;
119 extern exception_handler decrementer_handler;
120 extern exception_handler mmu_handler;
123 uint32_t findNames(intptr_t addr, char **module, char **function);
126 #endif /*KERNEL_INTERN_H_*/