OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Sep 25, 2018 4:56 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: INT 0x13 AH=0x42 returns error
PostPosted: Sat Sep 08, 2018 5:03 pm 
Offline

Joined: Thu May 25, 2017 10:41 pm
Posts: 21
I have been working on a simple bootloader for my OS, and I have encountered a problem.
I'm trying to use INT 0x13 AH=0x42 to load 8 sectors of code from the disk, but for some reason it always returns with AH=0x01 ("invalid function in AH or invalid parameter")

I think there is something wrong with this function, though I haven't been able to pinpoint anything:
Code:
loadstage2:
   mov ah, 0x42
   mov si, dap
   mov dl, byte [drivenum]
   int 0x13
   jc .errloading
   ret
.errloading:
   jmp hang

dap:       
   size db 0x10
   zero db 0
   sectors db 8
   load_address dd 0x00007E00
   start_sec dq 1


My code does check whether BIOS extensions are available, so I don't think that is the problem.


Top
 Profile  
 
 Post subject: Re: INT 0x13 AH=0x42 returns error
PostPosted: Sat Sep 08, 2018 5:22 pm 
Offline

Joined: Thu May 25, 2017 10:41 pm
Posts: 21
I found out the problem.

Strangely enough, the first letter of startmsg was being copied into start_sec of the DAP. I added a filler so that this doesn't happen, and the problem is (seemingly) fixed now.
Here is my fixed code:

Code:
dap:
[...]
   start_sec dq 1

   ; For some reason this is necessary.
   filler db 0
   
startmsg db 'booted TestOS.',13,10,0


Top
 Profile  
 
 Post subject: Re: INT 0x13 AH=0x42 returns error
PostPosted: Sat Sep 08, 2018 6:00 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 457
Location: USA
I would look into that. It sounds funny. Why would the first letter of the string, 8 bytes away, be copied into start_sec.

1) Assembler has a bug (doubtful)
2) You have a pointer issue somewhere
3) You are loading the code and skipping something.
4) Just about anything.

I would run it through Bochs, set a break point for when that byte gets changed, and see where you are.

Just for fun, you don't have to set up a separate place for the DAP. You can use the stack. For an example, see my code at https://github.com/fysnet/FYSOS/blob/master/boot/services/read_ext.inc.

Code:
  // edx:eax = LBA to read
  // ebx = physical address to read it to
  // cx = count of sectors to read (should not be more than 7Fh, as well as this makes CH = 0)
           push edx        ; offset 12
           push eax        ; offset 8
           shl  ebx,12
           shr  bx,12
           push ebx        ; offset 4
           push cx         ; offset 2 (ch = 0)
           push 10h        ; offset 0
           mov  si,sp
           mov  ah,42h     ; read
           mov  dl, ...
           int    13h

Just make sure you adjust the stack afterward. ( add sp,16 )

You can call another service to see if the MSEXT services are available.

Depending on the BIOS manufacturer, I have seen this service available for floppies as well, go figure. Most BIOSes will return the carry set when checking for this service when DL points to a floppy, but will return TRUE (carry clear and BX=sig, etc.) when DL points to a hard drive.

Ben
- http://www.fysnet.net/osdesign_book_series.htm


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], no92 and 4 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