;
%include "ui.inc"
-;
-; Enable disk emulation. The kind of disk we emulate is dependent on the
-; size of the file: 1200K, 1440K or 2880K floppy, otherwise harddisk.
-;
-is_disk_image:
- TRACER CR
- TRACER LF
- TRACER 'D'
- TRACER ':'
-
- mov edx,eax ; File size
- mov di,img_table
- mov cx,img_table_count
- mov eax,[si+file_sector] ; Starting LBA of file
- mov [dsp_lba],eax ; Location of file
- mov byte [dsp_drive], 0 ; 00h floppy, 80h hard disk
-.search_table:
- TRACER 't'
- mov eax,[di+4]
- cmp edx,[di]
- je .type_found
- add di,8
- loop .search_table
-
- ; Hard disk image. Need to examine the partition table
- ; in order to deduce the C/H/S geometry. Sigh.
-.hard_disk_image:
- TRACER 'h'
- cmp edx,512
- jb .bad_image
-
- mov bx,trackbuf
- mov cx,1 ; Load 1 sector
- pm_call getfssec
-
- cmp word [trackbuf+510],0aa55h ; Boot signature
- jne .bad_image ; Image not bootable
-
- mov cx,4 ; 4 partition entries
- mov di,trackbuf+446 ; Start of partition table
-
- xor ax,ax ; Highest sector(al) head(ah)
-
-.part_scan:
- cmp byte [di+4], 0
- jz .part_loop
- lea si,[di+1]
- call .hs_check
- add si,byte 4
- call .hs_check
-.part_loop:
- add di,byte 16
- loop .part_scan
-
- push eax ; H/S
- push edx ; File size
- mov bl,ah
- xor bh,bh
- inc bx ; # of heads in BX
- xor ah,ah ; # of sectors in AX
- cwde ; EAX[31:16] <- 0
- mul bx
- shl eax,9 ; Convert to bytes
- ; Now eax contains the number of bytes per cylinder
- pop ebx ; File size
- xor edx,edx
- div ebx
- and edx,edx
- jz .no_remainder
- inc eax ; Fractional cylinder...
- ; Now (e)ax contains the number of cylinders
-.no_remainder: cmp eax,1024
- jna .ok_cyl
- mov ax,1024 ; Max possible #
-.ok_cyl: dec ax ; Convert to max cylinder no
- pop ebx ; S(bl) H(bh)
- shl ah,6
- or bl,ah
- xchg ax,bx
- shl eax,16
- mov ah,bl
- mov al,4 ; Hard disk boot
- mov byte [dsp_drive], 80h ; Drive 80h = hard disk
-
-.type_found:
- TRACER 'T'
- mov bl,[sp_media]
- and bl,0F0h ; Copy controller info bits
- or al,bl
- mov [dsp_media],al ; Emulation type
- shr eax,8
- mov [dsp_chs],eax ; C/H/S geometry
- mov ax,[sp_devspec] ; Copy device spec
- mov [dsp_devspec],ax
- mov al,[sp_controller] ; Copy controller index
- mov [dsp_controller],al
-
- TRACER 'V'
- call vgaclearmode ; Reset video
-
- mov ax,4C00h ; Enable emulation and boot
- mov si,dspec_packet
- mov dl,[DriveNumber]
- lss sp,[InitStack]
- TRACER 'X'
-
- call int13
-
- ; If this returns, we have problems
-.bad_image:
- mov si,err_disk_image
- call writestr
- jmp enter_command
-
-;
-; Look for the highest seen H/S geometry
-; We compute cylinders separately
-;
-.hs_check:
- mov bl,[si] ; Head #
- cmp bl,ah
- jna .done_track
- mov ah,bl ; New highest head #
-.done_track: mov bl,[si+1]
- and bl,3Fh ; Sector #
- cmp bl,al
- jna .done_sector
- mov al,bl
-.done_sector: ret
-
-
-
; -----------------------------------------------------------------------------
; Common modules
; -----------------------------------------------------------------------------
;
alignz 4
exten_table: db '.cbt' ; COMBOOT (specific)
- db '.img' ; Disk image
db '.bin' ; CD boot sector
db '.com' ; COMBOOT (same as DOS)
db '.c32' ; COM32
exten_table_end:
dd 0, 0 ; Need 8 null bytes here
-
-;
-; Floppy image table
-;
- alignz 4
-img_table_count equ 3
-img_table:
- dd 1200*1024 ; 1200K floppy
- db 1 ; Emulation type
- db 80-1 ; Max cylinder
- db 15 ; Max sector
- db 2-1 ; Max head
-
- dd 1440*1024 ; 1440K floppy
- db 2 ; Emulation type
- db 80-1 ; Max cylinder
- db 18 ; Max sector
- db 2-1 ; Max head
-
- dd 2880*1024 ; 2880K floppy
- db 3 ; Emulation type
- db 80-1 ; Max cylinder
- db 36 ; Max sector
- db 2-1 ; Max head
at offset zero, which may confuse some systems.) This makes it
possible for the operating system, once booted, to use the remainder
of the device for persistent storage by creating a second partition.
-
-
- ++++ BOOTING DOS (OR OTHER SIMILAR OPERATING SYSTEMS) ++++
-
-WARNING: This feature depends on BIOS functionality which is
-apparently broken in a very large number of BIOSes. Therefore, this
-may not work on any particular system. No workaround is possible; if
-you find that it doesn't work please complain to your vendor and
-indicate that "BIOS INT 13h AX=4C00h fails."
-
-To boot DOS, or other real-mode operating systems (protected-mode
-operating systems may or may not work correctly), using ISOLINUX, you
-need to prepare a disk image (usually a floppy image, but a hard disk
-image can be used on *most* systems) with the relevant operating
-system. This file should be included on the CD-ROM in the /isolinux
-directory, and have a .img extension. The ".img" extension does not
-have to be specified on the command line, but has to be explicitly
-specified if used in a "kernel" statement in isolinux.cfg.
-
-For a floppy image, the size of the image should be exactly one of the
-following:
-
- 1,228,800 bytes - For a 1200K floppy image
- 1,474,560 bytes - For a 1440K floppy image
- 2,949,120 bytes - For a 2880K floppy image
-
-Any other size is assumed to be a hard disk image. In order to work
-on as many systems as possible, a hard disk image should have exactly
-one partition, marked active, that covers the entire size of the disk
-image file. Even so, hard disk images are not supported on all
-BIOSes.