[BACK]Return to bootxx.c CVS log [TXT][DIR] Up to [local] / sys / arch / mvmeppc / stand / bootxx

Annotation of sys/arch/mvmeppc/stand/bootxx/bootxx.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: bootxx.c,v 1.2 2002/03/14 03:15:58 millert Exp $ */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 1994 Paul Kranenburg
        !             5:  * All rights reserved.
        !             6:  *
        !             7:  * Redistribution and use in source and binary forms, with or without
        !             8:  * modification, are permitted provided that the following conditions
        !             9:  * are met:
        !            10:  * 1. Redistributions of source code must retain the above copyright
        !            11:  *    notice, this list of conditions and the following disclaimer.
        !            12:  * 2. Redistributions in binary form must reproduce the above copyright
        !            13:  *    notice, this list of conditions and the following disclaimer in the
        !            14:  *    documentation and/or other materials provided with the distribution.
        !            15:  * 3. All advertising materials mentioning features or use of this software
        !            16:  *    must display the following acknowledgement:
        !            17:  *      This product includes software developed by Paul Kranenburg.
        !            18:  * 4. The name of the author may not be used to endorse or promote products
        !            19:  *    derived from this software without specific prior written permission
        !            20:  *
        !            21:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            22:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        !            23:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            24:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
        !            25:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
        !            26:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        !            27:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
        !            28:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        !            29:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
        !            30:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        !            31:  */
        !            32:
        !            33: /*
        !            34:  * This is a generic "first-stage" boot program.
        !            35:  *
        !            36:  * Note that this program has absolutely no filesystem knowledge!
        !            37:  *
        !            38:  * Instead, this uses a table of disk block numbers that are
        !            39:  * filled in by the installboot program such that this program
        !            40:  * can load the "second-stage" boot program.
        !            41:  */
        !            42:
        !            43: #include <sys/param.h>
        !            44: #include <sys/time.h>
        !            45: #include <sys/exec.h>
        !            46: #include <machine/prom.h>
        !            47:
        !            48: #include "stand.h"
        !            49: #include "libsa.h"
        !            50:
        !            51: /*
        !            52:  * Boot device is derived from ROM provided information.
        !            53:  */
        !            54:
        !            55: /* This determines the largest boot program we can load. */
        !            56: #define MAXBLOCKNUM    64
        !            57:
        !            58: /*
        !            59:  * These three names are known by installboot.
        !            60:  * The block_table contains starting block numbers,
        !            61:  * in terms of 512-byte blocks.  Each non-zero value
        !            62:  * will result in a read of block_size bytes.
        !            63:  */
        !            64: int            block_size = 512;       /* default */
        !            65: int            block_count = MAXBLOCKNUM;      /* length of table */
        !            66: daddr_t        block_table[MAXBLOCKNUM] = { 0 };
        !            67:
        !            68: extern         char *version;
        !            69:
        !            70:
        !            71: main()
        !            72: {
        !            73:        struct open_file        f;
        !            74:        char    *addr;
        !            75:        int n, error;
        !            76:
        !            77:        bootdev_type = BUGDEV_DISK;
        !            78:
        !            79:        printf("Boot: bug device: ctrl=%d, dev=%d\n",
        !            80:                bugargs.ctrl_lun, bugargs.dev_lun);
        !            81:        printf("\nbootxx: first level bootstrap program [%s]\n\n", version);
        !            82:
        !            83:        f.f_flags = F_RAW;
        !            84:        if (devopen(&f, 0, &addr)) {
        !            85:                printf("bootxx: open failed\n");
        !            86:                _rtt();
        !            87:        }
        !            88:
        !            89:        addr = (char *)STAGE2_RELOC;
        !            90:        error = copyboot(&f, addr);
        !            91:        f.f_dev->dv_close(&f);
        !            92:        if (!error) {
        !            93:                bugexec((void (*)())addr);
        !            94:        }
        !            95:        /* copyboot had a problem... */
        !            96:        _rtt();
        !            97: }
        !            98:
        !            99: int
        !           100: copyboot(fp, addr)
        !           101:        struct open_file        *fp;
        !           102:        char                    *addr;
        !           103: {
        !           104:        int     n, i, blknum;
        !           105:        struct exec *x;
        !           106:
        !           107:        addr -= sizeof(struct exec); /* assume OMAGIC, verify below */
        !           108:        x = (struct exec *)addr;
        !           109:
        !           110:        if (!block_count) {
        !           111:                printf("bootxx: no data!?!\n");
        !           112:                return -1;
        !           113:        }
        !           114:
        !           115:        for (i = 0; i < block_count; i++) {
        !           116:
        !           117:                if ((blknum = block_table[i]) == 0)
        !           118:                        break;
        !           119:
        !           120: #ifdef DEBUG
        !           121:                printf("bootxx: read block # %d = %d\n", i, blknum);
        !           122: #endif
        !           123:                if ((fp->f_dev->dv_strategy)(fp->f_devdata, F_READ,
        !           124:                                           blknum, block_size, addr, &n))
        !           125:                {
        !           126:                        printf("bootxx: read failed\n");
        !           127:                        return -1;
        !           128:                }
        !           129:                if (n != block_size) {
        !           130:                        printf("bootxx: short read\n");
        !           131:                        return -1;
        !           132:                }
        !           133:                addr += block_size;
        !           134:        }
        !           135:
        !           136:        if (N_GETMAGIC(*x) != OMAGIC) {
        !           137:                printf("bootxx: secondary bootstrap isn't in OMAGIC format\n");
        !           138:                return(-1);
        !           139:        }
        !           140:
        !           141:        return 0;
        !           142: }

CVSweb