flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Boot CD-Rom code and how to create file ISO ? |
Author |
|
bitRAKE 08 Nov 2010, 15:11
I thought someone here did a bootable "El Torito" spec image from FASM. Yet, my quick search didn't turn up anything. Lots of result on Google. First one seems most helpful...
http://forum.osdev.org/viewtopic.php?f=1&t=20561 |
|||
08 Nov 2010, 15:11 |
|
rugxulo 08 Nov 2010, 15:59
Jorg Schilling's MKISOFS.EXE should work to create one. Alexei Frounze's FAT library has a DOS/DJGPP compile. (Obviously more popular OSes have 'em too, somewhere.)
|
|||
08 Nov 2010, 15:59 |
|
mindcooler 08 Nov 2010, 16:51
_________________ This is a block of text that can be added to posts you make. |
|||
08 Nov 2010, 16:51 |
|
cod3b453 08 Nov 2010, 19:25
You can make the ISO from FASM - note that the sector size is not 512 bytes, so it's better to use a symbolic constant rather than hardcoding if you want to have multiple boot images of the same code.
iso.asm Code: ; Output format binary as 'iso' ; Macros macro @align_null a { repeat ((a - ($ mod a)) mod a) db NULL end repeat } macro iso9660_timestamp yr,mo,da,hr,mi,sc,off { db (yr - 1900) db mo db da db hr db mi db sc db off } macro iso9660_dw v { dw v db (v shr 8) db (v and 0xFF) } macro iso9660_dd v { dd v db ((v shr 24) and 0xFF) db ((v shr 16) and 0xFF) db ((v shr 8) and 0xFF) db (v and 0xFF) } macro iso9660_ddx v { db ((v shr 24) and 0xFF) db ((v shr 16) and 0xFF) db ((v shr 8) and 0xFF) db (v and 0xFF) } ; Constants DISK_SIZE_SECTOR equ 2048 NULL equ 0 IS09660_VDT_BOOTRECORD equ 0x00 IS09660_VDT_PRIMARY equ 0x01 IS09660_VDT_SUPPLEMENTARY equ 0x02 IS09660_VDT_PARTITION equ 0x03 IS09660_VDT_TERMINATOR equ 0xFF ; ISO image rb (16 * DISK_SIZE_SECTOR) db IS09660_VDT_PRIMARY db 'CD001' db 0x01 db 0 db ' ' db ' ' iso9660_dd 0 iso9660_dd (iso9660.boot / DISK_SIZE_SECTOR) dd 0,0,0,0,0,0,0,0 iso9660_dw 1 iso9660_dw 1 iso9660_dw DISK_SIZE_SECTOR iso9660_dd 10 dd (iso9660.plpath / DISK_SIZE_SECTOR) dd 0 iso9660_ddx (iso9660.pmpath / DISK_SIZE_SECTOR) dd 0 db 0x22 db 0x00 iso9660_dd (iso9660.pdr / DISK_SIZE_SECTOR) iso9660_dd DISK_SIZE_SECTOR iso9660_timestamp 2000,1,1,0,0,0,0 db 0x02 db 0x00 db 0x00 iso9660_dw 0 db 0x01 db 0x00 dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 dq 0,0,0,0 dd 0 db 0 dq 0,0,0,0 dd 0 db 0 dq 0,0,0,0 dd 0 db 0 db '2000010100000000',0 db '2000010100000000',0 dd 0,0,0,0 db 0 dd 0,0,0,0 db 0 db 0x01 @align_null DISK_SIZE_SECTOR iso9660.brd: db IS09660_VDT_BOOTRECORD db 'CD001' db 0x01 db 'EL TORITO SPECIFICATION',0 dd 0,0 dd 0,0,0,0,0,0,0,0 dd (iso9660.bootcat / DISK_SIZE_SECTOR) @align_null DISK_SIZE_SECTOR iso9660.svd: db IS09660_VDT_SUPPLEMENTARY db 'CD001' db 0x01 db 0x00 dd 0,0,0,0,0,0,0,0 db 0,'c',0,'o',0,'d',0,'3',0,'b',0,'4',0,'5',0,'3' db 0,'b',0,'o',0,'o',0,'t',0,' ',0,'c',0,'d',0,' ' iso9660_dd 0 iso9660_dd (iso9660.boot / DISK_SIZE_SECTOR) db 0x25,0x2F,0x45,0 dd 0,0,0 dd 0,0,0,0 iso9660_dw 1 iso9660_dw 1 iso9660_dw DISK_SIZE_SECTOR iso9660_dd 10 dd (iso9660.slpath / DISK_SIZE_SECTOR) dd 0 iso9660_ddx (iso9660.smpath / DISK_SIZE_SECTOR) dd 0 db 0x22 db 0x00 iso9660_dd (iso9660.sdr / DISK_SIZE_SECTOR) iso9660_dd DISK_SIZE_SECTOR iso9660_timestamp 2000,1,1,0,0,0,0 db 0x02 db 0x00 db 0x00 iso9660_dw 0 db 0x01 db 0x00 dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 dq 0,0,0,0 dd 0 db 0 dq 0,0,0,0 dd 0 db 0 dq 0,0,0,0 dd 0 db 0 db '2000010100000000',0 db '2000010100000000',0 dd 0,0,0,0 db 0 dd 0,0,0,0 db 0 db 0x01 @align_null DISK_SIZE_SECTOR iso9660.tvd: db IS09660_VDT_TERMINATOR db 'CD001' db 0x01 @align_null DISK_SIZE_SECTOR iso9660.boot: ; The boot sector include 'boot.asm' org (21 * DISK_SIZE_SECTOR) iso9660.bootcat: db 0x01 db 0x00 dw 0 dd 0,0,0,0,0,0 db 0xAA,0x55 db 0x55,0xAA db 0x88 db 0x00 dw 0x0000 db 0x00 db 0 dw 0x0004 dd (iso9660.boot / DISK_SIZE_SECTOR) @align_null DISK_SIZE_SECTOR iso9660.pdr: db 0x22 db 0x00 iso9660_dd (iso9660.pdr / DISK_SIZE_SECTOR) iso9660_dd DISK_SIZE_SECTOR iso9660_timestamp 2000,1,1,0,0,0,0 db 0x02 db 0 db 0 iso9660_dw 0 db 0x01 db 0x00 db 0x22 db 0x00 iso9660_dd (iso9660.pdr / DISK_SIZE_SECTOR) iso9660_dd 2048 iso9660_timestamp 2000,1,1,0,0,0,0 db 0x02 db 0 db 0 iso9660_dw 0 db 0x01 db 0x01 @align_null DISK_SIZE_SECTOR iso9660.plpath: db 0x01 db 0x00 dd (iso9660.pdr / DISK_SIZE_SECTOR) dw 1 dw 0 @align_null DISK_SIZE_SECTOR iso9660.pmpath: db 0x01 db 0x00 iso9660_ddx (iso9660.pdr / DISK_SIZE_SECTOR) iso9660_dw 1 iso9660_dw 0 @align_null DISK_SIZE_SECTOR iso9660.sdr: db 0x22 db 0x00 iso9660_dd (iso9660.sdr / DISK_SIZE_SECTOR) iso9660_dd DISK_SIZE_SECTOR iso9660_timestamp 2000,1,1,0,0,0,0 db 0x02 db 0 db 0 iso9660_dw 0 db 0x01 db 0x00 db 0x22 db 0x00 iso9660_dd (iso9660.sdr / DISK_SIZE_SECTOR) iso9660_dd DISK_SIZE_SECTOR iso9660_timestamp 2000,1,1,0,0,0,0 db 0x02 db 0 db 0 iso9660_dw 0 db 0x01 db 0x01 @align_null DISK_SIZE_SECTOR iso9660.slpath: db 0x01 db 0x00 dd (iso9660.sdr / DISK_SIZE_SECTOR) dw 1 dw 0 @align_null DISK_SIZE_SECTOR iso9660.smpath: db 0x01 db 0x00 iso9660_ddx (iso9660.sdr / DISK_SIZE_SECTOR) iso9660_dw 1 iso9660_dw 0 @align_null DISK_SIZE_SECTOR ; Other disk data can go here boot.asm Code: org 0x7C00 cli jmp 0:@f @@: mov ax,0xB800 mov ds,ax mov word [ds:0],'Hi' xor ah,ah int 0x16 times (0x7C00 + DISK_SIZE_SECTOR - $ - 2) db 0 dw 0xAA55 Hope that helps |
|||
08 Nov 2010, 19:25 |
|
egos 09 Nov 2010, 12:45
I'm still developing mkisofs.inc for fasm and boot code for cdfs (iso9660). You can take current version of mkisofs.inc here, but be careful because it's experimental version. In boot code now I use the method that's realized in GRUB. I'm storing position and size of the loading file in boot code. I can show basic routines from my boot code.
cdrom.asc Code: include "mkimage/mkisofs.inc" rb 16*2048 ; system area primvd bootrec termvd bootcat lpt mpt defdir root { dent kernel,"KERNEL.BIN",FA_DEF dent readme,"README.TXT",FA_DEF } stof boot,"bootcode.bin" ; boot is reserved name for boot code store dword kernel_base/2048 at boot_base+16 store dword kernel_size at boot_base+20 stod root,root ; root is reserved name for root directory stof kernel,"content/kernel.bin" stof kernel,"content/readme.txt" fixvol Code: ; ; ax:cx - starting sector number ; dx - file size in kilobytes ; bx - buffer base in paragraphs (will be recalculated) ; loadfile: mov word [dapack.lba],ax mov word [dapack.lba+2],cx mov ax,SPB shr dx,1 pushf jmp short @f .read1: xor dx,dx .read2: push dx call read pop dx push ax aam 2 ror al,1 add bx,ax pop ax @@: sub dx,ax jnc short .read2 add ax,dx jnz short .read1 popf jnc short @f push bx mov bx,BUFSEG inc ax call read pop bx mov es,bx add bx,40h mov si,BUFSEG shl 4 xor di,di mov cx,512 rep movsw @@: ret tryagain: dec ah jnz short @f call putstr db 13,10,"Disk read error",0 bootfailure: call putstr db 13,10,"Disk boot failure",0 ; ; dword [dapack.lba] - starting sector number (will recalculated) ; ax - number of sectors to read (not abave 127) ; bx - buffer base in paragraphs ; read: mov word [dapack.pointer+2],bx mov ah,MAXTRIES push bx @@: mov si,dapack mov [dapack.length],al mov dl,[drive] push ax mov ah,42h int 13h pop ax jc short tryagain pop bx cbw add word [dapack.lba],ax adc word [dapack.lba+2],0 jc short bootfailure ret
|
|||||||||||
09 Nov 2010, 12:45 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.