continue FAT32 tests

This commit is contained in:
2025-03-25 23:50:43 +03:00
parent 4513325cfa
commit 12ae4fd814
3 changed files with 38 additions and 18 deletions
+5 -8
View File
@@ -16,6 +16,7 @@
#define STATUS_ERR 0x01
#define STATUS_BUSY 0x80
#define STATUS_DRQ 0x08
#define STATUS_RDY 0x40
// Define the IDE commands
#define IDE_CMD_IDENTIFY 0xEC
@@ -151,12 +152,8 @@ void ata_400ns_delay()
//just waiting for the drive to be ready to transfer data
void ata_poll()
{
while(1)
{
uint8_t status = inportb(0x1F7);
if(!(status & STATUS_BUSY) && (status & STATUS_DRQ))
break;
}
while(inportb(0x1F7)&STATUS_BUSY);
while(!(inportb(0x1F7)&STATUS_RDY));
}
//https://wiki.osdev.org/ATA_PIO_Mode
@@ -195,8 +192,8 @@ bool ata_write(const uint8_t *buffer, uint32_t lba)
{
uint16_t data = *(uint16_t*)(buffer + i * 2);
outw(0x1F0, data);
ata_400ns_delay();
//ata_400ns_delay();
ata_poll();
}
outb(0x1F7, 0xE7);//Cache flush
return true;
}
-1
View File
@@ -444,7 +444,6 @@ static fat_t* find_fat_volume(const char* path, int len)
if (len == it->pathlen && 0 == memcmp(path, it->path, len))
return it;
}
printf("BLYA!\n");
return NULL;
}
+32 -8
View File
@@ -54,7 +54,6 @@ static int ls(const char* path)
for (;;)
{
err = fat_readdir(&dir, &info);
if (err == FAT_ERR_EOF)
return FAT_ERR_NONE;
@@ -72,9 +71,17 @@ static int ls(const char* path)
}
}
void test(int err, const char* huy)
{
if(err != 0)
printf("ERROR: %X %s\n", err, huy);
else
printf("%s done", huy);
}
void file_fuckery()
{
int err;
int err, cnt;
err = fat_mount(&ops, 0, &g_fat, "ebalo");
if(err)
@@ -83,14 +90,31 @@ void file_fuckery()
printf("%X\n", err);
err = ls("/ebalo");
err = cat("/ebalo/boot/grub/grub.cfg");
err = fat_mkdir("/ebalo/pizdaa");
err = ls("/ebalo");
fat_umount(&g_fat);
//err = fat_fclose(&file);
err = fat_mkdir("/ebalo/numbers/");
//err = cat("/ebalo/boot/grub/grub.cfg");
char *filenames[] = {"/ebalo/numbers/d","/ebalo/numbers/e"};
for(int i = 0; i < 2; i++){
printf(filenames[i]);
file_t file;
err = fat_fopen(&file, filenames[i], "w");
if (err)
printf("ERROR! %X\n", err);
printf("1 err %X", err); goto unmount;
for (int i = 0; i < 10; i++)
{
cnt = fat_fprintf(&file, "This is test number %d\n", i);
if (cnt < 0)
printf("2 cnt: %X", cnt); goto unmount;
}
err = fat_fclose(&file);
}
unmount:
return;
printf("err%X", err);
err = fat_umount(&g_fat);
test(err, "unmount");
}
void apply_pic_masks()