solved some bugs, QEMU doesn't crash anymore

This commit is contained in:
notsomeidiot123 2026-06-26 20:19:55 -04:00
parent daa915363d
commit f20ee8046c
7 changed files with 24 additions and 17 deletions

View File

@ -86,7 +86,7 @@ void pci_make_file(uint32_t class, uint8_t bus, uint8_t slot, uint8_t func){
file = fcreate(cpy, 0);
// file->read = pci_read_file;
// file->write = pci_write_file;
if(file == 0) continue;
if(file == 0) break;
file->fileops = &pci_fileops;
if(tries >= 254){
mlog(MODULE_NAME, "Failed to make PCI file for device!\n", MLOG_PRINT);

View File

@ -39,6 +39,7 @@ int read_initrd(initrd_t *initrd){
vfile_t *tmp = fcreate(final_fname, 0);
if(!tmp){
mlog("INITRD", "Failed to read critical boot file: %s\n", MLOG_PRINT, file->filename);
return 1;
}
if(tmp->private){
kfree(tmp->private);
@ -48,4 +49,5 @@ int read_initrd(initrd_t *initrd){
// printf("%s, %d, %d\n", final_fname, filesize, fsize_pgs);
offset += (((filesize + 511) / 512) + 1) * 512;
}
return 0;
}

View File

@ -28,7 +28,7 @@ void sysinit(){
vfile_t *initrc = fopen("/boot/initrc.conf");
mlog("RAE", "\033[1;32mDid you remember to migrate your modules to the new API?\033[0m\n", MLOG_PRINT);
if(initrc){
mlog("KERNEL", "Found initrc", MLOG_PRINT);
mlog("KERNEL", "Found initrc\n", MLOG_PRINT);
initrc_read(initrc);
}
else{
@ -58,18 +58,17 @@ extern void kmain(kernel_info_t *kernel_info){
pic_setmask(0x0, PIC1_DATA);
pic_setmask(0x0, PIC2_DATA);
// fcreate("/dev", FS_FILE_IS_DIR);
// fcreate("/dev/disk", FS_FILE_IS_DIR);
// fcreate("/tmp", FS_FILE_IS_DIR);
// fcreate("/boot", FS_FILE_IS_DIR);
fcreate("/dev", FS_FILE_IS_DIR);
fcreate("/dev/disk", FS_FILE_IS_DIR);
fcreate("/tmp", FS_FILE_IS_DIR);
fcreate("/boot", FS_FILE_IS_DIR);
mlog("KERNEL", "Initializing Scheduler & starting PID 1\n", MLOG_PRINT);
boot_info = kernel_info;
scheduler_init();
disable_interrupts();
//scheduler doesn't work if there is no PID0, and I don't know why.
thread_start(pid0);
thread_start(sysinit);
for(;;);
// for(;;);
enable_interrupts();
for(;;);//we actually **shouldn't** return, like, ever. That's bad.
return;

View File

@ -17,11 +17,11 @@ int is_num(char c){
void initrc_read(vfile_t *file){
mlog("KERNEL", "Reading initrc:\n", MLOG_PRINT);
char *ptr = file->private;
if(!file || !ptr){
if(!file || !file->private){
mlog("KERNEL", "Failed to read initrc!\n", MLOG_PRINT);
return;
}
char *ptr = file->private;
uint32_t size = file->size;
char statement[512];
uint32_t i = 0;

View File

@ -22,7 +22,7 @@ vfile_t root_dir = {"/", FS_FILE_IS_DIR | FS_FILE_SYSTEM, &ramfs_ops};
void ramfs_init(){
mlog(MODULE_NAME, "Initializing VFS\n", MLOG_PRINT);
root_dir.private = kmalloc(1);
root_dir.size = PAGE_SIZE_BYTES;//one page is 4096 bytes
root_dir.size = 4096;//one page is 4096 bytes
// printf("Sizeof VFILE_T: %d", sizeof(vfile_t));
}
@ -40,16 +40,16 @@ vfile_t *ramfs_create(char *path, FS_FILE_FLAGS flags){
}
int ramfs_delete(vfile_t *file){
return 0;
}
int ramfs_write(vfile_t *file, char *buffer, uint32_t offset, uint32_t count){
return 0;
}
int ramfs_read(vfile_t *file, char *buffer, uint32_t offset, uint32_t count){
return 0;
}
vfile_t *ramfs_open(char *path){
return 0;
}
void ramfs_close(vfile_t *file){
file->refcount--;
@ -57,7 +57,7 @@ void ramfs_close(vfile_t *file){
return;
}
vfile_t *ramfs_rfopen(char *name, vfile_t *parent){
return 0;
}
vfile_t *get_root_dir(){

View File

@ -14,7 +14,9 @@
// }
vfile_t *fcreate(char *path, FS_FILE_FLAGS flags){
vfcreate(get_root_dir(), path, flags);
// return 0;
vfile_t *returnable = vfcreate(get_root_dir(), path, flags);
return 0;
}
vfile_t *vfcreate(vfile_t *parent_dir, char *relpath, FS_FILE_FLAGS flags){
@ -45,9 +47,11 @@ vfile_t *vfcreate(vfile_t *parent_dir, char *relpath, FS_FILE_FLAGS flags){
else{
vfile_t *new_parent = rfopen(name, parent_dir);
if(!new_parent){
// printf("No new parent found!\n");
kfree(name);
return 0;
}
// printf("Recursed\n");
new_file = vfcreate(new_parent, name+name_index+1, flags);
fclose(new_parent);
}

View File

@ -34,6 +34,8 @@ uint32_t fat32_mount(vfile_t *dev_file, char *destination, uint32_t offset){
}
puts(api, MODULE_NAME, "Valid BPB found!\n");
// fat32_make_mount()
return 1;
}