1998-10-22 00:16:33 +04:00
|
|
|
/* $NetBSD: bootxx.c,v 1.14 1998/10/21 20:16:33 ragge Exp $ */
|
1995-03-30 01:23:59 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1982, 1986 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* @(#)boot.c 7.15 (Berkeley) 5/4/91
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sys/param.h"
|
|
|
|
#include "sys/reboot.h"
|
1995-04-25 18:14:19 +04:00
|
|
|
#include "sys/disklabel.h"
|
|
|
|
|
1995-03-30 01:23:59 +04:00
|
|
|
#include "lib/libsa/stand.h"
|
|
|
|
#include "lib/libsa/ufs.h"
|
1995-04-25 18:14:19 +04:00
|
|
|
|
1995-03-30 01:23:59 +04:00
|
|
|
#include "../include/pte.h"
|
|
|
|
#include "../include/sid.h"
|
|
|
|
#include "../include/mtpr.h"
|
1995-09-16 17:01:06 +04:00
|
|
|
#include "../include/reg.h"
|
1995-10-20 16:35:41 +03:00
|
|
|
#include "../include/rpb.h"
|
1995-09-16 17:01:06 +04:00
|
|
|
|
1996-02-17 21:23:18 +03:00
|
|
|
#include "../mba/mbareg.h"
|
|
|
|
#include "../mba/hpreg.h"
|
|
|
|
|
1996-07-15 15:11:01 +04:00
|
|
|
#define NRSP 1 /* Kludge */
|
|
|
|
#define NCMD 1 /* Kludge */
|
|
|
|
|
1995-09-16 17:01:06 +04:00
|
|
|
#include "../uba/ubareg.h"
|
|
|
|
#include "../uba/udareg.h"
|
1996-07-15 15:11:01 +04:00
|
|
|
|
|
|
|
#include "../mscp/mscp.h"
|
|
|
|
#include "../mscp/mscpreg.h"
|
1995-04-25 18:14:19 +04:00
|
|
|
|
1995-03-30 01:23:59 +04:00
|
|
|
#include "data.h"
|
1995-04-25 18:14:19 +04:00
|
|
|
#include "vaxstand.h"
|
1995-03-30 01:23:59 +04:00
|
|
|
|
|
|
|
#include <a.out.h>
|
|
|
|
|
1996-08-02 15:21:41 +04:00
|
|
|
int romstrategy(), romopen();
|
1995-09-16 17:01:06 +04:00
|
|
|
int command(int, int);
|
1995-04-25 18:14:19 +04:00
|
|
|
|
1995-03-30 01:23:59 +04:00
|
|
|
/*
|
1995-09-16 17:01:06 +04:00
|
|
|
* Boot program... argume passed in r10 and r11 determine whether boot
|
1995-04-25 18:14:19 +04:00
|
|
|
* stops to ask for system name and which device boot comes from.
|
1995-03-30 01:23:59 +04:00
|
|
|
*/
|
|
|
|
|
1995-04-25 18:14:19 +04:00
|
|
|
volatile u_int devtype, bootdev;
|
1997-03-22 15:47:27 +03:00
|
|
|
unsigned opendev, boothowto, bootset, memsz;
|
1995-03-30 01:23:59 +04:00
|
|
|
|
1996-08-02 15:21:41 +04:00
|
|
|
extern unsigned *bootregs;
|
|
|
|
extern struct rpb *rpb;
|
|
|
|
|
1997-03-15 16:04:22 +03:00
|
|
|
/*
|
|
|
|
* The boot block are used by 11/750, 8200, MicroVAX II/III, VS2000,
|
|
|
|
* VS3100/??, VS4000 and VAX6000/???, and only when booting from disk.
|
|
|
|
*/
|
1996-08-02 15:21:41 +04:00
|
|
|
Xmain()
|
1995-03-30 01:23:59 +04:00
|
|
|
{
|
1995-09-16 17:01:06 +04:00
|
|
|
int io;
|
1996-08-02 15:21:41 +04:00
|
|
|
char *scbb;
|
|
|
|
char *new;
|
1995-09-16 17:01:06 +04:00
|
|
|
char *hej = "/boot";
|
|
|
|
|
1996-08-02 15:21:41 +04:00
|
|
|
switch (vax_cputype) {
|
1995-09-16 17:01:06 +04:00
|
|
|
|
1997-04-11 01:25:18 +04:00
|
|
|
case VAX_TYP_UV2:
|
|
|
|
case VAX_TYP_CVAX:
|
|
|
|
case VAX_TYP_RIGEL:
|
|
|
|
case VAX_TYP_NVAX:
|
|
|
|
case VAX_TYP_SOC:
|
1996-08-02 15:21:41 +04:00
|
|
|
/*
|
|
|
|
* now relocate rpb/bqo (which are used by ROM-routines)
|
|
|
|
*/
|
|
|
|
rpb = (void*)XXRPB;
|
|
|
|
bcopy ((void*)bootregs[11], rpb, 512);
|
|
|
|
rpb->rpb_base = rpb;
|
|
|
|
bqo = (void*)(512+(int)rpb);
|
|
|
|
bcopy ((void*)rpb->iovec, bqo, rpb->iovecsz);
|
|
|
|
rpb->iovec = (int)bqo;
|
|
|
|
bootregs[11] = (int)rpb;
|
1997-03-15 16:04:22 +03:00
|
|
|
bootdev = rpb->devtyp;
|
1997-03-22 15:47:27 +03:00
|
|
|
memsz = rpb->pfncnt << 9;
|
1996-08-02 15:21:41 +04:00
|
|
|
|
1995-09-16 17:01:06 +04:00
|
|
|
break;
|
1996-07-15 15:11:01 +04:00
|
|
|
case VAX_8200:
|
1995-09-16 17:01:06 +04:00
|
|
|
case VAX_750:
|
1995-04-25 18:14:19 +04:00
|
|
|
bootdev = bootregs[10];
|
1997-03-22 15:47:27 +03:00
|
|
|
memsz = 0;
|
1995-09-16 17:01:06 +04:00
|
|
|
|
|
|
|
break;
|
1996-07-15 15:11:01 +04:00
|
|
|
default:
|
1998-03-20 19:36:20 +03:00
|
|
|
nprint(vax_cputype, 10);
|
|
|
|
sprint(": Unknown CPU type, regs:\n");
|
|
|
|
for (io = 0; io < 16; io++) {
|
|
|
|
nprint(bootregs[io], 16);
|
|
|
|
putchar('\n');
|
|
|
|
}
|
1996-07-15 15:11:01 +04:00
|
|
|
asm("halt");
|
1995-09-16 17:01:06 +04:00
|
|
|
}
|
|
|
|
|
1995-04-25 18:14:19 +04:00
|
|
|
bootset = getbootdev();
|
|
|
|
|
1998-03-20 19:36:20 +03:00
|
|
|
sprint("\nhowto 0x");
|
|
|
|
nprint(boothowto, 16);
|
|
|
|
sprint(", bdev 0x");
|
|
|
|
nprint(bootdev, 16);
|
|
|
|
sprint(", booting...");
|
1995-09-16 17:01:06 +04:00
|
|
|
io = open(hej, 0);
|
|
|
|
|
1995-03-30 01:23:59 +04:00
|
|
|
if (io >= 0 && io < SOPEN_MAX) {
|
|
|
|
copyunix(io);
|
|
|
|
} else {
|
1998-03-20 19:36:20 +03:00
|
|
|
sprint("Boot failed, saerrno ");
|
|
|
|
nprint(errno, 10);
|
|
|
|
putchar('\n');
|
1995-03-30 01:23:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-04-25 18:14:19 +04:00
|
|
|
/* ARGSUSED */
|
1995-03-30 01:23:59 +04:00
|
|
|
copyunix(aio)
|
|
|
|
{
|
1995-04-25 18:14:19 +04:00
|
|
|
struct exec x;
|
|
|
|
register int io = aio, i;
|
|
|
|
char *addr;
|
1995-03-30 01:23:59 +04:00
|
|
|
|
1995-04-25 18:14:19 +04:00
|
|
|
i = read(io, (char *) &x, sizeof(x));
|
1995-03-30 01:23:59 +04:00
|
|
|
if (i != sizeof(x) || N_BADMAG(x)) {
|
1998-03-20 19:36:20 +03:00
|
|
|
sprint("Bad format\n");
|
1995-03-30 01:23:59 +04:00
|
|
|
return;
|
|
|
|
}
|
1997-06-08 21:49:15 +04:00
|
|
|
|
1995-04-25 18:14:19 +04:00
|
|
|
if (N_GETMAGIC(x) == ZMAGIC && lseek(io, N_TXTADDR(x), SEEK_SET) == -1)
|
1995-03-30 01:23:59 +04:00
|
|
|
goto shread;
|
1995-04-25 18:14:19 +04:00
|
|
|
if (read(io, (char *) 0x10000, x.a_text) != x.a_text)
|
1995-03-30 01:23:59 +04:00
|
|
|
goto shread;
|
1995-04-25 18:14:19 +04:00
|
|
|
addr = (char *) x.a_text;
|
1995-03-30 01:23:59 +04:00
|
|
|
if (N_GETMAGIC(x) == ZMAGIC || N_GETMAGIC(x) == NMAGIC)
|
1995-04-25 18:14:19 +04:00
|
|
|
while ((int) addr & CLOFSET)
|
1995-03-30 01:23:59 +04:00
|
|
|
*addr++ = 0;
|
1997-06-08 21:49:15 +04:00
|
|
|
|
1995-04-25 18:14:19 +04:00
|
|
|
if (read(io, addr + 0x10000, x.a_data) != x.a_data)
|
1995-03-30 01:23:59 +04:00
|
|
|
goto shread;
|
|
|
|
addr += x.a_data;
|
1995-04-25 18:14:19 +04:00
|
|
|
bcopy((void *) 0x10000, 0, (int) addr);
|
1997-06-08 21:49:15 +04:00
|
|
|
|
1995-03-30 01:23:59 +04:00
|
|
|
for (i = 0; i < x.a_bss; i++)
|
|
|
|
*addr++ = 0;
|
1995-04-25 18:14:19 +04:00
|
|
|
for (i = 0; i < 128 * 512; i++) /* slop */
|
1995-03-30 01:23:59 +04:00
|
|
|
*addr++ = 0;
|
1998-03-20 19:36:20 +03:00
|
|
|
sprint("done.\n");
|
1995-03-30 01:23:59 +04:00
|
|
|
hoppabort(x.a_entry, boothowto, bootset);
|
1995-04-25 18:14:19 +04:00
|
|
|
(*((int (*) ()) x.a_entry)) ();
|
1995-03-30 01:23:59 +04:00
|
|
|
return;
|
|
|
|
shread:
|
1998-03-20 19:36:20 +03:00
|
|
|
sprint("Short read\n");
|
1995-03-30 01:23:59 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
getbootdev()
|
|
|
|
{
|
1997-03-15 16:04:22 +03:00
|
|
|
int i, adaptor, controller, unit, partition, retval;
|
1995-03-30 01:23:59 +04:00
|
|
|
|
1997-03-15 16:04:22 +03:00
|
|
|
adaptor = controller = unit = partition = 0;
|
1995-09-16 17:01:06 +04:00
|
|
|
|
1996-08-02 15:21:41 +04:00
|
|
|
switch (vax_cputype) {
|
1997-04-11 01:25:18 +04:00
|
|
|
case VAX_TYP_UV2:
|
|
|
|
case VAX_TYP_CVAX:
|
1995-09-16 17:01:06 +04:00
|
|
|
adaptor = 0;
|
|
|
|
controller = ((rpb->csrphy & 017777) == 0xDC)?1:0;
|
|
|
|
unit = rpb->unit; /* DUC, DUD? */
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
1997-04-11 01:25:18 +04:00
|
|
|
case VAX_TYP_RIGEL:
|
|
|
|
unit = rpb->unit;
|
|
|
|
if (unit > 99)
|
|
|
|
unit /= 100; /* DKB300 is target 3 */
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case VAX_TYP_8SS:
|
1998-10-22 00:16:33 +04:00
|
|
|
controller = bootregs[1];
|
|
|
|
unit = bootregs[3];
|
|
|
|
break;
|
|
|
|
|
1997-04-11 01:25:18 +04:00
|
|
|
case VAX_TYP_750:
|
1995-09-16 17:01:06 +04:00
|
|
|
controller = 0; /* XXX Actually massbuss can be on 3 ctlr's */
|
|
|
|
unit = bootregs[3];
|
|
|
|
break;
|
1995-03-30 01:23:59 +04:00
|
|
|
}
|
1995-09-16 17:01:06 +04:00
|
|
|
|
1997-03-15 16:04:22 +03:00
|
|
|
switch (B_TYPE(bootdev)) {
|
|
|
|
case BDEV_HP: /* massbuss boot */
|
1995-04-25 18:14:19 +04:00
|
|
|
adaptor = (bootregs[1] & 0x6000) >> 17;
|
1995-03-30 01:23:59 +04:00
|
|
|
break;
|
|
|
|
|
1996-07-15 15:11:01 +04:00
|
|
|
case BDEV_UDA: /* UDA50 boot */
|
1996-08-02 15:21:41 +04:00
|
|
|
if (vax_cputype == VAX_750)
|
1995-04-25 18:14:19 +04:00
|
|
|
adaptor = (bootregs[1] & 0x40000 ? 0 : 1);
|
1995-03-30 01:23:59 +04:00
|
|
|
break;
|
1995-04-25 18:14:19 +04:00
|
|
|
|
1997-03-15 16:04:22 +03:00
|
|
|
case BDEV_TK: /* TK50 boot */
|
|
|
|
case BDEV_CNSL: /* Console storage boot */
|
1997-04-11 01:25:18 +04:00
|
|
|
case BDEV_RD: /* RD/RX on HDC9224 (MV2000) */
|
1997-03-15 16:04:22 +03:00
|
|
|
controller = 0; /* They are always on ctlr 0 */
|
1996-02-17 21:23:18 +03:00
|
|
|
break;
|
|
|
|
|
1998-10-22 00:16:33 +04:00
|
|
|
case BDEV_KDB: /* DSA disk on KDB50 (VAXBI VAXen) */
|
|
|
|
bootdev = (bootdev & ~B_TYPEMASK) | BDEV_UDA;
|
|
|
|
break;
|
|
|
|
|
1997-04-11 01:25:18 +04:00
|
|
|
case BDEV_ST: /* SCSI-tape on NCR5380 (MV2000) */
|
|
|
|
case BDEV_SD: /* SCSI-disk on NCR5380 (3100/76) */
|
|
|
|
/*
|
|
|
|
* No standalone routines for SCSI support yet.
|
|
|
|
* Use rom-routines instead!
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
1995-03-30 01:23:59 +04:00
|
|
|
default:
|
1998-03-20 19:36:20 +03:00
|
|
|
sprint("Unsupported boot device, trying anyway.\n");
|
1995-04-25 18:14:19 +04:00
|
|
|
boothowto |= (RB_SINGLE | RB_ASKNAME);
|
1995-03-30 01:23:59 +04:00
|
|
|
}
|
1997-03-15 16:04:22 +03:00
|
|
|
return MAKEBOOTDEV(bootdev, adaptor, controller, unit, partition);
|
1995-03-30 01:23:59 +04:00
|
|
|
}
|
|
|
|
|
1995-04-25 18:14:19 +04:00
|
|
|
struct devsw devsw[] = {
|
|
|
|
SADEV("rom", romstrategy,nullsys,nullsys, noioctl),
|
1995-03-30 01:23:59 +04:00
|
|
|
};
|
|
|
|
|
1995-04-25 18:14:19 +04:00
|
|
|
int ndevs = (sizeof(devsw) / sizeof(devsw[0]));
|
1995-03-30 01:23:59 +04:00
|
|
|
|
1995-04-25 18:14:19 +04:00
|
|
|
struct fs_ops file_system[] = {
|
|
|
|
{ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat}
|
1995-03-30 01:23:59 +04:00
|
|
|
};
|
|
|
|
|
1995-04-25 18:14:19 +04:00
|
|
|
int nfsys = (sizeof(file_system) / sizeof(struct fs_ops));
|
1995-09-16 17:01:06 +04:00
|
|
|
|
1995-03-30 01:23:59 +04:00
|
|
|
struct disklabel lp;
|
1995-09-16 17:01:06 +04:00
|
|
|
int part_off = 0; /* offset into partition holding /boot */
|
|
|
|
char io_buf[MAXBSIZE];
|
|
|
|
volatile struct uda {
|
1996-07-15 15:11:01 +04:00
|
|
|
struct mscp_1ca uda_ca; /* communications area */
|
1995-09-16 17:01:06 +04:00
|
|
|
struct mscp uda_rsp; /* response packets */
|
|
|
|
struct mscp uda_cmd; /* command packets */
|
|
|
|
} uda;
|
|
|
|
volatile struct udadevice *csr;
|
1995-03-30 01:23:59 +04:00
|
|
|
|
|
|
|
devopen(f, fname, file)
|
1995-04-25 18:14:19 +04:00
|
|
|
struct open_file *f;
|
1995-09-16 17:01:06 +04:00
|
|
|
const char *fname;
|
1995-04-25 18:14:19 +04:00
|
|
|
char **file;
|
1995-03-30 01:23:59 +04:00
|
|
|
{
|
1998-02-28 15:10:13 +03:00
|
|
|
extern char start;
|
1995-04-25 18:14:19 +04:00
|
|
|
char *msg;
|
1995-09-16 17:01:06 +04:00
|
|
|
int i, err, off;
|
|
|
|
char line[64];
|
|
|
|
|
1995-03-30 01:23:59 +04:00
|
|
|
f->f_dev = &devsw[0];
|
1996-02-17 21:23:18 +03:00
|
|
|
*file = (char *)fname;
|
1995-03-30 01:23:59 +04:00
|
|
|
|
1995-09-16 17:01:06 +04:00
|
|
|
/*
|
|
|
|
* On uVAX we need to init [T]MSCP ctlr to be able to use it.
|
|
|
|
*/
|
1997-04-11 01:25:18 +04:00
|
|
|
if (vax_cputype == VAX_TYP_UV2 || vax_cputype == VAX_TYP_CVAX) {
|
1995-09-16 17:01:06 +04:00
|
|
|
switch (bootdev) {
|
1996-07-15 15:11:01 +04:00
|
|
|
case BDEV_UDA: /* MSCP */
|
1997-03-15 16:04:22 +03:00
|
|
|
case BDEV_TK: /* TMSCP */
|
1995-09-16 17:01:06 +04:00
|
|
|
csr = (struct udadevice *)rpb->csrphy;
|
|
|
|
|
|
|
|
csr->udaip = 0; /* Start init */
|
1996-07-15 15:11:01 +04:00
|
|
|
while((csr->udasa & MP_STEP1) == 0);
|
1995-09-16 17:01:06 +04:00
|
|
|
csr->udasa = 0x8000;
|
1996-07-15 15:11:01 +04:00
|
|
|
while((csr->udasa & MP_STEP2) == 0);
|
1995-09-16 17:01:06 +04:00
|
|
|
csr->udasa = (short)(((u_int)&uda)&0xffff) + 8;
|
1996-07-15 15:11:01 +04:00
|
|
|
while((csr->udasa & MP_STEP3) == 0);
|
1995-09-16 17:01:06 +04:00
|
|
|
csr->udasa = 0x10;
|
1996-07-15 15:11:01 +04:00
|
|
|
while((csr->udasa & MP_STEP4) == 0);
|
1995-09-16 17:01:06 +04:00
|
|
|
csr->udasa = 0x0001;
|
|
|
|
|
|
|
|
uda.uda_ca.ca_rspdsc =
|
|
|
|
(int) &uda.uda_rsp.mscp_cmdref;
|
|
|
|
uda.uda_ca.ca_cmddsc =
|
|
|
|
(int) &uda.uda_cmd.mscp_cmdref;
|
1997-03-15 16:04:22 +03:00
|
|
|
if (bootdev == BDEV_TK)
|
1995-09-16 17:01:06 +04:00
|
|
|
uda.uda_cmd.mscp_vcid = 1;
|
|
|
|
command(M_OP_SETCTLRC, 0);
|
|
|
|
uda.uda_cmd.mscp_unit = rpb->unit;
|
|
|
|
command(M_OP_ONLINE, 0);
|
|
|
|
}
|
|
|
|
}
|
1995-03-30 01:23:59 +04:00
|
|
|
|
1995-09-16 17:01:06 +04:00
|
|
|
/*
|
|
|
|
* the disklabel _shall_ be at address LABELOFFSET + RELOC in
|
|
|
|
* phys memory now, no need at all to reread it again.
|
|
|
|
* Actually disklabel is only needed when using hp disks,
|
|
|
|
* but it doesn't hurt to always get it.
|
|
|
|
*/
|
1997-03-15 16:04:22 +03:00
|
|
|
if ((bootdev != BDEV_TK) && (bootdev != BDEV_CNSL)) {
|
1998-02-28 15:10:13 +03:00
|
|
|
msg = getdisklabel(LABELOFFSET + &start, &lp);
|
1998-03-20 19:36:20 +03:00
|
|
|
if (msg) {
|
|
|
|
sprint(msg);
|
|
|
|
putchar('\n');
|
|
|
|
}
|
1995-09-16 17:01:06 +04:00
|
|
|
}
|
1995-03-30 01:23:59 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1995-09-16 17:01:06 +04:00
|
|
|
command(cmd, arg)
|
|
|
|
{
|
|
|
|
volatile int hej;
|
|
|
|
|
|
|
|
uda.uda_cmd.mscp_opcode = cmd;
|
|
|
|
uda.uda_cmd.mscp_modifier = arg;
|
1995-03-30 01:23:59 +04:00
|
|
|
|
1995-09-16 17:01:06 +04:00
|
|
|
uda.uda_cmd.mscp_msglen = MSCP_MSGLEN;
|
|
|
|
uda.uda_rsp.mscp_msglen = MSCP_MSGLEN;
|
|
|
|
uda.uda_ca.ca_rspdsc |= MSCP_OWN|MSCP_INT;
|
|
|
|
uda.uda_ca.ca_cmddsc |= MSCP_OWN|MSCP_INT;
|
|
|
|
hej = csr->udaip;
|
|
|
|
while (uda.uda_ca.ca_rspdsc < 0);
|
1995-03-30 01:23:59 +04:00
|
|
|
|
1995-09-16 17:01:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int curblock = 0;
|
1995-03-30 01:23:59 +04:00
|
|
|
|
1995-04-25 18:14:19 +04:00
|
|
|
romstrategy(sc, func, dblk, size, buf, rsize)
|
1995-09-16 17:01:06 +04:00
|
|
|
void *sc;
|
|
|
|
int func;
|
|
|
|
daddr_t dblk;
|
|
|
|
char *buf;
|
|
|
|
int size, *rsize;
|
1995-03-30 01:23:59 +04:00
|
|
|
{
|
1995-09-16 17:01:06 +04:00
|
|
|
int i;
|
|
|
|
int block = dblk;
|
|
|
|
int nsize = size;
|
|
|
|
|
1996-08-02 15:21:41 +04:00
|
|
|
switch (vax_cputype) {
|
1997-04-11 01:25:18 +04:00
|
|
|
/*
|
|
|
|
* case VAX_TYP_UV2:
|
|
|
|
* case VAX_TYP_CVAX:
|
|
|
|
* case VAX_TYP_RIGEL:
|
|
|
|
*/
|
|
|
|
default:
|
1995-09-16 17:01:06 +04:00
|
|
|
switch (bootdev) {
|
|
|
|
|
1996-07-15 15:11:01 +04:00
|
|
|
case BDEV_UDA: /* MSCP */
|
1995-09-16 17:01:06 +04:00
|
|
|
uda.uda_cmd.mscp_seq.seq_lbn = dblk;
|
|
|
|
uda.uda_cmd.mscp_seq.seq_bytecount = size;
|
1995-10-20 16:35:41 +03:00
|
|
|
uda.uda_cmd.mscp_seq.seq_buffer = (int)buf;
|
1995-09-16 17:01:06 +04:00
|
|
|
uda.uda_cmd.mscp_unit = rpb->unit;
|
|
|
|
command(M_OP_READ, 0);
|
|
|
|
break;
|
1995-03-30 01:23:59 +04:00
|
|
|
|
1997-03-15 16:04:22 +03:00
|
|
|
case BDEV_TK: /* TMSCP */
|
1995-09-16 17:01:06 +04:00
|
|
|
if (dblk < curblock) {
|
|
|
|
uda.uda_cmd.mscp_seq.seq_bytecount =
|
|
|
|
curblock - dblk;
|
|
|
|
command(M_OP_POS, 12);
|
|
|
|
} else {
|
|
|
|
uda.uda_cmd.mscp_seq.seq_bytecount =
|
|
|
|
dblk - curblock;
|
|
|
|
command(M_OP_POS, 4);
|
|
|
|
}
|
|
|
|
curblock = size/512 + dblk;
|
|
|
|
for (i = 0 ; i < size/512 ; i++) {
|
|
|
|
uda.uda_cmd.mscp_seq.seq_lbn = 1;
|
|
|
|
uda.uda_cmd.mscp_seq.seq_bytecount = 512;
|
1995-10-20 16:35:41 +03:00
|
|
|
uda.uda_cmd.mscp_seq.seq_buffer =
|
|
|
|
(int)buf + i * 512;
|
1995-09-16 17:01:06 +04:00
|
|
|
uda.uda_cmd.mscp_unit = rpb->unit;
|
|
|
|
command(M_OP_READ, 0);
|
|
|
|
}
|
|
|
|
break;
|
1997-03-15 16:04:22 +03:00
|
|
|
case BDEV_RD:
|
1997-04-11 01:25:18 +04:00
|
|
|
case BDEV_ST:
|
|
|
|
case BDEV_SD:
|
|
|
|
|
1996-08-02 15:21:41 +04:00
|
|
|
default:
|
|
|
|
romread_uvax(block, size, buf, bootregs);
|
|
|
|
break;
|
1995-03-30 01:23:59 +04:00
|
|
|
|
1995-09-16 17:01:06 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1996-07-15 15:11:01 +04:00
|
|
|
case VAX_8200:
|
1995-09-16 17:01:06 +04:00
|
|
|
case VAX_750:
|
1997-03-15 16:04:22 +03:00
|
|
|
if (bootdev != BDEV_HP) {
|
1995-09-16 17:01:06 +04:00
|
|
|
while (size > 0) {
|
1998-03-20 19:36:20 +03:00
|
|
|
while ((read750(block, bootregs) & 0x01) == 0){
|
|
|
|
sprint("Retrying read bn# ");
|
|
|
|
nprint(block, 10);
|
|
|
|
putchar('\n');
|
|
|
|
}
|
1995-09-16 17:01:06 +04:00
|
|
|
bcopy(0, buf, 512);
|
|
|
|
size -= 512;
|
|
|
|
buf += 512;
|
|
|
|
block++;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
hpread(block, size, buf);
|
|
|
|
break;
|
1995-03-30 01:23:59 +04:00
|
|
|
}
|
1995-09-16 17:01:06 +04:00
|
|
|
|
1995-04-25 18:14:19 +04:00
|
|
|
*rsize = nsize;
|
1995-03-30 01:23:59 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1995-04-25 18:14:19 +04:00
|
|
|
hpread(block, size, buf)
|
|
|
|
char *buf;
|
1995-03-30 01:23:59 +04:00
|
|
|
{
|
1995-04-25 18:14:19 +04:00
|
|
|
volatile struct mba_regs *mr = (void *) bootregs[1];
|
|
|
|
volatile struct hp_drv *hd = (void*)&mr->mba_md[bootregs[3]];
|
|
|
|
struct disklabel *dp = &lp;
|
|
|
|
u_int pfnum, nsize, mapnr, bn, cn, sn, tn;
|
|
|
|
|
|
|
|
pfnum = (u_int) buf >> PGSHIFT;
|
|
|
|
|
|
|
|
for (mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG)
|
1996-02-17 21:23:18 +03:00
|
|
|
*(int *)&mr->mba_map[mapnr++] = PG_V | pfnum++;
|
1995-04-25 18:14:19 +04:00
|
|
|
mr->mba_var = ((u_int) buf & PGOFSET);
|
|
|
|
mr->mba_bc = (~size) + 1;
|
|
|
|
bn = block;
|
|
|
|
cn = bn / dp->d_secpercyl;
|
|
|
|
sn = bn % dp->d_secpercyl;
|
|
|
|
tn = sn / dp->d_nsectors;
|
|
|
|
sn = sn % dp->d_nsectors;
|
|
|
|
hd->hp_dc = cn;
|
|
|
|
hd->hp_da = (tn << 8) | sn;
|
|
|
|
hd->hp_cs1 = HPCS_READ;
|
|
|
|
while (mr->mba_sr & MBASR_DTBUSY);
|
1995-09-16 17:01:06 +04:00
|
|
|
if (mr->mba_sr & MBACR_ABORT){
|
1995-04-25 18:14:19 +04:00
|
|
|
return 1;
|
1995-09-16 17:01:06 +04:00
|
|
|
}
|
1995-03-30 01:23:59 +04:00
|
|
|
return 0;
|
|
|
|
}
|
1998-03-20 19:36:20 +03:00
|
|
|
|
|
|
|
sprint(s)
|
|
|
|
char *s;
|
|
|
|
{
|
|
|
|
while(*s)
|
|
|
|
putchar(*s++);
|
|
|
|
}
|
|
|
|
|
|
|
|
nprint(nr, base)
|
|
|
|
{
|
|
|
|
|
|
|
|
do {
|
|
|
|
putchar("0123456789abcdef"[nr % base]);
|
|
|
|
} while (nr /= base);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
twiddle()
|
|
|
|
{
|
|
|
|
static int pos;
|
|
|
|
|
|
|
|
putchar("|/-\\"[pos++ & 3]);
|
|
|
|
putchar('\b');
|
|
|
|
}
|