1 ;; $Id: parseconfig.inc,v 1.22 2005/04/06 09:53:39 hpa Exp $
2 ;; -----------------------------------------------------------------------
4 ;; Copyright 1994-2004 H. Peter Anvin - All Rights Reserved
6 ;; This program is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 ;; Boston MA 02111-1307, USA; either version 2 of the License, or
10 ;; (at your option) any later version; incorporated herein by reference.
12 ;; -----------------------------------------------------------------------
17 ;; Configuration file operations
24 pc_default: mov di,default_cmd
26 mov byte [di-1],0 ; null-terminate
32 pc_ontimeout: mov di,Ontimeout
34 sub di,Ontimeout+1 ; Don't need final space
41 pc_onerror: mov di,Onerror
50 pc_append: cmp byte [VKernel],0
55 .app1: mov [AppendLen],di
57 .vk: mov di,VKernelBuf+vk_append ; "append" command (vkernel)
59 sub di,VKernelBuf+vk_append
62 cmp byte [VKernelBuf+vk_append],'-'
64 xor di,di ; If "append -" -> null string
65 .app2: mov [VKernelBuf+vk_appendlen],di
69 ; "ipappend" command (PXELINUX only)
72 pc_ipappend: call getint
78 .vk: mov [VKernelBuf+vk_ipappend],bl
83 ; "localboot" command (PXELINUX, ISOLINUX)
85 %if IS_PXELINUX || IS_ISOLINUX
86 pc_localboot: call getint
87 cmp byte [VKernel],0 ; ("label" section only)
89 mov di,VKernelBuf+vk_rname
92 rep stosb ; Null kernel name
94 ; PXELINUX uses the first 4 bytes of vk_rname for the
96 mov [VKernelBuf+vk_rname+5], bx ; Return type
98 mov [VKernelBuf+vk_rname+1], bx ; Return type
105 pc_kernel: cmp byte [VKernel],0
106 je .err ; ("label" section only)
108 mov di,VKernelBuf+vk_rname
115 pc_timeout: call getint
117 mov ax,0D215h ; There are approx 1.D215h
118 mul bx ; clock ticks per 1/10 s
124 ; Generic integer variable setting commands:
125 ; "prompt", "implicit"
136 ; Generic file-processing commands:
137 ; "display", "font", "kbdmap"
139 pc_filecmd: push ax ; Function to tailcall
145 call searchdir ; tailcall
147 pop ax ; Drop the successor function
148 .ok: ret ; Tailcall if OK, error return
153 pc_serial: call getint
155 push bx ; Serial port #
163 mov [FlowControl], word 0 ; Default to no flow control
170 call getint ; Hardware flow control?
173 xor bx,bx ; Default -> no flow control
175 and bh,0Fh ; FlowIgnore
179 and bx,0F003h ; Valid bits
182 jmp short .parse_baud
184 mov ebx,DEFAULT_BAUD ; No baud rate given
186 pop di ; Serial port #
188 jb .err ; < 75 baud == bogus
193 push ax ; Baud rate divisor
195 ja .port_is_io ; If port > 3 then port is I/O addr
197 mov di,[di+serial_base] ; Get the I/O port from the BIOS
200 lea dx,[di+3] ; DX -> LCR
201 mov al,83h ; Enable DLAB
209 mov al,03h ; Disable DLAB
210 add dx,byte 2 ; DX -> LCR
212 in al,dx ; Read back LCR (detect missing hw)
213 cmp al,03h ; If nothing here we'll read 00 or FF
214 jne .serial_port_bad ; Assume serial port busted
215 sub dx,byte 2 ; DX -> IER
216 xor al,al ; IRQ disable
219 add dx,byte 3 ; DX -> MCR
221 or al,[FlowOutput] ; Assert bits
225 mov si,syslinux_banner
226 call write_serial_str
228 call write_serial_str
232 mov [SerialPort], word 0
241 call mangle_name ; Mangle file name
247 pc_label: call commit_vk ; Commit any current vkernel
248 mov di,VKernelBuf ; Erase the vkernelbuf for better compression
249 mov cx,(vk_size >> 1)
253 mov di,VKernelBuf+vk_vname
254 call mangle_name ; Mangle virtual name
255 mov byte [VKernel],1 ; We've seen a "label" statement
256 mov si,VKernelBuf+vk_vname ; By default, rname == vname
257 mov di,VKernelBuf+vk_rname
260 mov si,AppendBuf ; Default append==global append
261 mov di,VKernelBuf+vk_append
263 mov [VKernelBuf+vk_appendlen],cx
265 %if IS_PXELINUX ; PXELINUX only
266 mov al,[IPAppend] ; Default ipappend==global ipappend
267 mov [VKernelBuf+vk_ipappend],al
274 pc_say: call pc_getline ; "say" command
282 mov byte [KbdFlags],0
283 ; Fall into pc_getline
288 pc_comment: ; Fall into pc_getline
291 ; Common subroutine: load line into trackbuf; returns with SI -> trackbuf
293 pc_getline: mov di,trackbuf
297 stosb ; Null-terminate
302 ; Main loop for configuration file parsing
305 mov di,VKernelBuf ; Clear VKernelBuf at start
311 jnc .again ; If not EOF do it again
313 ; The fall through to commit_vk to commit any final
317 ; commit_vk: Store the current VKernelBuf into buffer segment
320 ; For better compression, clean up the append field
321 mov ax,[VKernelBuf+vk_appendlen]
322 mov di,VKernelBuf+vk_append
329 ; Pack temporarily into trackbuf
334 ; Now DX = number of bytes
335 mov di,[VKernelBytes]
338 jc .overflow ; If > 1 segment
339 mov [VKernelBytes],dx
348 mov si,vk_overflow_msg
353 vk_overflow_msg db 'Out of memory parsing config file', CR, LF, 0
356 AppendLen dw 0 ; Bytes in append= command
357 OntimeoutLen dw 0 ; Bytes in ontimeout command
358 OnerrorLen dw 0 ; Bytes in onerror command
359 KbdTimeOut dw 0 ; Keyboard timeout (if any)
360 CmdLinePtr dw cmd_line_here ; Command line advancing pointer
361 ForcePrompt dw 0 ; Force prompt
362 AllowImplicit dw 1 ; Allow implicit kernels
363 AllowOptions dw 1 ; User-specified options allowed
364 SerialPort dw 0 ; Serial port base (or 0 for no serial port)
365 VKernelBytes dw 0 ; Number of bytes used by vkernels
366 VKernel db 0 ; Have we seen any "label" statements?
369 alignb 4 ; For the good of REP MOVSD
370 command_line resb max_cmd_len+2 ; Command line buffer
372 default_cmd resb max_cmd_len+1 ; "default" command line
374 %include "rllpack.inc"