ghaerr / elks

Embeddable Linux Kernel Subset - Linux for 8086
Other
960 stars 103 forks source link

Booting from FAT12 disk images #296

Closed ghaerr closed 4 years ago

ghaerr commented 4 years ago

I'm not sure where to comment on MSDOS FAT12 issues, so I opened this.

@tkchia: Here's a link to the source code for the MSDOS 3.3 boot sector (http://read.pudn.com/downloads3/sourcecode/5346/SOURCE/SRC/BOOT/MSBOOT.ASM__.htm). Following is an extracted section.

I'm suggesting we use almost this entire block, from $START up to but not including CURHD. We can use the OEM label portion for our boot code, instead of jumping immediately to START, as this field isn't used in filesystems. However, our max heads and max sector count should be put in the HDLIM and SECLIM fields. Doing this will make our MSDOS boot compatible with the mtools utilities, which are well tested and used in my last PR for building correct MSDOS images.

The correct values for the other BPB fields are parameters in the package management PR, which are passed command line arguments for mformat. I will submit a PR for these values once this MINIX boot is updated.

I can start on modifying mfs to create a new, or update an existing, boot block with the ELKS head and sector limits once there is agreement on this.

Public $START $START: JMP START ;---------------------------------------------------------- ; ; THE FOLLOWING DATA CONFIGURES THE BOOT PROGRAM ; FOR ANY TYPE OF DRIVE OR HARDFILE ; DB "MSDOS" ; This section can contain ELKS boot code since DB "3.3" ; we only have 6 bytes free. ByteSec DW cbSec ; SIZE OF A PHYSICAL SECTOR set to 512 DB 8 ; SECTORS PER ALLOCATION UNIT set to 1 cSecRes DW 1 ; NUMBER OF RESERVED SECTORS cFat DB 2 ; NUMBER OF FATS DirNum DW 512 ; NUMBER OF DIREC ENTRIES I think this will be 244, will check DW 417305-1 ; NUMBER OF SECTORS - NUMBER OF HIDDEN SECTORS MEDIA DB 0F8H ; MEDIA BYTE cSecFat DW 8 ; NUMBER OF FAT SECTORS change to 9 SECLIM DW 17 ; SECTORS PER TRACK ELKS max_sect here HDLIM DW 4 ; NUMBER OF SURFACES ELKS max_heads here cSecHid DW 1 ; NUMBER OF HIDDEN SECTORS dw 0 ; high order word of Hiden Sectors dd 0 ; 32 bit version of NUMBER OF SECTORS ; (when 16 bit version is zero)

db  6 dup(?)        ; reserved for later expansion *** volume serial number and some other stuff is written here by the mtools mformat command, so we should keep this for ELKS.

*** ELKS doesn't need fields after this

CURHD DB ? ; Unitialized

; this is an image of the disk parameter table. Zero entries are copied ; from the rom table at boot. ; SEC9 DB 0 ; DISK_SPECIFY_1 DB 0 ; DISK_SPECIFY_2 DB 0 ; DISK_MOTOR_WAIT DB 0 ; DISK_SECTOR_SIZ DB 12h ; DISK_EOT DB 0 ; DISK_RW_GAP DB 0 ; DISK_DTL DB 0 ; DISK_FORMT_GAP DB 0 ; DISK_FILL DB 1 ; DISK_HEAD_STTL DB 0 ; DISK_MOTOR_STRT

ghaerr commented 4 years ago

@mfld-fr: This can probably be closed too. Other issues relating to perfecting FAT usability, like 8.3 filenames and others, can be brought up elsewhere. I am keeping a list of such issues.

mfld-fr commented 4 years ago

@ghaerr : Okay, so closing this one, as FAT boot is working fine on flat disks.