feat: setup structure for block devices
added ide block device added mbr block device driver started fat block device driver reordered boot start timer before pci/ide/etc. enable interrupts earlier fixed exception from ide controller cleanup code more printfs
This commit is contained in:
@@ -15,13 +15,16 @@
|
||||
#include <drivers/pci.h>
|
||||
#include <drivers/ide.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <fs/mbr.h>
|
||||
#include <fs/blockdev.h>
|
||||
|
||||
#define BOOTLOADER_NAME_MAX_LENGTH 64
|
||||
#define CMDLINE_MAX_LENGTH 256
|
||||
|
||||
const char *msg_booted = "Booted Successfully!\n";
|
||||
const char *newline = "\n";
|
||||
const char *msg_unknown_command = "Unknown command: ";
|
||||
const int version_major = 0,
|
||||
version_minor = 0,
|
||||
version_patch = 1;
|
||||
|
||||
char bootloader_name[BOOTLOADER_NAME_MAX_LENGTH];
|
||||
char cmdline[CMDLINE_MAX_LENGTH];
|
||||
@@ -67,8 +70,7 @@ void help(const char* arg) {
|
||||
}
|
||||
|
||||
void echo(const char *arg) {
|
||||
kprint(arg);
|
||||
kprint(newline);
|
||||
printf("%s\n", arg);
|
||||
}
|
||||
|
||||
void print(const char *arg) {
|
||||
@@ -85,19 +87,19 @@ void print(const char *arg) {
|
||||
} else if (strcmp(arg, "ide") == 0) {
|
||||
ide_print_devices();
|
||||
} else {
|
||||
kprint("Unknown print ");
|
||||
kprint(arg);
|
||||
kprint(newline);
|
||||
printf("Unknown print %s\n", arg);
|
||||
}
|
||||
}
|
||||
|
||||
void ide(const char* arg) {
|
||||
if (strcmp(arg, "devices") == 0) {
|
||||
if (strcmp(arg, "block_devices") == 0) {
|
||||
block_dev_print_info();
|
||||
} else if (strcmp(arg, "ide_devices") == 0) {
|
||||
ide_print_devices();
|
||||
} else if (strcmp(arg, "mbr") == 0) {
|
||||
mbr_read_from_ide(0);
|
||||
} else {
|
||||
kprint("Unknown print ");
|
||||
kprint(arg);
|
||||
kprint(newline);
|
||||
printf("Unknown print %s\n", arg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +144,14 @@ void init_pci_system() {
|
||||
pci_init_drivers();
|
||||
}
|
||||
|
||||
void init_block_devices() {
|
||||
// register drivers
|
||||
mbr_register_block_driver();
|
||||
|
||||
// scan
|
||||
block_dev_scan_repeat();
|
||||
}
|
||||
|
||||
void kmain(multiboot_info_t *multiboot_info) {
|
||||
isr_install();
|
||||
vga_clear_screen();
|
||||
@@ -153,22 +163,18 @@ void kmain(multiboot_info_t *multiboot_info) {
|
||||
store_bootloader_info(multiboot_info);
|
||||
init_mmap(multiboot_info);
|
||||
|
||||
init_pci_system();
|
||||
|
||||
kprint(msg_booted);
|
||||
kprint(newline);
|
||||
|
||||
// init done, enable interrupts
|
||||
__asm__ __volatile__("sti");
|
||||
// init timer for future task switching
|
||||
init_timer(1000);
|
||||
// setup PS/2 keyboard
|
||||
init_keyboard();
|
||||
init_pci_system();
|
||||
init_block_devices();
|
||||
|
||||
printf("%s v%d.%d.%d\n", msg_booted, version_major, version_minor, version_patch);
|
||||
// print_gdt();
|
||||
|
||||
// u8* tmp = malloc(4096);
|
||||
// ide_read_access(0, 0, 0, 16, tmp);
|
||||
// ide_access(0, 0, 0, 16, tmp);
|
||||
|
||||
// enter main loop
|
||||
while (true) {
|
||||
@@ -183,9 +189,7 @@ void main_loop() {
|
||||
int test_index = 0;
|
||||
while (true) {
|
||||
if (cmd_handlers[test_index].cmd == 0) {
|
||||
kprint(msg_unknown_command);
|
||||
kprint(msg);
|
||||
kprint(newline);
|
||||
printf("Unknown command: %s\n", msg);
|
||||
break;
|
||||
}
|
||||
if (strcmp(cmd_handlers[test_index].cmd, msg) == 0) {
|
||||
|
||||
Reference in New Issue
Block a user