diff options
Diffstat (limited to 'core/pxelinux.asm')
-rw-r--r-- | core/pxelinux.asm | 174 |
1 files changed, 117 insertions, 57 deletions
diff --git a/core/pxelinux.asm b/core/pxelinux.asm index d990553f..aa11702d 100644 --- a/core/pxelinux.asm +++ b/core/pxelinux.asm @@ -89,6 +89,7 @@ LocalBootType resw 1 ; Local boot return code DHCPMagic resb 1 ; PXELINUX magic flags section .text16 + global StackBuf StackBuf equ STACK_TOP-44 ; Base of stack if we use our own StackHome equ StackBuf @@ -154,54 +155,6 @@ _start1: lss esp,[BaseStack] sti ; Stack set up and ready -; -; Move the hardwired DHCP options (if present) to a safe place... -; -bdhcp_copy: - mov cx,[bdhcp_len] - mov ax,trackbufsize/2 - jcxz .none - cmp cx,ax - jbe .oksize - mov cx,ax - mov [bdhcp_len],ax -.oksize: - mov eax,[bdhcp_offset] - add eax,_start - mov si,ax - and si,000Fh - shr eax,4 - push ds - mov ds,ax - mov di,trackbuf - add cx,3 - shr cx,2 - rep movsd - pop ds -.none: - -adhcp_copy: - mov cx,[adhcp_len] - mov ax,trackbufsize/2 - jcxz .none - cmp cx,ax - jbe .oksize - mov cx,ax - mov [adhcp_len],ax -.oksize: - mov eax,[adhcp_offset] - add eax,_start - mov si,ax - and si,000Fh - shr eax,4 - push ds - mov ds,ax - mov di,trackbuf+trackbufsize/2 - add cx,3 - shr cx,2 - rep movsd - pop ds -.none: ; ; Initialize screen (if we're using one) @@ -223,7 +176,6 @@ adhcp_copy: mov eax,ROOT_FS_OPS xor ebp,ebp pm_call pm_fs_init - pm_call load_env32 section .rodata alignz 4 @@ -265,15 +217,124 @@ ROOT_FS_OPS: %endmacro ; +; Open configuration file. ldlinux.c32 needs ConfigName to be set - so we need +; to call open_config() before loading it. +; +; Note: We don't need to check return value of open_config() function. It will +; call kaboom() on failure. +; + extern open_config + pm_call open_config + +; ; Jump to 32-bit ELF space ; pm_call load_env32 + jmp kaboom ; load_env32() shouldn't return. If it does, then kaboom! + +print_hello: +enter_command: +auto_boot: + pm_call hello + +; +; Save hardwired DHCP options. This is done before the C environment +; is initialized, so it has to be done in assembly. +; +%define MAX_DHCP_OPTS 4096 + bits 32 + + section .savedata + global bdhcp_data, adhcp_data +bdhcp_data: resb MAX_DHCP_OPTS +adhcp_data: resb MAX_DHCP_OPTS + + section .textnr +pm_save_data: + mov eax,MAX_DHCP_OPTS + movzx ecx,word [bdhcp_len] + cmp ecx,eax + jna .oksize + mov ecx,eax + mov [bdhcp_len],ax +.oksize: + mov esi,[bdhcp_offset] + add esi,_start + mov edi,bdhcp_data + add ecx,3 + shr ecx,2 + rep movsd + +adhcp_copy: + movzx ecx,word [adhcp_len] + cmp ecx,eax + jna .oksize + mov ecx,eax + mov [adhcp_len],ax +.oksize: + mov esi,[adhcp_offset] + add esi,_start + mov edi,adhcp_data + add ecx,3 + shr ecx,2 + rep movsd + ret + + bits 16 + +; As core/ui.inc used to be included here in core/pxelinux.asm, and it's no +; longer used, its global variables that were previously used by +; core/pxelinux.asm are now declared here. + section .bss16 + alignb 4 +Kernel_EAX resd 1 +Kernel_SI resw 1 + + section .bss16 + global CmdOptPtr, KbdMap + alignb 4 +ThisKbdTo resd 1 ; Temporary holder for KbdTimeout +ThisTotalTo resd 1 ; Temporary holder for TotalTimeout +KernelExtPtr resw 1 ; During search, final null pointer +CmdOptPtrj resw 1 ; Pointer to first option on cmd line +KbdFlags resb 1 ; Check for keyboard escapes +FuncFlag resb 1 ; Escape sequences received from keyboard +KernelType resb 1 ; Kernel type, from vkernel, if known +KbdMap resb 256 ; Keyboard map + global KernelName +KernelName resb FILENAME_MAX ; Mangled name for kernel + section .config + global PXERetry +PXERetry dw 0 ; Extra PXE retries + section .data16 + global SerialNotice +SerialNotice db 1 ; Only print this once + extern IPOption + global IPAppends, numIPAppends + alignz 2 +IPAppends dw IPOption +numIPAppends equ ($-IPAppends)/2 + + section .text16 +; +; COMBOOT-loading code +; +%include "comboot.inc" +%include "com32.inc" + +; +; Boot sector loading code +; ; -; Now we have the config file open. Parse the config file and -; run the user interface. +; Abort loading code ; -%include "ui.inc" + +; +; Hardware cleanup common code +; + +%include "localboot.inc" ; ; kaboom: write a message and bail out. Wait for quite a while, @@ -317,7 +378,6 @@ kaboom: mov word [BIOS_magic],0 ; Cold reboot jmp 0F000h:0FFF0h ; Reset vector address - ; ; pxenv ; @@ -335,9 +395,9 @@ pxenv: pushad ; We may be removing ourselves from memory - cmp bx,0073h ; PXENV_RESTART_TFTP + cmp bx,PXENV_RESTART_TFTP jz .disable_timer - cmp bx,00E5h ; gPXE PXENV_FILE_EXEC + cmp bx,PXENV_FILE_EXEC jnz .store_stack .disable_timer: @@ -372,9 +432,9 @@ pxenv: popad ; If the call failed, it could return. - cmp bx,0073h + cmp bx,PXENV_RESTART_TFTP jz .enable_timer - cmp bx,00E5h + cmp bx,PXENV_FILE_EXEC jnz .pop_flags .enable_timer: |