1 ;; -----------------------------------------------------------------------
3 ;; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
4 ;; Copyright 2009 Intel Corporation; author: H. Peter Anvin
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
22 ; "default" or "ui" command, with level (1 = default, 2 = ui)
24 pc_default: cmp ax,[DefaultLevel]
25 jb skipline ; == call skipline + ret
29 mov byte [di-1],0 ; null-terminate
35 pc_ontimeout: mov di,Ontimeout
37 sub di,Ontimeout+1 ; Don't need final space
44 pc_onerror: mov di,Onerror
53 pc_append: cmp byte [VKernel],0
58 .app1: mov [AppendLen],di
60 .vk: mov di,VKernelBuf+vk_append ; "append" command (vkernel)
62 sub di,VKernelBuf+vk_append
65 cmp byte [VKernelBuf+vk_append],'-'
67 xor di,di ; If "append -" -> null string
68 .app2: mov [VKernelBuf+vk_appendlen],di
72 ; "ipappend" command (PXELINUX only)
75 pc_ipappend: call getint
81 .vk: mov [VKernelBuf+vk_ipappend],bl
88 pc_localboot: call getint
89 cmp byte [VKernel],0 ; ("label" section only)
91 mov [VKernelBuf+vk_rname],bx
92 mov byte [VKernelBuf+vk_type],VK_LOCALBOOT
96 ; "kernel", "config", ... command
98 pc_kernel: cmp byte [VKernel],0
99 je .err ; ("label" section only)
100 mov [VKernelBuf+vk_type],al
102 mov di,VKernelBuf+vk_rname
103 pm_call pm_mangle_name
107 ; "timeout", "totaltimeout" command
109 ; N.B. 1/10 s ~ 1.D2162AABh clock ticks
116 mul ebx ; clock ticks per 1/10 s
123 ; "totaltimeout" command
128 ; Generic integer variable setting commands:
129 ; "prompt", "implicit"
140 ; Generic file-processing commands:
143 pc_filecmd: push ax ; Function to tailcall
146 pm_call pm_mangle_name
149 pop ax ; Drop the successor function
150 .ok: ret ; Tailcall if OK, error return
153 ; Commands that expect the file to be opened on top of the getc stack.
154 ; "display", "include"
156 pc_opencmd: push ax ; Function to tailcall
159 pm_call pm_mangle_name
162 pop ax ; Drop the successor function
163 .ok: ret ; Tailcall if OK, error return
166 ; "include" command (invoked from pc_opencmd)
168 pc_include: inc word [IncludeLevel]
174 pc_serial: call getint
176 push bx ; Serial port #
178 mov [FlowControl],eax ; Default to no flow control
189 call getint ; Hardware flow control?
192 xor bx,bx ; Default -> no flow control
194 and bh,0Fh ; FlowIgnore
198 and bx,0F00Bh ; Valid bits
201 jmp short .parse_baud
203 mov ebx,DEFAULT_BAUD ; No baud rate given
205 pop di ; Serial port #
207 jb .err ; < 75 baud == bogus
212 push ax ; Baud rate divisor
214 ja .port_is_io ; If port > 3 then port is I/O addr
216 mov di,[di+serial_base] ; Get the I/O port from the BIOS
221 ; Begin code to actually set up the serial port
223 call sirq_cleanup_nowipe ; Cleanup existing IRQ handler
225 lea dx,[di+3] ; DX -> LCR
226 mov al,83h ; Enable DLAB
237 mov al,03h ; Disable DLAB
242 in al,dx ; Read back LCR (detect missing hw)
243 cmp al,03h ; If nothing here we'll read 00 or FF
244 jne .err ; Assume serial port busted
245 dec dx ; DX -> IIR/FCR
247 slow_out dx,al ; Enable FIFOs if present
249 cmp al,0C0h ; FIFOs enabled and usable?
251 xor ax,ax ; Disable FIFO if unusable
257 mov al,[FlowOutput] ; Assert bits
260 ; Enable interrupts if requested
267 cmp byte [SerialNotice],0
269 mov byte [SerialNotice],0
271 mov si,syslinux_banner
272 call write_serial_str
274 call write_serial_str
279 mov [SerialPort], word 0
283 ; Store mangled filename command (F-keys, "initrd")
288 pm_call pm_mangle_name ; Mangle file name
294 pc_label: call commit_vk ; Commit any current vkernel
295 mov byte [InitRD+NULLOFFSET],NULLFILE ; No "initrd" statement
296 mov di,VKernelBuf ; Erase the vkernelbuf for better compression
297 mov cx,(vk_size >> 1)
301 mov di,VKernelBuf+vk_vname
302 mov cx,FILENAME_MAX-1
310 mov byte [VKernel],1 ; We've seen a "label" statement
311 mov si,VKernelBuf+vk_vname ; By default, rname == mangled vname
312 mov di,VKernelBuf+vk_rname
313 pm_call pm_mangle_name
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 skipline ; 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
394 jz .nolabel ; Nothing to commit...
396 mov di,VKernelBuf+vk_append
397 add di,[VKernelBuf+vk_appendlen]
399 ; If we have an initrd statement, append it to the
401 cmp byte [InitRD+NULLOFFSET],NULLFILE
409 mov byte [es:di-1],' '
411 ; For better compression, clean up the append field
414 sub ax,VKernelBuf+vk_append
415 mov [VKernelBuf+vk_appendlen],ax
421 ; Pack into high memory
430 mov si,vk_overflow_msg
435 vk_overflow_msg db 'Out of memory parsing config file', CR, LF, 0
436 SerialNotice db 1 ; Only print this once
440 VKernelEnd resd 1 ; Lowest high memory address used
442 ; This symbol should be used by loaders to indicate
443 ; the highest address *they* are allowed to use.
444 HighMemRsvd equ VKernelEnd
448 KbdTimeout dd 0 ; Keyboard timeout (if any)
449 TotalTimeout dd 0 ; Total timeout (if any)
450 AppendLen dw 0 ; Bytes in append= command
451 OntimeoutLen dw 0 ; Bytes in ontimeout command
452 OnerrorLen dw 0 ; Bytes in onerror command
453 CmdLinePtr dw cmd_line_here ; Command line advancing pointer
454 ForcePrompt dw 0 ; Force prompt
455 NoEscape dw 0 ; No escape
456 NoComplete dw 0 ; No label completion on TAB key
457 AllowImplicit dw 1 ; Allow implicit kernels
458 AllowOptions dw 1 ; User-specified options allowed
459 IncludeLevel dw 1 ; Nesting level
460 DefaultLevel dw 0 ; The current level of default
462 PXERetry dw 0 ; Extra PXE retries
463 VKernel db 0 ; Have we seen any "label" statements?
466 IPAppend db 0 ; Default IPAPPEND option
470 alignb 4 ; For the good of REP MOVSD
471 command_line resb max_cmd_len+2 ; Command line buffer
473 default_cmd resb max_cmd_len+1 ; "default" command line