From 02f14113cbf14c6f842fb43ecbc68d0c851ef3b0 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 24 May 2020 11:02:43 -0400 Subject: very basic vga, ata, serial drivers. start of fat and fs drivers --- src/kernel/fat.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/kernel/fat.c (limited to 'src/kernel/fat.c') diff --git a/src/kernel/fat.c b/src/kernel/fat.c new file mode 100644 index 0000000..00fa61f --- /dev/null +++ b/src/kernel/fat.c @@ -0,0 +1,21 @@ +#include "fat.h" +#include "ata.h" +#include "panic.h" + +void load_fat() { + read_sectors(FAT_INFO->reserved_sectors, FAT_INFO->sectors_per_fat, FAT); +} + +uint16_t get_cluster(uint16_t n) { + uint32_t t = *(uint32_t *)(FAT + (n / 2) * 3); + return (n % 2 ? (t >> 12) : t) & 0xfff; +} + +void set_cluster(uint16_t n, uint16_t v) { + uint32_t *t = (uint32_t *)(FAT + (n / 2) * 3); + *t = (*t & (n % 2 ? 0xff000fff : 0xfffff000)) | (n % 2 ? v << 12 : v); +} + +uint16_t get_start_cluster(uint8_t *path) { + panic("Not implemented (get_start_cluster)."); +} \ No newline at end of file -- cgit v1.2.3