Working kernel written on C and userspace-ready #1
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include <Types.h>
|
||||
#include <Arch/IO.h>
|
||||
#include <Arch/Exceptions.h>
|
||||
|
||||
enum {
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
#include <Types.h>
|
||||
#include <Arch/Exceptions.h>
|
||||
|
||||
static const UInt64 kTimerFrequency = 1000; // 1ms
|
||||
static const UInt8 kTimerIRQ = 27;
|
||||
enum {
|
||||
kTimerFrequency = 1000, // 1ms
|
||||
kTimerIRQ = 27,
|
||||
};
|
||||
|
||||
void TimerInitialize();
|
||||
void TimerReset(UInt64 interval);
|
||||
|
||||
@@ -15,7 +15,7 @@ typedef struct __attribute__((aligned(16))) VMHeapBlockHeader {
|
||||
struct VMHeapBlockHeader* next;
|
||||
struct VMHeapBlockHeader* previous;
|
||||
UInt64 size;
|
||||
bool isFree;
|
||||
Boolean isFree;
|
||||
} VMHeapBlockHeader;
|
||||
|
||||
void HeapInitialize();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include <Types.h>
|
||||
#include "../Common/bootinfo.h"
|
||||
|
||||
enum {
|
||||
kVMPageSize = 4096,
|
||||
|
||||
@@ -25,11 +25,12 @@ enum {
|
||||
kVMKernelVMA = 0xFFFFFFFF80000000,
|
||||
kHHDMOffset = 0xFFFF888000000000,
|
||||
kVMFbVirtBase = 0xFFFFFFFFFC000000,
|
||||
kKernelPhysBase = 0x40100000,
|
||||
};
|
||||
|
||||
|
||||
static inline Address VMKernelVirtToPhys(Address virt) {
|
||||
return virt - 0xFFFFFFFF80100000 + 0x40100000; // TODO: hardcode is awful
|
||||
return virt - 0xFFFFFFFF80100000 + kKernelPhysBase;
|
||||
}
|
||||
|
||||
static inline Address VMPhysToHHDM(Address phys) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <Arch/DTB.h>
|
||||
#include <OS/Panic.h>
|
||||
#include <OS/Log.h>
|
||||
#include <Lib/Bytes.h>
|
||||
#include <Lib/Align.h>
|
||||
#include <Lib/String.h>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include <Arch/Exceptions.h>
|
||||
#include <Arch/CPU.h>
|
||||
#include <Arch/GIC.h>
|
||||
#include <IO/Serial.h>
|
||||
#include <OS/Panic.h>
|
||||
|
||||
Address ExceptionsHandler(ExceptionsContext* frame, ExceptionsType type) {
|
||||
|
||||
@@ -10,7 +10,7 @@ static void CombineForward(VMHeapBlockHeader* current) {
|
||||
if (!current->next || !current->next->isFree) return;
|
||||
current->size += sizeof(VMHeapBlockHeader) + current->next->size;
|
||||
current->next = current->next->next;
|
||||
if (current->next) current->next->previous = current; // what the fuck
|
||||
if (current->next) current->next->previous = current;
|
||||
}
|
||||
|
||||
void HeapInitialize() {
|
||||
|
||||
@@ -54,9 +54,9 @@ void PMMInitialize(VMBootMemoryMap* bootMap) {
|
||||
Size pagesToReserve = (regionSize + kVMPageSize - 1) / kVMPageSize;
|
||||
|
||||
for (Size p = 0; p < pagesToReserve; p++) {
|
||||
Address pageAdress = regionBase + (p * kVMPageSize);
|
||||
if (pageAdress >= sPMMRamBase && pageAdress < (sPMMRamBase + bootMap->totalRAM.size)) {
|
||||
BitmapSet(sPMMBitmap, pageAdress);
|
||||
Address pageAddress = regionBase + (p * kVMPageSize);
|
||||
if (pageAddress >= sPMMRamBase && pageAddress < (sPMMRamBase + bootMap->totalRAM.size)) {
|
||||
BitmapSet(sPMMBitmap, pageAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ void VMMInitialize(VMBootMemoryMap* bootMap, Bootinfo* info) {
|
||||
Size kernelSize = ((Address)_kernelEnd - (Address)_kernelStart) + pmmBitmapSize;
|
||||
kernelSize = (kernelSize + kVMPageSize - 1) & ~(kVMPageSize - 1);
|
||||
|
||||
Address kernelPhysStart = 0x40100000; // TODO: hardcode is awful
|
||||
Address kernelPhysStart = kKernelPhysBase;
|
||||
|
||||
for (Address offset = 0; offset < kernelSize; offset += kVMPageSize) {
|
||||
Address phys = kernelPhysStart + offset;
|
||||
|
||||
Reference in New Issue
Block a user