1 ;; -----------------------------------------------------------------------
3 ;; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 ;; Boston MA 02111-1307, USA; either version 2 of the License, or
9 ;; (at your option) any later version; incorporated herein by reference.
11 ;; -----------------------------------------------------------------------
16 ;; Configuration file operations
23 pc_default: mov di,default_cmd
25 mov byte [di-1],0 ; null-terminate
31 pc_ontimeout: mov di,Ontimeout
33 sub di,Ontimeout+1 ; Don't need final space
40 pc_onerror: mov di,Onerror
49 pc_append: cmp byte [VKernel],0
54 .app1: mov [AppendLen],di
56 .vk: mov di,VKernelBuf+vk_append ; "append" command (vkernel)
58 sub di,VKernelBuf+vk_append
61 cmp byte [VKernelBuf+vk_append],'-'
63 xor di,di ; If "append -" -> null string
64 .app2: mov [VKernelBuf+vk_appendlen],di
68 ; "ipappend" command (PXELINUX only)
71 pc_ipappend: call getint
77 .vk: mov [VKernelBuf+vk_ipappend],bl
82 ; "localboot" command (PXELINUX, ISOLINUX)
84 %if IS_PXELINUX || IS_ISOLINUX
85 pc_localboot: call getint
86 cmp byte [VKernel],0 ; ("label" section only)
88 mov di,VKernelBuf+vk_rname
91 rep stosb ; Null kernel name
93 ; PXELINUX uses the first 4 bytes of vk_rname for the
95 mov [VKernelBuf+vk_rname+5], bx ; Return type
97 mov [VKernelBuf+vk_rname+1], bx ; Return type
104 pc_kernel: cmp byte [VKernel],0
105 je .err ; ("label" section only)
107 mov di,VKernelBuf+vk_rname
112 ; "timeout", "totaltimeout" command
114 ; N.B. 1/10 s ~ 1.D2162AABh clock ticks
121 mul ebx ; clock ticks per 1/10 s
128 ; "totaltimeout" command
133 ; Generic integer variable setting commands:
134 ; "prompt", "implicit"
145 ; Generic file-processing commands:
146 ; "display", "font", "kbdmap"
148 pc_filecmd: push ax ; Function to tailcall
154 call searchdir ; tailcall
156 pop ax ; Drop the successor function
157 .ok: ret ; Tailcall if OK, error return
162 pc_serial: call getint
164 push bx ; Serial port #
172 mov [FlowControl], word 0 ; Default to no flow control
179 call getint ; Hardware flow control?
182 xor bx,bx ; Default -> no flow control
184 and bh,0Fh ; FlowIgnore
188 and bx,0F003h ; Valid bits
191 jmp short .parse_baud
193 mov ebx,DEFAULT_BAUD ; No baud rate given
195 pop di ; Serial port #
197 jb .err ; < 75 baud == bogus
202 push ax ; Baud rate divisor
204 ja .port_is_io ; If port > 3 then port is I/O addr
206 mov di,[di+serial_base] ; Get the I/O port from the BIOS
211 ; Begin code to actually set up the serial port
213 lea dx,[di+3] ; DX -> LCR
214 mov al,83h ; Enable DLAB
225 mov al,03h ; Disable DLAB
230 in al,dx ; Read back LCR (detect missing hw)
231 cmp al,03h ; If nothing here we'll read 00 or FF
232 jne .serial_port_bad ; Assume serial port busted
235 xor al,al ; IRQ disable
238 inc dx ; DX -> FCR/IIR
240 call slow_out ; Enable FIFOs if present
242 cmp al,0C0h ; FIFOs enabled and usable?
244 xor ax,ax ; Disable FIFO if unusable
251 or al,[FlowOutput] ; Assert bits
255 mov si,syslinux_banner
256 call write_serial_str
258 call write_serial_str
262 mov [SerialPort], word 0
271 call mangle_name ; Mangle file name
277 pc_label: call commit_vk ; Commit any current vkernel
278 mov di,VKernelBuf ; Erase the vkernelbuf for better compression
279 mov cx,(vk_size >> 1)
283 mov di,VKernelBuf+vk_vname
284 call mangle_name ; Mangle virtual name
285 mov byte [VKernel],1 ; We've seen a "label" statement
286 mov si,VKernelBuf+vk_vname ; By default, rname == vname
287 mov di,VKernelBuf+vk_rname
290 mov si,AppendBuf ; Default append==global append
291 mov di,VKernelBuf+vk_append
293 mov [VKernelBuf+vk_appendlen],cx
295 %if IS_PXELINUX ; PXELINUX only
296 mov al,[IPAppend] ; Default ipappend==global ipappend
297 mov [VKernelBuf+vk_ipappend],al
304 pc_say: call pc_getline ; "say" command
309 ; "text" command; ignore everything until we get an "endtext" line
311 pc_text: call pc_getline ; Ignore rest of line
330 ; If we get here we hit ENDTEXT
336 pc_comment: ; Fall into pc_getline
339 ; Common subroutine: load line into trackbuf; returns with SI -> trackbuf
341 pc_getline: mov di,trackbuf
345 stosb ; Null-terminate
350 ; Main loop for configuration file parsing
353 mov di,VKernelBuf ; Clear VKernelBuf at start
359 jnc .again ; If not EOF do it again
361 ; The fall through to commit_vk to commit any final
365 ; commit_vk: Store the current VKernelBuf into buffer segment
368 ; For better compression, clean up the append field
369 mov ax,[VKernelBuf+vk_appendlen]
370 mov di,VKernelBuf+vk_append
377 ; Pack temporarily into trackbuf
382 ; Now DX = number of bytes
383 mov di,[VKernelBytes]
386 jc .overflow ; If > 1 segment
387 mov [VKernelBytes],dx
396 mov si,vk_overflow_msg
401 vk_overflow_msg db 'Out of memory parsing config file', CR, LF, 0
404 KbdTimeout dd 0 ; Keyboard timeout (if any)
405 TotalTimeout dd 0 ; Total timeout (if any)
406 AppendLen dw 0 ; Bytes in append= command
407 OntimeoutLen dw 0 ; Bytes in ontimeout command
408 OnerrorLen dw 0 ; Bytes in onerror command
409 CmdLinePtr dw cmd_line_here ; Command line advancing pointer
410 ForcePrompt dw 0 ; Force prompt
411 NoEscape dw 0 ; No escape
412 AllowImplicit dw 1 ; Allow implicit kernels
413 AllowOptions dw 1 ; User-specified options allowed
414 SerialPort dw 0 ; Serial port base (or 0 for no serial port)
415 VKernelBytes dw 0 ; Number of bytes used by vkernels
416 VKernel db 0 ; Have we seen any "label" statements?
419 alignb 4 ; For the good of REP MOVSD
420 command_line resb max_cmd_len+2 ; Command line buffer
422 default_cmd resb max_cmd_len+1 ; "default" command line
424 %include "rllpack.inc"