123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
-
-
- #define PNP_SIGNATURE ( '$' + ( 'P' << 8 ) + ( 'n' << 16 ) + ( 'P' << 24 ) )
- #define PMM_SIGNATURE ( '$' + ( 'P' << 8 ) + ( 'M' << 16 ) + ( 'M' << 24 ) )
- #define STACK_MAGIC ( 'L' + ( 'R' << 8 ) + ( 'E' << 16 ) + ( 'T' << 24 ) )
- #define PNP_GET_BBS_VERSION 0x60
-
- .text
- .code16
- .arch i386
- .section ".prefix", "ax",
-
- .org 0x00
- romheader:
- .word 0xAA55
- romheader_size: .byte _load_size_sect
- jmp init
- checksum:
- .byte 0
- .org 0x16
- .word undiheader
- .org 0x18
- .word pciheader
- .org 0x1a
- .word pnpheader
- .size romheader, . - romheader
-
- .section ".zinfo.fixup", "a"
- .ascii "SUBB"
- .long romheader_size
- .long 512
- .long 0
- .previous
-
- pciheader:
- .ascii "PCIR"
- .word pci_vendor_id
- .word pci_device_id
- .word 0x0000
- .word pciheader_len
- .byte 0x00
- .byte 0x02
- .byte 0x00
- .byte 0x00
- pciheader_size: .word _load_size_sect
- .word 0x0001
- .byte 0x00
- .byte 0x80
- .word 0x0000
- .equ pciheader_len, . - pciheader
- .size pciheader, . - pciheader
-
- .section ".zinfo.fixup", "a"
- .ascii "SUBW"
- .long pciheader_size
- .long 512
- .long 0
- .previous
-
- pnpheader:
- .ascii "$PnP"
- .byte 0x01
- .byte ( pnpheader_len / 16 )
- .word 0x0000
- .byte 0x00
- .byte 0x00
- .long 0x00000000
- .word mfgstr
- .word prodstr
- .byte 0x02
- .byte 0x00
- .byte 0x00
- .byte 0x54
- .word 0x0000
- .word 0x0000
- .word bev_entry
- .word 0x0000
- .word 0x0000
- .equ pnpheader_len, . - pnpheader
- .size pnpheader, . - pnpheader
-
- mfgstr:
- .asciz "http://etherboot.org"
- .size mfgstr, . - mfgstr
- prodstr:
- .asciz "gPXE"
- .size prodstr, . - prodstr
-
- undiheader:
- .ascii "UNDI"
- .byte undiheader_len
- .byte 0
- .byte 0
- .byte 0,1,2
- .word undiloader
- .word _data16_size
- .word _data16_size
- .word _text16_size
- .equ undiheader_len, . - undiheader
- .size undiheader, . - undiheader
-
-
- init:
-
- pushaw
- pushw %ds
- pushw %es
- cld
- pushw %cs
- popw %ds
-
- movw $init_message, %si
- call print_message
-
- testw $0x0f, %di
- jnz hook_int19
- cmpl $PNP_SIGNATURE, %es:0(%di)
- jne hook_int19
-
- movw $init_message_pnp, %si
- call print_message
- xchgw %bx, %bx
-
- pushw %es:0x1b(%di)
- pushw %ds
- pushw $bbs_version
- pushw $PNP_GET_BBS_VERSION
- lcall *%es:0xd(%di)
- addw $8, %sp
- testw %ax, %ax
- jne hook_int19
- movw $init_message_bbs, %si
- call print_message
- jmp hook_bbs
-
- hook_int19:
- movw $init_message_int19, %si
- call print_message
- xorw %ax, %ax
- movw %ax, %es
- pushw %cs
- pushw $int19_entry
- popl %es:( 0x19 * 4 )
- hook_bbs:
-
- movw $( 0xe000 - 1 ), %di
- pmm_scan:
- incw %di
- jz no_pmm
- movw %di, %es
- cmpl $PMM_SIGNATURE, %es:0
- jne pmm_scan
- xorw %bx, %bx
- xorw %si, %si
- movzbw %es:5, %cx
- 1: es lodsb
- addb %al, %bl
- loop 1b
- jnz pmm_scan
-
- movw $init_message_pmm, %si
- call print_message
-
- pushw $0x0006
- pushl $0xffffffff
- pushl $( 0x00200000 / 16 )
- pushw $0x0000
- lcall *%es:7
- addw $12, %sp
- testw %dx, %dx
- jnz gotpmm
- movw $init_message_pmm_failed, %si
- call print_message
- jmp no_pmm
- gotpmm:
- pushal
- movw %ax, %es
- pushw %dx
- pushw %ax
- popl %edi
- movl %edi, image_source
- xorl %esi, %esi
- movzbl romheader_size, %ecx
- shll $9, %ecx
- addr32 rep movsb
- movl %edi, decompress_to
-
- xorw %bx, %bx
- xorw %si, %si
- movw $_prefix_size_sect, %cx
- movb %cl, romheader_size
- shlw $9, %cx
- 1: lodsb
- addb %al, %bl
- loop 1b
- subb %bl, checksum
- popal
- no_pmm:
-
- movw $'\n', %ax
- call print_character
-
- popw %es
- popw %ds
- popaw
-
- movw $0x20, %ax
- lret
- .size init, . - init
-
- init_message:
- .asciz "gPXE (http://etherboot.org) -"
- .size init_message, . - init_message
- init_message_pnp:
- .asciz " PnP"
- .size init_message_pnp, . - init_message_pnp
- init_message_bbs:
- .asciz " BBS"
- .size init_message_bbs, . - init_message_bbs
- init_message_pmm:
- .asciz " PMM"
- .size init_message_pmm, . - init_message_pmm
- init_message_pmm_failed:
- .asciz "(failed)"
- .size init_message_pmm_failed, . - init_message_pmm_failed
- init_message_int19:
- .asciz " INT19"
- .size init_message_int19, . - init_message_int19
-
-
- image_source:
- .long 0
- .size image_source, . - image_source
-
-
- decompress_to:
- .long HIGHMEM_LOADPOINT
- .size decompress_to, . - decompress_to
-
-
- bbs_version:
- .word 0
-
-
- bev_entry:
- pushw %cs
- call exec
- lret
- .size bev_entry, . - bev_entry
-
-
- int19_entry:
- pushw %cs
- call exec
-
- int $0x18
- .size int19_entry, . - int19_entry
-
-
- exec:
- pushw %cs
- popw %ds
-
-
- movw $exec_message, %si
- call print_message
-
-
- pushl $STACK_MAGIC
- movw %ss, %dx
- movw %sp, %bp
-
-
- xorw %ax, %ax
- movw %ax, %ss
- movw $0x7c00, %sp
-
-
- movl image_source, %esi
- movl decompress_to, %edi
- call alloc_basemem
- call install_prealloc
-
-
- movw %bx, %ss
- movw $_estack16, %sp
-
-
- pushw %ax
- pushw $1f
- lret
- .section ".text16", "awx",
- 1:
- pushl $main
- pushw %cs
- call prot_call
-
-
-
- movw %dx, %ss
- movw %bp, %sp
-
-
- popl %eax
- cmpl $STACK_MAGIC, %eax
- jne 1f
-
- lret
- 1:
- int $0x18
- .previous
-
- exec_message:
- .asciz "gPXE starting boot\n"
- .size exec_message, . - exec_message
-
-
- undiloader:
-
- pushl %esi
- pushl %edi
- pushw %es
- pushw %bx
-
- movw %sp, %bx
- movw %ss:12(%bx), %di
- movw %ss:14(%bx), %es
-
- pushw %di
- movw %es:12(%di), %bx
- movw %es:14(%di), %ax
- movl %cs:image_source, %esi
- movl %cs:decompress_to, %edi
- call install_prealloc
- popw %di
-
- pushl $pxe_loader_call
- pushw %cs
- pushw $1f
- pushw %ax
- pushw $prot_call
- lret
- 1: popw %bx
- popw %bx
-
- popw %bx
- popw %es
- popl %edi
- popl %esi
- lret
- .size undiloader, . - undiloader
|