Page 1 of 1

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

Posted: Thu Oct 06, 2011 12:04 pm
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 ?

Re: DETECT BOOTING FROM USB

Posted: Thu Oct 06, 2011 1:00 pm
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.

Re: DETECT BOOTING FROM USB

Posted: Thu Oct 06, 2011 1:05 pm
by VolTeK
Holus wrote:DETECT BOOTING FROM USB
Dont do that again.

Re: DETECT BOOTING FROM USB

Posted: Thu Oct 06, 2011 2:43 pm
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.

Re: DETECT BOOTING FROM USB

Posted: Thu Oct 06, 2011 2:54 pm
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.

Re: DETECT BOOTING FROM USB

Posted: Thu Oct 06, 2011 2:59 pm
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?

Re: DETECT BOOTING FROM USB

Posted: Thu Oct 06, 2011 3:03 pm
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.

Re: DETECT BOOTING FROM USB

Posted: Thu Oct 06, 2011 3:22 pm
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??

Re: DETECT BOOTING FROM USB

Posted: Thu Oct 06, 2011 10:46 pm
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?

Re: DETECT BOOTING FROM USB

Posted: Fri Oct 07, 2011 12:07 am
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

Re: DETECT BOOTING FROM USB

Posted: Fri Oct 07, 2011 12:09 am
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.

Re: DETECT BOOTING FROM USB

Posted: Fri Oct 07, 2011 12:15 am
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.

Re: DETECT BOOTING FROM USB

Posted: Fri Oct 07, 2011 12:20 am
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

Re: DETECT BOOTING FROM USB

Posted: Fri Oct 07, 2011 7:56 am
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.