Annotation of /tags/mkinitrd-6_2_3/isolinux/parsecmd.inc
Parent Directory | Revision Log
Revision 532 -
(hide annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (17 years ago) by niro
Original Path: trunk/mkinitrd-magellan/isolinux/parsecmd.inc
File size: 3263 byte(s)
Sat Sep 1 22:45:15 2007 UTC (17 years ago) by niro
Original Path: trunk/mkinitrd-magellan/isolinux/parsecmd.inc
File size: 3263 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | niro | 532 | ;; $Id: parsecmd.inc,v 1.1 2007-09-01 22:44:05 niro Exp $ |
2 | ;; ----------------------------------------------------------------------- | ||
3 | ;; | ||
4 | ;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved | ||
5 | ;; | ||
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. | ||
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 | getcommand: | ||
34 | .find: | ||
35 | call skipspace ; Skip leading whitespace | ||
36 | jz .eof ; End of file | ||
37 | jc .find ; End of line: try again | ||
38 | |||
39 | ; Do this explicitly so #foo is treated as a comment | ||
40 | cmp al,'#' ; Leading hash mark -> comment | ||
41 | je .skipline | ||
42 | |||
43 | or al,20h ; Convert to lower case | ||
44 | movzx ebx,al ; Hash for a one-char keyword | ||
45 | .read_loop: | ||
46 | push ebx | ||
47 | call getc | ||
48 | pop ebx | ||
49 | jc .eof | ||
50 | cmp al,' ' ; Whitespace | ||
51 | jbe .done | ||
52 | or al,20h | ||
53 | rol ebx,5 | ||
54 | xor bl,al | ||
55 | jmp short .read_loop | ||
56 | .done: call ungetc | ||
57 | call skipspace | ||
58 | jz .eof | ||
59 | jc .noparm | ||
60 | call ungetc ; Return nonwhitespace char to buf | ||
61 | mov si,keywd_table | ||
62 | mov cx,keywd_count | ||
63 | .table_search: | ||
64 | lodsd | ||
65 | cmp ebx,eax | ||
66 | je .found_keywd | ||
67 | lodsd ; Skip entrypoint/argument | ||
68 | loop .table_search | ||
69 | |||
70 | ; Otherwise unrecognized keyword | ||
71 | mov si,err_badcfg | ||
72 | jmp short .error | ||
73 | |||
74 | ; No parameter | ||
75 | .noparm: | ||
76 | mov si,err_noparm | ||
77 | mov al,10 ; Already at EOL | ||
78 | .error: | ||
79 | call cwritestr | ||
80 | jmp short .skipline | ||
81 | |||
82 | .found_keywd: lodsw ; Load argument into ax | ||
83 | call [si] | ||
84 | clc | ||
85 | ret | ||
86 | |||
87 | .eof: stc | ||
88 | ret | ||
89 | |||
90 | .skipline: cmp al,10 ; Search for LF | ||
91 | je .find | ||
92 | call getc | ||
93 | jc .eof | ||
94 | jmp short .skipline | ||
95 | |||
96 | section .latebss | ||
97 | alignb 4 | ||
98 | vk_size equ (vk_end + 3) & ~3 | ||
99 | VKernelBuf: resb vk_size ; "Current" vkernel | ||
100 | AppendBuf resb max_cmd_len+1 ; append= | ||
101 | Ontimeout resb max_cmd_len+1 ; ontimeout | ||
102 | Onerror resb max_cmd_len+1 ; onerror | ||
103 | KbdMap resb 256 ; Keyboard map | ||
104 | FKeyName resb 10*FILENAME_MAX ; File names for F-key help | ||
105 | KernelCNameLen resw 1 ; Length of unmangled kernel name | ||
106 | InitRDCNameLen resw 1 ; Length of unmangled initrd name | ||
107 | %if IS_SYSLINUX | ||
108 | KernelName resb FILENAME_MAX+1 ; Mangled name for kernel | ||
109 | KernelCName resb FILENAME_MAX+2 ; Unmangled kernel name | ||
110 | InitRDCName resb FILENAME_MAX+2 ; Unmangled initrd name | ||
111 | %else | ||
112 | KernelName resb FILENAME_MAX ; Mangled name for kernel | ||
113 | KernelCName resb FILENAME_MAX ; Unmangled kernel name | ||
114 | InitRDCName resb FILENAME_MAX ; Unmangled initrd name | ||
115 | %endif | ||
116 | MNameBuf resb FILENAME_MAX | ||
117 | InitRD resb FILENAME_MAX |