FILENAME_MAX equ 32 ; Including final null; should be a power of 2
retry_count equ 6 ; How patient are we with the disk?
HIGHMEM_MAX equ 038000000h ; Highest address for an initrd
+HIGHMEM_SLOP equ 128*1024 ; Avoid this much memory near the top
DEFAULT_BAUD equ 9600 ; Default baud rate for serial port
BAUD_DIVISOR equ 115200 ; Serial port parameter
MAX_SOCKETS equ 64 ; Max number of open sockets
jmp 0:_start1 ; Canonicalize address
_start1:
mov bp,sp
- les bx,[ss:bp+4] ; Initial !PXE structure pointer
+ les bx,[bp+4] ; Initial !PXE structure pointer
- push cs
- pop ds
+ mov ax,cs
+ mov ds,ax
sti ; Stack already set up by PXE
cld ; Copy upwards
push ds
mov [Stack],sp
- push ss
- pop word [Stack+2]
+ mov ax,ss
+ mov [Stack+2],ax
;
; Now we need to find the !PXE structure. It's *supposed* to be pointed
call writestr
mov eax,[bootp.yip] ; "Your" IP address
call writehex8
- mov al,' '
- call writechr
- mov eax,[bootp.sip] ; Server IP address(?)
- call writehex8
- mov al,' '
- call writechr
- mov eax,[bootp.gip] ; Gateway IP address(?)
- call writehex8
call crlf
; Print the boot file
dec di
loop .tryagain
- jmp near no_config_file
+ jmp no_config_file
;
; Now we have the config file open
je near pc_implicit
cmp ax,'se' ; SErial
je near pc_serial
+ cmp ax,'sa' ; SAy
+ je near pc_say
cmp al,'f' ; F-key
jne parse_config
jmp pc_fkey
call getline
sub di,AppendBuf
pc_app1: mov [AppendLen],di
- jmp short parse_config
+ jmp short parse_config_2
pc_append_vk: mov di,VKernelBuf+vk_append ; "append" command (vkernel)
call getline
sub di,VKernelBuf+vk_append
call loadkeys
parse_config_3: jmp parse_config
+pc_say: mov di,trackbuf ; "say" command
+ push di
+ call getline
+ xor al,al
+ stosb ; Null-terminate
+ pop si
+ call writestr
+ call crlf
+ jmp short parse_config_3
+
;
; pc_getfile: For command line options that take file argument, this
; routine decodes the file argument and runs it through searchdir
call get_msg_file
jmp short fk_wrcmd
fk_nofile:
- mov si,crlf_msg
- call cwritestr
+ call crlf
fk_wrcmd:
mov si,boot_prompt
call cwritestr
rep movsd
jmp short load_kernel
command_done:
- mov si,crlf_msg
- call cwritestr
+ call crlf
cmp di,command_line ; Did we just hit return?
je auto_boot
xor al,al ; Store a final null
shl eax,10 ; Convert from kilobytes
add eax,(1 << 20) ; First megabyte
got_highmem:
+ sub eax,HIGHMEM_SLOP
mov [HighMemSize],eax
call writehex8
;
add si,byte 4
call parseint
jc skip_this_opt ; Not an integer
+ sub ebx,HIGHMEM_SLOP
mov [cs:HighMemSize],ebx
jmp short skip_this_opt
cmdline_end:
;
; Unload PXE stack
;
- mov al,'U'
- call writechr
call unload_pxe
cli
xor ax,ax
mov ss,ax
mov sp,7C00h ; Set up a more normal stack
- mov al,'L'
- call writechr
;
; Copy real_mode stuff up to 90000h
jne rd_load_loop ; Apparently not
rd_load_done:
pop si ; Clean up the stack
- mov si,crlf_msg
- call cwritestr
+ call crlf
mov si,loading_msg ; Write new "Loading " for
call cwritestr ; the benefit of the kernel
pop es ; Restore original ES
push bp
mov bp,sp
- call dot
-
call allocate_socket
jz near .error
- call dot
-
mov ax,PKT_RETRY ; Retry counter
.sendreq: push ax ; [bp-2] - Retry counter
sub di,packet_buf ; Get packet size
mov [pxe_udp_write_pkt.buffersize],di
- mov al,'S'
- call writechr
-
mov di,pxe_udp_write_pkt
mov bx,PXENV_UDP_WRITE
call far [PXENVEntry]
jmp .failure
.got_packet:
- mov al,'R'
- call writechr
-
mov si,[bp-6] ; TFTP pointer
mov bx,[bp-8] ; TID
; Now we need to parse the OACK packet to get the transfer
; size.
- mov al,'A'
- call writechr
-
.parse_oack: mov cx,[pxe_udp_read_pkt.buffersize]
mov si,packet_buf+2
sub cx,byte 2
xor edi,edi ; ZF <- 1
; Success, done!
- mov al,'*'
- call writechr
pop si ; Junk
pop si ; We want the packet ptr in SI
call writestr
jmp kaboom
-.bailnow: mov al,'B'
- call writechr
- add sp,byte 8 ; Immediate error - no retry
+.bailnow: add sp,byte 8 ; Immediate error - no retry
jmp short .error
.failure: mov al,'F'
mov cx,[BufSafe]
getc_oksize: sub [FClust],cx ; Reduce remaining clusters
mov si,[FNextClust]
+ push es ; ES may be != DS, save old ES
+ mov bx,ds
+ mov es,bx
mov bx,getcbuf
push bx
- push es ; ES may be != DS, save old ES
- push ds ; Trackbuf is in DS, not ES
- pop es
call getfssec ; Load a trackbuf full of data
mov [FNextClust],si ; Store new next pointer
- pop es ; Restore ES
pop si ; SI -> newly loaded data
+ pop es ; Restore ES
getc_loaded: lodsb ; Load a byte
mov [FPtr],si ; Update next byte pointer
- dec dword [FBytes] ; Update bytes left counter (CF = 1)
+ dec dword [FBytes] ; Update bytes left counter
clc ; Not EOF
getc_ret: ret
retf
;
-; Debugging routine: print packet data
-;
-debug_pxenv:
- push ax
- push bx
- mov al,'['
- call writechr
- mov ax,bx
- call writehex4
- mov al,':'
- call writechr
- pop bx
- pop ax
- push di
- call far [PXENVEntry]
- pop di
- pushf
- push ax
- mov ax,[di]
- call writehex4
- mov al,']'
- call writechr
- pop ax
- popf
- ret
-
-;
; dot: debugging routine, prints a dot w/o clobbering registers
;
dot: pushad
db 'im' ; implicit
db 'ke' ; kernel
db 'se' ; serial
+ db 'sa' ; say
db 'f1' ; F1
db 'f2' ; F2
db 'f3' ; F3
BufSafeBytes dw trackbufsize ; = how many bytes?
EndOfGetCBuf dw getcbuf+trackbufsize ; = getcbuf+BufSafeBytes
ClustPerMoby dw 65536/TFTP_BLOCKSIZE ; Clusters per 64K
+%if ( trackbufsize % TFTP_BLOCKSIZE ) != 0
+%error trackbufsize must be a multiple of TFTP_BLOCKSIZE
+%endif
;
; Stuff for the command line; we do some trickery here with equ to avoid