[BACK]Return to bootconfig.c CVS log [TXT][DIR] Up to [local] / sys / arch / arm / arm

Annotation of sys/arch/arm/arm/bootconfig.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: bootconfig.c,v 1.1 2004/02/01 05:09:48 drahn Exp $    */
                      2: /*     $NetBSD: bootconfig.c,v 1.2 2002/03/10 19:56:39 lukem Exp $     */
                      3:
                      4: /*
                      5:  * Copyright (c) 1994-1998 Mark Brinicombe.
                      6:  * Copyright (c) 1994 Brini.
                      7:  * All rights reserved.
                      8:  *
                      9:  * This code is derived from software written for Brini by Mark Brinicombe
                     10:  *
                     11:  * Redistribution and use in source and binary forms, with or without
                     12:  * modification, are permitted provided that the following conditions
                     13:  * are met:
                     14:  * 1. Redistributions of source code must retain the above copyright
                     15:  *    notice, this list of conditions and the following disclaimer.
                     16:  * 2. Redistributions in binary form must reproduce the above copyright
                     17:  *    notice, this list of conditions and the following disclaimer in the
                     18:  *    documentation and/or other materials provided with the distribution.
                     19:  * 3. All advertising materials mentioning features or use of this software
                     20:  *    must display the following acknowledgement:
                     21:  *     This product includes software developed by Mark Brinicombe
                     22:  *     for the NetBSD Project.
                     23:  * 4. The name of the company nor the name of the author may be used to
                     24:  *    endorse or promote products derived from this software without specific
                     25:  *    prior written permission.
                     26:  *
                     27:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
                     28:  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
                     29:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     30:  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
                     31:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     32:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     33:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     34:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     35:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     36:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     37:  * SUCH DAMAGE.
                     38:  */
                     39:
                     40: #include <sys/param.h>
                     41:
                     42: #include <sys/systm.h>
                     43:
                     44: #include <machine/bootconfig.h>
                     45:
                     46: #include "rd.h"
                     47:
                     48: /*
                     49:  * Function to identify and process different types of boot argument
                     50:  */
                     51:
                     52: int
                     53: get_bootconf_option(opts, opt, type, result)
                     54:        char *opts;
                     55:        char *opt;
                     56:        int type;
                     57:        void *result;
                     58: {
                     59:        char *ptr;
                     60:        char *optstart;
                     61:        int not;
                     62:
                     63:        ptr = opts;
                     64:
                     65:        while (*ptr) {
                     66:                /* Find start of option */
                     67:                while (*ptr == ' ' || *ptr == '\t')
                     68:                        ++ptr;
                     69:
                     70:                if (*ptr == 0)
                     71:                        break;
                     72:
                     73:                not = 0;
                     74:
                     75:                /* Is it a negate option */
                     76:                if ((type & BOOTOPT_TYPE_MASK) == BOOTOPT_TYPE_BOOLEAN && *ptr == '!') {
                     77:                        not = 1;
                     78:                        ++ptr;
                     79:                }
                     80:
                     81:                /* Find the end of option */
                     82:                optstart = ptr;
                     83:                while (*ptr != 0 && *ptr != ' ' && *ptr != '\t' && *ptr != '=')
                     84:                        ++ptr;
                     85:
                     86:                if ((*ptr == '=')
                     87:                    || (*ptr != '=' && ((type & BOOTOPT_TYPE_MASK) == BOOTOPT_TYPE_BOOLEAN))) {
                     88:                        /* compare the option */
                     89:                        if (strncmp(optstart, opt, (ptr - optstart)) == 0) {
                     90:                                /* found */
                     91:
                     92:                                if (*ptr == '=')
                     93:                                        ++ptr;
                     94:
                     95: #if 0
                     96: /* BELCH */
                     97:                                switch(type & BOOTOPT_TYPE_MASK) {
                     98:                                case BOOTOPT_TYPE_BOOLEAN :
                     99:                                        if (*(ptr - 1) == '=')
                    100:                                                *((int *)result) = ((u_int)strtoul(ptr, NULL, 10) != 0);
                    101:                                        else
                    102:                                                *((int *)result) = !not;
                    103:                                        break;
                    104:                                case BOOTOPT_TYPE_STRING :
                    105:                                        *((char **)result) = ptr;
                    106:                                        break;
                    107:                                case BOOTOPT_TYPE_INT :
                    108:                                        *((int *)result) = (u_int)strtoul(ptr, NULL, 10);
                    109:                                        break;
                    110:                                case BOOTOPT_TYPE_BININT :
                    111:                                        *((int *)result) = (u_int)strtoul(ptr, NULL, 2);
                    112:                                        break;
                    113:                                case BOOTOPT_TYPE_HEXINT :
                    114:                                        *((int *)result) = (u_int)strtoul(ptr, NULL, 16);
                    115:                                        break;
                    116:                                default:
                    117:                                        return(0);
                    118:                                }
                    119: #endif
                    120:                                return(1);
                    121:                        }
                    122:                }
                    123:                /* skip to next option */
                    124:                while (*ptr != ' ' && *ptr != '\t' && *ptr != 0)
                    125:                        ++ptr;
                    126:        }
                    127:        return(0);
                    128: }

CVSweb