18#include <FreeNOS/System.h>
39 ERROR(
"failed to create memory context");
47 ERROR(
"failed to initialize MemoryContext: result = " << (
int) memResult);
60 ERROR(
"failed to allocate user stack");
68 ERROR(
"failed to map user stack");
79 ERROR(
"failed to allocate kernel stack");
116 regs->
seg.
fs = dataSel;
117 regs->
seg.
gs = dataSel;
118 regs->
seg.
es = dataSel;
119 regs->
seg.
ds = dataSel;
123 regs->
irq.
cs = codeSel;
Intel virtual memory implementation.
Process which may execute on an Intel CPU.
Address m_kernelStackBase
Base kernel stack (fixed)
Address m_kernelStack
Current kernel stack address (changes during execution).
virtual void execute(Process *previous)
Execute the process.
IntelProcess(ProcessID id, Address entry, bool privileged, const MemoryMap &map)
Constructor function.
virtual void reset(const Address entry)
Restart execution at the given entry point.
static const Size KernelStackSize
Size of the kernel stack.
virtual Result initialize()
Initialize the Process.
virtual ~IntelProcess()
Destructor function.
SplitAllocator * getAllocator()
Get physical memory allocator.
static void * set(void *dest, int ch, unsigned count)
Fill memory with a constant byte.
virtual Result initialize()=0
Initialize the MemoryContext.
virtual Result activate(bool initializeMMU=false)=0
Activate the MemoryContext.
virtual Result mapRangeContiguous(Memory::Range *range)
Map a range of contiguous physical pages to virtual addresses.
Describes virtual memory map layout.
Memory::Range range(Region region) const
Get memory range for the given region.
Represents a process which may run on the host.
MemoryContext * m_memoryContext
MMU memory context.
virtual Result initialize()
Initialize the Process.
MemoryMap m_map
Virtual memory layout.
bool m_privileged
Privilege level.
Address m_entry
Entry point of the program.
Allocator which separates kernel mapped memory at virtual and physical addresses.
Address toPhysical(const Address virt) const
Convert Address to physical pointer.
virtual Result release(const Address addr)
Release memory page.
static Kernel * instance()
Retrieve the instance.
#define PAGESIZE
ARM uses 4K pages.
#define MEMALIGN
Memory address alignment.
C void loadCoreState()
Load Core State.
#define INTEL_EFLAGS_DEFAULT
TSS kernelTss
Task State Segment.
C void switchCoreState(Address *currentStack, Address stack)
Switch Core Stack.
u32 ProcessID
Process Identification Number.
unsigned long Address
A memory address.
#define ERROR(msg)
Output an error message.
unsigned short u16
Unsigned 16-bit number.
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.
Structure represents the pusha/popa format.
Contains all the CPU registers.
Privileged Interrupt Registers (ring 0)
Size size
Size in number of bytes.
Address phys
Physical address.
Address virt
Virtual address.
Access access
Page access flags.