summaryrefslogtreecommitdiff
path: root/src/kernel/fat.c
blob: 00fa61fd4ce2b098508b22d2a62cfb1c6ce8fe47 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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).");
}