Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / all-mingw32 / kernel / kernel_intern.h
blob91ed59793fa2ec111a40d84100a88fe378d4cb33
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 <stdio.h>
11 #include <stdarg.h>
12 #include "hostinterface.h"
14 #define STACK_SIZE 4096
16 /* In Windows-hosted kernel exceptions and IRQs work in the following way:
18 Exceptions are currently not used. They are reserved for implementing CPU
19 exceptions handling (access violation, division by zero, etc).
21 IRQs are used to receive events from emulated hardware. Hardware is mostly
22 emulated using Windows threads running asynchronously to AROS. When the
23 thread finishes its job it calls host-size KrnCauseIRQ() function in order
24 to initiate an IRQ in AROS.
26 Currently number of IRQs are fixed and they are used as following:
27 IRQ 0 - main system periodic timer (50 Hz). Used internally by kernel.resource
28 for task switching and VBlank emulation. Exec uses it as a VBLANK source.
29 In current implementation it can not be caused manually using KernelCauseIRQ().
30 IRQ 1 - Used by emul.handler to serve input from host's console.
31 IRQ 2 - Used by graphics HIDD.
32 IRQ 3 - Used by mouse HIDD.
33 IRQ 4 - Used by keyboard HIDD.
35 In future there can be much more drivers many of which would need an IRQ. In order to manage
36 this i have an idea of implementing dynamic allocation of IRQs in some way.
38 The whole described thing is experimental and subject to change.
41 #define EXCEPTIONS_NUM 1
42 #define INTERRUPTS_NUM 5
44 #define INT_TIMER 0
45 #define INT_IO 1
46 #define INT_GFX 2
47 #define INT_MOUSE 3
48 #define INT_KBD 4
50 struct KernelBase {
51 struct Node kb_Node;
52 void * kb_MemPool;
53 struct List kb_Exceptions[EXCEPTIONS_NUM];
54 struct List kb_Interrupts[INTERRUPTS_NUM];
57 struct KernelBSS {
58 void *addr;
59 IPTR len;
62 enum intr_types {
63 it_exception = 0xe0,
64 it_interrupt = 0xf0
67 struct IntrNode {
68 struct MinNode in_Node;
69 void (*in_Handler)(void *, void *);
70 void *in_HandlerData;
71 void *in_HandlerData2;
72 uint8_t in_type;
73 uint8_t in_nr;
76 #ifdef bug
77 #undef bug
78 #endif
80 #ifdef __AROS__
81 struct KernelInterface {
82 long (*core_init)(unsigned long TimerPeriod, struct ExecBase **SysBasePointer, APTR *KernelBasePointer);
83 long (*core_intr_disable)(void);
84 long (*core_intr_enable)(void);
85 void (*core_syscall)(unsigned long n);
86 unsigned char (*core_is_super)(void);
89 extern struct HostInterface *HostIFace;
90 extern struct KernelInterface KernelIFace;
91 extern APTR KernelBase;
93 IPTR krnGetTagData(Tag tagValue, intptr_t defaultVal, const struct TagItem *tagList);
94 struct TagItem *krnFindTagItem(Tag tagValue, const struct TagItem *tagList);
95 struct TagItem *krnNextTagItem(const struct TagItem **tagListPtr);
97 AROS_LD2(int, KrnBug,
98 AROS_LDA(const char *, format, A0),
99 AROS_LDA(va_list, args, A1),
100 struct KernelBase *, KernelBase, 11, Kernel);
102 static inline void bug(const char *format, ...)
104 va_list args;
105 va_start(args, format);
106 AROS_SLIB_ENTRY(KrnBug, Kernel)(format, args, KernelBase);
107 va_end(args);
110 #else
112 #define SLEEP_MODE_OFF 0
113 #define SLEEP_MODE_PENDING 1
114 #define SLEEP_MODE_ON 2
116 extern DWORD SwitcherId;
117 extern DWORD *LastErrorPtr;
118 extern unsigned char Ints_Enabled;
119 extern unsigned char Sleep_Mode;
120 extern unsigned char PendingInts[INTERRUPTS_NUM];
121 extern struct ExecBase **SysBasePtr;
122 extern struct KernelBase **KernelBasePtr;
124 void core_Dispatch(CONTEXT *regs);
125 void core_Switch(CONTEXT *regs);
126 void core_Schedule(CONTEXT *regs);
127 void core_ExitInterrupt(CONTEXT *regs);
128 void core_Cause(struct ExecBase *SysBase);
129 long core_intr_enable(void);
131 #endif
133 #endif /*KERNEL_INTERN_H_*/