Implemented the basis for syscalls

A software interrupt with vector 0x50 will cause a syscall to start executing.
The EAX register will hold the syscall_num.
Other registers and the stack can be used to hold further arguments.
This commit is contained in:
2023-02-27 00:34:30 +01:00
parent 2d0bb16fad
commit 5781f730d9
7 changed files with 141 additions and 143 deletions

View File

@ -9,23 +9,37 @@
#include "drivers/vga/VBE.h"
#include "pci/pci.h"
#include "drivers/pit/pit.h"
#include "acpi/acpi.h"
#include "i386/processor.h"
#include "terminal/kterm.h"
#include "interrupts/idt.h"
#include "serial.h"
#include "storage/vfs/vfs.h"
#include "storage/filesystems/FAT/FAT.h"
#include "../CoreLib/Memory.h"
#include "acpi/acpi.h"
#include "memory/VirtualMemoryManager.h"
extern BootInfoBlock* BIB;
extern "C" void LoadGlobalDescriptorTable();
extern "C" void jump_usermode();
extern BootInfoBlock* BIB;
void initBootDrive(){
printf("Boot device: 0x%x\n", BIB->bootDeviceID);
unsigned int part3 = BIB->bootDeviceID & 0xFF;
unsigned int part2 = (BIB->bootDeviceID & 0xFF00) >> 8;
unsigned int part1 = (BIB->bootDeviceID & 0xFF0000) >> 16;
unsigned int drive = (BIB->bootDeviceID & 0xFF000000) >> 24;
if (drive == 0x80 )
printf("booted from disk!\n");
if(drive == 0x00)
printf("booted from floppy disk\n");
printf("Part1: %d, Part2: %d, Part3: %d\n", part1, part2 , part3);
ATAPIO::Identify(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER);
}
extern "C" void kernel ()
{
init_serial();
kterm_init();
@ -42,32 +56,21 @@ extern "C" void kernel ()
initHeap();
pit_initialise();
ACPI::initialize();
PCI::Scan();
processor::initialize();
processor::enable_protectedMode();
printf("Boot device: 0x%x\n", BIB->bootDeviceID);
unsigned int part3 = BIB->bootDeviceID & 0xFF;
unsigned int part2 = (BIB->bootDeviceID & 0xFF00) >> 8;
unsigned int part1 = (BIB->bootDeviceID & 0xFF0000) >> 16;
unsigned int drive = (BIB->bootDeviceID & 0xFF000000) >> 24;
if (drive == 0x80 )
printf("booted from disk!\n");
if(drive == 0x00)
printf("booted from floppy disk\n");
printf("Part1: %d, Part2: %d, Part3: %d\n", part1, part2 , part3);
ATAPIO::Identify(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER);
initBootDrive();
VirtualFileSystem::initialize();
printf("Lets open hello.txt\n");
auto fontFile = VirtualFileSystem::open("/HELLO TXT", 0);
if(fontFile->flags == 0){
uint16_t* contents = (uint16_t*) malloc(sizeof(uint16_t) * 256);
fontFile->read(fontFile, contents, 512);
for(int i =0 ; i < fontFile->root->size; i++ ){
#ifdef VFS_EXAMPLE
auto fontFile = VirtualFileSystem::open("/FONT PSF", 0);
if(grubcfg->flags == 0){
uint16_t* contents = (uint16_t*) malloc(sizeof(uint16_t) * 256);
grubcfg->read(grubcfg, contents, 512);
for(int i =0 ; i < grubcfg->root->size; i++ ){
kterm_put(contents[i] & 0x00ff);
kterm_put(contents[i] >> 8);
}
@ -76,8 +79,7 @@ extern "C" void kernel ()
}else{
printf("Could not find file\n");
}
#endif
#ifdef USERMODE_RELEASE
// Lets jump into user mode