38 u32 entries_per_sector =
fat16.bytes_per_sector / 32;
39 u32 root_dir_sectors =
40 ((
fat16.root_entry_count * 32) + (
fat16.bytes_per_sector - 1)) /
41 fat16.bytes_per_sector;
45 for (
u32 i = 0; i < root_dir_sectors; i++) {
48 for (
u32 j = 0; j < entries_per_sector; j++) {
51 if (entry[0] == 0x00) {
60 if (entry[0] == 0xE5) {
65 u16 cluster = entry[26] | (entry[27] << 8);
66 u32 size = entry[28] | (entry[29] << 8) | (entry[30] << 16) |
70 for (
int i = 0; i < 8; i++) {
72 if (entry[i] ==
' ' || !entry[i] || (i >= 0x5B && i <= 0x40)) {
78 for (
int i = 0; i < 3; i++) {
80 if (entry[i] ==
' ' || !entry[i] || (i >= 0x5B && i <= 0x40)) {
84 Kprintf(
" | Cluster: %x | Size: %x\n", cluster, size);
void AtaReadSector(u32 lba, u8 *buffer)
Read a single 512-byte sector from the ATA device using LBA addressing.
u8 sector[SECTOR_SIZE]
Buffer for reading sectors.
struct FaT16Info fat16
Holds FAT16 filesystem info and a sector buffer.
Definitions and declarations for FAT16 filesystem and ATA I/O.
void Kprintf(const char *fmt,...)
Formatted output to the screen.
void Kputchar(char c)
Outputs a single character to the screen at the current cursor position.
void Fat16Ls()
List files in the FAT16 root directory.
unsigned int u32
32-Bit Unsigned Int
unsigned short u16
16-Bit Unsigned Int
unsigned char u8
8-Bit Unsigned Int