1 ;; -----------------------------------------------------------------------
3 ;; Copyright 1994-2008 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
103 ; "kernel", "config", ... command
105 pc_kernel: cmp byte [VKernel],0
106 je .err ; ("label" section only)
107 mov [VKernelBuf+vk_type],al
109 mov di,VKernelBuf+vk_rname
114 ; "timeout", "totaltimeout" command
116 ; N.B. 1/10 s ~ 1.D2162AABh clock ticks
123 mul ebx ; clock ticks per 1/10 s
130 ; "totaltimeout" command
135 ; Generic integer variable setting commands:
136 ; "prompt", "implicit"
147 ; Generic file-processing commands:
150 pc_filecmd: push ax ; Function to tailcall
156 pop ax ; Drop the successor function
157 .ok: ret ; Tailcall if OK, error return
160 ; Commands that expect the file to be opened on top of the getc stack.
161 ; "display", "include"
163 pc_opencmd: push ax ; Function to tailcall
169 pop ax ; Drop the successor function
170 .ok: ret ; Tailcall if OK, error return
173 ; "include" command (invoked from pc_opencmd)
175 pc_include: inc word [IncludeLevel]
181 pc_serial: call getint
183 push bx ; Serial port #
191 mov [FlowControl], word 0 ; Default to no flow control
198 call getint ; Hardware flow control?
201 xor bx,bx ; Default -> no flow control
203 and bh,0Fh ; FlowIgnore
207 and bx,0F003h ; Valid bits
210 jmp short .parse_baud
212 mov ebx,DEFAULT_BAUD ; No baud rate given
214 pop di ; Serial port #
216 jb .err ; < 75 baud == bogus
221 push ax ; Baud rate divisor
223 ja .port_is_io ; If port > 3 then port is I/O addr
225 mov di,[di+serial_base] ; Get the I/O port from the BIOS
230 ; Begin code to actually set up the serial port
232 lea dx,[di+3] ; DX -> LCR
233 mov al,83h ; Enable DLAB
244 mov al,03h ; Disable DLAB
249 in al,dx ; Read back LCR (detect missing hw)
250 cmp al,03h ; If nothing here we'll read 00 or FF
251 jne .serial_port_bad ; Assume serial port busted
254 xor al,al ; IRQ disable
257 inc dx ; DX -> FCR/IIR
259 call slow_out ; Enable FIFOs if present
261 cmp al,0C0h ; FIFOs enabled and usable?
263 xor ax,ax ; Disable FIFO if unusable
270 or al,[FlowOutput] ; Assert bits
274 cmp byte [SerialNotice],0
276 mov byte [SerialNotice],0
278 mov si,syslinux_banner
279 call write_serial_str
281 call write_serial_str
286 mov [SerialPort], word 0
295 call mangle_name ; Mangle file name
301 pc_label: call commit_vk ; Commit any current vkernel
302 mov di,VKernelBuf ; Erase the vkernelbuf for better compression
303 mov cx,(vk_size >> 1)
307 mov di,VKernelBuf+vk_vname
308 call mangle_name ; Mangle virtual name
309 mov byte [VKernel],1 ; We've seen a "label" statement
310 mov si,VKernelBuf+vk_vname ; By default, rname == vname
311 ; mov di,VKernelBuf+vk_rname ; -- already set
314 mov si,AppendBuf ; Default append==global append
315 mov di,VKernelBuf+vk_append
317 mov [VKernelBuf+vk_appendlen],cx
319 %if IS_PXELINUX ; PXELINUX only
320 mov al,[IPAppend] ; Default ipappend==global ipappend
321 mov [VKernelBuf+vk_ipappend],al
328 pc_say: call pc_getline ; "say" command
333 ; "text" command; ignore everything until we get an "endtext" line
335 pc_text: call pc_getline ; Ignore rest of line
340 ; Leading spaces are already removed...
342 and eax,0xdfdfdfdf ; Upper case
346 and eax,0x00dfdfdf ; Upper case and mask
349 ; If we get here we hit ENDTEXT
356 pc_comment: ; Fall into pc_getline
359 ; Common subroutine: load line into trackbuf; returns with SI -> trackbuf
362 pc_getline: mov di,trackbuf
365 mov byte [di],0 ; Null-terminate
370 ; Main loop for configuration file parsing
373 mov di,VKernelBuf ; Clear VKernelBuf at start
379 call getcommand ; Parse one command
380 jnc .again ; If not EOF...
382 dec word [IncludeLevel] ; Still parsing?
386 ; The fall through to commit_vk to commit any final
390 ; commit_vk: Store the current VKernelBuf into buffer segment
393 ; For better compression, clean up the append field
394 mov ax,[VKernelBuf+vk_appendlen]
395 mov di,VKernelBuf+vk_append
402 ; Pack into high memory
410 mov si,vk_overflow_msg
415 vk_overflow_msg db 'Out of memory parsing config file', CR, LF, 0
416 SerialNotice db 1 ; Only print this once
420 VKernelEnd resd 1 ; Lowest high memory address used
422 ; This symbol should be used by loaders to indicate
423 ; the highest address *they* are allowed to use.
424 HighMemRsvd equ VKernelEnd
428 KbdTimeout dd 0 ; Keyboard timeout (if any)
429 TotalTimeout dd 0 ; Total timeout (if any)
430 AppendLen dw 0 ; Bytes in append= command
431 OntimeoutLen dw 0 ; Bytes in ontimeout command
432 OnerrorLen dw 0 ; Bytes in onerror command
433 CmdLinePtr dw cmd_line_here ; Command line advancing pointer
434 ForcePrompt dw 0 ; Force prompt
435 NoEscape dw 0 ; No escape
436 AllowImplicit dw 1 ; Allow implicit kernels
437 AllowOptions dw 1 ; User-specified options allowed
438 IncludeLevel dw 1 ; Nesting level
439 SerialPort dw 0 ; Serial port base (or 0 for no serial port)
440 VKernel db 0 ; Have we seen any "label" statements?
443 IPAppend db 0 ; Default IPAPPEND option
447 alignb 4 ; For the good of REP MOVSD
448 command_line resb max_cmd_len+2 ; Command line buffer
450 default_cmd resb max_cmd_len+1 ; "default" command line
452 %include "rllpack.inc"