|
From: Tim R. <ti...@ga...> - 2002-08-14 10:12:58
|
[Grr... should have hit 'Reply To All'] On Wed, 14 Aug 2002 11:10:27 +0530 "prakash saivasan" <hel...@ho...> wrote: | That was very fast :)... I was just going thru the Mobius OS. I have | some doubts regarding the internals. | 1) We dont support any kind of bottom half and top half ( during Interrupt | processing) am I right ? There is a bit of bottom half support. You can queue an Asynchronous Procedure Call in a particular thread using the ThrQueueKernelApc function (void ThrQueueKernelApc(thread_t *thr, void (*fn)(void*), void *param);). This will cause the thread to be scheduled next time the scheduler runs, if necessary, and your routine will be called before the thread returns to user mode. Although interrupts aren't currently enabled during the execution of an APC routine, they ought to be. Alternatively, you could start a kernel thread in the system process (ThrCreateThread(NULL, etc.)) to do the processing. These threads are scheduled just like user threads, except that they run in kernel mode. | 2) How much of DMA support do we have in Mobius ( API kind)? Currently, there's nothing specific to DMA, although it's possible to allocate a contiguous block of physical memory (addr_t MemAllocLowSpan (size_t pages);). For example, the floppy driver talks to the ISA DMA controller directly but it gets its memory from MemAllocLowSpan. To free that memory, call MemFreeLow for each page in the block. | 3) would like to know more about how to implement a system call in Mobius | !!! To add one permanently: 1) Add a system call ID #define to the relevant section at the top of include/os/sysdef.h. There are several groups of system calls defined already, or you could start your own if need be. 2) Lower down in sysdef.h, add your system call prototype. This should look like: SYSCALL(return_type, name, params_size, (int param1, int param2)); where: -- return_type and name are the return type and name of the function which implements the system call -- params_size is the size, in bytes, of the parameters (usually 4*number, although uint64_t takes up 8 bytes) -- the bit between the brackets is the full parameter list for the function, or (void) for none This macro gets expanded to give: -- function prototype for include/os/syscall.h, for both user and kernel modes -- entry in the system call dispatcher table (see src/kernel/i386/scdsptch.c) -- user-mode stub function assembly code for src/libsys/syscall.S 3) Add the name of your function to the kernel export list in src/kernel/kernel.def 4) Add the name of your function to the libsys export list in src/libsys/libsys.def 5) Implement the function anywhere in the kernel. Misc. syscalls go in syscall.c, although most groups of functions have their own file. If the system call has a different prototype in user and kernel modes (e.g. ThrSleep is void ThrSleep(unsigned) in user mode and void ThrSleep(thread_t*, unsigned) in kernel mode), see the note at the top of sysdef.h. To add one temporarily, (e.g. to hook another system call inside a driver), use the KeSetSysCall and KeGetSysCall functions. -- Tim Robinson <tim...@ic...> |