]>
git.saurik.com Git - apple/xnu.git/blob - pexpert/gen/bootargs.c
2d7f80b3f6f1026f5c0dceebee987e8644ec121e
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 #include <pexpert/pexpert.h>
30 extern boolean_t
isargsep( char c
);
31 extern int argstrcpy(char *from
, char *to
);
32 extern int getval(char *s
, int *val
);
39 const char *arg_string
,
42 return PE_parse_boot_argn(arg_string
, arg_ptr
, -1);
47 const char *arg_string
,
55 boolean_t arg_boolean
;
58 args
= PE_boot_args();
59 if (*args
== '\0') return FALSE
;
63 while(isargsep(*args
)) args
++;
73 while (!isargsep (*cp
) && *cp
!= '=')
75 if (*cp
!= '=' && !arg_boolean
)
81 if (strncmp(args
, arg_string
, i
) ||
82 (i
!=strlen(arg_string
)))
85 *(unsigned int *)arg_ptr
= TRUE
;
89 while (isargsep (*cp
))
91 if (*cp
== '=' && c
!= '=') {
95 if ('_' == *arg_string
) /* Force a string copy if the argument name begins with an underscore */
97 int hacklen
= 16 > max_len
? 16 : max_len
;
98 argstrcpy2 (++cp
, (char *)arg_ptr
, hacklen
); /* Hack - terminate after 16 characters */
102 switch (getval(cp
, &val
))
105 *(unsigned int *)arg_ptr
= val
;
109 if(max_len
> 0) //max_len of 0 performs no copy at all
110 argstrcpy2(++cp
, (char *)arg_ptr
, max_len
);
111 else if(max_len
== -1)
112 argstrcpy(++cp
, (char *)arg_ptr
);
119 /* Skip over current arg */
120 while(!isargsep(*args
)) args
++;
122 /* Skip leading white space (catch end of args) */
123 while(*args
&& isargsep(*args
)) args
++;
132 if (c
== ' ' || c
== '\0' || c
== '\t')
145 while (!isargsep(*from
)) {
161 while (!isargsep(*from
) && i
< maxlen
) {
174 unsigned int radix
, intval
;
197 case '0': case '1': case '2': case '3':
198 case '4': case '5': case '6': case '7':
208 } else if (intval
>= radix
) {
216 ((c
>= '0') && (c
<= ('9' - (10 - radix
))))) {
218 } else if ((radix
== 16) &&
219 ((c
>= '0') && (c
<= '9'))) {
221 } else if ((radix
== 16) &&
222 ((c
>= 'a') && (c
<= 'f'))) {
224 } else if ((radix
== 16) &&
225 ((c
>= 'A') && (c
<= 'F'))) {
227 } else if (c
== 'k' || c
== 'K') {
230 } else if (c
== 'm' || c
== 'M') {
233 } else if (c
== 'g' || c
== 'G') {
234 sign
*= 1024 * 1024 * 1024;
244 if (!isargsep(c
) && !isargsep(*s
))
246 *val
= intval
* sign
;