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