http://www.aros.orgAROS-ExecAROS-Exec ArchivesPower2People
kitty mascottop logo menu

kernel

Index


KrnAddExceptionHandler() KrnAddIRQHandler() KrnAllocPages() KrnBug()
KrnCause() KrnCli() KrnCreateContext() KrnDeleteContext()
KrnDispatch() KrnDisplayAlert() KrnFormatStr() KrnFreePages()
KrnGetBootInfo() KrnGetCPUCount() KrnGetCPUNumber() KrnGetScheduler()
KrnGetSystemAttr() KrnInitMemory() KrnIsSuper() KrnMapGlobal()
KrnMayGetChar() KrnModifyIRQHandler() KrnObtainInput() KrnPutChar()
KrnReleaseInput() KrnRemExceptionHandler() KrnRemIRQHandler() KrnSchedule()
KrnSetProtection() KrnSetScheduler() KrnStatMemoryA() KrnSti()
KrnSwitch() KrnUnmapGlobal() KrnVirtualToPhysical()  

KrnAddExceptionHandler()

Synopsis

void * KrnAddExceptionHandler(
         uint8_t num,
         exhandler_t * handler,
         void * handlerData,
         void * handlerData2 );

Function

Add a raw CPU exception handler to the chain of handlers.

Inputs

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.

Result

An opaque handle that can be used for handler removal or NULL in case
of failure (like unsupported exception number).

Notes

The specification of this function is preliminary and subject to change.
Consider it private for now.

KrnAddIRQHandler()

Synopsis

void * KrnAddIRQHandler(
         uint8_t irq,
         irqhandler_t * handler,
         void * handlerData,
         void * handlerData2 );

Function

Add a raw hardware IRQ handler to the chain of handlers.

Inputs

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.

Result

An opaque handle that can be used for handler removal or NULL in case
of failure (like unsupported exception number).

KrnAllocPages()

Synopsis

void * KrnAllocPages(
         void * addr,
         uintptr_t length,
         uint32_t flags );

Function

Allocate physical memory pages

Inputs

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().

Result

Real starting address of the allocated region.

Notes

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.

KrnBug()

Synopsis

int KrnBug(
         const char * format,
         va_list args );

Function

Output a formatted string to low-level debug output stream.

The function supports the same set of formatting specifiers
as standard C printf() function.

Inputs

format - A format string
args   - A list of arguments

Result

Number of succesfully printed characters

KrnCause()

Synopsis

void KrnCause();

Function

Run software interrupt processing sequence

Inputs

None

Result

None

Notes

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.

KrnCli()

Synopsis

void KrnCli();

Function

Instantly disable interrupts.

Inputs

None

Result

None

Notes

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 isn't implemented on all platforms.

KrnCreateContext()

Synopsis

void * KrnCreateContext();

Function

Allocate and initialize CPU context storage area.

Inputs

None.

Result

A pointer to a CPU context storage area.

Notes

CPU context storage is considered private and accessible
only from within supevisor mode.

KrnDeleteContext()

Synopsis

void KrnDeleteContext(
         void * context );

Function

Free CPU context storage area

Inputs

context - a pointer to a CPU context storage previously allocated using
          KrnCreateContext()

Result

None.

KrnDispatch()

Synopsis

void KrnDispatch();

Function

Run the next available task

Inputs

None

Result

None

Notes

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.

KrnDisplayAlert()

Synopsis

void KrnDisplayAlert(
         uint32_t code,
         const char * text );

Function

Inform the user about critical system failure.

Inputs

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.

Result

None. This function is not guaranteed to return.

Notes

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.

KrnFormatStr()

Synopsis

int KrnFormatStr(
         void * putch,
         const char * format,
         va_list args );

Function

Format a string using C printf() convention, using 'putch'
as character output function.

Inputs

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.

Result

Number of succesfully printed characters

KrnFreePages()

Synopsis

void KrnFreePages(
         void * addr,
         uintptr_t length );

Notes

This function works only on systems with MMU support.

KrnGetBootInfo()

Synopsis

struct TagItem * KrnGetBootInfo();

KrnGetCPUCount()

Synopsis

unsigned int KrnGetCPUCount();

Function

Return total number of processors in the system

Inputs

None

Result

Number of running CPUs in this system

KrnGetCPUNumber()

Synopsis

unsigned int KrnGetCPUNumber();

Function

Return number of the caller CPU

Inputs

None

Result

Number of the CPU on which the function is called

KrnGetScheduler()

Synopsis

KRN_SchedType KrnGetScheduler();

KrnGetSystemAttr()

Synopsis

intptr_t KrnGetSystemAttr(
         uint32_t id );

Function

Get value of internal system attributes.
Currently defined attributes are:

  KATTR_Architecture [.G] (char *)        - Name of architecture the kernel built for.

Inputs

id - ID of the attribute to get

Result

Value of the attribute

KrnInitMemory()

Synopsis

void KrnInitMemory(
         struct MemHeader * mh );

Function

Initialize kernel memory management on a given memory region

Inputs

mh - Address of a filled in structure describing the region.

Result

None.

KrnIsSuper()

Synopsis

int KrnIsSuper();

Function

Determine if the caller is running in supervisor mode

Inputs

None

Result

Nonzero for supervisor mode, zero for user mode

Notes

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).

KrnMapGlobal()

Synopsis

int KrnMapGlobal(
         void * virtual,
         void * physical,
         uint32_t length,
         KRN_MapAttr flags );

KrnMayGetChar()

Synopsis

int KrnMayGetChar();

Function

Read a single character from low-level debug input stream

Inputs

None

Result

An ASCII code of the character or -1 if there's no character
available

Notes

This function never waits. If there is no character available on
the stream it just returns with -1

KrnModifyIRQHandler()

Synopsis

void KrnModifyIRQHandler(
         void * handle,
         void * handlerData,
         void * handlerData2 );

Function

Modify the data passed to a raw hardware IRQ handler.

Inputs

handle       - Existing handle
handlerData,
handlerData2 - User-defined data which is passed to the
               handler.

KrnObtainInput()

Synopsis

int KrnObtainInput();

Function

Take over low-level debug input hardware and initialize the input

Inputs

None

Result

Nonzero for success, zero for failure (for example there's no input channel)

KrnPutChar()

Synopsis

void KrnPutChar(
         char c );

Function

Output a single character to low-level debug output stream

Inputs

c - A character to output

Result

None

KrnReleaseInput()

Synopsis

void KrnReleaseInput();

Function

Release low-level debug input hardware and hand it back to the operating system

Inputs

None

Result

None

KrnRemExceptionHandler()

Synopsis

void KrnRemExceptionHandler(
         void * handle );

Function

Remove previously installed CPU exception handler

Inputs

handle - an opaque handler returned by KrnAddExceptionHandler()
         function

Result

None

KrnRemIRQHandler()

Synopsis

void KrnRemIRQHandler(
         void * handle );

Function

Remove previously installed hardware IRQ handler

Inputs

handle - an opaque handler returned by KrnAddIRQHandler()
         function

Result

None

KrnSchedule()

Synopsis

void KrnSchedule();

Function

Run task scheduling sequence

Inputs

None

Result

None

Notes

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.

KrnSetProtection()

Synopsis

void KrnSetProtection(
         void * address,
         uint32_t length,
         KRN_MapAttr flags );

KrnSetScheduler()

Synopsis

void KrnSetScheduler(
         KRN_SchedType sched );

KrnStatMemoryA()

Synopsis

ULONG KrnStatMemoryA(
         ULONG flags,
         struct TagItem * query );

ULONG KrnStatMemory(
         ULONG flags,
         TAG tag, ... );

Function

Get various statistics about memory usage

Inputs

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().

Result

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.

Notes

For all unknown tag IDs result values will be set to 0.

KrnSti()

Synopsis

void KrnSti();

Function

Instantly enable interrupts.

Inputs

None

Result

None

Notes

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 isn't implemented on all platforms.

KrnSwitch()

Synopsis

void KrnSwitch();

Function

Save context of caller's task and dispatch the next available task

Inputs

None

Result

None

Notes

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.

KrnUnmapGlobal()

Synopsis

int KrnUnmapGlobal(
         void * virtual,
         uint32_t length );

KrnVirtualToPhysical()

Synopsis

void * KrnVirtualToPhysical(
         void * virtual );

Copyright © 1995-2014, The AROS Development Team. All rights reserved.
Amiga®, AmigaOS®, Workbench and Intuition are trademarks of Amiga Inc. All other trademarks belong to their respective owners.