OSDev.org

The Place to Start for Operating System Developers
It is currently Thu May 16, 2024 9:52 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: disk read error
PostPosted: Wed Apr 12, 2006 11:00 pm 
Offline

Joined: Wed Mar 29, 2006 12:00 am
Posts: 6
hello,

i tried to load my some data with the int 0x13,
but it doesn't work, the error code is 0x10
i looked in a list:
0x10 means "read error"

what can be the problem?
"read error" is helping a lot


Top
 Profile  
 
 Post subject: Re: disk read error
PostPosted: Thu Apr 13, 2006 11:00 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 21, 2004 11:00 pm
Posts: 349
Location: Munich, Germany
Hello,
from what I know it's possible that the floppy just didn't manage to spin-up in the given amount of time. You should try to read for a few times before giving up..

regards,
gaf


Top
 Profile  
 
 Post subject: Re: disk read error
PostPosted: Thu Apr 13, 2006 11:00 pm 
Offline

Joined: Wed Mar 29, 2006 12:00 am
Posts: 6
I tried that too, but it didn't make any difference
but maybe I've to wait longer...


Top
 Profile  
 
 Post subject: Re: disk read error
PostPosted: Thu Apr 13, 2006 11:00 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 21, 2004 11:00 pm
Posts: 349
Location: Munich, Germany
According to this list of error-code, 0x10 means "uncorrectable CRC or ECC error on read". A read error is code 0x04 and a timeout would be 0x80.

What parameters are you using to call int 0x13 ? Maybe you're trying to access a non-existing sector and your BIOS just returns the wrong error-code.

regards,
gaf


Top
 Profile  
 
 Post subject: Re: disk read error
PostPosted: Fri Apr 14, 2006 11:00 pm 
Offline

Joined: Wed Mar 29, 2006 12:00 am
Posts: 6
you're right, I made a mistake in my function, which should read the error code
the right error code is 0x01, he means "invalid function in AH or invalid parameter",

that's strange, the program runs in bochs without problems,
only my old ami-bios makes problems

maybe yousee the mistake:

Code:
readdisk:
push bp
mov bp, sp
sub sp, 0x0006
push ax
push bx
push cx
push dx
push es

mov ax, [bp+0x04]
mov bx, 0x0024
xor dx, dx
div bx
mov [bp-0x02], ax
mov ax, dx
push ax
mov bx, 0x0012
xor dx, dx
div bx
mov [bp-0x04], ax
pop ax
xor dx, dx
div bx 
mov ax, dx
inc ax
mov [bp-0x06], ax

mov ax, [bp+0x06]
mov es, ax
xor bx, bx
mov ah, 0x02
mov al, 0x01
mov ch, [bp-0x02]
mov cl, [bp-0x06]
mov dh, [bp-0x04]
mov dl, 0x00
int 0x13

pop es
pop dx
pop cx
pop bx
pop ax
mov sp, bp
pop bp
ret


the first parameter contains the the logical sector and he second one the segment

But it can't be a mathematical problem in the function, in bochs he reads exactly the correct sectors


Last edited by scales of justice on Fri Apr 14, 2006 11:00 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: disk read error
PostPosted: Fri Apr 14, 2006 11:00 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 21, 2004 11:00 pm
Posts: 349
Location: Munich, Germany
Code:
mov ax, [bp+0x04] ; ax = logical sector
mov bx, 0x0024
xor dx, dx
div bx
mov [bp-0x02], ax ; bp-2 = sector/0x24
mov ax, dx
push ax           ; push [sector%24]
mov bx, 0x0012    ; sectors per track
xor dx, dx
div bx
mov [bp-0x04], ax ; bp-4 = (sector%0x24)/0x12
pop ax
xor dx, dx
div bx
mov ax, dx
inc ax
mov [bp-0x06], ax ; bp-6 = ((sector%24)%0x12) + 1

mov ax, [bp+0x06]
mov es, ax        ; es = segment                 (es:bx buffer)
xor bx, bx        ; bx = 0
mov ah, 0x02      ; ah = 2                       (function)
mov al, 0x01      ; al = 1                       (number of sectors)
mov ch, [bp-0x02] ; ch = sector/0x24             (lower 9bits of track number)
mov cl, [bp-0x06] ; cl = ((sector%0x24)%0x12) +1 (sector number)
mov dh, [bp-0x04] ; dh = (sector%0x24)/0x12      (head number)
mov dl, 0x00      ; dl = 0                       (drive number)
int 0x13


Hmm, I've gone through your code, and either my assembler is much worse than I thought it was, or you mixed up some of the facts about floppy disk geometry.
The first thing is that there is 18 sectors per track and not 36, except if you're using a 2.88 MB floppy, which however seems rather unlikely to me. This means that you have to change the value in line 2, so that CH will eventually be sector/0x12. To get the sector number (CL) all you have to do is to take the remainer of the division. The sector is the offset in the current track and there should be no need to do any additionaly divsions as you do in lines 6-10. To get the head number, all you have to do is to divide the logical sector number by the number of sectors per head (1440).

I also suggest that you add one to the logical sector number at the very beginning of your calculations, as it will influence all other results.

cheers,
gaf


Top
 Profile  
 
 Post subject: Re: disk read error
PostPosted: Fri Apr 14, 2006 11:00 pm 
Offline

Joined: Wed Mar 29, 2006 12:00 am
Posts: 6
this time you're not right:

36 is correct, at first you must divide with the sectors per Track and then with the heads, I combined these two steps

look here:
http://www.osdever.net/tutorials/chs_lba.php?the_id=87


but I found the real problem now:

if there are more than 10 bytes on the stack int 13h doesn't work
but I can't imagine why o.O


EDIT:
no it works
I changed the position of the stack
maybe there was anything of my bios


Last edited by scales of justice on Fri Apr 14, 2006 11:00 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: disk read error
PostPosted: Fri Apr 14, 2006 11:00 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 21, 2004 11:00 pm
Posts: 349
Location: Munich, Germany
Ok, had a look at the tutorial and it seems as if you were right about the heads. It's actually been some time that I did this for the last time and I'm sorry if I just added to the confusion..

While you can basically forget about my whole explanation, I still think that the comments I added to your code are essentially correct. In that case however the formulas given in the tutorial only agree with your algorithm for the sectors, but not for the head- and track numbers. It might be that your code works for some LBA addresses, but I'm quite sure that it will fail once you're trying to load something significantly large - such as a kernel.

regards,
gaf


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group