IBNOS
|
Classes | |
struct | GDTTable |
struct | GDTEntry |
struct | IDTTable |
struct | IDTEntry |
Macros | |
#define | INTJMP_ENTRY_SIZE 8 |
#define | INTJMP_ENTRY_MASK 7 |
#define | INTJMP_ENTRY_BITS 3 |
#define | KERNEL_IDLE_BEGIN ((uint32_t)&__kernelIdleBegin) |
#define | KERNEL_IDLE_END ((uint32_t)&__kernelIdleEnd) |
#define | KERNELSTACK_SIZE PAGE_SIZE |
Functions | |
void | __attribute__ ((cdecl)) |
void | gdtInit () |
Initializes the GDT, task registers, and sets up everything required for multiprocessing. More... | |
struct GDTEntry * | gdtGetFreeEntry () |
Get a free entry in the GDT. More... | |
uint32_t | gdtGetEntryOffset (struct GDTEntry *entry, uint32_t ring) |
Determines the offset of a GDT entry. More... | |
void | gdtEntrySetAddress (struct GDTEntry *entry, uint32_t address) |
Helper function to set the address inside a GDTEntry. More... | |
void | gdtEntrySetLimit (struct GDTEntry *entry, uint64_t length) |
Helper function to set the length inside a GDTEntry. More... | |
void | gdtReleaseEntry (struct GDTEntry *entry) |
Mark a GDTEntry as free. More... | |
uint32_t | tssRunUsermodeThread (struct thread *t) |
Run a thread. More... | |
struct GDTTable | __attribute__ ((packed)) |
Variables | |
void * | kernelStack |
void * | intJmpTable_kernel |
void * | intJmpTable_user |
struct GDTEntry * | codeRing0 |
struct GDTEntry * | dataRing0 |
struct GDTEntry * | codeRing3 |
struct GDTEntry * | dataRing3 |
struct GDTEntry * | kernelTask |
struct GDTEntry * | usermodeTask |
uint32_t | __kernelIdleBegin |
uint32_t | __kernelIdleEnd |
GDT Privileges | |
#define | GDT_CPL_MASK 3 |
#define | GDT_CPL_RING0 0 |
#define | GDT_CPL_RING3 3 |
Interrupt types | |
For more information take a look at http://wiki.osdev.org/Interrupt_Descriptor_Table | |
#define | INT_TYPE_TASK32 0x5 |
#define | INT_TYPE_INT16 0x6 |
#define | INT_TYPE_TRAP16 0x7 |
#define | INT_TYPE_INT32 0xE |
#define | INT_TYPE_TRAP32 0xF |
GDT Size | |
#define | GDT_MAX_SIZE 0x10000 |
#define | GDT_MAX_PAGES ((GDT_MAX_SIZE + PAGE_MASK) >> PAGE_BITS) |
#define | GDT_MAX_COUNT (GDT_MAX_SIZE / sizeof(struct GDTEntry)) |
IDT Size | |
#define | IDT_MAX_SIZE PAGE_SIZE |
#define | IDT_MAX_COUNT 256 |
#define GDT_CPL_MASK 3 |
#define GDT_MAX_COUNT (GDT_MAX_SIZE / sizeof(struct GDTEntry)) |
#define GDT_MAX_PAGES ((GDT_MAX_SIZE + PAGE_MASK) >> PAGE_BITS) |
#define GDT_MAX_SIZE 0x10000 |
#define IDT_MAX_SIZE PAGE_SIZE |
#define INT_TYPE_INT32 0xE |
#define KERNEL_IDLE_BEGIN ((uint32_t)&__kernelIdleBegin) |
#define KERNEL_IDLE_END ((uint32_t)&__kernelIdleEnd) |
#define KERNELSTACK_SIZE PAGE_SIZE |
struct GDTTable __attribute__ | ( | (packed) | ) |
void gdtEntrySetAddress | ( | struct GDTEntry * | entry, |
uint32_t | address | ||
) |
Helper function to set the address inside a GDTEntry.
The address value is split across 3 attributes inside the GDTEntry structure (GDTEntry::address1, GDTEntry::address2, GDTEntry::address3). This functions should make it easier to set this value.
[in] | entry | The entry which should be altered |
[in] | address | The address which should be set |
void gdtEntrySetLimit | ( | struct GDTEntry * | entry, |
uint64_t | length | ||
) |
Helper function to set the length inside a GDTEntry.
The length value or to be more precise the limit (length - 1) is split across 2 attributes inside the GDTEntry structure (GDTEntry::limit1, GDTEntry::limit2). All these fields can only save a value with a maximum of 20 bits. To store a length with a higher value (for example for a segment covering the whole address space), the value can be stored as pages. The function will automatically set the GDTEntry::granularity bit to identify the limit as page count.
[in] | entry | The entry which should be altered |
[in] | length | The length which should be set |
uint32_t gdtGetEntryOffset | ( | struct GDTEntry * | entry, |
uint32_t | ring | ||
) |
Determines the offset of a GDT entry.
This functions calculates the offset of an entry relative to the base address of the GDT. This CPU always uses offsets to identify an entry, so that the absolute address of an entry is only useful for changing it. These offsets are for example required to specify a segment as value in a segment register (CS, DS, SS, ...) or an task inside the task register. The CPU also stores the needed privilege level (ring) inside such a register. To simplify your work, this function will embed the ring passed as parameter.
[in] | entry | The entry for which you want to get the offset |
[in] | ring | The ring which is required to access the segment |
struct GDTEntry * gdtGetFreeEntry | ( | ) |
void gdtInit | ( | ) |
void gdtReleaseEntry | ( | struct GDTEntry * | entry | ) |
uint32_t tssRunUsermodeThread | ( | struct thread * | t | ) |
Run a thread.
This function loads the saved thread context inside a hardware task and starts it.
[in] | t | A pointer to a thread structure containing the tss context |
uint32_t __kernelIdleBegin |
uint32_t __kernelIdleEnd |