1 #ifndef KERNEL_INTERN_H_
2 #define KERNEL_INTERN_H_
4 #include <aros/libcall.h>
6 #include <exec/lists.h>
7 #include <exec/execbase.h>
8 #include <exec/memory.h>
9 #include <utility/tagitem.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
53 struct List kb_Exceptions
[EXCEPTIONS_NUM
];
54 struct List kb_Interrupts
[INTERRUPTS_NUM
];
68 struct MinNode in_Node
;
69 void (*in_Handler
)(void *, void *);
71 void *in_HandlerData2
;
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
);
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
, ...)
105 va_start(args
, format
);
106 AROS_SLIB_ENTRY(KrnBug
, Kernel
)(format
, args
, KernelBase
);
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);
133 #endif /*KERNEL_INTERN_H_*/