wok-6.x annotate syslinux/stuff/iso2exe/bootiso.S @ rev 13729

Add gputils
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Dec 22 16:41:33 2012 +0100 (2012-12-22)
parents 9d2380009b81
children b5ea41033c21
rev   line source
pascal@13691 1 .text
pascal@13691 2 .code16
pascal@13691 3 .org 0
pascal@13691 4
pascal@13691 5 CODESZ = 0x8000 // 16 sectors = 32Kb
pascal@13691 6 #define EXEADRS(x) x+0xE0
pascal@13691 7 #define EXESTR(x) x-0x20
pascal@13691 8
pascal@13691 9 .globl _start
pascal@13691 10 _start:
pascal@13691 11 decw %bp // Magic number: MZ
pascal@13691 12 popw %dx
pascal@13691 13 jmp start // Bytes on last page of file
pascal@13691 14 .word (CODESZ+511)/512 // Pages in file
pascal@13691 15 .word 0 // Relocations
pascal@13691 16 .word (end_header-_start)/16 // Size of header in paragraphs
pascal@13691 17 .word 4064-(CODESZ/16) // Minimum extra paragraphs needed
pascal@13691 18 .word 4064-(CODESZ/16) // Maximum extra paragraphs needed
pascal@13691 19 .word 0xFFF0 // Initial (relative) SS value
pascal@13691 20 .word 0xFFFE // Initial SP value
pascal@13691 21 .word 0 // Checksum
pascal@13729 22 .word EXEADRS(exestart) // Initial IP value
pascal@13691 23 .word 0xFFF0 // Initial (relative) CS value
pascal@13691 24 .word 0x001C // File address of relocation table
pascal@13691 25 .word 0 // Overlay number
pascal@13691 26 initramfssize:
pascal@13691 27 .word 0
pascal@13691 28 id:
pascal@13691 29 .word 0
pascal@13691 30 end_header:
pascal@13691 31
pascal@13691 32 chksum:
pascal@13697 33 .word 0
pascal@13691 34 comstart:
pascal@13691 35 .word 0
pascal@13691 36
pascal@13691 37 /////////////////////// Master Boot Record code //////////////////////////////
pascal@13691 38
pascal@13691 39 start:
pascal@13691 40 incw %bp
pascal@13691 41 pushw %dx // restore SP
pascal@13713 42 pushw $0
pascal@13713 43 popw %ds
pascal@13713 44 movw $0x7C00, %bx
pascal@13713 45 pushfw
pascal@13713 46 pushw %ds
pascal@13713 47 pushw %bx
pascal@13691 48 pushaw
pascal@13691 49 movw %sp, %bp
pascal@13691 50 pushw %es
pascal@13691 51 call setreg
pascal@13691 52 rep
pascal@13691 53 movsw
pascal@13691 54 ljmp $0, $0x0600+start2
pascal@13691 55
pascal@13699 56 readsector2:
pascal@13699 57 incw %cx
pascal@13699 58 readsector1:
pascal@13699 59 movw %cx, (%bx)
pascal@13699 60 incw %cx
pascal@13699 61 movw $0x201, %ax
pascal@13699 62 int $0x13
pascal@13691 63 setreg:
pascal@13691 64 cld
pascal@13713 65 pushw %ds
pascal@13713 66 popw %es
pascal@13699 67 movw %bx, %si
pascal@13691 68 movw $0x0600, %di
pascal@13691 69 movw $0x0100, %cx
pascal@13691 70 return:
pascal@13691 71 ret
pascal@13691 72 start2:
pascal@13691 73 movw $0x80, %dx
pascal@13691 74 dxloop:
pascal@13699 75 call readsector1
pascal@13691 76 repe
pascal@13691 77 cmpsw
pascal@13691 78 je dxfound
pascal@13691 79 next:
pascal@13699 80 xorw %cx, %cx
pascal@13699 81 xchgw %ax, %dx
pascal@13699 82 addb $0x7D, %al // try every hard disk
pascal@13699 83 andb $0x83, %al // and floppy disk
pascal@13699 84 cmpb $0x80, %al
pascal@13699 85 xchgw %ax, %dx
pascal@13691 86 jnz dxloop
pascal@13691 87 fail:
pascal@13713 88 movw $0x0600+noloader, %si
pascal@13713 89 call putslp
pascal@13713 90 stop:
pascal@13713 91 hlt
pascal@13713 92 jmp stop
pascal@13691 93 dxfound:
pascal@13691 94 movw %dx, 10(%bp)
pascal@13699 95 call readsector2
pascal@13699 96 lodsw
pascal@13713 97 shrw $1, %ax
pascal@13699 98 jz fail // read fail or not isohydrid
pascal@13691 99 popw %es
pascal@13691 100 popa
pascal@13713 101 iret
pascal@13691 102
pascal@13713 103
pascal@13691 104 ////////////////////////////// DOS EXE code ///////////////////////////////////
pascal@13691 105
pascal@13713 106 help:
pascal@13729 107 .ascii "SliTaz GNU/L" // SliTaz GNU/Linux boot loader
pascal@13729 108 .byte EXESTR(iloader)
pascal@13713 109 no386:
pascal@13713 110 .ascii "No 386" // No 386+
pascal@13713 111 .byte EXESTR(plus)
pascal@13713 112 ERRvcpi:
pascal@13713 113 .ascii "No EMM386/VCPI 4" // No EMM386/VCPI 4.0+
pascal@13713 114 .byte EXESTR(dot0)
pascal@13713 115 chkerr:
pascal@13713 116 .ascii "Broken ISO image fil" // Broken ISO image file.
pascal@13713 117 .byte EXESTR(eeol)
pascal@13713 118 vm86modemsg:
pascal@13713 119 .ascii "vm86" // vm86 mode.
pascal@13713 120 .byte EXESTR(mode)
pascal@13713 121 rmPaging:
pascal@13713 122 .ascii "Invalid: paging + " // Invalid: paging + real mode.
pascal@13713 123 realmodemsg:
pascal@13713 124 .ascii "real" // real mode.
pascal@13729 125 // --------------- Must be in 00A0 011F range ------------------------
pascal@13713 126 mode:
pascal@13713 127 .ascii " mod"
pascal@13713 128 eeol:
pascal@13713 129 .ascii "e"
pascal@13713 130 .byte EXESTR(eol)
pascal@13713 131 noloader:
pascal@13729 132 .ascii "No isol" // No isolinux boot loader
pascal@13729 133 iloader:
pascal@13729 134 .ascii "inux boot loader"
pascal@13697 135 eol:
pascal@13713 136 .ascii "."
pascal@13713 137 eol2:
pascal@13713 138 .asciz "\r\n"
pascal@13691 139 noDOS3:
pascal@13713 140 .ascii "No DOS 3" // No DOS 3.0+
pascal@13713 141 dot0:
pascal@13713 142 .ascii ".0"
pascal@13713 143 plus:
pascal@13713 144 .ascii "+"
pascal@13713 145 .byte EXESTR(eol2)
pascal@13729 146 // -------------------------------------------------------------------
pascal@13697 147
pascal@13729 148 exestart:
pascal@13699 149 cld
pascal@13697 150 movw $0x100, %si
pascal@13713 151 movw -127(%si), %ax
pascal@13729 152 cwd // clear dx
pascal@13713 153 pushw %dx // dos exit
pascal@13713 154 cmpw $0x2F20, %ax
pascal@13729 155 movw $0x1000+EXESTR(help), %ax
pascal@13691 156 je abort
pascal@13729 157 pushfw // save flags
pascal@13729 158 // bits 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
pascal@13729 159 // flags 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF
pascal@13729 160 // movb $0x10, %ah
pascal@13729 161 pushw %ax
pascal@13729 162 popfw // < 286 : flags[12..15] are forced 1
pascal@13729 163 pushfw // = 286 : flags[12..15] are forced 0
pascal@13729 164 popw %cx // > 286 : only flags[15] is forced 0
pascal@13729 165 popfw // restore flags
pascal@13729 166 addb %ah, %ch // test F0 and 00 cases
pascal@13729 167 cmpb %ah, %ch
pascal@13729 168 movb $EXESTR(no386), %al
pascal@13729 169 jbe abort // C=8086/80186, Z=80286
pascal@13729 170 #if 1
pascal@13697 171 movw (%si), %cx
pascal@13729 172 jcxz is386
pascal@13729 173 #endif
pascal@13697 174 movw $0x7FE0/2, %cx
pascal@13697 175 chklp:
pascal@13697 176 lodsw
pascal@13697 177 addw %ax, %dx
pascal@13697 178 loop chklp
pascal@13713 179 movb $EXESTR(chkerr), %al
pascal@13729 180 je is386 // dx == 0 ?
pascal@13691 181 abort:
pascal@13691 182 puts:
pascal@13713 183 movb $1, %ah
pascal@13713 184 xchgw %ax, %si
pascal@13713 185 putslp:
pascal@13713 186 lodsb
pascal@13713 187 orb %al, %al
pascal@13713 188 jz moveret
pascal@13713 189 js puts
pascal@13713 190 movw $7, %bx
pascal@13713 191 movb $0xE, %ah
pascal@13713 192 int $0x10
pascal@13713 193 jmp putslp
pascal@13691 194
pascal@13691 195 is386:
pascal@13697 196 movl %cr0, %eax
pascal@13691 197 andb $1, %al
pascal@13691 198 jne tstvcpi
pascal@13691 199 shll $1, %eax
pascal@13713 200 movb $EXESTR(rmPaging), %al
pascal@13691 201 jc abort
pascal@13713 202 movb $EXESTR(realmodemsg), %al
pascal@13691 203 realmode:
pascal@13691 204 call puts
pascal@13699 205 movb $0x30, %ah
pascal@13699 206 int $0x21
pascal@13699 207 cmpb $3, %al
pascal@13713 208 movb $EXESTR(noDOS3), %al
pascal@13713 209 jb abort
pascal@13691 210 movw EXEADRS(comstart), %ax // .com address
pascal@13691 211 movw $moveend-move, %cx
pascal@13691 212 movw $EXEADRS(move), %si
pascal@13691 213 movw $0xC000, %di
pascal@13691 214 jmp move2
pascal@13691 215 move:
pascal@13691 216 movb $0x80, %ch
pascal@13691 217 xchgw %ax, %si
pascal@13691 218 movw $0x0100, %di
pascal@13691 219 move2:
pascal@13691 220 pushw %di
pascal@13691 221 rep
pascal@13691 222 movsb
pascal@13713 223 moveret:
pascal@13691 224 ret
pascal@13691 225 moveend:
pascal@13713 226
pascal@13713 227 VersionVCPI:
pascal@13713 228 cmpb $0x40, %dl // >= 4.0 ?
pascal@13713 229 jb NoVCPI
pascal@13713 230 movb $EXESTR(vm86modemsg), %al
pascal@13713 231 jmp realmode
pascal@13713 232 tstvcpi:
pascal@13713 233 pushw %ds
pascal@13713 234 movw %cx, %ds // %cx = 0
pascal@13713 235 movw 0x67*4+2, %ds
pascal@13713 236 movw $10, %si
pascal@13713 237 lodsw
pascal@13713 238 xorw $0x4D45, %ax // EM(MX) or EM(MQ)
pascal@13713 239 xchgw %ax, %dx
pascal@13713 240 lodsw // si += 2
pascal@13713 241 lodsw
pascal@13713 242 xorw $0x5858, %ax // XX
pascal@13713 243 orw %ax, %dx
pascal@13713 244 lodsw
pascal@13713 245 popw %ds
pascal@13713 246 xorw $0x3058, %ax // X0
pascal@13713 247 orw %ax, %dx
pascal@13713 248 movw $EXEADRS(CmdVCPI), %si
pascal@13713 249 ChkVCPI:
pascal@13713 250 NoVCPI:
pascal@13713 251 xchgw %ax, %dx
pascal@13713 252 movb $EXESTR(ERRvcpi), %al
pascal@13713 253 jne abort
pascal@13713 254 lodsb
pascal@13713 255 shlw $8, %ax
pascal@13713 256 je VersionVCPI
pascal@13713 257 int $0x67
pascal@13713 258 testb %ah, %ah
pascal@13713 259 jmp ChkVCPI
pascal@13713 260 CmdVCPI:
pascal@13713 261 .byte 0x40 // status
pascal@13713 262 .byte 0xDE // vcpi present ?
pascal@13713 263 .byte 0x46 // version
pascal@13713 264 .byte 0
pascal@13713 265
pascal@13691 266 .org 440
pascal@13691 267 //////////////////////////// partition table //////////////////////////////////
pascal@13691 268