28#define ATA_IO_BASE 0x1F0
34#define ATA_STATUS (ATA_IO_BASE + 7)
37#define ATA_COMMAND (ATA_IO_BASE + 7)
40#define ATA_DRIVE (ATA_IO_BASE + 6)
43#define ATA_ERROR (ATA_IO_BASE + 1)
46#define ATA_SECCNT (ATA_IO_BASE + 2)
49#define ATA_LBA_LOW (ATA_IO_BASE + 3)
52#define ATA_LBA_MID (ATA_IO_BASE + 4)
55#define ATA_LBA_HI (ATA_IO_BASE + 5)
58#define ATA_DATA (ATA_IO_BASE + 0)
61#define ATA_CMD_READ_SECTORS 0x20
64#define ATA_SR_BSY 0x80
67#define ATA_SR_DRQ 0x08
70#define ATA_SR_ERR 0x01
73#define ATA_WRITE_CMD 0x30
166void Writefile(
const char *filename,
const char *ext,
const char *data,
186void Fileconts(
const char *filename,
const char *ext);
193void Mkfile(
const char *filename,
const char *ext);
210static inline void Padname(
const char *src,
char *dest,
int len) {
212 while (i < len && src[i] !=
'\0') {
214 dest[i] = (ch >=
'a' && ch <=
'z') ? (ch - 32) : ch;
struct FaT16Info fat16
Holds FAT16 filesystem info and a sector buffer.
void Fileconts(const char *filename, const char *ext)
Prints contents of a FAT16 file.
void Mkfile(const char *filename, const char *ext)
Creates a new empty file in the FAT16 root directory.
void Writefile(const char *filename, const char *ext, const char *data, u32 size)
Writes data to a FAT16 file, replacing its contents.
void AtaWriteSector(u32 lba, const u8 *buffer)
Writes a 512-byte sector to ATA disk from buffer.
void Fat16Ls(void)
Lists files in the FAT16 root directory.
volatile u8 irq14stat
IRQ status flags for IRQ14 and IRQ15 (primary and secondary IDE interrupts)
void Fat16RemoveFile(const char *filename, const char *ext)
Removes a file from the FAT16 root directory and frees clusters.
void AtaReadSector(u32 lba, u8 *buffer)
Reads a 512-byte sector from ATA disk into buffer.
u32 FindFat16Partition(void)
Finds the FAT16 partition on disk.
u32 Fat16Mount(u32 partition_lba)
Mounts FAT16 partition and reads filesystem info.
#define PKG
Add attribute packed.
unsigned int u32
32-Bit Unsigned Int
unsigned short u16
16-Bit Unsigned Int
unsigned char u8
8-Bit Unsigned Int
FAT16 BIOS Parameter Block (BPB) structure — describes volume layout.
Parsed FAT16 filesystem layout and parameters.