Annotation of src/sys/arch/vax/boot/boot/rom.c, Revision 1.1
1.1 ! ragge 1: /* $NetBSD: rom.c,v 1.1 1996/08/02 11:22:21 ragge Exp $ */
! 2: /*
! 3: * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
! 4: * All rights reserved.
! 5: *
! 6: * This code is derived from software contributed to Ludd by
! 7: * Bertram Barth.
! 8: *
! 9: * Redistribution and use in source and binary forms, with or without
! 10: * modification, are permitted provided that the following conditions
! 11: * are met:
! 12: * 1. Redistributions of source code must retain the above copyright
! 13: * notice, this list of conditions and the following disclaimer.
! 14: * 2. Redistributions in binary form must reproduce the above copyright
! 15: * notice, this list of conditions and the following disclaimer in the
! 16: * documentation and/or other materials provided with the distribution.
! 17: * 3. All advertising materials mentioning features or use of this software
! 18: * must display the following acknowledgement:
! 19: * This product includes software developed at Ludd, University of
! 20: * Lule}, Sweden and its contributors.
! 21: * 4. The name of the author may not be used to endorse or promote products
! 22: * derived from this software without specific prior written permission
! 23: *
! 24: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 25: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 26: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 27: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 28: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 29: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 30: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 31: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 32: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 33: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 34: */
! 35:
! 36: #include "sys/param.h"
! 37: #include "sys/reboot.h"
! 38: #include "sys/disklabel.h"
! 39:
! 40: #include "lib/libsa/stand.h"
! 41: #include "lib/libsa/ufs.h"
! 42:
! 43: #include "../include/pte.h"
! 44: #include "../include/sid.h"
! 45: #include "../include/mtpr.h"
! 46: #include "../include/reg.h"
! 47: #include "../include/rpb.h"
! 48:
! 49: #include "data.h"
! 50: #include "vaxstand.h"
! 51:
! 52: extern unsigned *bootregs;
! 53: extern struct rpb *rpb;
! 54:
! 55: struct rom_softc {
! 56: int part;
! 57: int unit;
! 58: };
! 59:
! 60: int romstrategy(), romopen();
! 61: struct disklabel romlabel;
! 62: struct rom_softc rom_softc;
! 63: char io_buf[MAXBSIZE];
! 64:
! 65: romopen(f, adapt, ctlr, unit, part)
! 66: struct open_file *f;
! 67: int ctlr, unit, part;
! 68: {
! 69: char *msg;
! 70: struct disklabel *lp = &romlabel;
! 71: volatile struct rom_softc *rsc = &rom_softc;
! 72: int i,err;
! 73:
! 74: bootregs[11] = XXRPB;
! 75: rpb = (void*)XXRPB;
! 76: bqo = (void*)rpb->iovec;
! 77:
! 78: if (rpb->unit > 0 && (rpb->unit % 100) == 0) {
! 79: printf ("changing rpb->unit from %d ", rpb->unit);
! 80: rpb->unit /= 100;
! 81: printf ("to %d\n", rpb->unit);
! 82: }
! 83:
! 84: bzero(lp, sizeof(struct disklabel));
! 85: rsc->unit = unit;
! 86: rsc->part = part;
! 87:
! 88: err = romstrategy(rsc, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i);
! 89: if (err) {
! 90: printf("reading disklabel: %s\n",strerror(err));
! 91: return 0;
! 92: }
! 93: msg = getdisklabel(io_buf+LABELOFFSET, lp);
! 94: if (msg)
! 95: printf("getdisklabel: %s\n",msg);
! 96: f->f_devdata = (void*)rsc;
! 97: return(0);
! 98: }
! 99:
! 100: romstrategy (rsc, func, dblk, size, buf, rsize)
! 101: struct rom_softc *rsc;
! 102: int func;
! 103: daddr_t dblk;
! 104: char *buf;
! 105: int size, *rsize;
! 106: {
! 107: struct disklabel *lp;
! 108: int block;
! 109:
! 110: lp = &romlabel;
! 111: block = dblk + lp->d_partitions[rsc->part].p_offset;
! 112: if (rsc->unit >= 0 && rsc->unit < 10)
! 113: rpb->unit = rsc->unit;
! 114:
! 115: if (func == F_WRITE)
! 116: romwrite_uvax(block, size, buf, bootregs);
! 117: else
! 118: romread_uvax(block, size, buf, bootregs);
! 119:
! 120: *rsize = size;
! 121: return 0;
! 122: }
! 123:
CVSweb <webmaster@jp.NetBSD.org>