summaryrefslogtreecommitdiff
path: root/src/kernel/fat.c
diff options
context:
space:
mode:
authorBenji Dial <benji3.141@gmail.com>2020-05-24 11:02:43 -0400
committerBenji Dial <benji3.141@gmail.com>2020-05-24 11:02:43 -0400
commit02f14113cbf14c6f842fb43ecbc68d0c851ef3b0 (patch)
tree75d2d943d9822b3f945fd947e9b91eec1d68e900 /src/kernel/fat.c
parent31d8ae388a7ded576abd3e3d99c3d9193ea6d704 (diff)
downloadportland-os-02f14113cbf14c6f842fb43ecbc68d0c851ef3b0.tar.gz
very basic vga, ata, serial drivers. start of fat and fs drivers
Diffstat (limited to 'src/kernel/fat.c')
-rw-r--r--src/kernel/fat.c21
1 files changed, 21 insertions, 0 deletions
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