wok annotate linux-libre/stuff/linux-libre-header-2.6.37-libre.u @ rev 11253

upx: Fixed ucl and upx to be more compatable with my wok-tank cooking branch and still be compatible with official cookutils.
author Christopher Rogers <slaxemulator@gmail.com>
date Mon Nov 07 10:04:51 2011 +0000 (2011-11-07)
parents
children
rev   line source
gokhlayeh@9257 1 --- linux-2.6.30.6/arch/x86/boot/header.S
gokhlayeh@9257 2 +++ linux-2.6.30.6/arch/x86/boot/header.S
gokhlayeh@9257 3 @@ -6,7 +6,7 @@
gokhlayeh@9257 4 * Based on bootsect.S and setup.S
gokhlayeh@9257 5 * modified by more people than can be counted
gokhlayeh@9257 6 *
gokhlayeh@9257 7 - * Rewritten as a common file by H. Peter Anvin (Apr 2007)
gokhlayeh@9257 8 + * Rewritten Pascal Bellard (Nov 2009)
gokhlayeh@9257 9 *
gokhlayeh@9257 10 * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment
gokhlayeh@9257 11 * addresses must be multiplied by 16 to obtain their respective linear
gokhlayeh@9257 12 @@ -27,6 +27,8 @@
gokhlayeh@9257 13
gokhlayeh@9257 14 BOOTSEG = 0x07C0 /* original address of boot-sector */
gokhlayeh@9257 15 SYSSEG = 0x1000 /* historical load address >> 4 */
gokhlayeh@9257 16 +INITSEG = 0x9000 /* boot address >> 4 */
gokhlayeh@9257 17 +SETUPSEG = 0x9020 /* setup address >> 4 */
gokhlayeh@9257 18
gokhlayeh@9257 19 #ifndef SVGA_MODE
gokhlayeh@9257 20 #define SVGA_MODE ASK_VGA
gokhlayeh@9257 21 @@ -40,53 +42,412 @@
gokhlayeh@9257 22 #define ROOT_RDONLY 1
gokhlayeh@9257 23 #endif
gokhlayeh@9257 24
gokhlayeh@9257 25 +/* some extra features */
gokhlayeh@9257 26 +#define EDIT_CMDLINE on hotkey
gokhlayeh@9257 27 +#define SHOW_REGS show int13 status & parameters
gokhlayeh@9257 28 +
gokhlayeh@9257 29 .code16
gokhlayeh@9257 30 .section ".bstext", "ax"
gokhlayeh@9257 31
gokhlayeh@9257 32 .global bootsect_start
gokhlayeh@9257 33 bootsect_start:
gokhlayeh@9257 34 + cld # assume nothing
gokhlayeh@9257 35 +stacktop = 0x9E00 # in 0x8000 .. 0xA000
gokhlayeh@9257 36 +zeroed = 48+10 # gdt + zeroed registers
gokhlayeh@9257 37 + movw $stacktop-12-zeroed, %di # stacktop is an arbitrary value >=
gokhlayeh@9257 38 + # length of bootsect + length of
gokhlayeh@9257 39 + # setup + room for stack;
gokhlayeh@9257 40 + # 12 is disk parm size.
gokhlayeh@9257 41 + pushw $INITSEG
gokhlayeh@9257 42 + popw %es # %es = INITSEG
gokhlayeh@9257 43 +
gokhlayeh@9257 44 + pushw %es
gokhlayeh@9257 45 + popw %ss # %ss and %es already contain INITSEG
gokhlayeh@9257 46 + movw %di, %sp # put stack at INITSEG:stacktop-...
gokhlayeh@9257 47 +
gokhlayeh@9257 48 +# Many BIOS's default disk parameter tables will not recognize
gokhlayeh@9257 49 +# multi-sector reads beyond the maximum sector number specified
gokhlayeh@9257 50 +# in the default diskette parameter tables - this may mean 7
gokhlayeh@9257 51 +# sectors in some cases.
gokhlayeh@9257 52 +#
gokhlayeh@9257 53 +# Since single sector reads are slow and out of the question,
gokhlayeh@9257 54 +# we must take care of this by creating new parameter tables
gokhlayeh@9257 55 +# (for the first disk) in RAM. We can set the maximum sector
gokhlayeh@9257 56 +# count to 36 - the most we will encounter on an ED 2.88.
gokhlayeh@9257 57 +#
gokhlayeh@9257 58 +# High doesn't hurt. Low does. Let's use the max: 63
gokhlayeh@9257 59 +#
gokhlayeh@9257 60 +# Segments are as follows: %es = %ss = INITSEG,
gokhlayeh@9257 61 +
gokhlayeh@9257 62 + xorw %ax, %ax # %ax = 0
gokhlayeh@9257 63 + movw $zeroed/2, %cx # clear gdt + offset, %ds, limits
gokhlayeh@9257 64 + rep # don't worry about cld
gokhlayeh@9257 65 + stosw # already done above
gokhlayeh@9257 66 + popw %bx # offset = 0
gokhlayeh@9257 67 + popw %ds # %ds = 0
gokhlayeh@9257 68 + popw %gs # %gs = 0
gokhlayeh@9257 69 +
gokhlayeh@9257 70 + movb setup_sects+0x7C00, %al # read bootsector + setup (%ds = 0)
gokhlayeh@9257 71 + incw %ax
gokhlayeh@9257 72 +
gokhlayeh@9257 73 + pushw %es
gokhlayeh@9257 74 + pushw %di # %ds:%bx+0x78 is parameter table address
gokhlayeh@9257 75 + ldsw 0x78(%bx), %si # %ds:%si is source
gokhlayeh@9257 76 + movb $6, %cl # copy 12 bytes
gokhlayeh@9257 77 + rep # don't worry about cld
gokhlayeh@9257 78 + movsw # already done above
gokhlayeh@9257 79 + popl %gs:0x78(%bx) # update parameter table address
gokhlayeh@9257 80 + pushw %es
gokhlayeh@9257 81 + popw %ds # now %ds = %es = %ss = INITSEG
gokhlayeh@9257 82 + movb $63, 0x4-12(%di) # patch sector count, %di = stacktop
gokhlayeh@9257 83 + cli
gokhlayeh@9257 84 +
gokhlayeh@9257 85 + xchg %ax, %di # sector count
gokhlayeh@9257 86 + popw %ax # limits = 0
gokhlayeh@9257 87 + incw %cx # cylinder 0, sector 1
gokhlayeh@9257 88 + call read_first_sectors # read setup
gokhlayeh@9257 89 +
gokhlayeh@9257 90 +offset_version = 0xE
gokhlayeh@9257 91 + movw $0x200,%si
gokhlayeh@9257 92 + addw offset_version(%si),%si # starting protocol 2.00, Kernel 1.3.73
gokhlayeh@9257 93 + call putstr # show which kernel we are loading
gokhlayeh@9257 94 +
gokhlayeh@9257 95 +# The cmdline can be entered and modifed at boot time.
gokhlayeh@9257 96 +# Only characters before the cursor are passed to the kernel.
gokhlayeh@9257 97 + popw %bx # clear %bx
gokhlayeh@9257 98 + orw cmd_line_ptr, %bx
gokhlayeh@9257 99 + jz nocmdline
gokhlayeh@9257 100 + pushw %bx
gokhlayeh@9257 101 + incw %di
gokhlayeh@9257 102 + call read_sectors
gokhlayeh@9257 103 + popw %si
gokhlayeh@9257 104 + call putstr
gokhlayeh@9257 105 +#ifdef EDIT_CMDLINE
gokhlayeh@9257 106 +cmdlp:
gokhlayeh@9257 107 + movb $0x20, %al # clear end of line
gokhlayeh@9257 108 + int $0x10 # with Space
gokhlayeh@9257 109 + movb $8, %al # and BackSpace
gokhlayeh@9257 110 + int $0x10
gokhlayeh@9257 111 + decw %si
gokhlayeh@9257 112 +cmdget:
gokhlayeh@9257 113 + call wait4key
gokhlayeh@9257 114 + cmpb $8, %al # BackSpace ?
gokhlayeh@9257 115 + je cmdbs
gokhlayeh@9257 116 + movb %al, (%si) # store char
gokhlayeh@9257 117 + lodsw # %si += 2
gokhlayeh@9257 118 +cmdbs:
gokhlayeh@9257 119 +#if 1
gokhlayeh@9257 120 + cmpw %si,cmd_line_ptr
gokhlayeh@9257 121 + je cmdget
gokhlayeh@9257 122 +#endif
gokhlayeh@9257 123 + call putc # set %ah and %bx
gokhlayeh@9257 124 + cmpb $10, %al # Enter ?
gokhlayeh@9257 125 + jne cmdlp
gokhlayeh@9257 126 + movb %bh,-2(%si) # set end of string and remove CR
gokhlayeh@9257 127 +endcmdline:
gokhlayeh@9257 128 +#endif
gokhlayeh@9257 129 +nocmdline:
gokhlayeh@9257 130
gokhlayeh@9257 131 - # Normalize the start address
gokhlayeh@9257 132 - ljmp $BOOTSEG, $start2
gokhlayeh@9257 133 -
gokhlayeh@9257 134 -start2:
gokhlayeh@9257 135 - movw %cs, %ax
gokhlayeh@9257 136 - movw %ax, %ds
gokhlayeh@9257 137 - movw %ax, %es
gokhlayeh@9257 138 - movw %ax, %ss
gokhlayeh@9257 139 - xorw %sp, %sp
gokhlayeh@9257 140 - sti
gokhlayeh@9257 141 - cld
gokhlayeh@9257 142 -
gokhlayeh@9257 143 - movw $bugger_off_msg, %si
gokhlayeh@9257 144 +# This routine loads the system at address SYSSEG, making sure
gokhlayeh@9257 145 +# no 64kB boundaries are crossed. We try to load it as fast as
gokhlayeh@9257 146 +# possible, loading whole tracks whenever we can.
gokhlayeh@9257 147 +
gokhlayeh@9257 148 +ramdisk_image = 0x0218
gokhlayeh@9257 149 +ramdisk_size = 0x021C
gokhlayeh@9257 150 + movw %sp, %si # for bootsect_gdt
gokhlayeh@9257 151 + decw 16(%si) # bootsect_src = 64Kb
gokhlayeh@9257 152 + decw 24(%si) # bootsect_dst = 64Kb
gokhlayeh@9257 153 + movw $syssize, %di
gokhlayeh@9257 154 +type_of_loader = 0x210
gokhlayeh@9257 155 +loadflags = 0x211
gokhlayeh@9257 156 +heap_end_ptr = 0x224
gokhlayeh@9257 157 +ksyssize = 500
gokhlayeh@9257 158 + orw $0x80FF, type_of_loader-ksyssize(%di) # loader type = 0xFF
gokhlayeh@9257 159 + movw $stacktop-0x200, heap_end_ptr-ksyssize(%di)
gokhlayeh@9257 160 + movb $0x10, %al # destination = 0x100000
gokhlayeh@9257 161 + movb $5, %cl
gokhlayeh@9257 162 +initrdlp:
gokhlayeh@9257 163 + decw %ax
gokhlayeh@9257 164 + movb $0x93,%ah
gokhlayeh@9257 165 + movw %ax, 28(%si) # bootsect_dst_base+2
gokhlayeh@9257 166 + movb $(SYSSEG/4096), %al # source = SYSSEG
gokhlayeh@9257 167 + movw %ax, 20(%si) # bootsect_src_base+2
gokhlayeh@9257 168 + cbw
gokhlayeh@9257 169 + cwde
gokhlayeh@9257 170 + shlw %cl, %ax
gokhlayeh@9257 171 + decw %ax
gokhlayeh@9257 172 + addl (%di),%eax
gokhlayeh@9257 173 + shrl %cl, %eax
gokhlayeh@9257 174 +syslp:
gokhlayeh@9257 175 + pushw $SYSSEG
gokhlayeh@9257 176 + popw %es
gokhlayeh@9257 177 + movw $128,%di # 64Kb
gokhlayeh@9257 178 + subw %di, %ax # max 32M > int 15 limit
gokhlayeh@9257 179 + pushf
gokhlayeh@9257 180 + jnc not_last
gokhlayeh@9257 181 + addw %ax, %di
gokhlayeh@9257 182 +not_last:
gokhlayeh@9257 183 + xorw %bx, %bx # clear %bx
gokhlayeh@9257 184 + pushw %ax
gokhlayeh@9257 185 +#if defined(SHOW_REGS)
gokhlayeh@9257 186 + pushw %si
gokhlayeh@9257 187 + call read_sectors
gokhlayeh@9257 188 + popw %si
gokhlayeh@9257 189 +#else
gokhlayeh@9257 190 + call read_sectors
gokhlayeh@9257 191 +#endif
gokhlayeh@9257 192 + movw $0x8000, %cx # full 64K
gokhlayeh@9257 193 + movb $0x87, %ah
gokhlayeh@9257 194 + incb 28(%si) # bootsect_dst_base+2
gokhlayeh@9257 195 + int $0x15 # max 16M
gokhlayeh@9257 196 + popw %ax
gokhlayeh@9257 197 + popf
gokhlayeh@9257 198 + ja syslp
gokhlayeh@9257 199 + movw ramdisk_image+2,%ax
gokhlayeh@9257 200 + movw $ramdisk_size,%di
gokhlayeh@9257 201 + movb $9, %cl
gokhlayeh@9257 202 + cmpb %al,28(%si)
gokhlayeh@9257 203 + jb initrdlp
gokhlayeh@9257 204 +
gokhlayeh@9257 205 +# This procedure turns off the floppy drive motor, so
gokhlayeh@9257 206 +# that we enter the kernel in a known state, and
gokhlayeh@9257 207 +# don't have to worry about it later.
gokhlayeh@9257 208 +
gokhlayeh@9257 209 +#if 1
gokhlayeh@9257 210 +kill_motor:
gokhlayeh@9257 211 + xchgw %ax, %bx # reset FDC
gokhlayeh@9257 212 + int $0x13
gokhlayeh@9257 213 +#else
gokhlayeh@9257 214 +kill_motor:
gokhlayeh@9257 215 + movw $0x3f2, %dx
gokhlayeh@9257 216 + xchgw %ax, %bx
gokhlayeh@9257 217 + outb %al, %dx
gokhlayeh@9257 218 +#endif
gokhlayeh@9257 219
gokhlayeh@9257 220 -msg_loop:
gokhlayeh@9257 221 - lodsb
gokhlayeh@9257 222 - andb %al, %al
gokhlayeh@9257 223 - jz bs_die
gokhlayeh@9257 224 - movb $0xe, %ah
gokhlayeh@9257 225 - movw $7, %bx
gokhlayeh@9257 226 +# After that (everything loaded), we jump to the setup-routine
gokhlayeh@9257 227 +# loaded directly after the bootblock:
gokhlayeh@9257 228 +# Segments are as follows: %ds = %ss = INITSEG
gokhlayeh@9257 229 +
gokhlayeh@9257 230 + ljmp $SETUPSEG, $0
gokhlayeh@9257 231 +
gokhlayeh@9257 232 +# read_sectors reads %di sectors into %es:0 buffer.
gokhlayeh@9257 233 +# %es:0 is updated to the next memory location.
gokhlayeh@9257 234 +# First, sectors are read sector by sector until
gokhlayeh@9257 235 +# sector per track count is known. Then they are
gokhlayeh@9257 236 +# read track by track.
gokhlayeh@9257 237 +# Assume no error on first track.
gokhlayeh@9257 238 +
gokhlayeh@9257 239 +#define FLOPPY_CYLINDERS 80 /* 80 cylinders minimum */
gokhlayeh@9257 240 +#define FLOPPY_HEADS 2 /* 2 heads minimum */
gokhlayeh@9257 241 +#define FLOPPY_SECTORS 18 /* 18 sectors minimum */
gokhlayeh@9257 242 +
gokhlayeh@9257 243 +#ifdef SHOW_REGS
gokhlayeh@9257 244 +print_loop:
gokhlayeh@9257 245 + movb $0x6 + 'A' - 1, %al
gokhlayeh@9257 246 + subb %cl, %al
gokhlayeh@9257 247 + movw $regs, %si # caller %si is saved
gokhlayeh@9257 248 + call putcs # putc(%al) + putstr(%si)
gokhlayeh@9257 249 +# it will print out all of the registers.
gokhlayeh@9257 250 + popw %bp # load word into %si
gokhlayeh@9257 251 + jmp print_all # print %bp (status)
gokhlayeh@9257 252 +#endif
gokhlayeh@9257 253 +check_limits:
gokhlayeh@9257 254 +#ifndef SHOW_REGS
gokhlayeh@9257 255 + popw %dx
gokhlayeh@9257 256 +#endif
gokhlayeh@9257 257 + cmpb $FLOPPY_SECTORS+1, %cl # 18 sectors minimum
gokhlayeh@9257 258 + jb check_head
gokhlayeh@9257 259 + cmpb %al, %cl # max sector known ?
gokhlayeh@9257 260 + ja next_head # no -> store it
gokhlayeh@9257 261 +check_head:
gokhlayeh@9257 262 + cmpb $FLOPPY_HEADS, %dh # 2 heads minimum
gokhlayeh@9257 263 + jb check_cylinder
gokhlayeh@9257 264 + cmpb %ah, %dh # max head known ?
gokhlayeh@9257 265 + ja next_cylinder # no -> store it
gokhlayeh@9257 266 +check_cylinder:
gokhlayeh@9257 267 + pushaw
gokhlayeh@9257 268 +#ifdef SHOW_REGS
gokhlayeh@9257 269 + cmpw $0x600,%bp # disk changed ?
gokhlayeh@9257 270 + je reset_floppy
gokhlayeh@9257 271 + pushw %es # print %es (named EX)
gokhlayeh@9257 272 + pushw %dx # print %dx
gokhlayeh@9257 273 + pushw %cx # print %cx
gokhlayeh@9257 274 + pushw %bx # print %bx
gokhlayeh@9257 275 + xchgw %ax, %si
gokhlayeh@9257 276 + movb $2,%ah
gokhlayeh@9257 277 + pushw %ax # print %ax
gokhlayeh@9257 278 + movb $6,%cl
gokhlayeh@9257 279 +print_all:
gokhlayeh@9257 280 + movb $4, %ch # 4 hex digits
gokhlayeh@9257 281 +print_digit:
gokhlayeh@9257 282 + rolw $4, %bp # rotate to use low 4 bits
gokhlayeh@9257 283 + movb $0x0f, %al
gokhlayeh@9257 284 + andw %bp, %ax # %al = mask for nybble
gokhlayeh@9257 285 + addb $0x90, %al # convert %al to ascii hex
gokhlayeh@9257 286 + daa # in only four instructions!
gokhlayeh@9257 287 + adcb $0x40, %al
gokhlayeh@9257 288 + daa
gokhlayeh@9257 289 + call putc # set %ah and %bx
gokhlayeh@9257 290 + decb %ch
gokhlayeh@9257 291 + jnz print_digit
gokhlayeh@9257 292 + movb $0x20, %al # SPACE
gokhlayeh@9257 293 int $0x10
gokhlayeh@9257 294 - jmp msg_loop
gokhlayeh@9257 295 -
gokhlayeh@9257 296 -bs_die:
gokhlayeh@9257 297 - # Allow the user to press a key, then reboot
gokhlayeh@9257 298 - xorw %ax, %ax
gokhlayeh@9257 299 + loop print_loop
gokhlayeh@9257 300 + call wait
gokhlayeh@9257 301 + cbw # %ah = 0
gokhlayeh@9257 302 +reset_floppy:
gokhlayeh@9257 303 +#else
gokhlayeh@9257 304 + cbw # %ah = 0
gokhlayeh@9257 305 +#endif
gokhlayeh@9257 306 + int $0x13 # reset controler
gokhlayeh@9257 307 + popaw
gokhlayeh@9257 308 +read_sectorslp:
gokhlayeh@9257 309 + pushw %dx # some bios break dx...
gokhlayeh@9257 310 + pushw %ax # limits
gokhlayeh@9257 311 + subb %cl, %al # sectors remaining in track
gokhlayeh@9257 312 + ja tolastsect
gokhlayeh@9257 313 + movb $1, %al # 1 sector mini
gokhlayeh@9257 314 +tolastsect:
gokhlayeh@9257 315 + cbw
gokhlayeh@9257 316 + cmpw %di, %ax
gokhlayeh@9257 317 + jb more1trk
gokhlayeh@9257 318 + movw %di, %ax # sectors to read
gokhlayeh@9257 319 +more1trk:
gokhlayeh@9257 320 + pushw %ax # save context
gokhlayeh@9257 321 + movb $2, %ah # cmd: read chs
gokhlayeh@9257 322 + int $0x13
gokhlayeh@9257 323 +#ifdef SHOW_REGS
gokhlayeh@9257 324 + xchgw %ax, %bp # status
gokhlayeh@9257 325 +#endif
gokhlayeh@9257 326 +# ifdef SHOW_REGS
gokhlayeh@9257 327 + popw %si # save %ax
gokhlayeh@9257 328 + popw %ax # limits
gokhlayeh@9257 329 + popw %dx
gokhlayeh@9257 330 +# else
gokhlayeh@9257 331 + popw %dx # save %ax
gokhlayeh@9257 332 + popw %ax # limits
gokhlayeh@9257 333 +# endif
gokhlayeh@9257 334 + jc check_limits
gokhlayeh@9257 335 + xchgw %ax, %bp
gokhlayeh@9257 336 +# ifdef SHOW_REGS
gokhlayeh@9257 337 +update_regs:
gokhlayeh@9257 338 + incw %cx # next sector
gokhlayeh@9257 339 + movw %cx, %fs
gokhlayeh@9257 340 + addb $2,%bh # next location
gokhlayeh@9257 341 + decw %di # update sector counter
gokhlayeh@9257 342 + jz putcdot
gokhlayeh@9257 343 + decw %si
gokhlayeh@9257 344 + jnz update_regs
gokhlayeh@9257 345 +# else
gokhlayeh@9257 346 + addw %dx,%cx # next sector
gokhlayeh@9257 347 + addb %dl,%bh
gokhlayeh@9257 348 + addb %dl,%bh # next location
gokhlayeh@9257 349 + subw %dx,%di # update sector counter
gokhlayeh@9257 350 + popw %dx
gokhlayeh@9257 351 + jz putcdot
gokhlayeh@9257 352 +# endif
gokhlayeh@9257 353 +read_sectors:
gokhlayeh@9257 354 + movw %fs, %cx
gokhlayeh@9257 355 + xchgw %ax, %bp
gokhlayeh@9257 356 + cmpb %al,%cl # reach sector limit ?
gokhlayeh@9257 357 + jne bdendlp
gokhlayeh@9257 358 +next_head:
gokhlayeh@9257 359 + movb %cl,%al
gokhlayeh@9257 360 + incb %dh # next head
gokhlayeh@9257 361 + movb $1,%cl # first sector
gokhlayeh@9257 362 + cmpb %ah, %dh # reach head limit ?
gokhlayeh@9257 363 + jne bdendlp
gokhlayeh@9257 364 +next_cylinder:
gokhlayeh@9257 365 + movb %dh,%ah
gokhlayeh@9257 366 +# NOTE : support 256 cylinders max
gokhlayeh@9257 367 + incb %ch # next cylinder
gokhlayeh@9257 368 +read_first_sectors:
gokhlayeh@9257 369 + movb $0,%dh # first head
gokhlayeh@9257 370 +cylinder_count = 496
gokhlayeh@9257 371 + cmpb $FLOPPY_CYLINDERS,%ch # reach cylinder limit ?
gokhlayeh@9257 372 + jb bdendlp
gokhlayeh@9257 373 + cmpb cylinder_count, %ch
gokhlayeh@9257 374 + jb bdendlp
gokhlayeh@9257 375 +next_floppy:
gokhlayeh@9257 376 + movb $0,%ch # first cylinder
gokhlayeh@9257 377 + pushaw
gokhlayeh@9257 378 + movw $swap_floppy,%si
gokhlayeh@9257 379 + incb 12(%si)
gokhlayeh@9257 380 + pushw %bx
gokhlayeh@9257 381 + call putstr
gokhlayeh@9257 382 + popw %bx
gokhlayeh@9257 383 +waitfloppy:
gokhlayeh@9257 384 + call wait
gokhlayeh@9257 385 + jne waitfloppydone
gokhlayeh@9257 386 + pushw %dx # some bios break dx...
gokhlayeh@9257 387 + cbw
gokhlayeh@9257 388 + int $0x13 # reset FDC
gokhlayeh@9257 389 + movw $0x201,%ax
gokhlayeh@9257 390 +# cwd
gokhlayeh@9257 391 +# movw $1,%cx
gokhlayeh@9257 392 + int $0x13 # read first sector
gokhlayeh@9257 393 + popw %dx
gokhlayeh@9257 394 + rclb $1,%ah # floppy changed 06=>0D no error 00
gokhlayeh@9257 395 + cmpb -2(%si), %ah # 0D then 00
gokhlayeh@9257 396 + jne waitfloppy # no => try again
gokhlayeh@9257 397 + incw %si
gokhlayeh@9257 398 + orb %ah,%ah # was 00 ?
gokhlayeh@9257 399 + jne waitfloppy
gokhlayeh@9257 400 +waitfloppydone:
gokhlayeh@9257 401 + popaw
gokhlayeh@9257 402 +bdendlp:
gokhlayeh@9257 403 + jmp read_sectorslp
gokhlayeh@9257 404 +
gokhlayeh@9257 405 +putcdot:
gokhlayeh@9257 406 + pushw %ss
gokhlayeh@9257 407 + popw %es # restore es
gokhlayeh@9257 408 + movb $0x2e+3, %al # loading... message 2e = .
gokhlayeh@9257 409 +putclf:
gokhlayeh@9257 410 + subb $3, %al
gokhlayeh@9257 411 +putc:
gokhlayeh@9257 412 + movb $0xe, %ah
gokhlayeh@9257 413 + movw $7, %bx # one dot each 64k
gokhlayeh@9257 414 + int $0x10
gokhlayeh@9257 415 + cmp $0xd, %al # CR ?
gokhlayeh@9257 416 + je putclf
gokhlayeh@9257 417 + ret
gokhlayeh@9257 418 +
gokhlayeh@9257 419 +putstr:
gokhlayeh@9257 420 + movb $0xd, %al # CR
gokhlayeh@9257 421 +putcs:
gokhlayeh@9257 422 + call putc
gokhlayeh@9257 423 + lodsb
gokhlayeh@9257 424 + orb %al,%al # end of string is \0
gokhlayeh@9257 425 + jnz putcs
gokhlayeh@9257 426 + ret
gokhlayeh@9257 427 +
gokhlayeh@9257 428 +clock = 0x46C
gokhlayeh@9257 429 +wait:
gokhlayeh@9257 430 +wait4key:
gokhlayeh@9257 431 + movw $clock, %di
gokhlayeh@9257 432 +#define DELAY 5
gokhlayeh@9257 433 + movb $(DELAY*182)/10,%cl
gokhlayeh@9257 434 + addb %gs:(%di),%cl
gokhlayeh@9257 435 +waitkbd:
gokhlayeh@9257 436 + movw $0x10D, %ax # test keyboard, timeout => CR
gokhlayeh@9257 437 + cmpb %gs:(%di),%cl
gokhlayeh@9257 438 + je waitdone
gokhlayeh@9257 439 int $0x16
gokhlayeh@9257 440 - int $0x19
gokhlayeh@9257 441 + jz waitkbd
gokhlayeh@9257 442 + cbw
gokhlayeh@9257 443 + int $0x16 # eat char
gokhlayeh@9257 444 + movw %di, %gs # disable timeout
gokhlayeh@9257 445 + incw %di # clear Z
gokhlayeh@9257 446 +waitdone:
gokhlayeh@9257 447 + ret
gokhlayeh@9257 448
gokhlayeh@9257 449 - # int 0x19 should never return. In case it does anyway,
gokhlayeh@9257 450 - # invoke the BIOS reset code...
gokhlayeh@9257 451 - ljmp $0xf000,$0xfff0
gokhlayeh@9257 452 -
gokhlayeh@9257 453 - .section ".bsdata", "a"
gokhlayeh@9257 454 -bugger_off_msg:
gokhlayeh@9257 455 - .ascii "Direct booting from floppy is no longer supported.\r\n"
gokhlayeh@9257 456 - .ascii "Please use a boot loader program instead.\r\n"
gokhlayeh@9257 457 - .ascii "\n"
gokhlayeh@9257 458 - .ascii "Remove disk and press any key to reboot . . .\r\n"
gokhlayeh@9257 459 - .byte 0
gokhlayeh@9257 460 +#ifdef SHOW_REGS
gokhlayeh@9257 461 +regs: .asciz "X:"
gokhlayeh@9257 462 +#endif
gokhlayeh@9257 463
gokhlayeh@9257 464 +swap_floppy: .ascii "Insert disk 1"
gokhlayeh@9257 465 + .ascii "."
gokhlayeh@9257 466 + .byte 7,13,0
gokhlayeh@9257 467
gokhlayeh@9257 468 # Kernel attributes; used by setup. This is part 1 of the
gokhlayeh@9257 469 # header, from the old boot sector.