Completely changed how XnoeOS boots, organised the code somewhat, renamed kernel32 to kernel, now uses the 9 sectors after the boot sector to store a 32 bit stage2 loader. No longer spends unnecessary time in real mode. Updated atapio to properly account for the reserved sector count.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#include "../kernel/atapio.h"
|
||||
#include "../kernel/screenstuff.h"
|
||||
|
||||
|
||||
void main() {
|
||||
init_term();
|
||||
init_atapio();
|
||||
|
||||
uint8_t* kernel_location = 0x80000;
|
||||
load_file("KERNEL BIN", kernel_location);
|
||||
|
||||
printf("Stage2 success!");
|
||||
|
||||
//while (1);
|
||||
|
||||
((void(*)(void))kernel_location)();
|
||||
}
|
||||
+3
-3
@@ -59,8 +59,8 @@ void init_atapio() {
|
||||
total_28_lbas = *(uint32_t*)(identify_result+60);
|
||||
|
||||
// We've initialised now, let's load the FAT and RootDirEntries.
|
||||
read_sectors(sectorsPerFAT * countFATs + 1, countRDEs / 16, rootDirEntries);
|
||||
read_sectors(1, sectorsPerFAT, FAT1);
|
||||
read_sectors(sectorsPerFAT * countFATs + countReserved, countRDEs / 16, rootDirEntries);
|
||||
read_sectors(countReserved, sectorsPerFAT, FAT1);
|
||||
}
|
||||
|
||||
void read_sector(uint32_t address, uint8_t* buffer) {
|
||||
@@ -111,7 +111,7 @@ void load_file(char* filename, uint8_t* destination) {
|
||||
|
||||
bool loaded = false;
|
||||
while (!loaded) {
|
||||
uint16_t fromSector = location + (sectorsPerFAT * countFATs) + (countRDEs / 16) - 1;
|
||||
uint16_t fromSector = location + (sectorsPerFAT * countFATs) + (countRDEs / 16) + (countReserved - 1) - 1;
|
||||
read_sector(fromSector, destination+offset);
|
||||
offset += 512;
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "io.h"
|
||||
#include "types.h"
|
||||
#include "strings.h"
|
||||
#include "screenstuff.h"
|
||||
|
||||
void init_atapio();
|
||||
void read_sector(uint32_t address, uint8_t* buffer);
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
GateEntry idt[256];
|
||||
|
||||
void set_entry(uint8_t interrupt_number, uint16_t code_segment, void* handler, uint8_t type) {
|
||||
uint32_t handler_addr = (uint16_t)handler;
|
||||
uint32_t handler_addr = (uint32_t)handler;
|
||||
uint16_t* handler_halves = (uint16_t*)&handler_addr;
|
||||
idt[interrupt_number] = (GateEntry){
|
||||
.offset_low = handler_halves[0],
|
||||
|
||||
@@ -13,9 +13,11 @@ int main() {
|
||||
printf("KERNEL32 OK!\n");
|
||||
|
||||
printf("Hello, World!\n\nWe are running XnoeOS Code in C now, Protected Mode has been achieved and everything is working super nicely!\n\nHow wonderful!\n\nNow I just need to hope my print function works properly too~~\n");
|
||||
|
||||
|
||||
init_keyboard();
|
||||
|
||||
enable_idt();
|
||||
printf("A\n");
|
||||
init_atapio();
|
||||
|
||||
uint8_t sector[512];
|
||||
Reference in New Issue
Block a user