Annotation of /tags/mkinitrd-6_3_2/isolinux/parsecmd.inc
Parent Directory | Revision Log
Revision 1164 -
(hide annotations)
(download)
Tue Sep 14 20:33:28 2010 UTC (14 years ago) by niro
File size: 3738 byte(s)
Tue Sep 14 20:33:28 2010 UTC (14 years ago) by niro
File size: 3738 byte(s)
tagged 'mkinitrd-6_3_2'
1 | niro | 532 | ;; ----------------------------------------------------------------------- |
2 | ;; | ||
3 | niro | 1133 | ;; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved |
4 | ;; Copyright 2009 Intel Corporation; author: H. Peter Anvin | ||
5 | ;; | ||
6 | niro | 532 | ;; 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. | ||
11 | ;; | ||
12 | ;; ----------------------------------------------------------------------- | ||
13 | |||
14 | ;; | ||
15 | ;; parsecmd.inc | ||
16 | ;; | ||
17 | ;; Command line parser code | ||
18 | ;; | ||
19 | |||
20 | section .text | ||
21 | |||
22 | ; ------------------------------------------------------------------------- | ||
23 | ; getcommand: Get a keyword from the current "getc" file and match it | ||
24 | ; against a list of keywords (keywd_table). Each entry in | ||
25 | ; that table should have the following form: | ||
26 | ; <32 bit hash value> <16 bit handler offset> | ||
27 | ; | ||
28 | ; The handler is called, and upon return this function | ||
29 | ; returns with CF = 0. On EOF, this function returns | ||
30 | ; with CF = 1. | ||
31 | ; ------------------------------------------------------------------------- | ||
32 | |||
33 | niro | 1133 | getcommand.skipline: |
34 | call skipline | ||
35 | |||
36 | niro | 532 | getcommand: |
37 | .find: | ||
38 | call skipspace ; Skip leading whitespace | ||
39 | jz .eof ; End of file | ||
40 | jc .find ; End of line: try again | ||
41 | |||
42 | ; Do this explicitly so #foo is treated as a comment | ||
43 | cmp al,'#' ; Leading hash mark -> comment | ||
44 | je .skipline | ||
45 | |||
46 | niro | 1133 | ; Abuse the trackbuf by putting the keyword there for |
47 | ; possible error messaging... | ||
48 | mov di,trackbuf | ||
49 | stosb | ||
50 | niro | 532 | or al,20h ; Convert to lower case |
51 | movzx ebx,al ; Hash for a one-char keyword | ||
52 | .read_loop: | ||
53 | call getc | ||
54 | jc .eof | ||
55 | cmp al,' ' ; Whitespace | ||
56 | jbe .done | ||
57 | niro | 1133 | stosb |
58 | niro | 532 | or al,20h |
59 | rol ebx,5 | ||
60 | xor bl,al | ||
61 | jmp short .read_loop | ||
62 | .done: call ungetc | ||
63 | niro | 1133 | xor ax,ax |
64 | stosb ; Null-terminate the trackbuf | ||
65 | niro | 532 | call skipspace |
66 | jz .eof | ||
67 | jc .noparm | ||
68 | call ungetc ; Return nonwhitespace char to buf | ||
69 | mov si,keywd_table | ||
70 | mov cx,keywd_count | ||
71 | .table_search: | ||
72 | lodsd | ||
73 | cmp ebx,eax | ||
74 | je .found_keywd | ||
75 | lodsd ; Skip entrypoint/argument | ||
76 | loop .table_search | ||
77 | |||
78 | ; Otherwise unrecognized keyword | ||
79 | mov si,err_badcfg | ||
80 | niro | 1133 | call writestr |
81 | mov si,trackbuf | ||
82 | call writestr | ||
83 | call crlf | ||
84 | jmp .skipline | ||
85 | niro | 532 | |
86 | ; No parameter | ||
87 | .noparm: | ||
88 | mov si,err_noparm | ||
89 | niro | 1133 | call writestr |
90 | mov si,trackbuf | ||
91 | call writestr | ||
92 | call crlf | ||
93 | jmp .find | ||
94 | niro | 532 | |
95 | .found_keywd: lodsw ; Load argument into ax | ||
96 | call [si] | ||
97 | clc | ||
98 | ret | ||
99 | |||
100 | .eof: stc | ||
101 | ret | ||
102 | |||
103 | niro | 1133 | skipline: cmp al,10 ; Search for LF |
104 | je .end | ||
105 | niro | 532 | call getc |
106 | niro | 1133 | jnc skipline |
107 | .end: ret | ||
108 | niro | 532 | |
109 | niro | 1133 | section .data |
110 | err_badcfg db 'Unknown keyword in configuration file: ',0 | ||
111 | err_noparm db 'Missing parameter in configuration file. Keyword: ',0 | ||
112 | |||
113 | section .uibss | ||
114 | niro | 532 | alignb 4 |
115 | vk_size equ (vk_end + 3) & ~3 | ||
116 | VKernelBuf: resb vk_size ; "Current" vkernel | ||
117 | AppendBuf resb max_cmd_len+1 ; append= | ||
118 | Ontimeout resb max_cmd_len+1 ; ontimeout | ||
119 | Onerror resb max_cmd_len+1 ; onerror | ||
120 | niro | 1133 | ; This could be in .uibss but that makes PXELINUX overflow |
121 | section .bss | ||
122 | niro | 532 | KbdMap resb 256 ; Keyboard map |
123 | niro | 1133 | FKeyName resb MAX_FKEYS*FILENAME_MAX ; File names for F-key help |
124 | niro | 532 | KernelCNameLen resw 1 ; Length of unmangled kernel name |
125 | InitRDCNameLen resw 1 ; Length of unmangled initrd name | ||
126 | %if IS_SYSLINUX | ||
127 | KernelName resb FILENAME_MAX+1 ; Mangled name for kernel | ||
128 | KernelCName resb FILENAME_MAX+2 ; Unmangled kernel name | ||
129 | InitRDCName resb FILENAME_MAX+2 ; Unmangled initrd name | ||
130 | %else | ||
131 | KernelName resb FILENAME_MAX ; Mangled name for kernel | ||
132 | KernelCName resb FILENAME_MAX ; Unmangled kernel name | ||
133 | InitRDCName resb FILENAME_MAX ; Unmangled initrd name | ||
134 | %endif | ||
135 | MNameBuf resb FILENAME_MAX | ||
136 | InitRD resb FILENAME_MAX |