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.
Hi @ all,
I'm currently developing a kind of boot loader for x86 compatible
BIOS's which should be bootable from USB MSC, especially from USB
flash device. I have one restriction:
* The boot-sector must not include a (full) primary partition table.
Because I need many bytes as possible for the code in the bootsector.
But some BIOS's are checking for a valid partition table to determine
if the USB device is to be emulated as hard drive
* mov $0x80, %dl
int $0x13
or as floppy
* xor %dl, %dl
int $0x13
One of these BIOS's is:
* American Megatrends, Version 216
ASUS K52 series
In this case I don't know from which drive I need to load the code
(%dl = $0x00 or %dl = $0x80 @ %ah = $0x02). Because after doing tests
on many PC's I found out that there 3 kinds of BIOS characteristics if
it is trying to boot from an USB MSC:
1. BIOS assumes that the device is a hard drive
2. BIOS asks the user which kind of USB device it is (floppy, hdd,
zip)
3. BIOS analyzes the bootsector described above
So my question:
* Is there a way to find out which device is the USB device ($0x80
or $0x00)?
* Do anybody know how the BIOS is detecting if there exist a valid
partition table? I found out that it checks if the (in any kind)
LBA's and CHS's are valid. It is insufficient to set the
active-flags in the partition table.
Thanks for your responses,
DJ-L.
Because I need many bytes as possible for the code in the bootsector.
It there any good reason not to use the 2nd sectors?
Are you sure you want to abuse the master boot record, while you should put your code on the volume boot record?
And once you run out of space on the volume boot sector, there are many way to load more sectors to memory using a few BIOS call.
Some boot manager resides on the MBR,
1) they have a stub on the tiny space in MBR which loads more sectors*
2) or, they create a small partition for its own usage, and use it legally without worry to conflict with other tool.
*) usually the 2~N sectors, since by tradition most fdisk tool create partitions on head alignment, so the 2~N sectors can be abused.
EDIT:
For your original question, if I understand correctly, you want to make a disk which works for both floppy and harddisk emulation.
Here is a plan I did not tested:
you may write a dual mode boot code, having a both BPB and a usual partiton table and tidy space(410 bytes) for your code.
BIOS should pass you drive letter upon boot, so you know it's a floppy or HDD,
if it's a HDD, do a chain-load to VBR, so the VBR looks at the partition regions
if it's a floppy, do a chain-load as if it is a HDD; the BPB is tweak to skip enough "reserved" sectors so the FS starts at exactly same place as if it boots in HDD mode.
Once in the chain-loaded code you have much flexibility and you can load more sectors.
Probably on DL? Historically DL will be 80h or 00h, some extends 81h, etc.
However I don't ever bothered to test my boot sector with floppy drive, so i don't know if that still works on newer machine.
bluemoon wrote:Probably on DL? Historically DL will be 80h or 00h, some extends 81h, etc.
However I don't ever bothered to test my boot sector with floppy drive, so i don't know if that still works on newer machine.
Aaah, great,
it works on all my machines ... I had not seen yet in any boot
code that %dl must be saved.