feat: introduced tasking, added paging (no vm), moved malloc, added

syscalls, other stuff
This commit is contained in:
2021-02-27 11:46:26 +01:00
parent 8f615b259c
commit 9f72d4bb1a
42 changed files with 907 additions and 292 deletions

View File

@@ -4,8 +4,8 @@
#include <libc/libc.h>
#include <libk.h>
#include <mem/mem.h>
#include <libc/kprintf.h>
#include <mem/malloc.h>
#include "blockdev.h"
#define MAX_BLOCK_DEVS 64
@@ -21,7 +21,7 @@ uint8_t block_dev_register_driver(block_dev_driver *driver) {
return BLOCK_DEV_REGISTER_DRIVER_FULL;
}
memcpy((uint8_t *) &block_dev_drivers[last_block_driver++], (const uint8_t *) driver, sizeof(block_dev_drivers));
memcpy((uint8_t *) &block_dev_drivers[last_block_driver++], (const uint8_t *) driver, sizeof(block_dev_driver));
return BLOCK_DEV_REGISTER_DRIVER_OK;
}

View File

@@ -8,7 +8,8 @@
#include <types.h>
#include <libc/libc.h>
#include <libc/kprintf.h>
#include <mem/mem.h>
#include <mem/malloc.h>
#include <attributes.h>
#define FAT_TYPE_12 1
#define FAT_TYPE_16 2
@@ -31,7 +32,7 @@ typedef struct {
uint16_t heads_sides;
uint32_t hidden_sectors;
uint32_t large_total_sectors;
} __attribute((packed)) bpb;
} packed bpb;
union {
struct {
uint8_t drive_number;
@@ -40,7 +41,7 @@ typedef struct {
uint32_t serial;
uint8_t label[11];
uint8_t system_id[8];
} __attribute((packed)) ebr_12_16;
} packed ebr_12_16;
struct {
uint32_t sectors_per_fat;
uint16_t flags;
@@ -55,21 +56,21 @@ typedef struct {
uint32_t serial;
uint8_t label[11];
uint8_t system_id[8];
} __attribute((packed)) ebr_32;
} packed ebr_32;
};
} __attribute((packed)) fat_bpb;
} packed fat_bpb;
typedef struct {
uint8_t hours: 5;
uint8_t minutes: 6;
uint8_t seconds: 5;
} __attribute((packed)) time_83;
} packed time_83;
typedef struct {
uint8_t hours: 5;
uint8_t minutes: 6;
uint8_t seconds: 5;
} __attribute((packed)) date_83;
} packed date_83;
typedef struct {
union {
@@ -86,7 +87,7 @@ typedef struct {
date_83 last_mod_date;
uint16_t low_first_cluster;
uint32_t file_size;
} __attribute((packed)) name_83;
} packed name_83;
struct {
uint8_t order;
uint16_t text_1[5];
@@ -96,9 +97,9 @@ typedef struct {
uint16_t text_2[6];
uint16_t reserved;
uint16_t text_3[2];
} __attribute((packed)) long_name;
} packed long_name;
};
} __attribute((packed)) fat_directory_entry;
} packed fat_directory_entry;
uint8_t fat_check_device(const block_device *device, uint8_t *first_sector);
@@ -128,7 +129,8 @@ uint8_t fat_check_device(const block_device *device, uint8_t *first_sector) {
uint32_t total_sectors = bpb.bpb.total_sectors == 0 ? bpb.bpb.large_total_sectors : bpb.bpb.total_sectors;
uint32_t fat_size = bpb.bpb.sectors_per_fat == 0 ? bpb.ebr_32.sectors_per_fat : bpb.bpb.sectors_per_fat;
uint32_t root_dir_sectors = ((bpb.bpb.directories * 32) + (bpb.bpb.bytes_per_sector - 1)) / bpb.bpb.bytes_per_sector;
uint32_t root_dir_sectors =
((bpb.bpb.directories * 32) + (bpb.bpb.bytes_per_sector - 1)) / bpb.bpb.bytes_per_sector;
uint32_t first_data_sector = bpb.bpb.reserved_sectors + (bpb.bpb.fats * fat_size) + root_dir_sectors;
uint32_t first_fat_sector = bpb.bpb.reserved_sectors;
uint32_t data_sectors = total_sectors - (bpb.bpb.reserved_sectors + (bpb.bpb.fats * fat_size) + root_dir_sectors);
@@ -163,7 +165,8 @@ typedef struct {
} table_result;
table_result
get_fat_table_value(uint8_t fat_type, const uint8_t *fat_table, uint32_t active_cluster, uint32_t first_fat_cluster, uint32_t sector_size) {
get_fat_table_value(uint8_t fat_type, const uint8_t *fat_table, uint32_t active_cluster, uint32_t first_fat_cluster,
uint32_t sector_size) {
uint32_t fat_offset;
table_result result = {
.value = 0,

View File

@@ -5,10 +5,11 @@
#include "mbr.h"
#include <types.h>
#include <drivers/ide.h>
#include <mem/mem.h>
#include <libc/kprintf.h>
#include <fs/blockdev.h>
#include <libc/libc.h>
#include <mem/malloc.h>
#include <attributes.h>
typedef struct {
uint8_t bootable;
@@ -21,14 +22,14 @@ typedef struct {
uint16_t ending_cylinder: 10;
uint32_t start_lba;
uint32_t num_lbas;
} __attribute((packed)) mbr_partition_table_entry;
} packed mbr_partition_table_entry;
typedef struct {
uint32_t unique_id;
uint16_t reserved;
mbr_partition_table_entry entries[4];
uint8_t signature[2];
} __attribute((packed)) mbr_table;
} packed mbr_table;
typedef struct {
const block_device *device;