Page 1 of 1
Disk Access in Real Mode
Posted: Thu Nov 07, 2002 4:26 am
by PlayOS
Hi,
I am having trouble reading the floppy in real mode, I have a routine that I have been using to read the first 17 sectors after the boot sector, however when I put head 1, track 0, sector 1 I get read errors in bochs.
Does anyone have any examples?
thanks.
Re:Disk Access in Real Mode
Posted: Thu Nov 07, 2002 11:29 am
by beyondsociety
I do. I used it in my bootsector though, but you shouldn't have any problems with it running in the second stage loader.
Here it is: I have it set up as 17 sectors, sector 2, Head 0
Just change [mov cl,2] to [mov cl,1] and [mov dh,0] to [mov dh,1] and should work for you.
Code: Select all
mov ah, 02h ; Read disk sectors function
mov al, 17 ; Read in 17 sectors
mov ch, 0 ; Cylinder = 0
mov cl, 2 ; Sector = 2
mov dh, 0 ; Head = 0 = side one
mov dl, [bootdrv] ; disk = what we booted from
I tested it on a real machine, so I haven't tried it on bochs. I've only tested it as I have above in the posted code.
Try it out and see how it works for you. Good luck
Re:Disk Access in Real Mode
Posted: Thu Nov 07, 2002 11:33 am
by beyondsociety
By the way:
Code: Select all
mov dl,[bootdrv] ; The drive we booted from
should be equal to:
Re:Disk Access in Real Mode
Posted: Fri Nov 08, 2002 5:09 am
by PlayOS
Hi,
This is what I am doing now and I am not getting what I am supposed to, I know this because if I make my kernel fit within 17 sectors, everything runs fine. But when I exceed this I end up with an error.
It is not the new code because the new code that I add to put it over 17 sectors is a variation of the code that is already working.
Could someone explain exactly how a disk is written to?
I have been told that the disk is written track by track, ie side 0, track 0 then side 1, track 0 then side 0, track 1 then side 1, track 1 etc...
This doesn't sound like a smart way to do it but that is what I was told is done, so does anyone know?
thanks.
Re:Disk Access in Real Mode
Posted: Fri Nov 08, 2002 9:04 am
by PlayOS
Well I got it to work, my kernel is being written like this
side 0, track 0
side 0, track 1
etc...
I am using a program called bootcopy so I dont know if it is this program or not but it is now working when I follow this scheme.
Any ideas on the true and correct way to read and write data to disks?
thanks