Page 1 of 1

OSDEV: FAT filesystem problem on my Operating System

Posted: Sun May 26, 2013 8:39 am
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:

Re: OSDEV: FAT filesystem problem on my Operating System

Posted: Sun May 26, 2013 8:58 am
by HugeCode
Can you provide content of floppy image?

Re: OSDEV: FAT filesystem problem on my Operating System

Posted: Sun May 26, 2013 9:00 am
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 ;)

Re: OSDEV: FAT filesystem problem on my Operating System

Posted: Sat Jun 01, 2013 5:56 am
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);