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

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

1.1     ! nbrk        1: /*     $OpenBSD: bootxx.c,v 1.6 2006/05/16 22:52:09 miod 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: size_t         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: int    copyboot(struct open_file *, char *);
        !            71:
        !            72: int
        !            73: main()
        !            74: {
        !            75:        struct open_file f;
        !            76:        char *addr;
        !            77:        int error;
        !            78:
        !            79:        printf("\nbootxx: first level bootstrap program [%s]\n", version);
        !            80: #ifdef DEBUG
        !            81:        printf("boot device: ctrl=%d, dev=%d\n",
        !            82:                bugargs.ctrl_lun, bugargs.dev_lun);
        !            83: #endif
        !            84:
        !            85:        f.f_flags = F_RAW;
        !            86:        if (devopen(&f, 0, &addr)) {
        !            87:                printf("bootxx: open failed\n");
        !            88:                _rtt();
        !            89:        }
        !            90:
        !            91:        addr = (char *)STAGE2_RELOC;
        !            92:        error = copyboot(&f, addr);
        !            93:        f.f_dev->dv_close(&f);
        !            94:        if (!error) {
        !            95:                bugexec((void (*)())addr + 8);
        !            96:        }
        !            97:        /* copyboot had a problem... */
        !            98:        _rtt();
        !            99:        return (0);
        !           100: }
        !           101:
        !           102: int
        !           103: copyboot(struct open_file *fp, char *addr)
        !           104: {
        !           105:        size_t n;
        !           106:        int i, blknum;
        !           107:        struct exec *x;
        !           108:
        !           109:        addr -= sizeof(struct exec); /* assume OMAGIC, verify below */
        !           110:        x = (struct exec *)addr;
        !           111:
        !           112:        if (!block_count) {
        !           113:                printf("bootxx: no data!?!\n");
        !           114:                return -1;
        !           115:        }
        !           116:
        !           117:        for (i = 0; i < block_count; i++) {
        !           118:
        !           119:                if ((blknum = block_table[i]) == 0)
        !           120:                        break;
        !           121:
        !           122: #ifdef DEBUG
        !           123:                printf("bootxx: read block # %d = %d\n", i, blknum);
        !           124: #endif
        !           125:                if ((fp->f_dev->dv_strategy)(fp->f_devdata, F_READ,
        !           126:                    blknum, block_size, addr, &n)) {
        !           127:                        printf("bootxx: read failed\n");
        !           128:                        return -1;
        !           129:                }
        !           130:                if (n != block_size) {
        !           131:                        printf("bootxx: short read\n");
        !           132:                        return -1;
        !           133:                }
        !           134:                addr += block_size;
        !           135:        }
        !           136:
        !           137:        if (N_GETMAGIC(*x) != OMAGIC) {
        !           138:                printf("bootxx: secondary bootstrap isn't in OMAGIC format\n");
        !           139:                return(-1);
        !           140:        }
        !           141:
        !           142:        return 0;
        !           143: }

CVSweb