OSDEV: FAT filesystem problem on my Operating System

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Piso94
Posts: 3
Joined: Sun May 26, 2013 8:24 am

OSDEV: FAT filesystem problem on my Operating System

Post by Piso94 »

Hi everyone, I'm new! Sorry for my bad english but I'm Italian and I'm using Google Translator! Returning to the topic, I'm writing this OS and have a good point, I wrote the GDT, IDT, ISR, FPU, Drivers Keyboard and Mouse, Timer, IRQ, floppy drives and FAT file system, the latter with the help of: http: / / http://www.brokenthorn.com/Resources/OSDev22.html, but I have a problem with the filesystem.
The guide is written that to mount the FAT, just do:
p_bootsector_t bootsector = (p_bootsector_t) flp_read_sector (0);
/ / And other code ...
But when I go to start the car sends me into a kernel panic for Division by zero in fact doing a log of all the variables:
bootsector-> Bpb.NumSectors
bootsector-> Bpb.SectorsPerFat
bootsector-> Bpb.NumDirEntries
(Bootsector-> Bpb.NumDirEntries * 32) / bootsector-> Bpb.BytesPerSector

give me all result 0, but I do not understand why, I also did a test by entering the correct values ​​(taken from the internet), but the output is an infinite series of strings "0 @ P` p ', and do not understand the why!
Can you give me a hand?
Thank you very much :)
PS: I followed the guide only to implement the drivers in C for DMA, FDC and FAT! Maybe there's more to implement? :mrgreen:
Attachments
fat.h
FAT filesystem header
(1.55 KiB) Downloaded 86 times
flp.c
Floppy driver implementation
(7.44 KiB) Downloaded 80 times
fat.c
FAT filesystem implementation
(5.55 KiB) Downloaded 62 times
HugeCode
Member
Member
Posts: 112
Joined: Mon Dec 17, 2012 9:12 am

Re: OSDEV: FAT filesystem problem on my Operating System

Post by HugeCode »

Can you provide content of floppy image?
Piso94
Posts: 3
Joined: Sun May 26, 2013 8:24 am

Re: OSDEV: FAT filesystem problem on my Operating System

Post by Piso94 »

Certainly!
os.img:
\kernel.bin
\fil.txt (what I read)
\boot\grub\stage1
\boot\grub\stage2
\boot\grub\menu.cfg

P.S: Here is my github with code: https://github.com/Piso94/MudStorm-OS ;)
Piso94
Posts: 3
Joined: Sun May 26, 2013 8:24 am

Re: OSDEV: FAT filesystem problem on my Operating System

Post by Piso94 »

Ok, now I was able to go the fat_mount () :) thanks to:

Code: Select all

p_bs_t bootsector;
uint8_t *sector = flp_read_sector(0);

for (int i=0;i<(sizeof(p_bs_t) - 2);i++)
        ((uint8_t*)&bootsector)[i] = sector[i];

// Other code...
But now, when I go to read the fil.txt I do not write anything on the screen! I try to debug and let you know;)

Edit:
I was able to run the floppy ... for the kernel panic was a problem in the code of the driver floppy! But now I have a 'other problem ... that can not recognize me, do you read my files ... that even though I to the "open" the step "0", he wrote to me in a video sequence of "S" endless! How come? He can not understand ... but I double checked the code of the fat and there is no inequality! :evil:

I also checked the floppy image ... is formatted in FAT 12 bit ... the same code version of the guide FAT! How can I do? thanks

NB: Now I'm back to the code of guidance, namely:

Code: Select all

p_bs_t bootsector;

bootsector = (p_bs_t)flp_read_sector(0);
Post Reply