]>
git.saurik.com Git - apple/xnu.git/blob - pexpert/gen/bootargs.c
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 #include <pexpert/pexpert.h>
32 extern boolean_t
isargsep( char c
);
33 extern int argstrcpy(char *from
, char *to
);
34 extern int getval(char *s
, int *val
);
41 const char *arg_string
,
44 return PE_parse_boot_argn(arg_string
, arg_ptr
, -1);
49 const char *arg_string
,
57 boolean_t arg_boolean
;
60 args
= PE_boot_args();
61 if (*args
== '\0') return FALSE
;
65 while(isargsep(*args
)) args
++;
75 while (!isargsep (*cp
) && *cp
!= '=')
77 if (*cp
!= '=' && !arg_boolean
)
83 if (strncmp(args
, arg_string
, i
) ||
84 (i
!=strlen(arg_string
)))
87 *(unsigned int *)arg_ptr
= TRUE
;
91 while (isargsep (*cp
))
93 if (*cp
== '=' && c
!= '=') {
97 if ('_' == *arg_string
) /* Force a string copy if the argument name begins with an underscore */
99 int hacklen
= 16 > max_len
? 16 : max_len
;
100 argstrcpy2 (++cp
, (char *)arg_ptr
, hacklen
); /* Hack - terminate after 16 characters */
104 switch (getval(cp
, &val
))
107 *(unsigned int *)arg_ptr
= val
;
111 if(max_len
> 0) //max_len of 0 performs no copy at all
112 argstrcpy2(++cp
, (char *)arg_ptr
, max_len
);
113 else if(max_len
== -1)
114 argstrcpy(++cp
, (char *)arg_ptr
);
121 /* Skip over current arg */
122 while(!isargsep(*args
)) args
++;
124 /* Skip leading white space (catch end of args) */
125 while(*args
&& isargsep(*args
)) args
++;
134 if (c
== ' ' || c
== '\0' || c
== '\t')
147 while (!isargsep(*from
)) {
163 while (!isargsep(*from
) && i
< maxlen
) {
176 unsigned int radix
, intval
;
199 case '0': case '1': case '2': case '3':
200 case '4': case '5': case '6': case '7':
210 } else if (intval
>= radix
) {
218 ((c
>= '0') && (c
<= ('9' - (10 - radix
))))) {
220 } else if ((radix
== 16) &&
221 ((c
>= '0') && (c
<= '9'))) {
223 } else if ((radix
== 16) &&
224 ((c
>= 'a') && (c
<= 'f'))) {
226 } else if ((radix
== 16) &&
227 ((c
>= 'A') && (c
<= 'F'))) {
229 } else if (c
== 'k' || c
== 'K') {
232 } else if (c
== 'm' || c
== 'M') {
235 } else if (c
== 'g' || c
== 'G') {
236 sign
*= 1024 * 1024 * 1024;
246 if (!isargsep(c
) && !isargsep(*s
))
248 *val
= intval
* sign
;