FreeNOS
Public Member Functions | Static Private Member Functions | Private Attributes
IntelKernel Class Reference

Implements an x86 compatible kernel. More...

#include <IntelKernel.h>

Inheritance diagram for IntelKernel:
Kernel WeakSingleton< Kernel >

Public Member Functions

 IntelKernel (CoreInfo *info)
 Constructor function. More...
 
virtual void enableIRQ (u32 irq, bool enabled)
 Enable or disable an hardware interrupt (IRQ). More...
 
- Public Member Functions inherited from Kernel
 Kernel (CoreInfo *info)
 Constructor function. More...
 
SplitAllocatorgetAllocator ()
 Get physical memory allocator. More...
 
ProcessManagergetProcessManager ()
 Get process manager. More...
 
APIgetAPI ()
 Get API. More...
 
MemoryContextgetMemoryContext ()
 Get the current MMU context. More...
 
CoreInfogetCoreInfo ()
 Get CoreInfo. More...
 
TimergetTimer ()
 Get Timer. More...
 
int run ()
 Execute the kernel. More...
 
virtual Result sendIRQ (const uint coreId, const uint irq)
 Send a inter-processor-interrupt (IPI) to another core. More...
 
virtual void hookIntVector (u32 vec, InterruptHandler h, ulong p)
 Hooks a function to an hardware interrupt. More...
 
virtual void executeIntVector (u32 vec, CPUState *state)
 Execute an interrupt handler. More...
 
virtual Result loadBootImage ()
 Loads the boot image. More...
 
- Public Member Functions inherited from WeakSingleton< Kernel >
 WeakSingleton (Kernel *obj)
 Constructor. More...
 

Static Private Member Functions

static void exception (CPUState *state, ulong param, ulong vector)
 Called when the CPU detects a fault. More...
 
static void interrupt (CPUState *state, ulong param, ulong vector)
 Default interrupt handler. More...
 
static void trap (CPUState *state, ulong param, ulong vector)
 Kernel trap handler (system calls). More...
 
static void clocktick (CPUState *state, ulong param, ulong vector)
 i8253 system clock interrupt handler. More...
 

Private Attributes

IntelPIT m_pit
 PIT timer instance. More...
 
IntelAPIC m_apic
 APIC instance (used if available) More...
 
IntelPIC m_pic
 PIC instance. More...
 

Additional Inherited Members

- Public Types inherited from Kernel
enum  Result { Success, InvalidBootImage, ProcessError, IOError }
 Result codes. More...
 
- Static Public Member Functions inherited from Kernel
static Error initializeHeap ()
 Initialize heap. More...
 
- Static Public Member Functions inherited from WeakSingleton< Kernel >
static Kernelinstance ()
 Retrieve the instance. More...
 
- Protected Attributes inherited from Kernel
SplitAllocatorm_alloc
 Physical memory allocator. More...
 
ProcessManagerm_procs
 Process Manager. More...
 
APIm_api
 API handlers object. More...
 
CoreInfom_coreInfo
 CoreInfo object for this core. More...
 
Vector< List< InterruptHook * > * > m_interrupts
 Interrupt handlers. More...
 
IntControllerm_intControl
 Interrupt Controller. More...
 
Timerm_timer
 Timer device. More...
 

Detailed Description

Implements an x86 compatible kernel.

Todo:
Debugging the kernel under GDB 9.2 on Ubuntu 20.04 seems to give a malformed/corrupted stacktrace It only happens with intel/pc on compilers g++-8 and g++-9 and g++-10.

Definition at line 43 of file IntelKernel.h.

Constructor & Destructor Documentation

◆ IntelKernel()

IntelKernel::IntelKernel ( CoreInfo info)

Member Function Documentation

◆ clocktick()

void IntelKernel::clocktick ( CPUState state,
ulong  param,
ulong  vector 
)
staticprivate

i8253 system clock interrupt handler.

Parameters
stateCPU registers on time of interrupt.
paramNot used.
vectorNot used.

Definition at line 192 of file IntelKernel.cpp.

References IntelAPIC::clear(), enableIRQ(), Timer::getInterrupt(), Kernel::getProcessManager(), WeakSingleton< Kernel >::instance(), m_apic, Kernel::m_timer, ProcessManager::schedule(), and Timer::tick().

Referenced by IntelKernel().

◆ enableIRQ()

void IntelKernel::enableIRQ ( u32  irq,
bool  enabled 
)
virtual

Enable or disable an hardware interrupt (IRQ).

Parameters
irqIRQ number.
enabledTrue to enable, and false to disable.

Reimplemented from Kernel.

Definition at line 140 of file IntelKernel.cpp.

References Kernel::enableIRQ(), Timer::getInterrupt(), m_apic, IntelAPIC::start(), and IntelAPIC::stop().

Referenced by clocktick(), and IntelKernel().

◆ exception()

void IntelKernel::exception ( CPUState state,
ulong  param,
ulong  vector 
)
staticprivate

Called when the CPU detects a fault.

Parameters
stateContains CPU registers, interrupt vector and error code.
paramNot used.
vectorNot used.

Definition at line 155 of file IntelKernel.cpp.

References assert, CoreInfo::coreId, coreInfo, ProcessManager::current(), FATAL, Process::getID(), Kernel::getProcessManager(), WeakSingleton< Kernel >::instance(), IntelCore::logException(), ProcessManager::remove(), ProcessManager::schedule(), and ZERO.

Referenced by IntelKernel().

◆ interrupt()

void IntelKernel::interrupt ( CPUState state,
ulong  param,
ulong  vector 
)
staticprivate

Default interrupt handler.

Parameters
stateContains CPU registers, interrupt vector and error code.
paramNot used.
vectorNot used.

Definition at line 168 of file IntelKernel.cpp.

References IntController::clear(), IntController::getBase(), WeakSingleton< Kernel >::instance(), Kernel::m_intControl, and CPUState::vector.

Referenced by IntelKernel().

◆ trap()

void IntelKernel::trap ( CPUState state,
ulong  param,
ulong  vector 
)
staticprivate

Kernel trap handler (system calls).

Parameters
stateContains the arguments for the APIHandler, in CPU registers.
paramNot used.
vectorNot used.

Definition at line 180 of file IntelKernel.cpp.

References CPURegs::eax, CPURegs::ebx, CPURegs::ecx, CPURegs::edi, CPURegs::edx, CPURegs::esi, Kernel::getAPI(), WeakSingleton< Kernel >::instance(), API::invoke(), and CPUState::regs.

Referenced by IntelKernel().

Field Documentation

◆ m_apic

IntelAPIC IntelKernel::m_apic
private

APIC instance (used if available)

Definition at line 104 of file IntelKernel.h.

Referenced by clocktick(), enableIRQ(), and IntelKernel().

◆ m_pic

IntelPIC IntelKernel::m_pic
private

PIC instance.

Definition at line 107 of file IntelKernel.h.

Referenced by IntelKernel().

◆ m_pit

IntelPIT IntelKernel::m_pit
private

PIT timer instance.

Definition at line 101 of file IntelKernel.h.

Referenced by IntelKernel().


The documentation for this class was generated from the following files: