feat: introduced tasking, added paging (no vm), moved malloc, added
syscalls, other stuff
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user