18#include <FreeNOS/ProcessManager.h>
19#include <FreeNOS/System.h>
58 for (
int i = 0; i < 17; i++)
63 for (
int i = 17; i < 256; i++)
90 NOTICE(
"Using APIC timer");
108 NOTICE(
"Using PIT timer");
C void executeInterrupt(CPUState state)
Result invoke(Number number, ulong arg1, ulong arg2, ulong arg3, ulong arg4, ulong arg5)
Execute a generic API function.
Number
Enumeration of supported generic kernel API functions.
uint getBase() const
Get interrupt number base offset.
virtual Result clear(uint irq)=0
Clear hardware interrupt (IRQ).
virtual Timer::Result initialize()
Initialize the APIC.
virtual Timer::Result stop()
Stop the APIC timer.
Timer::Result start(IntelPIT *pit)
Start the timer using PIT as reference timer.
virtual IntController::Result clear(uint irq)
Clear hardware interrupt (IRQ).
uint getCounter() const
Get timer initial counter.
volatile u32 readCR3() const
Read the CR3 register.
void logException(CPUState *state) const
Log a CPU exception.
Implements an x86 compatible kernel.
IntelAPIC m_apic
APIC instance (used if available)
static void clocktick(CPUState *state, ulong param, ulong vector)
i8253 system clock interrupt handler.
static void exception(CPUState *state, ulong param, ulong vector)
Called when the CPU detects a fault.
static void interrupt(CPUState *state, ulong param, ulong vector)
Default interrupt handler.
IntelPIT m_pit
PIT timer instance.
IntelKernel(CoreInfo *info)
Constructor function.
static void trap(CPUState *state, ulong param, ulong vector)
Kernel trap handler (system calls).
IntelPIC m_pic
PIC instance.
virtual void enableIRQ(u32 irq, bool enabled)
Enable or disable an hardware interrupt (IRQ).
Defines memory map for Intel systems.
Result initialize()
Initialize the PIC.
virtual Result setFrequency(Size hertz)
Set interrupt frequency.
Intel virtual memory implementation.
virtual Result initialize()
Initialize the MemoryContext.
virtual Result activate(bool initializeMMU=false)
Activate the MemoryContext.
FreeNOS kernel implementation.
CoreInfo * m_coreInfo
CoreInfo object for this core.
SplitAllocator * m_alloc
Physical memory allocator.
virtual void hookIntVector(u32 vec, InterruptHandler h, ulong p)
Hooks a function to an hardware interrupt.
virtual void executeIntVector(u32 vec, CPUState *state)
Execute an interrupt handler.
IntController * m_intControl
Interrupt Controller.
virtual void enableIRQ(u32 irq, bool enabled)
Enable or disable an hardware interrupt (IRQ).
Timer * m_timer
Timer device.
ProcessManager * getProcessManager()
Get process manager.
static void * set(void *dest, int ch, unsigned count)
Fill memory with a constant byte.
Represents a process which may run on the host.
void remove(Process *proc, const uint exitStatus=0)
Remove a Process.
Result schedule()
Schedule next process to run.
Process * current()
Current process running.
ProcessID getID() const
Retrieve our ID number.
virtual Result allocate(Range &args)
Allocate physical memory.
Size getFrequency() const
Get timer frequency.
virtual Result tick()
Process timer tick.
Size getInterrupt() const
Get timer interrupt number.
static Kernel * instance()
Retrieve the instance.
#define PAGESIZE
ARM uses 4K pages.
#define ltr(sel)
Loads the Task State Register (LTR) with the given segment.
TSS kernelTss
Task State Segment.
C void(* interruptRun)(CPUState state)
Process an interrupt.
#define KERNEL_TSS
Kernel Task State Segment.
Segment gdt[]
Global Descriptor Table.
CoreInfo coreInfo
Local CoreInfo instance.
#define assert(exp)
Insert program diagnostics.
unsigned int u32
Unsigned 32-bit number.
unsigned long Address
A memory address.
#define MegaByte(v)
Convert megabytes to bytes.
#define NOTICE(msg)
Output a notice message.
unsigned long ulong
Unsigned long number.
#define FATAL(msg)
Output a critical message and terminate program immediatly.
unsigned int Size
Any sane size indicator cannot go negative.
#define C
Used to define external C functions.
void param(Terminal *term, int key, int value)
Set terminal parameters.
Contains all the CPU registers.
Per-Core information structure.
uint timerCounter
Arch-specific timer counter.
uint coreId
Core identifier.
Memory::Range memory
Defines the physical memory available to the core.
Address phys
Physical address.
Intel's Task State Segment.