wok-6.x annotate linux/stuff/linux-header-2.6.30.6.u @ rev 4663

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