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)
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
102 %endif ; HAS_LOCALBOOT
105 ; "kernel", "config", ... command
107 pc_kernel: cmp byte [VKernel],0
108 je .err ; ("label" section only)
109 mov [VKernelBuf+vk_type],al
111 mov di,VKernelBuf+vk_rname
116 ; "timeout", "totaltimeout" command
118 ; N.B. 1/10 s ~ 1.D2162AABh clock ticks
125 mul ebx ; clock ticks per 1/10 s
132 ; "totaltimeout" command
137 ; Generic integer variable setting commands:
138 ; "prompt", "implicit"
149 ; Generic file-processing commands:
152 pc_filecmd: push ax ; Function to tailcall
158 pop ax ; Drop the successor function
159 .ok: ret ; Tailcall if OK, error return
162 ; Commands that expect the file to be opened on top of the getc stack.
163 ; "display", "include"
165 pc_opencmd: push ax ; Function to tailcall
171 pop ax ; Drop the successor function
172 .ok: ret ; Tailcall if OK, error return
175 ; "include" command (invoked from pc_opencmd)
177 pc_include: inc word [IncludeLevel]
183 pc_serial: call getint
185 push bx ; Serial port #
193 mov [FlowControl], word 0 ; Default to no flow control
200 call getint ; Hardware flow control?
203 xor bx,bx ; Default -> no flow control
205 and bh,0Fh ; FlowIgnore
209 and bx,0F003h ; Valid bits
212 jmp short .parse_baud
214 mov ebx,DEFAULT_BAUD ; No baud rate given
216 pop di ; Serial port #
218 jb .err ; < 75 baud == bogus
223 push ax ; Baud rate divisor
225 ja .port_is_io ; If port > 3 then port is I/O addr
227 mov di,[di+serial_base] ; Get the I/O port from the BIOS
232 ; Begin code to actually set up the serial port
234 lea dx,[di+3] ; DX -> LCR
235 mov al,83h ; Enable DLAB
246 mov al,03h ; Disable DLAB
251 in al,dx ; Read back LCR (detect missing hw)
252 cmp al,03h ; If nothing here we'll read 00 or FF
253 jne .serial_port_bad ; Assume serial port busted
256 xor al,al ; IRQ disable
259 inc dx ; DX -> FCR/IIR
261 call slow_out ; Enable FIFOs if present
263 cmp al,0C0h ; FIFOs enabled and usable?
265 xor ax,ax ; Disable FIFO if unusable
272 or al,[FlowOutput] ; Assert bits
276 cmp byte [SerialNotice],0
278 mov byte [SerialNotice],0
280 mov si,syslinux_banner
281 call write_serial_str
283 call write_serial_str
288 mov [SerialPort], word 0
297 call mangle_name ; Mangle file name
303 pc_label: call commit_vk ; Commit any current vkernel
304 mov di,VKernelBuf ; Erase the vkernelbuf for better compression
305 mov cx,(vk_size >> 1)
309 mov di,VKernelBuf+vk_vname
310 call mangle_name ; Mangle virtual name
311 mov byte [VKernel],1 ; We've seen a "label" statement
312 mov si,VKernelBuf+vk_vname ; By default, rname == vname
313 ; mov di,VKernelBuf+vk_rname ; -- already set
316 mov si,AppendBuf ; Default append==global append
317 mov di,VKernelBuf+vk_append
319 mov [VKernelBuf+vk_appendlen],cx
321 %if IS_PXELINUX ; PXELINUX only
322 mov al,[IPAppend] ; Default ipappend==global ipappend
323 mov [VKernelBuf+vk_ipappend],al
330 pc_say: call pc_getline ; "say" command
335 ; "text" command; ignore everything until we get an "endtext" line
337 pc_text: call pc_getline ; Ignore rest of line
342 ; Leading spaces are already removed...
344 and eax,0xdfdfdfdf ; Upper case
348 and eax,0x00dfdfdf ; Upper case and mask
351 ; If we get here we hit ENDTEXT
358 pc_comment: ; Fall into pc_getline
361 ; Common subroutine: load line into trackbuf; returns with SI -> trackbuf
364 pc_getline: mov di,trackbuf
367 mov byte [di],0 ; Null-terminate
372 ; Main loop for configuration file parsing
375 mov di,VKernelBuf ; Clear VKernelBuf at start
381 call getcommand ; Parse one command
382 jnc .again ; If not EOF...
384 dec word [IncludeLevel] ; Still parsing?
388 ; The fall through to commit_vk to commit any final
392 ; commit_vk: Store the current VKernelBuf into buffer segment
395 ; For better compression, clean up the append field
396 mov ax,[VKernelBuf+vk_appendlen]
397 mov di,VKernelBuf+vk_append
404 ; Pack into high memory
412 mov si,vk_overflow_msg
417 vk_overflow_msg db 'Out of memory parsing config file', CR, LF, 0
418 SerialNotice db 1 ; Only print this once
422 VKernelEnd resd 1 ; Lowest high memory address used
424 ; This symbol should be used by loaders to indicate
425 ; the highest address *they* are allowed to use.
426 HighMemRsvd equ VKernelEnd
430 KbdTimeout dd 0 ; Keyboard timeout (if any)
431 TotalTimeout dd 0 ; Total timeout (if any)
432 AppendLen dw 0 ; Bytes in append= command
433 OntimeoutLen dw 0 ; Bytes in ontimeout command
434 OnerrorLen dw 0 ; Bytes in onerror command
435 CmdLinePtr dw cmd_line_here ; Command line advancing pointer
436 ForcePrompt dw 0 ; Force prompt
437 NoEscape dw 0 ; No escape
438 AllowImplicit dw 1 ; Allow implicit kernels
439 AllowOptions dw 1 ; User-specified options allowed
440 IncludeLevel dw 1 ; Nesting level
441 SerialPort dw 0 ; Serial port base (or 0 for no serial port)
442 VKernel db 0 ; Have we seen any "label" statements?
445 IPAppend db 0 ; Default IPAPPEND option
449 alignb 4 ; For the good of REP MOVSD
450 command_line resb max_cmd_len+2 ; Command line buffer
452 default_cmd resb max_cmd_len+1 ; "default" command line
454 %include "rllpack.inc"