; trackbuf ends at 5000h
absolute 5000h ; Here we keep our BSS stuff
-StackBuf equ $ ; Start the stack here (grow down - 4K)
VKernelBuf: resb vk_size ; "Current" vkernel
alignb 4
AppendBuf resb max_cmd_len+1 ; append=
bootsec equ $
_start:
jmp 0:_start1 ; Canonicalize address
-_start1:
+_start1:
+ pushad ; Paranoia... in case of return to PXE
+ pushfd ; ... save as much state as possible
+ push ds
+ push es
+ push fs
+ push gs
+
mov bp,sp
les bx,[bp+4] ; Initial !PXE structure pointer
je near pc_say
cmp ax,'ip' ; IPappend
je pc_ipappend
+ cmp ax,'lo' ; LOcalboot
+ je pc_localboot
cmp al,'f' ; F-key
jne parse_config
jmp pc_fkey
.vk: mov [VKernelBuf+vk_ipappend],bl
jmp short parse_config_2
+pc_localboot: cmp word [VKernelCtr],byte 0 ; "localboot" command
+ je parse_config_2 ; ("label" section only)
+ mov [VKernelBuf+vk_rname], byte 0 ; Null kernel name
+ jmp short parse_config_2
+
pc_kernel: cmp word [VKernelCtr],byte 0 ; "kernel" command
- je near parse_config ; ("label" section only)
+ je parse_config_2 ; ("label" section only)
mov di,trackbuf
push di
call getline
mov di,KernelName ; Search on disk
call searchdir
pop bx
- jnz kernel_good
+ jnz near kernel_good
mov eax,[bx] ; Try a different extension
mov si,[KernelExtPtr]
mov [si],eax
mov al,[VKernelBuf+vk_ipappend]
mov [IPAppend],al
xor bx,bx ; Try only one version
- jmp get_kernel
+
+ ; Is this a "localboot" pseudo-kernel?
+ cmp byte [VKernelBuf+vk_rname], 0
+ jne near get_kernel ; No, it's real, go get it
+
+ jmp local_boot
;
; kernel_corrupt: Called if the kernel file does not seem healthy
;
.badness: jmp short .badness
;
+; Boot to the local disk by returning the appropriate PXE magic
+;
+local_boot:
+ lss sp,[cs:Stack] ; Restore stack pointer
+ pop ds ; Restore DS
+ mov si,localboot_msg
+ call writestr
+ ; Restore the environment we were called with
+ pop gs
+ pop fs
+ pop es
+ pop ds
+ popfd
+ popad
+ xor ax,ax ; Unload PXE and local boot
+ retf ; Return to PXE
+
+;
; 32-bit bcopy routine for real mode
;
; We enter protected mode, set up a flat 32-bit environment, run rep movsd
mov ds,ax
mov es,ax
cli
- mov sp,StackBuf-2*3 ; Reset stack
- mov ss,ax ; Just in case...
+ lss sp,[cs:Stack] ; Reset the stack
sti
call cwritestr ; Expects SI -> error msg
al_ok: jmp enter_command ; Return to command prompt
kaboom:
lss sp,[cs:Stack]
pop ds
+ push ds
sti
.patch: mov si,bailmsg
call writestr ; Returns with AL = 0
notfound_msg db 'not found', CR, LF, 0
myipaddr_msg db 'My IP address seems to be ',0
tftpprefix_msg db 'TFTP prefix: ', 0
+localboot_msg db 'Booting from local disk...', CR, LF, 0
cmdline_msg db 'Command line: ', CR, LF, 0
ready_msg db ' ready.', CR, LF, 0
trying_msg db 'Trying to load: ', 0
align 2, db 0
keywd_table db 'ap' ; append
- db 'ip' ; ipappend
db 'de' ; default
db 'ti' ; timeout
db 'fo' ; font
db 'f8' ; F8
db 'f9' ; F9
db 'f0' ; F10
+ ; PXELINUX specific options...
+ db 'ip' ; ipappend
+ db 'lo' ; localboot
dw 0
;
; Extensions to search for (in *forward* order).