solved some bugs, QEMU doesn't crash anymore
This commit is contained in:
parent
daa915363d
commit
f20ee8046c
|
|
@ -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 = fcreate(cpy, 0);
|
||||||
// file->read = pci_read_file;
|
// file->read = pci_read_file;
|
||||||
// file->write = pci_write_file;
|
// file->write = pci_write_file;
|
||||||
if(file == 0) continue;
|
if(file == 0) break;
|
||||||
file->fileops = &pci_fileops;
|
file->fileops = &pci_fileops;
|
||||||
if(tries >= 254){
|
if(tries >= 254){
|
||||||
mlog(MODULE_NAME, "Failed to make PCI file for device!\n", MLOG_PRINT);
|
mlog(MODULE_NAME, "Failed to make PCI file for device!\n", MLOG_PRINT);
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ int read_initrd(initrd_t *initrd){
|
||||||
vfile_t *tmp = fcreate(final_fname, 0);
|
vfile_t *tmp = fcreate(final_fname, 0);
|
||||||
if(!tmp){
|
if(!tmp){
|
||||||
mlog("INITRD", "Failed to read critical boot file: %s\n", MLOG_PRINT, file->filename);
|
mlog("INITRD", "Failed to read critical boot file: %s\n", MLOG_PRINT, file->filename);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
if(tmp->private){
|
if(tmp->private){
|
||||||
kfree(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);
|
// printf("%s, %d, %d\n", final_fname, filesize, fsize_pgs);
|
||||||
offset += (((filesize + 511) / 512) + 1) * 512;
|
offset += (((filesize + 511) / 512) + 1) * 512;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -28,7 +28,7 @@ void sysinit(){
|
||||||
vfile_t *initrc = fopen("/boot/initrc.conf");
|
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);
|
mlog("RAE", "\033[1;32mDid you remember to migrate your modules to the new API?\033[0m\n", MLOG_PRINT);
|
||||||
if(initrc){
|
if(initrc){
|
||||||
mlog("KERNEL", "Found initrc", MLOG_PRINT);
|
mlog("KERNEL", "Found initrc\n", MLOG_PRINT);
|
||||||
initrc_read(initrc);
|
initrc_read(initrc);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -58,18 +58,17 @@ extern void kmain(kernel_info_t *kernel_info){
|
||||||
pic_setmask(0x0, PIC1_DATA);
|
pic_setmask(0x0, PIC1_DATA);
|
||||||
pic_setmask(0x0, PIC2_DATA);
|
pic_setmask(0x0, PIC2_DATA);
|
||||||
|
|
||||||
// fcreate("/dev", FS_FILE_IS_DIR);
|
fcreate("/dev", FS_FILE_IS_DIR);
|
||||||
// fcreate("/dev/disk", FS_FILE_IS_DIR);
|
fcreate("/dev/disk", FS_FILE_IS_DIR);
|
||||||
// fcreate("/tmp", FS_FILE_IS_DIR);
|
fcreate("/tmp", FS_FILE_IS_DIR);
|
||||||
// fcreate("/boot", FS_FILE_IS_DIR);
|
fcreate("/boot", FS_FILE_IS_DIR);
|
||||||
mlog("KERNEL", "Initializing Scheduler & starting PID 1\n", MLOG_PRINT);
|
mlog("KERNEL", "Initializing Scheduler & starting PID 1\n", MLOG_PRINT);
|
||||||
boot_info = kernel_info;
|
boot_info = kernel_info;
|
||||||
scheduler_init();
|
scheduler_init();
|
||||||
disable_interrupts();
|
|
||||||
//scheduler doesn't work if there is no PID0, and I don't know why.
|
//scheduler doesn't work if there is no PID0, and I don't know why.
|
||||||
thread_start(pid0);
|
thread_start(pid0);
|
||||||
thread_start(sysinit);
|
thread_start(sysinit);
|
||||||
for(;;);
|
// for(;;);
|
||||||
enable_interrupts();
|
enable_interrupts();
|
||||||
for(;;);//we actually **shouldn't** return, like, ever. That's bad.
|
for(;;);//we actually **shouldn't** return, like, ever. That's bad.
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@ int is_num(char c){
|
||||||
|
|
||||||
void initrc_read(vfile_t *file){
|
void initrc_read(vfile_t *file){
|
||||||
mlog("KERNEL", "Reading initrc:\n", MLOG_PRINT);
|
mlog("KERNEL", "Reading initrc:\n", MLOG_PRINT);
|
||||||
char *ptr = file->private;
|
if(!file || !file->private){
|
||||||
if(!file || !ptr){
|
|
||||||
mlog("KERNEL", "Failed to read initrc!\n", MLOG_PRINT);
|
mlog("KERNEL", "Failed to read initrc!\n", MLOG_PRINT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
char *ptr = file->private;
|
||||||
uint32_t size = file->size;
|
uint32_t size = file->size;
|
||||||
char statement[512];
|
char statement[512];
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ vfile_t root_dir = {"/", FS_FILE_IS_DIR | FS_FILE_SYSTEM, &ramfs_ops};
|
||||||
void ramfs_init(){
|
void ramfs_init(){
|
||||||
mlog(MODULE_NAME, "Initializing VFS\n", MLOG_PRINT);
|
mlog(MODULE_NAME, "Initializing VFS\n", MLOG_PRINT);
|
||||||
root_dir.private = kmalloc(1);
|
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));
|
// 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){
|
int ramfs_delete(vfile_t *file){
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
int ramfs_write(vfile_t *file, char *buffer, uint32_t offset, uint32_t count){
|
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){
|
int ramfs_read(vfile_t *file, char *buffer, uint32_t offset, uint32_t count){
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
vfile_t *ramfs_open(char *path){
|
vfile_t *ramfs_open(char *path){
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
void ramfs_close(vfile_t *file){
|
void ramfs_close(vfile_t *file){
|
||||||
file->refcount--;
|
file->refcount--;
|
||||||
|
|
@ -57,7 +57,7 @@ void ramfs_close(vfile_t *file){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vfile_t *ramfs_rfopen(char *name, vfile_t *parent){
|
vfile_t *ramfs_rfopen(char *name, vfile_t *parent){
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vfile_t *get_root_dir(){
|
vfile_t *get_root_dir(){
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,9 @@
|
||||||
// }
|
// }
|
||||||
|
|
||||||
vfile_t *fcreate(char *path, FS_FILE_FLAGS flags){
|
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){
|
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{
|
else{
|
||||||
vfile_t *new_parent = rfopen(name, parent_dir);
|
vfile_t *new_parent = rfopen(name, parent_dir);
|
||||||
if(!new_parent){
|
if(!new_parent){
|
||||||
|
// printf("No new parent found!\n");
|
||||||
kfree(name);
|
kfree(name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
// printf("Recursed\n");
|
||||||
new_file = vfcreate(new_parent, name+name_index+1, flags);
|
new_file = vfcreate(new_parent, name+name_index+1, flags);
|
||||||
fclose(new_parent);
|
fclose(new_parent);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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");
|
puts(api, MODULE_NAME, "Valid BPB found!\n");
|
||||||
|
|
||||||
|
// fat32_make_mount()
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue