18#include <FreeNOS/System.h>
19#include <FreeNOS/Config.h>
224 i.current()->handler(state, i.current()->param, vec);
233 FATAL(
"failed to raise interrupt notification for IRQ #" << vec);
245 FATAL(
"failed to initialize BootImageStorage: result = " << (
int) result);
267 FATAL(
"failed to read BootSymbol: result = " << (
int) readResult);
280 FATAL(
"failed to load BootSymbol " << program.
name <<
": result = " << (
int) loadResult);
301 FATAL(
"failed to create boot program: " << program.
name);
322 FATAL(
"failed to read BootSegment for BootProgram " <<
323 program.
name <<
": result = " << (
int) result);
338 " for BootProgram " << program.
name <<
": result = " << (
int) mapResult);
353 " for BootProgram " << program.
name <<
": result = " << (
int) readResult);
370 FATAL(
"failed to allocate program arguments page");
378 FATAL(
"failed to map program arguments page");
Generic Kernel API implementation.
Memory mapping for the kernel and user processes on the ARM architecture.
static void setDefault(Allocator *alloc)
Makes the given Allocator the default.
Uses a BootImage as a storage provider.
const BootImage bootImage() const
Get BootImage header.
virtual FileSystem::Result initialize()
Initialize the Storage device.
virtual FileSystem::Result read(const u64 offset, void *buffer, const Size size) const
Reads data from the boot image.
Keeps growing allocated memory, and can't actually free memory (hence the name).
virtual Result disable(uint irq)=0
Disable hardware interrupt (IRQ).
uint getBase() const
Get interrupt number base offset.
virtual Result send(const uint targetCoreId, const uint irq)
Send an inter-processor-interrupt (IPI).
virtual Result enable(uint irq)=0
Enable hardware interrupt (IRQ).
FreeNOS kernel implementation.
CoreInfo * m_coreInfo
CoreInfo object for this core.
Kernel(CoreInfo *info)
Constructor function.
API * m_api
API handlers object.
CoreInfo * getCoreInfo()
Get CoreInfo.
virtual Result sendIRQ(const uint coreId, const uint irq)
Send a inter-processor-interrupt (IPI) to another core.
Vector< List< InterruptHook * > * > m_interrupts
Interrupt handlers.
SplitAllocator * getAllocator()
Get physical memory allocator.
SplitAllocator * m_alloc
Physical memory allocator.
Timer * getTimer()
Get Timer.
virtual Result loadBootProgram(const BootImageStorage &bootImage, const BootSymbol &program)
Load a boot program.
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.
static Error initializeHeap()
Initialize heap.
virtual void enableIRQ(u32 irq, bool enabled)
Enable or disable an hardware interrupt (IRQ).
ProcessManager * m_procs
Process Manager.
int run()
Execute the kernel.
Timer * m_timer
Timer device.
ProcessManager * getProcessManager()
Get process manager.
MemoryContext * getMemoryContext()
Get the current MMU context.
virtual Result loadBootImage()
Loads the boot image.
virtual bool hasCurrent() const
Check if there is a current item on the List.
Simple linked list template class.
void append(const char *str)
Append to buffered output.
static void * set(void *dest, int ch, unsigned count)
Fill memory with a constant byte.
static Size copy(void *dest, const void *src, Size count)
Copy memory from one place to another.
Virtual memory abstract interface.
virtual Result mapRangeContiguous(Memory::Range *range)
Map a range of contiguous physical pages to virtual addresses.
@ UserArgs
< Used for copying program arguments and file descriptors
@ KernelData
< Kernel program data from libexec, e.g.
Memory::Range range(Region region) const
Get memory range for the given region.
Memory allocator which uses pools that each manage same-sized objects.
Represents a process which may run on the host.
Process * create(const Address entry, const MemoryMap &map, const bool readyToRun=false, const bool privileged=false)
Create a new Process.
Result schedule()
Schedule next process to run.
Result interruptNotify(const u32 vector)
Raise interrupt notifications for a interrupt vector.
Process * current()
Current process running.
Represents a process which may run on the host.
MemoryContext * getMemoryContext()
Get MMU memory context.
virtual void fill(T value)
Fill the Sequence with the given value.
Allocator which separates kernel mapped memory at virtual and physical addresses.
Address toPhysical(const Address virt) const
Convert Address to physical pointer.
virtual Result allocate(Range &args)
Allocate physical memory.
Address toVirtual(const Address phys) const
Convert Address to virtual pointer.
Represents a configurable timer device.
virtual int insert(const T &item)
Adds the given item to the Vector, if possible.
Singleton design pattern: only one instance is allowed.
static Log * instance()
Retrieve the instance.
void InterruptHandler(struct CPUState *state, ulong param, ulong vector)
Function which is called when the CPU is interrupted.
#define PAGESIZE
ARM uses 4K pages.
CoreInfo coreInfo
Local CoreInfo instance.
#define BOOTIMAGE_NAMELEN
Maximum length of BootSymbol names.
@ BootProgram
Executable program.
@ BootPrivProgram
Privileged executable program.
#define assert(exp)
Insert program diagnostics.
unsigned int u32
Unsigned 32-bit number.
slong Error
Error code defined in Error.h.
#define MegaByte(v)
Convert megabytes to bytes.
#define ERROR(msg)
Output an error message.
#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 uint
Unsigned integer number.
unsigned int Size
Any sane size indicator cannot go negative.
#define BANNER
Print this banner per default on new Terminals.
Result
Result code for filesystem Actions.
Describes a range of memory.
Size alignment
Alignment in bytes or ZERO for default alignment.
Address address
Starting address of the memory range.
Size size
Amount of memory in bytes.
BootImage contains executable programs to be loaded at system bootup.
u16 symbolTableCount
Number of entries in the symbols table.
u32 segmentsTableOffset
Offset of the segments table.
u32 symbolTableOffset
Offset of the symbol table.
u32 size
Total size of the segment.
u32 virtualAddress
Virtual memory address to load the segment.
u32 offset
Offset in the boot image of the segment contents.
Program embedded in the BootImage.
u16 segmentsCount
Number of contiguous entries in the segment table.
u32 entry
Program entry point (only valid for BootProgram symbols).
u32 segmentsOffset
Offset in the segments table.
BootSymbolType type
Type of boot symbol.
char name[BOOTIMAGE_NAMELEN]
Name of the boot symbol.
Contains all the CPU registers.
Per-Core information structure.
Address bootImageSize
Boot image size in bytes.
Memory::Range kernel
Kernel memory range.
Size coreChannelSize
Size of the IPC channel in bytes.
uint coreId
Core identifier.
Address coreChannelAddress
Physical memory address of IPC channel for CoreServer of this core.
Address bootImageAddress
Boot image physical memory address.
Memory::Range memory
Defines the physical memory available to the core.
Size heapSize
Size in bytes of the kernel heap.
Address heapAddress
Physical memory address of the kernel heap.
Size size
Size in number of bytes.
Address phys
Physical address.
Address virt
Virtual address.
Access access
Page access flags.