How can you see your are booting from USB and not HDD.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

How can you see your are booting from USB and not HDD.

Post by Holus »

I want my OS to work on USB and HDD but how do i know where i'm booting from?
I know BIOS leave register DL (yes not BL) as boot device. But afther booting it's 80 for both.

Is there a way to read/write from USB afther enable Protected mode?
Can I stil use INT 0x13 function AH=0x42 ?
Last edited by Holus on Fri Oct 07, 2011 12:11 am, edited 3 times in total.
Computer says NOOOO
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: DETECT BOOTING FROM USB

Post by Chandra »

Holus wrote:I want my OS to work on USB and HDD but how do i know where i'm booting from?
I know BIOS leave register BL as boot device. But afther booting it's 80 for both.
Actually, its DL not BL.
Is there a way to read/write from USB afther enable Protected mode?
Yes there is. And that is....
Can I stil use INT 0x13 function AH=0x42 ?
Int 13h Extensions.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

Re: DETECT BOOTING FROM USB

Post by VolTeK »

Holus wrote:DETECT BOOTING FROM USB
Dont do that again.
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

Re: DETECT BOOTING FROM USB

Post by Holus »

Chandra wrote:
Holus wrote:I want my OS to work on USB and HDD but how do i know where i'm booting from?
I know BIOS leave register BL as boot device. But afther booting it's 80 for both.
Actually, its DL not BL.
Is there a way to read/write from USB afther enable Protected mode?
Yes there is. And that is....
Can I stil use INT 0x13 function AH=0x42 ?
Int 13h Extensions.
EBX bootimg DL bootdevice You are right.
If i use INT 0x13 in protected mode the computer just reset.
Maybe the IDT is not set up right. I ask this because I don't know where I'm looking for.

I know there is a way to read from USB. Where to start?
Can I use the IDE controller?
Can I use ATA controller?

Do I have to can PCI for devices with CLASS CODE 0x01 and SUBCLASS CODE 0x80? (other mass storrage controller)
Or CLASS CODE 0x05 SUBCLASS CODE 0x01 (Flash controller)

Or do I have to build the whole thing using CLASS CODE 0x0C SUBCLASS CODE 0x03, 0x20 or 0x80??

I can not use the harddisk controller by using the ports 1F0 to 1F8.
That start reading from HDD. Even if the USB look like a HDD on bootup with DOS.
Computer says NOOOO
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: DETECT BOOTING FROM USB

Post by gerryg400 »

You can't use Bios services in 32 bit mode. You need to write your own drivers. I'm sure that Chandra knows that, I think he just didn't read your question correctly. :wink:

Reading from a USB drive using your own driver takes an enormous amount of work. I guess it's 20 times more work than an IDE driver. I recommend that, if this is your first OS/disk driver, you start with an IDE driver.
If a trainstation is where trains stop, what is a workstation ?
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

Re: DETECT BOOTING FROM USB

Post by Holus »

gerryg400 wrote:You can't use Bios services in 32 bit mode. You need to write your own drivers. I'm sure that Chandra knows that, I think he just didn't read your question correctly. :wink:

Reading from a USB drive using your own driver takes an enormous amount of work. I guess it's 20 times more work than an IDE driver. I recommend that, if this is your first OS/disk driver, you start with an IDE driver.
The IDE driver is working. With some help on OSDEV and GOOGLE.
I hoped there was some simple sollution becouse it starts so nice and easy just like a HDD.

Do you know how to find out you booted from USB-flash drive and not from HDD?
Computer says NOOOO
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: DETECT BOOTING FROM USB

Post by gerryg400 »

Holus wrote:The IDE driver is working. With some help on OSDEV and GOOGLE.
I hoped there was some simple sollution becouse it starts so nice and easy just like a HDD.

Do you know how to find out you booted from USB-flash drive and not from HDD?
No I don't think there is a simple solution. But since you have IDE you can now implement a USB stack.

Did you look in DL ? Your original post says BL.
If a trainstation is where trains stop, what is a workstation ?
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

Re: DETECT BOOTING FROM USB

Post by Holus »

gerryg400 wrote:
Holus wrote:The IDE driver is working. With some help on OSDEV and GOOGLE.
I hoped there was some simple sollution becouse it starts so nice and easy just like a HDD.

Do you know how to find out you booted from USB-flash drive and not from HDD?
No I don't think there is a simple solution. But since you have IDE you can now implement a USB stack.

Did you look in DL ? Your original post says BL.
If I boot from USB register DL=0x80 just like booting from HDD.
That is the point. If I finished my drivers for USB in 2023 I still need to know what drivers I have to use to read from the BOOT-device.

(The BL in the first post was a keyboard error I think :^o )

On start up
EBX = 0x06540020

I do not know what it is. I just found some text BOOTIMG. Is it something usefull in this case??
Computer says NOOOO
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: DETECT BOOTING FROM USB

Post by Chandra »

gerryg400 wrote:You can't use Bios services in 32 bit mode. You need to write your own drivers. I'm sure that Chandra knows that, I think he just didn't read your question correctly.
Right. I assumed he wanted to load the kernel from the USB disk and that could be done from within the bootloader(before entering protected mode, of course). So I just gave a hint. Didn't read enough of his post and whole thing turned out to be stupid, lol.

Edit: hey, I didn't quote that 'read from protected mode' part. I must have seriously missed it. Or was the original post edited?
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

Re: DETECT BOOTING FROM USB

Post by Holus »

Chandra wrote:
gerryg400 wrote:You can't use Bios services in 32 bit mode. You need to write your own drivers. I'm sure that Chandra knows that, I think he just didn't read your question correctly.
Right. I assumed he wanted to load the kernel from the USB disk and that could be done from within the bootloader(before entering protected mode, of course). So I just gave a hint. Didn't read enough of his post and whole thing turned out to be stupid, lol.

Edit: hey, I didn't quote that 'read from protected mode' part. I must have seriously missed it. Or was the original post edited?
Even if I used 80 stages of bootloaders I still need to know how to read/write from witch device when I do want to read/write.

But I found the answer. Afther boot I first call INT 0x13 function AH=0x48.
In [DS:SI] I found the drive parameters I need:
- Drive is USB/ATA/ATAPI/SCSI/etc.
- Even parameters about the connection DMA, IRQ and supported functions/options.

Afther that I know what to do afther switching to PMODE.

I hope version v2.0+ and v3.0 is supported well on today's computers.

Thanks anyway. #-o
Last edited by Holus on Fri Oct 07, 2011 12:10 am, edited 1 time in total.
Computer says NOOOO
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: DETECT BOOTING FROM USB

Post by egos »

Holus wrote:If I boot from USB register DL=0x80 just like booting from HDD.
That is the point. If I finished my drivers for USB in 2023 I still need to know what drivers I have to use to read from the BOOT-device.
You should use function 48h. I have no USB drivers yet for my OS but I can get info that boot device has USB interface. Here is example:

Code: Select all

size: 32
part: 1
type: 0
extra: 0
bus type: PCI
interface type: USB
interface: 00 00 00 00 00 00 00 00 ; PCI 0:0:0 (?), channel 0
device: 88 00 00 00 00 00 00 00
On start up
EBX = 0x06540020

I do not know what it is.
I don't know too.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

Re: DETECT BOOTING FROM USB

Post by Holus »

egos wrote:
Holus wrote:If I boot from USB register DL=0x80 just like booting from HDD.
That is the point. If I finished my drivers for USB in 2023 I still need to know what drivers I have to use to read from the BOOT-device.
You should use function 48h. I have no USB drivers yet for my OS but I can get info that boot device has USB interface. Here is example:

Code: Select all

size: 32
part: 1
type: 0
extra: 0
bus type: PCI
interface type: USB
interface: 00 00 00 00 00 00 00 00 ; PCI 0:0:0 (?), channel 0
device: 88 00 00 00 00 00 00 00
On start up
EBX = 0x06540020

I do not know what it is.
I don't know too.
Thanks!!!
I just found the way to pull this off.
I'm a starter in this and I just tricked by int 0x13 with 64bit addressing support. Why te support if you can't use it in 32bit or 64bit.
Computer says NOOOO
User avatar
Holus
Member
Member
Posts: 51
Joined: Thu Jan 27, 2011 5:57 pm

Re: DETECT BOOTING FROM USB

Post by Holus »

Now i see the light I think I start over and reverse engeneer my OS from BIOS.
BIOS knows all the main functions that te computer need before I make the HAL (hardware abstraction layer) I need some main functions to process it. :idea:

http://www.delorie.com/djgpp/doc/rbinter/id/21/7.html
Computer says NOOOO
Casm
Member
Member
Posts: 221
Joined: Sun Oct 17, 2010 2:21 pm
Location: United Kingdom

Re: DETECT BOOTING FROM USB

Post by Casm »

gerryg400 wrote:
Holus wrote:The IDE driver is working. With some help on OSDEV and GOOGLE.
I hoped there was some simple sollution becouse it starts so nice and easy just like a HDD.

Do you know how to find out you booted from USB-flash drive and not from HDD?
No I don't think there is a simple solution. But since you have IDE you can now implement a USB stack.

Did you look in DL ? Your original post says BL.
At some future date, when you have a working operating system, making a USB drive bootable will presumably be something to be performed by the operating system, or at least by the shell. As part of that function it could write a signature into the boot loader for the relevant device; indicating it to be a CD, USB drive, or whatever. With that thought in mind, you could start putting signatures into your boot loaders as of today.
Post Reply