working on filesystem
This commit is contained in:
parent
5c58761a2a
commit
a461dac04e
|
|
@ -29,15 +29,15 @@ void sysinit(){
|
|||
}
|
||||
modules_init();
|
||||
initrc_read(initrc);
|
||||
vfile_t *disk_dir = fget_file("/dev/disk");
|
||||
if(disk_dir == 0){
|
||||
mlog("KERNEL", "Error: /dev/disk does not exist\n", MLOG_PRINT);
|
||||
}
|
||||
vfile_t **dir_data = disk_dir->access.data.ptr;
|
||||
for(uint32_t i = 0; dir_data[i]; i++){
|
||||
mlog("KERNEL", "Filename: %s\n", MLOG_PRINT, dir_data[i]->name);
|
||||
vfs_detect_partitions(dir_data[i]);
|
||||
}
|
||||
// vfile_t *disk_dir = fget_file("/dev/disk");
|
||||
// if(disk_dir == 0){
|
||||
// mlog("KERNEL", "Error: /dev/disk does not exist\n", MLOG_PRINT);
|
||||
// }
|
||||
// vfile_t **dir_data = disk_dir->access.data.ptr;
|
||||
// for(uint32_t i = 0; dir_data[i]; i++){
|
||||
// mlog("KERNEL", "Filename: %s\n", MLOG_PRINT, dir_data[i]->name);
|
||||
// vfs_detect_partitions(dir_data[i]);
|
||||
// }
|
||||
// dispatch_message(0);
|
||||
printf("Bleh\n");
|
||||
//why did i stop working on this? what was wrong with this?
|
||||
|
|
|
|||
|
|
@ -85,11 +85,11 @@ void vector_push(vector_t *vector, void *new_element){
|
|||
for(uint8_t i = 0; i < (vector->size - 1) * vector->sizeof_elements; i++){
|
||||
((uint8_t *)(newptr))[i] = ((uint8_t *)vector->ptr)[i * vector->size];
|
||||
}
|
||||
}
|
||||
void *tmp = vector->ptr;
|
||||
vector->ptr = newptr;
|
||||
kfree(tmp);
|
||||
}
|
||||
vector->ptr = newptr;
|
||||
}
|
||||
for(uint32_t i = 0; i < vector->sizeof_elements; i++){
|
||||
((uint8_t *)(vector->ptr))[vector->size * vector->sizeof_elements + i] = ((uint8_t *)new_element)[i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,10 @@ void initrc_read(vfile_t *file){
|
|||
// printf("TEST: %s, %s, %d\n", mount_src_name, mount_dest, ptr[i]);
|
||||
|
||||
vfile_t *to_mount = fget_file(mount_src_name);
|
||||
dispatch_message(MESSAGE_MOUNT_FS, to_mount, mount_dest, offset);
|
||||
if(!dispatch_message(MESSAGE_MOUNT_FS, to_mount, mount_dest, offset)){
|
||||
mlog("INITRC", "Error: Could not mount device %s at %s", MLOG_PRINT, mount_src_name, mount_dest);
|
||||
asm("int $13");
|
||||
}
|
||||
}
|
||||
else if(!strcmp(statement, "END")){
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ uint32_t module_api(uint32_t func, ...){
|
|||
|
||||
|
||||
|
||||
void dispatch_message(uint32_t message, ...){
|
||||
uint32_t dispatch_message(uint32_t message, ...){
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
|
||||
|
|
@ -180,12 +180,13 @@ void dispatch_message(uint32_t message, ...){
|
|||
result = handler(message, srcfile, destname, offset);
|
||||
break;
|
||||
}
|
||||
if((int32_t) message > 0 && result){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if((int32_t) message >= 0 && result){
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
va_end(args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void module_start(void *ptr){
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ enum MESSAGES{
|
|||
MESSAGE_BROADCAST = 0x80000000, //placeholder
|
||||
};
|
||||
|
||||
void dispatch_message(uint32_t message, ...);
|
||||
|
||||
typedef struct module{
|
||||
void *init_entry;
|
||||
|
|
@ -57,5 +56,6 @@ typedef struct module{
|
|||
void (*fini)(void);
|
||||
}module_t;
|
||||
|
||||
uint32_t dispatch_message(uint32_t message, ...);
|
||||
void modules_init();
|
||||
void module_start(void *ptr);
|
||||
|
|
@ -17,20 +17,38 @@ module_t module_data = {
|
|||
0,
|
||||
};
|
||||
|
||||
// void mount_fat32(vfile_t *dev_file, char *destination){
|
||||
uint8_t fat32_check_valid(fat32_bpb_t *bpb){
|
||||
return bpb->signature == 0x28 || bpb->signature == 0x29;
|
||||
}
|
||||
|
||||
// }
|
||||
uint32_t fat32_mount(vfile_t *dev_file, char *destination, uint32_t offset){
|
||||
char *bpb_buffer = malloc(api, 1);
|
||||
fread(api, dev_file, bpb_buffer, offset, 4096);
|
||||
fat32_bpb_t *bpb = bpb_buffer;
|
||||
|
||||
api(MODULE_API_PRINT, MODULE_NAME, "Sizeof struct: %d, sig: %x, boot sig: %x\n", sizeof(fat32_bpb_t), bpb->signature, bpb->bootable_sig);
|
||||
if(!fat32_check_valid(bpb)){
|
||||
api(MODULE_API_PRINT, MODULE_NAME, "Error: No valid BPB\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t message_handler(uint32_t message, ...){
|
||||
puts(api, MODULE_NAME, "Called message handler!\n");
|
||||
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
|
||||
if(message == MESSAGE_MOUNT_FS){
|
||||
vfile_t *device = va_arg(args, vfile_t *);
|
||||
char *dest = va_arg(args, char *);
|
||||
uint32_t offset = va_arg(args, uint32_t);
|
||||
return fat32_mount(device, dest, offset);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int phony_read(vfile_t *file, char*buffer, uint32_t offset, uint32_t count){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void init(KOS_MAPI_FP module_api, uint32_t api_version){
|
||||
api = module_api;
|
||||
api(MODULE_API_PRINT, MODULE_NAME, "KIFSM Filesystem Driver Module v0.1.0\nSupported Filesystems:\n");
|
||||
|
|
|
|||
|
|
@ -1,2 +1,36 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct fat32_bpb{
|
||||
//fat12/fat16 bpb
|
||||
char nop[3];
|
||||
char oem[8];
|
||||
uint16_t bytes_per_sector;
|
||||
uint8_t sectors_per_cluster;
|
||||
uint16_t reserved_sectors;
|
||||
uint8_t fat_count;
|
||||
uint16_t root_dir_entries;
|
||||
uint16_t sectors_small;
|
||||
uint8_t media;
|
||||
uint16_t sectors_per_fat_16;
|
||||
uint16_t sectors_per_track;
|
||||
uint16_t heads;
|
||||
uint32_t partition_start;
|
||||
uint32_t sector_count;
|
||||
//fat32 exclusive
|
||||
uint32_t sectors_per_fat;
|
||||
uint16_t flags;
|
||||
uint16_t fat_version;
|
||||
uint32_t root_dir_cluster;
|
||||
uint16_t fsinfo_sector;
|
||||
uint16_t backup_bpb_sector;
|
||||
uint8_t reserved[12];
|
||||
uint8_t drive_no;
|
||||
uint8_t ntflags;
|
||||
uint8_t signature; //must be 0x28 or 0x29
|
||||
uint32_t serial_id;
|
||||
char label[11];
|
||||
char system_id[8];
|
||||
char boot_code[420];
|
||||
uint16_t bootable_sig;
|
||||
}__attribute__((packed)) fat32_bpb_t;
|
||||
|
|
@ -47,10 +47,11 @@ typedef struct cpu_registers{
|
|||
uint32_t eip, cs, eflags, useresp, ss;
|
||||
}__attribute__((packed))cpu_registers_t;
|
||||
|
||||
typedef enum mount_ops{
|
||||
MOUNT_NEW,
|
||||
MOUNT_UNMOUNT,
|
||||
}MOUNT_OPERATION;
|
||||
enum MESSAGES{
|
||||
MESSAGE_MOUNT_FS,
|
||||
MESSAGE_UNMOUNT_FS,
|
||||
MESSAGE_BROADCAST = 0x80000000, //placeholder
|
||||
};
|
||||
|
||||
typedef enum vfile_type{
|
||||
VFILE_NULL,
|
||||
|
|
|
|||
Loading…
Reference in New Issue