Hi all,
I'm trying to write an OS booting from USB.
My MBR is loaded fine but I don't know how to
load the kernel from Usb.
I tried to use int 13h but it didn't work.
Any other way to read USB content from MBR?
(x86 assembly code pls)
Many thanks
Read Usb from Mbr
- paulqddinh
- Posts: 9
- Joined: Thu Jan 14, 2010 9:12 am
- Location: Hanoi, VN
Read Usb from Mbr
Asus EeePC 1000H/XP Pro
x86 Intel Atom N270 1.6GHz -- 1GB RAM
x86 Intel Atom N270 1.6GHz -- 1GB RAM
Re: Read Usb from Mbr
What do you mean with that? int 13h works well for me. The BIOS emulates the USB device as a floppy disk or a hard disk via int 13h (depending on the size, I think).paulqddinh wrote:I tried to use int 13h but it didn't work.
And I don't think there's another easy way to boot from USB. Of course you could reserve some sectors after the MBR and write a full USB driver there but I don't suggest this at all. Check your int 13h code first because that works well for me (and for GRUB, too).
- paulqddinh
- Posts: 9
- Joined: Thu Jan 14, 2010 9:12 am
- Location: Hanoi, VN
Re: Read Usb from Mbr
tkx xanclic, i agree that usb driver cant be < 512byte
help me check whether my code below is ok?
my signature is my PC features.
help me check whether my code below is ok?
Code: Select all
mov ah,2 ;to read sector
mov al,1 ;read 1 sector
mov dl,80h ;first hard disk
mov dh,0 ;head 0
mov ch,0 ;cylinder 0
mov cl,1 ;sector 1 (1 of 1 to 63)
mov ax,1000h ;read to 1000:0000, second 64K segment
mov es,ax
xor bx,bx
int 13h
Asus EeePC 1000H/XP Pro
x86 Intel Atom N270 1.6GHz -- 1GB RAM
x86 Intel Atom N270 1.6GHz -- 1GB RAM
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Read Usb from Mbr
Code: Select all
mov dl,80h ;first *hard disk*
Do you see what I see?load the kernel from Usb.
Oh and, you may want to use the value in DL that you get when your bootloader is called. The bios provides the right drive number for you.
- paulqddinh
- Posts: 9
- Joined: Thu Jan 14, 2010 9:12 am
- Location: Hanoi, VN
Re: Read Usb from Mbr
tkx for the tip of value of DL
when my Mbr (on Usb) is loaded by Bios, DL = 80h (already checked on real machine)
that means my Usb is considered as first HDD (80h)
now I read by int 13h func 42h, but i dont know if this DAP is correct?
when my Mbr (on Usb) is loaded by Bios, DL = 80h (already checked on real machine)
that means my Usb is considered as first HDD (80h)
now I read by int 13h func 42h, but i dont know if this DAP is correct?
Code: Select all
dap: db 10h ;size of Dap
db 0 ;0
dw 1 ;1 sector
dw 0 ;offset 0000h
dw 1000h ;segment 1000h
dq 0 ;start from sector 0 (re-read Mbr, just to verify)
Asus EeePC 1000H/XP Pro
x86 Intel Atom N270 1.6GHz -- 1GB RAM
x86 Intel Atom N270 1.6GHz -- 1GB RAM
Re: Read Usb from Mbr
paulqddinh wrote:help me check whether my code below is ok?
Code: Select all
mov ah,2 ;to read sector
mov al,1 ;read 1 sector
...
mov ax,1000h ;read to 1000:0000, second 64K segment
mov es,ax
xor bx,bx
int 13h
See EDD Spec.now I read by int 13h func 42h, but i dont know if this DAP is correct?
If you have seen bad English in my words, tell me what's wrong, please.
- paulqddinh
- Posts: 9
- Joined: Thu Jan 14, 2010 9:12 am
- Location: Hanoi, VN
Re: Read Usb from Mbr
oh YESS egos,
my terrible mistake , i changed function number AH in AX
hm
tkx tkx
i can load my kernel now, thx guys
my terrible mistake , i changed function number AH in AX
hm
tkx tkx
i can load my kernel now, thx guys
Asus EeePC 1000H/XP Pro
x86 Intel Atom N270 1.6GHz -- 1GB RAM
x86 Intel Atom N270 1.6GHz -- 1GB RAM