123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631 |
- /*
- * header.S
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- *
- * Based on bootsect.S and setup.S
- * modified by more people than can be counted
- *
- * Rewritten as a common file by H. Peter Anvin (Apr 2007)
- *
- * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment
- * addresses must be multiplied by 16 to obtain their respective linear
- * addresses. To avoid confusion, linear addresses are written using leading
- * hex while segment addresses are written as segment:offset.
- *
- */
- BOOTSEG = 0x07C0 /* original address of boot-sector */
- SYSSEG = 0x1000 /* historical load address >> 4 */
- .code16
- .section ".bstext", "ax"
- .global bootsect_start
- bootsect_start:
-
- .byte 0x4d
- .byte 0x5a
-
- ljmp $BOOTSEG, $start2
- start2:
- movw %cs, %ax
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %ss
- xorw %sp, %sp
- sti
- cld
- movw $bugger_off_msg, %si
- msg_loop:
- lodsb
- andb %al, %al
- jz bs_die
- movb $0xe, %ah
- movw $7, %bx
- int $0x10
- jmp msg_loop
- bs_die:
-
- xorw %ax, %ax
- int $0x16
- int $0x19
-
-
- ljmp $0xf000,$0xfff0
- .org 0x3c
-
-
-
- .long pe_header
- .section ".bsdata", "a"
- bugger_off_msg:
- .ascii "Use a boot loader.\r\n"
- .ascii "\n"
- .ascii "Remove disk and press any key to reboot...\r\n"
- .byte 0
- pe_header:
- .ascii "PE"
- .word 0
- coff_header:
- .word 0x14c
- .word 0x8664
- .word 4
- .long 0
- .long 0
- .long 1
- .word section_table - optional_header
- .word 0x306
-
-
-
-
- .word 0x206
-
-
-
- optional_header:
- .word 0x10b
- .word 0x20b
- .byte 0x02
- .byte 0x14
-
- .long 0
- .long 0
- .long 0
-
- .long 0x0000
- .long 0x0200
- .long 0
- extra_header_fields:
- .long 0
- .quad 0
- .long 0x20
- .long 0x20
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .word 0
- .long 0
-
-
-
- .long 0
- .long 0x200
- .long 0
- .word 0xa
- .word 0
- .long 0
- .long 0
- .long 0
- .long 0
- .quad 0
- .quad 0
- .quad 0
- .quad 0
- .long 0
- .long 0x6
- .quad 0
- .quad 0
- .quad 0
- .quad 0
- .quad 0
- .quad 0
-
- section_table:
-
-
-
- .ascii ".setup"
- .byte 0
- .byte 0
- .long 0
- .long 0x0
- .long 0
-
- .long 0x0
- .long 0
- .long 0
- .word 0
- .word 0
- .long 0x60500020
-
-
-
-
-
- .ascii ".reloc"
- .byte 0
- .byte 0
- .long 0
- .long 0
- .long 0
- .long 0
- .long 0
- .long 0
- .word 0
- .word 0
- .long 0x42100040
-
-
-
- .ascii ".text"
- .byte 0
- .byte 0
- .byte 0
- .long 0
- .long 0x0
- .long 0
-
- .long 0x0
- .long 0
- .long 0
- .word 0
- .word 0
- .long 0x60500020
-
-
-
- .ascii ".bss"
- .byte 0
- .byte 0
- .byte 0
- .byte 0
- .long 0
- .long 0x0
- .long 0
-
- .long 0x0
- .long 0
- .long 0
- .word 0
- .word 0
- .long 0xc8000080
-
-
- .section ".header", "a"
- .globl sentinel
- sentinel: .byte 0xff, 0xff /* Used to detect broken loaders */
- .globl hdr
- hdr:
- setup_sects: .byte 0 /* Filled in by build.c */
- root_flags: .word ROOT_RDONLY
- syssize: .long 0 /* Filled in by build.c */
- ram_size: .word 0 /* Obsolete */
- vid_mode: .word SVGA_MODE
- root_dev: .word 0 /* Filled in by build.c */
- boot_flag: .word 0xAA55
-
- .globl _start
- _start:
-
-
-
- .byte 0xeb
- .byte start_of_setup-1f
- 1:
-
- .ascii "HdrS"
- .word 0x020d
-
- .globl realmode_swtch
- realmode_swtch: .word 0, 0
- start_sys_seg: .word SYSSEG
-
- .word kernel_version-512
-
-
-
- type_of_loader: .byte 0
-
-
-
- loadflags:
- .byte LOADED_HIGH
- setup_move_size: .word 0x8000
-
-
-
-
-
- code32_start:
-
- .long 0x100000
- ramdisk_image: .long 0
-
-
-
- ramdisk_size: .long 0
- bootsect_kludge:
- .long 0
- heap_end_ptr: .word _end+STACK_SIZE-512
-
-
-
-
- ext_loader_ver:
- .byte 0
- ext_loader_type:
- .byte 0
- cmd_line_ptr: .long 0
-
-
-
-
-
-
-
-
-
-
-
-
-
- initrd_addr_max: .long 0x7fffffff
-
-
-
-
-
-
- kernel_alignment: .long CONFIG_PHYSICAL_ALIGN
-
-
- relocatable_kernel: .byte 1
- relocatable_kernel: .byte 0
- min_alignment: .byte MIN_KERNEL_ALIGN_LG2
- xloadflags:
- /* kernel/boot_param/ramdisk could be loaded above 4g */
- .word XLF0 | XLF1 | XLF23 | XLF4
- cmdline_size: .long COMMAND_LINE_SIZE-1
-
-
- hardware_subarch: .long 0
-
- hardware_subarch_data: .quad 0
- payload_offset: .long ZO_input_data
- payload_length: .long ZO_z_input_len
- setup_data: .quad 0
-
-
- pref_address: .quad LOAD_PHYSICAL_ADDR
- ZO_z_input_len)
- /*
- * The extract_offset has to be bigger than ZO head section. Otherwise when
- * the head code is running to move ZO to the end of the buffer, it will
- * overwrite the head code itself.
- */
- init_size: .long INIT_SIZE
- handover_offset: .long 0
- .section ".entrytext", "ax"
- start_of_setup:
- movw %ds, %ax
- movw %ax, %es
- cld
- movw %ss, %dx
- cmpw %ax, %dx
- movw %sp, %dx
- je 2f
-
- movw $_end, %dx
- testb $CAN_USE_HEAP, loadflags
- jz 1f
- movw heap_end_ptr, %dx
- 1: addw $STACK_SIZE, %dx
- jnc 2f
- xorw %dx, %dx
- 2:
- andw $~3, %dx
- jnz 3f
- movw $0xfffc, %dx
- 3: movw %ax, %ss
- movzwl %dx, %esp
- sti
- pushw %ds
- pushw $6f
- lretw
- 6:
- cmpl $0x5a5aaa55, setup_sig
- jne setup_bad
- movw $__bss_start, %di
- movw $_end+3, %cx
- xorl %eax, %eax
- subw %di, %cx
- shrw $2, %cx
- rep; stosl
- calll main
- setup_bad:
- movl $setup_corrupt, %eax
- calll puts
-
- .globl die
- .type die, @function
- die:
- hlt
- jmp die
- .size die, .-die
- .section ".initdata", "a"
- setup_corrupt:
- .byte 7
- .string "No setup signature found...\n"
|