Preparations towards context switching
This commit is contained in:
parent
b79ae4ec95
commit
2dd799b406
2
Makefile
2
Makefile
@ -13,7 +13,7 @@ run: disk.img
|
||||
qemu-system-x86_64 disk.img
|
||||
|
||||
debug: disk.img
|
||||
qemu-system-x86_64 -s -S disk.img & gdb --command=gdbscript
|
||||
qemu-system-x86_64 -s -S -no-reboot -no-shutdown disk.img & gdb --command=gdbscript
|
||||
|
||||
disk.img: clean prepare build/boot/boot.bin build/boot_stage2/boot.bin $(DISK_IMG_FILES)
|
||||
dd if=/dev/zero of=disk.img count=43 bs=100k
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "memory.h"
|
||||
#include "global.h"
|
||||
|
||||
namespace Global {
|
||||
Allocator* allocator = 0;
|
||||
Kernel* kernel = 0;
|
||||
}
|
||||
|
||||
void* operator new (uint32_t size) {
|
||||
|
@ -1,10 +1,14 @@
|
||||
#ifndef GLOBAL_H
|
||||
#define GLOBAL_H
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
class Kernel;
|
||||
class Allocator;
|
||||
|
||||
namespace Global {
|
||||
extern Allocator* allocator;
|
||||
extern Kernel* kernel;
|
||||
}
|
||||
|
||||
void* operator new (uint32_t size);
|
||||
|
@ -1,9 +1,20 @@
|
||||
#include "kernel.h"
|
||||
|
||||
Kernel* Kernel::kernel;
|
||||
|
||||
Kernel::Kernel(PageDirectory* page_directory, PageMap* phys, PageMap* virt, uint32_t virt_alloc_base)
|
||||
: Process(0, 0x8a000, page_directory, phys, virt, virt_alloc_base)
|
||||
{
|
||||
this->kernel = this;
|
||||
this->currentPID = 1;
|
||||
Global::allocator = this;
|
||||
Global::kernel = this;
|
||||
}
|
||||
|
||||
void Kernel::init_kernel() {
|
||||
this->pid_map = new xnoe::hashtable<uint32_t, Process*>();
|
||||
}
|
||||
|
||||
Process* Kernel::createProcess() {
|
||||
Process* p = new Process(currentPID);
|
||||
this->pid_map->set(currentPID, p);
|
||||
currentPID++;
|
||||
return p;
|
||||
}
|
@ -2,14 +2,22 @@
|
||||
#define KERNEL_H
|
||||
|
||||
#include "process.h"
|
||||
#include "datatypes/hashtable.h"
|
||||
#include "global.h"
|
||||
|
||||
class Kernel : public Process {
|
||||
private:
|
||||
static Kernel* kernel;
|
||||
uint32_t currentPID;
|
||||
|
||||
public:
|
||||
xnoe::hashtable<uint32_t, Process*>* pid_map; // Map of PIDs -> Process*s
|
||||
uint32_t current_PID;
|
||||
|
||||
Kernel(PageDirectory* page_directory, PageMap* phys, PageMap* virt, uint32_t virt_alloc_base);
|
||||
|
||||
void init_kernel();
|
||||
|
||||
Process* createProcess();
|
||||
};
|
||||
|
||||
#endif
|
@ -28,7 +28,7 @@ int main() {
|
||||
PageMap virt_pm(0xc0620000);
|
||||
|
||||
Kernel kernel = Kernel(&kernel_pd, &phys_pm, &virt_pm, 0xc0000000);
|
||||
Global::allocator = &kernel;
|
||||
kernel.init_kernel();
|
||||
|
||||
Terminal* current_term;
|
||||
|
||||
@ -46,8 +46,8 @@ int main() {
|
||||
term->printf("Hello, World!\n\nWe are running XnoeOS Code in C++ now, Protected Mode has been achieved (as well as Virtual Memory / Paging!!!) and everything is working super nicely!\n\nHow wonderful!\n\nNow I just need to hope my print function works properly too~~\n");
|
||||
|
||||
term->printf("KERNEL OK!\n");
|
||||
|
||||
Process* process = new Process(1);
|
||||
|
||||
kernel.createProcess();
|
||||
|
||||
term->deactivate();
|
||||
term2->activate();
|
||||
|
Loading…
x
Reference in New Issue
Block a user