kernel
Index
void * KrnAddExceptionHandler(
uint8_t num,
exhandler_t * handler,
void * handlerData,
void * handlerData2 );
Add a raw CPU exception handler to the chain of handlers.
num - CPU-specific exception number
handler - Pointer to a handler function
handlerData,
handlerData2 - User-defined data which is passed to the
handler.
Handler function uses a C calling convention and must be
declared as follows:
int ExceptionHandler(void *ctx, void *handlerData, void *handlerData2)
handlerData and handlerData2 will be values passed to the
KrnAddExceptionHandler() function. ctx is a CPU context handle.
Consider this parameter private and reserved for now.
Exception handler should return nonzero value if it processes the
exception and wants to continue program execution. Otherwise it should
return zero. If all exception handlers in the chain return zero, the
exception will be passed on to exec.library trap handler pointed to
by tc_TrapCode field of task structure.
An opaque handle that can be used for handler removal or NULL in case
of failure (like unsupported exception number).
The specification of this function is preliminary and subject to change.
Consider it private for now.
void * KrnAddIRQHandler(
uint8_t irq,
irqhandler_t * handler,
void * handlerData,
void * handlerData2 );
Add a raw hardware IRQ handler to the chain of handlers.
num - hardware-specific IRQ number
handler - Pointer to a handler function
handlerData,
handlerData2 - User-defined data which is passed to the
handler.
Handler function uses a C calling convention and must be
declared as follows:
void IRQHandler(void *handlerData, void *handlerData2)
handlerData and handlerData2 will be values passed to the
KrnAddExceptionHandler() function.
There is no return code for the IRQ handler.
An opaque handle that can be used for handler removal or NULL in case
of failure (like unsupported exception number).
void * KrnAllocPages(
void * addr,
uintptr_t length,
uint32_t flags );
Allocate physical memory pages
addr - Starting address of region which must be included in the
allocated region or NULL for the system to choose the
starting address. Normally you will supply NULL here.
length - Length of the memory region to allocate
flags - Flags describing type of needed memory. These are the same
flags as passed to exec.library/AllocMem().
Real starting address of the allocated region.
Since this allocator is page-based, length will always be round up
to system's memory page size. The same applies to starting address
(if specified), it will be rounded down to page boundary.
This function works only on systems with MMU support. Without MMU
it will always return NULL.
int KrnBug(
const char * format,
va_list args );
Output a formatted string to low-level debug output stream.
The function supports the same set of formatting specifiers
as standard C printf() function.
format - A format string
args - A list of arguments
Number of succesfully printed characters
Run software interrupt processing sequence
This entry point directly calls interrupt processing routine
in supervisor mode. It neither performs any checks of caller status
nor obeys interrupt enable state.
This function is safe to call only from within user mode.
This function is considered internal, and not meant to be called
by user's software.
Instantly disable interrupts.
This is low level function, it does not have nesting count
and state tracking mechanism. It operates directly on the CPU.
Normal applications should consider using exec.library/Disable().
This function is unimplemented.
void * KrnCreateContext();
Allocate and initialize CPU context storage area.
A pointer to a CPU context storage area.
CPU context storage is considered private and accessible
only from within supevisor mode.
void KrnDeleteContext(
void * context );
Free CPU context storage area
context - a pointer to a CPU context storage previously allocated using
KrnCreateContext()
Run the next available task
This entry point directly calls task dispatch routine in supervisor mode.
It neither performs any checks of caller status nor obeys interrupt enable
state. After calling this function, caller's task will be replaced by
another one, and caller's state will be lost.
This function is safe to call only from within user mode.
This function is considered internal, and not meant to be called
by user's software.
void KrnDisplayAlert(
uint32_t code,
const char * text );
Inform the user about critical system failure.
code - Corresponding alert code.
text - A NULL-terminated text to print out.
First three lines are assumed to be a header. Some implementations
may print them centered inside a frame.
None. This function is not guaranteed to return.
This function exists for system internal purposes. Please do not
call it from within regular applications! In 99% of cases this function
will halt or reboot the machine. Certain structures in RAM, as well as
video hardware state, will be irreversibly destroyed.
'code' parameter is passed for convenience. Based on it, the system
can make a decision to log the alert in debug output and continue,
instead of displaying a message and halting.
This function is currently experimental. Its definition may change.
int KrnFormatStr(
void * putch,
const char * format,
va_list args );
Format a string using C printf() convention, using 'putch'
as character output function.
putch - A pointer to the output function
format - A format string
args - A list of arguments
A character output function needs to be declared as:
int myPutCh(int char, void *KernelBase)
It is expected to return 1 on success and 0 on failure.
Number of succesfully printed characters
void KrnFreePages(
void * addr,
uintptr_t length );
This function works only on systems with MMU support.
struct TagItem * KrnGetBootInfo();
unsigned int KrnGetCPUCount();
Return total number of processors in the system
Number of running CPUs in this system
unsigned int KrnGetCPUNumber();
Return number of the caller CPU
Number of the CPU on which the function is called
KRN_SchedType KrnGetScheduler();
intptr_t KrnGetSystemAttr(
uint32_t id );
Get value of internal system attributes.
Currently defined attributes are:
KATTR_Architecture [.G] (char *) - Name of architecture the kernel built for.
id - ID of the attribute to get
void KrnInitMemory(
struct MemHeader * mh );
Initialize kernel memory management on a given memory region
mh - Address of a filled in structure describing the region.
Determine if the caller is running in supervisor mode
Nonzero for supervisor mode, zero for user mode
Callers should only test the return value against zero.
Nonzero values may actually be different, since they
may carry some private implementation-dependent information
(like CPU privilege level, for example).
int KrnMapGlobal(
void * virtual,
void * physical,
uint32_t length,
KRN_MapAttr flags );
Read a single character from low-level debug input stream
An ASCII code of the character or -1 if there's no character
available
This function never waits. If there is no character available on
the stream it just returns with -1
void KrnModifyIRQHandler(
void * handle,
void * handlerData,
void * handlerData2 );
Modify the data passed to a raw hardware IRQ handler.
handle - Existing handle
handlerData,
handlerData2 - User-defined data which is passed to the
handler.
Take over low-level debug input hardware and initialize the input
Nonzero for success, zero for failure (for example there's no input channel)
void KrnPutChar(
char c );
Output a single character to low-level debug output stream
c - A character to output
Release low-level debug input hardware and hand it back to the operating system
void KrnRemExceptionHandler(
void * handle );
Remove previously installed CPU exception handler
handle - an opaque handler returned by KrnAddExceptionHandler()
function
void KrnRemIRQHandler(
void * handle );
Remove previously installed hardware IRQ handler
handle - an opaque handler returned by KrnAddIRQHandler()
function
Run task scheduling sequence
This entry point directly calls task scheduling routine
in supervisor mode. It neither performs any checks of caller status
nor obeys interrupt enable state.
This function is safe to call only from within user mode.
This function is considered internal, and not meant to be called
by user's software.
void KrnSetProtection(
void * address,
uint32_t length,
KRN_MapAttr flags );
void KrnSetScheduler(
KRN_SchedType sched );
ULONG KrnStatMemoryA(
ULONG flags,
struct TagItem * query );
ULONG KrnStatMemory(
ULONG flags,
TAG tag, ... );
Get various statistics about memory usage
query - An array of TagItems containing query specification. Each
TagItem consists of tag ID and a pointer to a value of
specified type which will contain the result of the query.
Available tag IDs are:
KMS_Free (IPTR) - Get amount of free memory in bytes
KMS_Total (IPTR) - Get total amount of memory in bytes
KMS_LargestAlloc (IPTR) - Get size of the largest allocated chunk in bytes
KMS_SmallestAlloc (IPTR) - Get size of the smallest allocated chunk in bytes
KMS_LargestFree (IPTR) - Get size of the largest free chunk in bytes
KMS_SmallestFree (IPTR) - Get size of the smallest free chunk in bytes
KMS_NumAlloc (IPTR) - Get number of allocated chunks
KMS_NumFree (IPTR) - Get number of free chunks
KMS_PageSize (ULONG) - Get memory page size
flags - Flags which specify physical properties of the memory to query.
These are the same flags as passed to exec.library/AllocMem().
TRUE if the function worked, FALSE if MMU is not up and running on the system.
If the function returns FALSE, values will stay uninitialized.
For all unknown tag IDs result values will be set to 0.
Instantly enable interrupts.
This is low level function, it does not have nesting count
and state tracking mechanism. It operates directly on the CPU.
Normal applications should consider using exec.library/Enable().
This function is unimplemented.
Save context of caller's task and dispatch the next available task
This entry point directly calls task switch routine
in supervisor mode. It neither performs any checks of caller status
nor obeys interrupt enable state. After calling this function, caller's
task will be replaced by another one, and it's caller's responsibility
to do anything to prevent task loss.
This function is safe to call only from within user mode.
This function is considered internal, and not meant to be called
by user's software.
int KrnUnmapGlobal(
void * virtual,
uint32_t length );
void * KrnVirtualToPhysical(
void * virtual );
|
|