1 /* -*- linux-c -*- ------------------------------------------------------- *
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 * Copyright 2007 rPath, Inc. - All Rights Reserved
6 * This file is part of the Linux kernel, and is made available under
7 * the terms of the GNU General Public License version 2.
9 * ----------------------------------------------------------------------- */
12 * arch/i386/boot/cmdline.c
14 * Simple command-line parser for early boot.
19 static inline int myisspace(u8 c
)
21 return c
<= ' '; /* Close enough approximation */
25 * Find a non-boolean option, that is, "option=argument". In accordance
26 * with standard Linux practice, if this option is repeated, this returns
27 * the last instance on the command line.
29 * Returns the length of the argument (regardless of if it was
30 * truncated to fit in the buffer), or -1 on not found.
32 int cmdline_find_option(const char *option
, char *buffer
, int bufsize
)
34 u32 cmdline_ptr
= boot_params
.hdr
.cmd_line_ptr
;
38 const char *opptr
= NULL
;
39 char *bufptr
= buffer
;
41 st_wordstart
, /* Start of word/after whitespace */
42 st_wordcmp
, /* Comparing this word */
43 st_wordskip
, /* Miscompare, skip */
44 st_bufcpy
/* Copying this to buffer */
45 } state
= st_wordstart
;
47 if (!cmdline_ptr
|| cmdline_ptr
>= 0x100000)
48 return -1; /* No command line, or inaccessible */
50 cptr
= cmdline_ptr
& 0xf;
51 set_fs(cmdline_ptr
>> 4);
53 while (cptr
< 0x10000 && (c
= rdfs8(cptr
++))) {
65 if (c
== '=' && !*opptr
) {
69 } else if (myisspace(c
)) {
71 } else if (c
!= *opptr
++) {