wok annotate linux/stuff/linux-header-2.6.34.u @ rev 6555

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