Page 1 of 1
Loading USB SecondStage Loader Problem
Posted: Wed Dec 08, 2010 3:14 am
by Muneer
Hi,
I know this has been discussed before and I have searched through almost all the topics related to this but the problem is that i still cant get it to work.
My Pc supports USB booting ( I can load my MBR and get it to work).
But When I load the second sector and jump to it , it triple faults in real hardware ( and not in virtual box or virtual pc or Bochs).
Also my Pc boots Usb as HDD
Code: Select all
Load_Second_Sector:
Mov Ax , 0x1000 ; Segment Address To Copy Sector
Mov Es , Ax
Xor Bx , Bx ; Offset Address To Copy Sector
Mov Ah , 2 ; Copy Sector Function
Mov Al , 1 ; Number Of Sectors to Copy
Mov Ch , 0 ; Track Number
Mov Cl , 2 ; Sector Number
Mov Dh , 0 ; Head Number
mov Dl , [BootDiskNumber] ; Drive Number With Which Bios Was Booted
Int 0x13
Ret
BootDiskNumber: db 0
Thanks In Advance
Re: Loading USB SecondStage Loader Problem
Posted: Wed Dec 08, 2010 3:27 am
by Combuster
What's with the lack of error checking?
Re: Loading USB SecondStage Loader Problem
Posted: Wed Dec 08, 2010 3:31 am
by Muneer
This is supposed to be a basic bios call procedure . So I thought I could do without it. Does it make any difference?......
Re: Loading USB SecondStage Loader Problem
Posted: Wed Dec 08, 2010 3:42 am
by Combuster
Yes. It's called basic debugging skills.
How else do you think you can find out if the bios call is the problem? It even gives a description of the error if it has one.
(and on real hardware, you can have random read errors although for USB they should be rather unlikely)
Re: Loading USB SecondStage Loader Problem
Posted: Wed Dec 08, 2010 3:43 am
by Muneer
Thanks . I will check and post the result
Re: Loading USB SecondStage Loader Problem
Posted: Wed Dec 08, 2010 11:06 am
by Muneer
I still cant get it to work. No Error after reading the drive.
Here is the code with Extended Functions (unlike earlier with 02 funtion)
Code: Select all
DriveRead:
Mov Ax , 0
Mov Ds , Ax
Mov Si , Packet
Mov Ah , 0x42 ; Extended Bios Drive Read Function
Mov Dl , [BootDiskNumber] ; Drive Number With Which Bios Was Booted
Int 0x13
Jnc Continue
Call Display_Error ; Procedure that prints "There is Error" to screen
Continue:
Packet:
db 16 ; Size Of packet
db 0 ; Should Be 0
db 1 ; Number Of Sectors To Be Read
db 0 ; Should Be 0
dw 0 ; Offset (1000:0000)
dw 1000 ; Segment
dd 1 , 0 ; Start Of Sector To Be Read (First sector of drive has number 0)
BootDiskNumber: db 0
Can Someone post code to read the second sector from a Usb-HDD . ....
Re: Loading USB SecondStage Loader Problem
Posted: Wed Dec 08, 2010 1:58 pm
by gerryg400
Is that supposed to be 0x1000 ?
Re: Loading USB SecondStage Loader Problem
Posted: Wed Dec 08, 2010 4:40 pm
by Combuster
Code: Select all
Jnc Continue
Call Display_Error ; Procedure that prints "There is Error" to screen
Continue: ; continue anyway
Doesn't this qualify as "print a message then crash anyway" (especially, crash before you can see the printout)
Re: Loading USB SecondStage Loader Problem
Posted: Wed Dec 08, 2010 11:25 pm
by Muneer
Hi gerryg400,
Well you are right. That was supposed to be 0x1000. But anyways i had detected it just after posting that and the result is still the same.
Hi Combuster ,
It has a Cli and Hlt just after the code so that I can check whether the crash will print to the screen. But then It does not, So I have to take it as no error. Both the codes ( supposed to function similarly does not work out and both gives back "no error" result)
First Method:
Code: Select all
Load_Second_Sector:
Mov Ax , 0x1000 ; Segment Address To Copy Sector
Mov Es , Ax
Xor Bx , Bx ; Offset Address To Copy Sector
Mov Ah , 2 ; Copy Sector Function
Mov Al , 1 ; Number Of Sectors to Copy
Mov Ch , 0 ; Track Number
Mov Cl , 2 ; Sector Number
Mov Dh , 0 ; Head Number
mov Dl , [BootDiskNumber] ; Drive Number With Which Bios Was Booted
Int 0x13
Ret
BootDiskNumber: db 0
Second Method:
Code: Select all
DriveRead:
Mov Ax , 0
Mov Ds , Ax
Mov Si , Packet
Mov Ah , 0x42 ; Extended Bios Drive Read Function
Mov Dl , [BootDiskNumber] ; Drive Number With Which Bios Was Booted
Int 0x13
Jnc Continue
Call Display_Error ; Procedure that prints "There is Error" to screen
Continue:
Packet:
db 16 ; Size Of packet
db 0 ; Should Be 0
db 1 ; Number Of Sectors To Be Read
db 0 ; Should Be 0
dw 0 ; Offset (1000:0000)
dw 0x1000 ; Segment
dd 1 , 0 ; Start Of Sector To Be Read (First sector of drive has number 0)
BootDiskNumber: db 0
VirtualBox when booting with Usb works all right with the first method ( I suppose it is because It emulates Usb FDD ), whereas with the second method it displays "There is Error" message as expected with my code ( May be because it doesn't emulate Usb HDD ). But in the real hardware neither causes a error ( My Pc supports only Usb HDD ) but looks as if the area to which the load was made doesn't have the value as expected.
I really cant understand what is going on.. Thabks