Remove more unused files.

This commit is contained in:
ragge 1999-06-20 16:00:14 +00:00
parent dc65be6cf8
commit 7a1f65022b
7 changed files with 0 additions and 1869 deletions

View File

@ -1,310 +0,0 @@
/* $NetBSD: consio.c,v 1.12 1999/03/09 12:57:57 ragge Exp $ */
/*
* Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden.
* 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 at Ludd, University of Lule}.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/* All bugs are subject to removal without further notice */
#include "sys/param.h"
#include "../vax/gencons.h"
#include "../include/mtpr.h"
#include "../include/sid.h"
#include "../include/rpb.h"
#include "data.h"
void setup __P((void));
int vax_cputype;
int vax_boardtype;
int is_750;
int is_mvax;
unsigned *bootregs;
struct rpb *rpb;
struct bqo *bqo;
static int (*put_fp) __P((int)) = NULL;
static int (*get_fp) __P((void)) = NULL;
int pr_putchar __P((int c)); /* putchar() using mtpr/mfpr */
int pr_getchar __P((void));
int rom_putchar __P((int c)); /* putchar() using ROM routines */
int rom_getchar __P((void));
static int rom_putc; /* ROM-address of put-routine */
static int rom_getc; /* ROM-address of get-routine */
/* Location of address of KA630 console page */
#define NVR_ADRS 0x200B8024
/* Definitions for various locations in the KA630 console page */
#define KA630_PUTC_POLL 0x20
#define KA630_PUTC 0x24
#define KA630_GETC 0x1C
#define KA630_ROW 0x4C
#define KA630_MINROW 0x4D
#define KA630_MAXROW 0x4E
#define KA630_COL 0x50
#define KA630_MINCOL 0x51
#define KA630_MAXCOL 0x52
/* Pointer to KA630 console page, initialized by ka630_consinit */
unsigned char *ka630_conspage;
/* Function that initializes things for KA630 ROM console I/O */
void ka630_consinit __P((void));
/* Functions that use KA630 ROM for console I/O */
int ka630_rom_putchar __P((int c));
int ka630_rom_getchar __P((void));
putchar(c)
int c;
{
(*put_fp)(c);
if (c == 10)
(*put_fp)(13); /* CR/LF */
}
getchar()
{
int c;
do
c = (*get_fp)() & 0177;
while (c == 17 || c == 19); /* ignore XON/XOFF */
if (c < 96 && c > 64)
c += 32;
return c;
}
/*
* setup() is called out of the startup files (start.s, srt0.s) and
* initializes data which are globally used and is called before main().
*/
void
setup()
{
vax_cputype = (mfpr(PR_SID) >> 24) & 0xFF;
put_fp = pr_putchar; /* Default */
get_fp = pr_getchar;
/*
* according to vax_cputype we initialize vax_boardtype.
*/
switch (vax_cputype) {
case VAX_TYP_UV2:
case VAX_TYP_CVAX:
case VAX_TYP_RIGEL:
case VAX_TYP_MARIAH:
case VAX_TYP_NVAX:
case VAX_TYP_SOC:
is_mvax = 1;
vax_boardtype = (vax_cputype << 24) |
((*(int*)0x20040004 >> 24) & 0377);
rpb = (struct rpb *)bootregs[11]; /* bertram: ??? */
break;
}
/*
* According to the vax_boardtype (vax_cputype is not specific
* enough to do that) we decide which method/routines to use
* for console I/O.
* mtpr/mfpr are restricted to serial consoles, ROM-based routines
* support both serial and graphical consoles.
* We default to mtpr routines; so that we don't crash if
* it isn't a supported system.
*/
switch (vax_boardtype) {
case VAX_BTYP_660:
/* case VAX_BTYP_670: */
case VAX_BTYP_690:
case VAX_BTYP_1303:
put_fp = rom_putchar;
get_fp = rom_getchar;
rom_putc = 0x20040058; /* 537133144 */
rom_getc = 0x20040008; /* 537133064 */
break;
case VAX_BTYP_43:
case VAX_BTYP_49:
case VAX_BTYP_410:
case VAX_BTYP_420:
put_fp = rom_putchar;
get_fp = rom_getchar;
rom_putc = 0x20040058; /* 537133144 */
rom_getc = 0x20040044; /* 537133124 */
break;
case VAX_BTYP_630:
ka630_consinit();
break;
case VAX_BTYP_46:
case VAX_BTYP_48:
put_fp = rom_putchar;
get_fp = rom_getchar;
rom_putc = 0x20040068;
rom_getc = 0x20040054;
break;
#ifdef notdef
case VAX_BTYP_630:
case VAX_BTYP_650:
case VAX_BTYP_9CC:
case VAX_BTYP_60:
put_fp = pr_putchar;
get_fp = pr_getchar;
break
#endif
}
return;
}
/*
* putchar() using MTPR
*/
pr_putchar(c)
int c;
{
int timeout = 1<<15; /* don't hang the machine! */
while ((mfpr(PR_TXCS) & GC_RDY) == 0) /* Wait until xmit ready */
if (--timeout < 0)
break;
mtpr(c, PR_TXDB); /* xmit character */
}
/*
* getchar() using MFPR
*/
pr_getchar()
{
while ((mfpr(PR_RXCS) & GC_DON) == 0); /* wait for char */
return (mfpr(PR_RXDB)); /* now get it */
}
/*
* int rom_putchar (int c) ==> putchar() using ROM-routines
*/
asm("
.globl _rom_putchar
_rom_putchar:
.word 0x04 # save-mask: R2
movl 4(ap), r2 # move argument to R2
jsb *_rom_putc # write it
ret # that's all
");
/*
* int rom_getchar (void) ==> getchar() using ROM-routines
*/
asm("
.globl _rom_getchar
_rom_getchar:
.word 0x02 # save-mask: R1
loop: # do {
jsb *_rom_getc # call the getc-routine
tstl r0 # check if char ready
beql loop # } while (R0 == 0)
movl r1, r0 # R1 holds char
ret # we're done
");
_rtt()
{
asm("halt");
}
/*
* void ka630_rom_getchar (void) ==> initialize KA630 ROM console I/O
*/
void ka630_consinit()
{
register short *NVR;
register int i;
/* Find the console page */
NVR = (short *) NVR_ADRS;
i = *NVR++ & 0xFF;
i |= (*NVR++ & 0xFF) << 8;
i |= (*NVR++ & 0xFF) << 16;
i |= (*NVR++ & 0xFF) << 24;
ka630_conspage = (char *) i;
/* Go to last row to minimize confusion */
ka630_conspage[KA630_ROW] = ka630_conspage[KA630_MAXROW];
ka630_conspage[KA630_COL] = ka630_conspage[KA630_MINCOL];
/* Use KA630 ROM console I/O routines */
put_fp = ka630_rom_putchar;
get_fp = ka630_rom_getchar;
}
/*
* int ka630_rom_getchar (void) ==> getchar() using ROM-routines on KA630
*/
asm("
.globl _ka630_rom_getchar
_ka630_rom_getchar:
.word 0x802 # save-mask: R1, R11
movl _ka630_conspage,r11 # load location of console page
loop630g: # do {
jsb *0x1C(r11) # call the getc-routine (KA630_GETC)
blbc r0, loop630g # } while (R0 == 0)
movl r1, r0 # R1 holds char
ret # we're done
");
/*
* int ka630_rom_putchar (int c) ==> putchar() using ROM-routines on KA630
*/
asm("
.globl _ka630_rom_putchar
_ka630_rom_putchar:
.word 0x802 # save-mask: R1, R11
movl _ka630_conspage,r11 # load location of console page
loop630p: # do {
jsb *0x20(r11) # is rom ready? (KA630_PUTC_POLL)
blbc r0, loop630p # } while (R0 == 0)
movl 4(ap), r1 # R1 holds char
jsb *0x24(r11) # output character (KA630_PUTC)
ret # we're done
");

View File

@ -1,654 +0,0 @@
/* $NetBSD: mfm.c,v 1.2 1997/03/15 13:04:28 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
*
* This code is derived from software contributed to Ludd by
* Bertram Barth.
*
* 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 at Ludd, University of
* Lule}, Sweden and its contributors.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* ToDo:
*
* - insert appropriate delays for diskette-drive where needed
* - allow more than one sector per diskette-read
* - check for and handle bad sectors
* - ???
*/
#include "sys/param.h"
#include "sys/reboot.h"
#include "sys/disklabel.h"
#include "lib/libsa/stand.h"
#include "lib/libsa/ufs.h"
#include "../include/pte.h"
#include "../include/sid.h"
#include "../include/mtpr.h"
#include "../include/reg.h"
#include "../include/rpb.h"
#include "ka410.h"
#include "../vsa/hdc9224.h"
#include "data.h"
#include "vaxstand.h"
#define MAX_WAIT (1000*1000) /* # of loop-instructions in seconds */
struct mfm_softc {
int part;
int unit;
};
int mfmstrategy(), mfmopen();
struct disklabel mfmlabel;
struct mfm_softc mfm_softc;
char io_buf[MAXBSIZE];
/*
* These should probably be somewhere else, but ka410 is the only
* one with mfm disks anyway...
*/
volatile unsigned char *ka410_intreq = (void*)0x2008000f;
volatile unsigned char *ka410_intclr = (void*)0x2008000f;
volatile unsigned char *ka410_intmsk = (void*)0x2008000c;
static volatile struct hdc9224_DKCreg *dkc = (void *) 0x200c0000;
static volatile struct hdc9224_UDCreg sreg; /* input */
static volatile struct hdc9224_UDCreg creg; /* output */
/*
* we have to wait 0.7 usec between two accesses to any of the
* dkc-registers, on a VS2000 with 1 MIPS, this is roughly one
* instruction. Thus the loop-overhead will be enough...
*/
static int
sreg_read()
{
int i;
char *p;
dkc->dkc_cmd = 0x40; /* set internal counter to zero */
p = (void *) &sreg;
for (i = 0; i < 10; i++)
*p++ = dkc->dkc_reg; /* dkc_reg auto-increments */
}
static int
creg_write()
{
int i;
char *p;
dkc->dkc_cmd = 0x40; /* set internal counter to zero */
p = (void *) &creg;
for (i = 0; i < 10; i++)
dkc->dkc_reg = *p++; /* dkc_reg auto-increments */
}
/*
* floppies are handled in a quite strange way by this controller...
*
* before reading/writing a sector from/to floppy, we use the SEEK/READ_ID
* command to place the head at the desired location. Then we wait some
* time before issueing the real command in order to let the drive become
* ready...
*/
int
mfm_rxprepare()
{
int error;
error = mfm_command(DKC_CMD_SEEKREADID | 0x04); /* step=1, verify=0 */
if (error) {
printf("error while stepping to position %d/%d/%x. Retry...\n",
creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl);
error = mfm_command(DKC_CMD_SEEKREADID | 0x04);
}
return error;
}
int
mfm_rxselect(unit)
int unit;
{
int error;
/*
* bring "creg" in some known-to-work state and
* select the drive with the DRIVE SELECT command.
*/
creg.udc_dma7 = 0;
creg.udc_dma15 = 0;
creg.udc_dma23 = 0;
creg.udc_dsect = 1; /* sectors are numbered 1..15 !!! */
creg.udc_dhead = 0;
creg.udc_dcyl = 0;
creg.udc_scnt = 0;
creg.udc_rtcnt = UDC_RC_RX33READ;
creg.udc_mode = UDC_MD_RX33;
creg.udc_term = UDC_TC_FDD;
/*
* this is ...
*/
error = mfm_command(DKC_CMD_DRSEL_RX33 | unit);
if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) {
printf("\nfloppy-drive not ready (new floppy inserted?)\n\n");
creg.udc_rtcnt &= ~UDC_RC_INVRDY; /* clear INVRDY-flag */
error = mfm_command(DKC_CMD_DRSEL_RX33 | unit);
if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) {
printf("diskette not ready(1): %x/%x\n",
error, sreg.udc_dstat);
printf("floppy-drive offline?\n");
return (-1);
}
if (sreg.udc_dstat & UDC_DS_TRK00)
error = mfm_command(DKC_CMD_STEPIN_FDD);
else
error = mfm_command(DKC_CMD_STEPOUT_FDD);
/*
* now ready should be 0, cause INVRDY is not set
* (retrying a command makes this fail...)
*/
if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 1)) {
printf("diskette not ready(2): %x/%x\n",
error, sreg.udc_dstat);
}
creg.udc_rtcnt |= UDC_RC_INVRDY;
error = mfm_command(DKC_CMD_DRSEL_RX33 | unit);
if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) {
printf("diskette not ready(3): %x/%x\n",
error, sreg.udc_dstat);
printf("no floppy inserted or floppy-door open\n");
return (-1);
}
printf("floppy-drive reselected.\n");
}
return (error);
}
int
mfm_rdselect(unit)
int unit;
{
int error;
/*
* bring "creg" in some known-to-work state and
* select the drive with the DRIVE SELECT command.
*/
creg.udc_dma7 = 0;
creg.udc_dma15 = 0;
creg.udc_dma23 = 0;
creg.udc_dsect = 0; /* sectors are numbered 0..16 */
creg.udc_dhead = 0;
creg.udc_dcyl = 0;
creg.udc_scnt = 0;
creg.udc_rtcnt = UDC_RC_HDD_READ;
creg.udc_mode = UDC_MD_HDD;
creg.udc_term = UDC_TC_HDD;
error = mfm_command(DKC_CMD_DRSEL_HDD | unit);
return (error);
}
static int mfm_retry = 0;
int
mfm_command(cmd)
int cmd;
{
int termcode, ready, i;
creg_write(); /* write command-registers */
*ka410_intclr = INTR_DC;
dkc->dkc_cmd = cmd; /* issue command */
for (i = 0; i < MAX_WAIT; i++) {
if (*ka410_intreq & INTR_DC) /* wait for interrupt */
break;
}
if ((*ka410_intreq & INTR_DC) == 0)
printf("timeout in mfm_command...\n");
sreg_read(); /* read status-registers */
if (dkc->dkc_stat == (DKC_ST_DONE | DKC_TC_SUCCESS))
return (0);
if (sreg.udc_cstat & UDC_CS_ECCERR) {
printf(
"\nspurious(?) ECC/CRC error at s%d/t%d/c%d [s%d/t%d/c%d(%d)]\n",
sreg.udc_csect, sreg.udc_chead, sreg.udc_ccyl,
creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl,creg.udc_scnt);
if (sreg.udc_csect != creg.udc_dsect + creg.udc_scnt - 1) {
printf("DMA: %x %x %x [%x]\n",
sreg.udc_dma23, sreg.udc_dma15,
sreg.udc_dma7, 512 * (sreg.udc_csect -
creg.udc_dsect));
creg.udc_scnt = creg.udc_scnt -
(sreg.udc_csect - creg.udc_dsect) - 1;
creg.udc_dsect = sreg.udc_csect + 1;
creg.udc_dma23 = sreg.udc_dma23;
creg.udc_dma15 = sreg.udc_dma15 + 2;
creg.udc_dma7 = 0;
printf("Retry starting from s%d/t%d/c%d (%d). ",
creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl,
creg.udc_scnt);
}
goto retry;
}
termcode = (dkc->dkc_stat & DKC_ST_TERMCOD) >> 3;
ready = sreg.udc_dstat & UDC_DS_READY;
printf("cmd:0x%x: termcode=0x%x, status=0x%x, cstat=0x%x, dstat=0x%x\n",
cmd, termcode, dkc->dkc_stat, sreg.udc_cstat, sreg.udc_dstat);
if (dkc->dkc_stat & DKC_ST_BADSECT)
printf("bad sector found: s%d/t%d/c%d\n", creg.udc_dsect,
creg.udc_dhead, creg.udc_dcyl);
retry:
if ((mfm_retry == 0) && (sreg.udc_cstat & UDC_CS_RETREQ)) {
mfm_retry = 1;
printf("Retrying... ");
mfm_command(cmd);
printf("Retry done.\n");
mfm_retry = 0;
}
return ((dkc->dkc_stat & DKC_ST_TERMCOD) >> 3);
}
/*
* on-disk geometry block
*/
#define _aP __attribute__ ((packed)) /* force byte-alignment */
volatile struct mfm_xbn {
char mbz[10];/* 10 bytes of zero */
long xbn_count _aP; /* number of XBNs */
long dbn_count _aP; /* number of DBNs */
long lbn_count _aP; /* number of LBNs (Logical-Block-Numbers) */
long rbn_count _aP; /* number of RBNs (Replacement-Block-Numbers) */
short nspt; /* number of sectors per track */
short ntracks;/* number of tracks */
short ncylinders; /* number of cylinders */
short precomp;/* first cylinder for write precompensation */
short reduced;/* first cylinder for reduced write current */
short seek_rate; /* seek rate or zero for buffered
* seeks */
short crc_eec;/* 0 if CRC is being used or 1 if ECC is
* being used */
short rct; /* "replacement control table" (RCT) */
short rct_ncopies; /* number of copies of the RCT */
long media_id _aP; /* media identifier */
short interleave; /* sector-to-sector interleave */
short headskew; /* head-to-head skew */
short cylskew;/* cylinder-to-cylinder skew */
short gap0_size; /* size of GAP 0 in the MFM format */
short gap1_size; /* size of GAP 1 in the MFM format */
short gap2_size; /* size of GAP 2 in the MFM format */
short gap3_size; /* size of GAP 3 in the MFM format */
short sync_value; /* sync value used to start a track
* when formatting */
char reserved[32]; /* reserved for use by the RQDX1/2/3
* formatter */
short serial_number; /* serial number */
char fill[412]; /* Filler bytes to the end of the
* block */
short checksum; /* checksum over the XBN */
} mfm_xbn;
#ifdef verbose
display_xbn(p)
struct mfm_xbn *p;
{
printf("**DiskData** XBNs: %d, DBNs: %d, LBNs: %d, RBNs: %d\n",
p->xbn_count, p->dbn_count, p->lbn_count, p->rbn_count);
printf("sect/track: %d, tracks: %d, cyl: %d, precomp/reduced: %d/%d\n",
p->nspt, p->ntracks, p->ncylinders, p->precomp, p->reduced);
printf("seek-rate: %d, crc/eec: %s, RCT: %d, RCT-copies: %d\n",
p->seek_rate, p->crc_eec ? "EEC" : "CRC", p->rct, p->rct_ncopies);
printf("media-ID: 0x%x, interleave: %d, headskew: %d, cylskew: %d\n",
&p->media_id, p->interleave, p->headskew, p->cylskew);
printf("gap0: %d, gap1: %d, gap2: %d, gap3: %d, sync-value: %d\n",
p->gap0_size, p->gap1_size, p->gap2_size, p->gap3_size,
p->sync_value);
printf("serial: %d, checksum: %d, size: %d, reserved: %32c\n",
p->serial_number, p->checksum, sizeof(*p), p->reserved);
}
#endif
mfmopen(f, adapt, ctlr, unit, part)
struct open_file *f;
int ctlr, unit, part;
{
char *msg;
struct disklabel *lp = &mfmlabel;
volatile struct mfm_softc *msc = &mfm_softc;
int i, err;
bzero(lp, sizeof(struct disklabel));
msc->unit = unit;
msc->part = part;
err = mfmstrategy(msc, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i);
if (err) {
printf("reading disklabel: %s\n", strerror(err));
return 0;
}
msg = getdisklabel(io_buf + LABELOFFSET, lp);
if (msg)
printf("getdisklabel: %s\n", msg);
f->f_devdata = (void *) msc;
{
int k;
unsigned char *ucp;
struct mfm_xbn *xp;
/* mfmstrategy(msc, F_READ, -16, 8192, io_buf, &i); */
mfmstrategy(msc, F_READ, -16, 512, io_buf, &i);
#ifdef verbose
printf("dumping raw disk-block #0:\n");
ucp = io_buf;
for (k = 0; k < 128; k++) {
if (ucp[k] < 0x10)
printf("0");
printf("%x ", ucp[k]);
if (k % 8 == 7)
printf(" ");
if (k % 16 == 15)
printf("\n");
}
printf("\n");
xp = (void *) io_buf;
display_xbn(xp);
printf("\n");
#endif
}
if (unit == 2) { /* floppy! */
if (lp->d_ntracks != 2) {
#ifdef verbose
printf("changing number of tracks from %d to %d.\n",
lp->d_ntracks, 2);
#endif
lp->d_ntracks = 2;
}
} else { /* hard-disk */
unsigned short *usp = (void *) io_buf;
#ifdef verbose
printf("label says: s/t/c = %d/%d/%d\n",
lp->d_nsectors, lp->d_ntracks, lp->d_ncylinders);
#endif
if (lp->d_nsectors != usp[13]) {
#ifdef verbose
printf("changing number of sectors from %d to %d.\n",
lp->d_nsectors, usp[13]);
#endif
lp->d_nsectors = usp[13];
}
if (lp->d_ntracks != usp[14]) {
#ifdef verbose
printf("changing number of heads/tracks from %d to %d.\n",
lp->d_ntracks, usp[14]);
#endif
lp->d_ntracks = usp[14];
}
if (lp->d_ncylinders != usp[15]) {
#ifdef verbose
printf("changing number of cylinders from %d to %d.\n",
lp->d_ncylinders, usp[15]);
#endif
lp->d_ncylinders = usp[15];
}
lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks;
}
return (0);
}
mfm_rxstrategy(msc, func, dblk, size, buf, rsize)
struct mfm_softc *msc;
int func;
daddr_t dblk;
char *buf;
int size, *rsize;
{
struct disklabel *lp;
int block, sect, head, cyl, scount, i, cmd, res, sval;
lp = &mfmlabel;
block = (dblk < 0 ? 0 : dblk + lp->d_partitions[msc->part].p_offset);
mfm_rxselect(msc->unit);
/*
* if label is empty, assume RX33
*/
if (lp->d_nsectors == 0)
lp->d_nsectors = 15;
if (lp->d_ntracks == 0)
lp->d_ntracks = 2;
if (lp->d_secpercyl == 0)
lp->d_secpercyl = 30;
bzero((void *) 0x200D0000, size);
scount = size / 512;
while (scount) {
/*
* prepare drive/operation parameter
*/
cyl = block / lp->d_secpercyl;
sect = block % lp->d_secpercyl;
head = sect / lp->d_nsectors;
sect = sect % lp->d_nsectors;
/*
* *rsize = 512; /* one sector after the other
* ...
*/
*rsize = 512 * min(scount, lp->d_nsectors - sect);
/*
* now initialize the register values ...
*/
creg.udc_dma7 = 0;
creg.udc_dma15 = 0;
creg.udc_dma23 = 0;
creg.udc_dsect = sect + 1; /* sectors are numbered 1..15
* !!! */
head |= (cyl >> 4) & 0x70;
creg.udc_dhead = head;
creg.udc_dcyl = cyl;
creg.udc_scnt = *rsize / 512;
if (func == F_WRITE) {
creg.udc_rtcnt = UDC_RC_RX33WRT;
creg.udc_mode = UDC_MD_RX33;
creg.udc_term = UDC_TC_FDD;
mfm_rxprepare();
/* copy from buf */
bcopy(buf, (void *) 0x200D0000, *rsize);
res = mfm_command(DKC_CMD_WRITE_RX33);
} else {
creg.udc_rtcnt = UDC_RC_RX33READ;
creg.udc_mode = UDC_MD_RX33;
creg.udc_term = UDC_TC_FDD;
mfm_rxprepare();
/* clear disk buffer */
bzero((void *) 0x200D0000, *rsize);
res = mfm_command(DKC_CMD_READ_RX33);
/* copy to buf */
bcopy((void *) 0x200D0000, buf, *rsize);
}
scount -= *rsize / 512;
block += *rsize / 512;
buf += *rsize;
}
*rsize = size;
return 0;
}
mfm_rdstrategy(msc, func, dblk, size, buf, rsize)
struct mfm_softc *msc;
int func;
daddr_t dblk;
char *buf;
int size, *rsize;
{
struct disklabel *lp;
int block, sect, head, cyl, scount, i, cmd, res, sval;
lp = &mfmlabel;
block = (dblk < 0 ? 0 : dblk + lp->d_partitions[msc->part].p_offset);
/*
* if label is empty, assume RD32 (XXX this must go away!!!)
*/
if (lp->d_nsectors == 0)
lp->d_nsectors = 17;
if (lp->d_ntracks == 0)
lp->d_ntracks = 6;
if (lp->d_secpercyl == 0)
lp->d_secpercyl = 102;
mfm_rdselect(msc->unit);
bzero((void *) 0x200D0000, size);
scount = size / 512;
while (scount) {
/*
* prepare drive/operation parameter
*/
cyl = block / lp->d_secpercyl;
sect = block % lp->d_secpercyl;
head = sect / lp->d_nsectors;
sect = sect % lp->d_nsectors;
if (dblk < 0) {
#ifdef verbose
printf("using raw diskblock-data!\n");
printf("block %d, dblk %d ==> cyl %d, head %d, sect %d\n",
block, dblk, cyl, sect, head);
#endif
} else
cyl += 1; /* first cylinder is reserved for
* controller! */
*rsize = 512 * min(scount, lp->d_nsectors - sect);
/*
* now re-initialize the register values ...
*/
creg.udc_dma7 = 0;
creg.udc_dma15 = 0;
creg.udc_dma23 = 0;
creg.udc_dsect = sect;
head |= (cyl >> 4) & 0x70;
creg.udc_dhead = head;
creg.udc_dcyl = cyl;
creg.udc_scnt = *rsize / 512;
if (func == F_WRITE) {
creg.udc_rtcnt = UDC_RC_HDD_WRT;
creg.udc_mode = UDC_MD_HDD;
creg.udc_term = UDC_TC_HDD;
cmd = DKC_CMD_WRITE_HDD;
bcopy(buf, (void *) 0x200D0000, *rsize);
res = mfm_command(cmd);
} else {
creg.udc_rtcnt = UDC_RC_HDD_READ;
creg.udc_mode = UDC_MD_HDD;
creg.udc_term = UDC_TC_HDD;
cmd = DKC_CMD_READ_HDD;
bzero((void *) 0x200D0000, *rsize);
res = mfm_command(cmd);
bcopy((void *) 0x200D0000, buf, *rsize);
}
scount -= *rsize / 512;
block += *rsize / 512;
buf += *rsize;
}
/*
* unselect the drive ...
*/
mfm_command(DKC_CMD_DRDESELECT);
*rsize = size;
return 0;
}
int
mfmstrategy(msc, func, dblk, size, buf, rsize)
struct mfm_softc *msc;
int func;
daddr_t dblk;
char *buf;
int size, *rsize;
{
int res = -1;
switch (msc->unit) {
case 0:
case 1:
res = mfm_rdstrategy(msc, func, dblk, size, buf, rsize);
break;
case 2:
res = mfm_rxstrategy(msc, func, dblk, size, buf, rsize);
break;
default:
printf("invalid unit %d in mfmstrategy()\n");
}
return (res);
}

View File

@ -1,278 +0,0 @@
/* $NetBSD: netio.c,v 1.4 1999/05/07 16:19:27 drochner Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* Copyright (c) 1995 Gordon W. Ross
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* 4. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Gordon W. Ross
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* This module implements a "raw device" interface suitable for
* use by the stand-alone I/O library NFS code. This interface
* does not support any "block" access, and exists only for the
* purpose of initializing the network interface, getting boot
* parameters, and performing the NFS mount.
*
* At open time, this does:
*
* find interface - netif_open()
* RARP for IP address - rarp_getipaddress()
* RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...)
* RPC/mountd - nfs_mount(sock, ip, path)
*
* the root file handle from mountd is saved in a global
* for use by the NFS open code (NFS/lookup).
*/
#include <sys/param.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <lib/libkern/libkern.h>
#include "stand.h"
#include "samachdep.h"
#include "net.h"
#include "netif.h"
#include "bootparam.h"
#include "nfs.h"
extern int nfs_root_node[]; /* XXX - get from nfs_mount() */
struct in_addr myip, rootip, gateip;
n_long netmask;
char rootpath[FNAME_SIZE];
int netdev_sock = -1;
static int open_count;
int netio_ask = 0; /* default to bootparam, can override */
static char input_line[100];
/*
* Called by devopen after it sets f->f_dev to our devsw entry.
* This opens the low-level device and sets f->f_devdata.
*/
int
netopen(f, devname)
struct open_file *f;
char *devname; /* Device part of file name (or NULL). */
{
int error = 0;
/* On first open, do netif open, mount, etc. */
if (open_count == 0) {
/* Find network interface. */
if ((netdev_sock = netif_open(devname)) < 0)
return (error=ENXIO);
if ((error = netmountroot(f, devname)) != 0)
return (error);
}
open_count++;
f->f_devdata = nfs_root_node;
return (error);
}
int
netclose(f)
struct open_file *f;
{
/* On last close, do netif close, etc. */
if (open_count > 0)
if (--open_count == 0)
netif_close(netdev_sock);
f->f_devdata = NULL;
}
int
netstrategy(devdata, func, dblk, size, v_buf, rsize)
void *devdata;
int func;
daddr_t dblk;
size_t size;
void *v_buf;
size_t *rsize;
{
*rsize = size;
return EIO;
}
int
netmountroot(f, devname)
struct open_file *f;
char *devname; /* Device part of file name (or NULL). */
{
int error;
struct iodesc *d;
if (netio_ask) {
get_my_ip:
printf("My IP address? ");
bzero(input_line, sizeof(input_line));
gets(input_line);
if ((myip.s_addr = inet_addr(input_line)) ==
htonl(INADDR_NONE)) {
printf("invalid IP address: %s\n", input_line);
goto get_my_ip;
}
get_my_netmask:
printf("My netmask? ");
bzero(input_line, sizeof(input_line));
gets(input_line);
if ((netmask = inet_addr(input_line)) ==
htonl(INADDR_NONE)) {
printf("invalid netmask: %s\n", input_line);
goto get_my_netmask;
}
get_my_gateway:
printf("My gateway? ");
bzero(input_line, sizeof(input_line));
gets(input_line);
if ((gateip.s_addr = inet_addr(input_line)) ==
htonl(INADDR_NONE)) {
printf("invalid IP address: %s\n", input_line);
goto get_my_gateway;
}
get_server_ip:
printf("Server IP address? ");
bzero(input_line, sizeof(input_line));
gets(input_line);
if ((rootip.s_addr = inet_addr(input_line)) ==
htonl(INADDR_NONE)) {
printf("invalid IP address: %s\n", input_line);
goto get_server_ip;
}
get_server_path:
printf("Server path? ");
bzero(rootpath, sizeof(rootpath));
gets(rootpath);
if (rootpath[0] == '\0' || rootpath[0] == '\n')
goto get_server_path;
if ((d = socktodesc(netdev_sock)) == NULL)
return (EMFILE);
d->myip = myip;
goto do_nfs_mount;
}
/*
* Get info for NFS boot: our IP address, our hostname,
* server IP address, and our root path on the server.
* There are two ways to do this: The old, Sun way,
* and the more modern, BOOTP way. (RFC951, RFC1048)
*/
#ifdef SUN_BOOTPARAMS
/* Get boot info using RARP and Sun bootparams. */
/* Get our IP address. (rarp.c) */
if (rarp_getipaddress(netdev_sock) == -1)
return (errno);
printf("boot: client IP address: %s\n", inet_ntoa(myip));
/* Get our hostname, server IP address. */
if (bp_whoami(netdev_sock))
return (errno);
printf("boot: client name: %s\n", hostname);
/* Get the root pathname. */
if (bp_getfile(netdev_sock, "root", &rootip, rootpath))
return (errno);
#else
/* Get boot info using BOOTP way. (RFC951, RFC1048) */
bootp(netdev_sock);
printf("Using IP address: %s\n", inet_ntoa(myip));
printf("myip: %s (%s)", hostname, inet_ntoa(myip));
if (gateip.s_addr)
printf(", gateip: %s", inet_ntoa(gateip));
if (netmask)
printf(", mask: %s", intoa(netmask));
printf("\n");
#endif /* SUN_BOOTPARAMS */
printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath);
do_nfs_mount:
/* Get the NFS file handle (mount). */
error = nfs_mount(netdev_sock, rootip, rootpath);
return (error);
}

View File

@ -1,231 +0,0 @@
/* $NetBSD: ra.c,v 1.6 1998/10/09 06:15:33 matt Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
* 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 at Ludd, University of Lule}.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/* All bugs are subject to removal without further notice */
#define NRSP 1 /* Kludge */
#define NCMD 1 /* Kludge */
#include "sys/param.h"
#include "sys/disklabel.h"
#include "lib/libsa/stand.h"
#include "../include/pte.h"
/*#include "../include/macros.h"*/
#include "../include/sid.h"
#include "../uba/ubareg.h"
#include "../uba/udareg.h"
#include "../mscp/mscp.h"
#include "../mscp/mscpreg.h"
#include "../bi/bireg.h"
#include "../bi/kdbreg.h"
#include "vaxstand.h"
static command(int);
/*
* These routines for RA disk standalone boot is wery simple,
* assuming a lots of thing like that we only working at one ra disk
* a time, no separate routines for uba driver etc..
* This code is foolish and should need a cleanup.
* But it works :)
*/
struct ra_softc {
int udaddr;
int ubaddr;
int part;
int unit;
unsigned short *ra_ip;
unsigned short *ra_sa;
unsigned short *ra_sw;
};
volatile struct uda {
struct mscp_1ca uda_ca; /* communications area */
struct mscp uda_rsp; /* response packets */
struct mscp uda_cmd; /* command packets */
} uda;
volatile struct uda *ubauda;
volatile struct udadevice *udacsr;
struct disklabel ralabel;
struct ra_softc ra_softc;
char io_buf[MAXBSIZE];
raopen(f, adapt, ctlr, unit, part)
struct open_file *f;
int ctlr, unit, part;
{
char *msg;
struct disklabel *lp = &ralabel;
volatile struct ra_softc *ra = &ra_softc;
volatile struct uba_regs *mr = (void *)ubaaddr[adapt];
volatile u_int *nisse;
unsigned short johan, johan2;
int i,err;
bzero(lp, sizeof(struct disklabel));
ra->unit = unit;
ra->part = part;
if (vax_cputype != VAX_8200) {
if (adapt > nuba)
return(EADAPT);
if (ctlr > nuda)
return(ECTLR);
nisse = (u_int *)&mr->uba_map[0];
nisse[494] = PG_V | (((u_int)&uda) >> 9);
nisse[495] = nisse[494] + 1;
udacsr = (void*)uioaddr[adapt] + udaaddr[ctlr];
ubauda = (void*)0x3dc00 + (((u_int)(&uda))&0x1ff);
johan = (((u_int)ubauda) & 0xffff) + 8;
johan2 = 3;
ra->ra_ip = (short *)&udacsr->udaip;
ra->ra_sa = ra->ra_sw = (short *)&udacsr->udasa;
ra->udaddr = uioaddr[adapt] + udaaddr[ctlr];
ra->ubaddr = (int)mr;
*ra->ra_ip = 0; /* Start init */
} else {
struct bi_node *bi = (void *)biaddr[adapt];
struct kdb_regs *kb = (void *)&bi[ctlr];
volatile int i = 10000;
ra->ra_ip = &kb->kdb_ip;
ra->ra_sa = &kb->kdb_sa;
ra->ra_sw = &kb->kdb_sw;
johan = ((u_int)&uda.uda_ca.ca_rspdsc) & 0xffff;
johan2 = (((u_int)&uda.uda_ca.ca_rspdsc) & 0xffff0000) >> 16;
kb->kdb_bi.bi_csr |= BICSR_NRST;
while (i--) /* Need delay??? */
;
kb->kdb_bi.bi_ber = ~(BIBER_MBZ|BIBER_NMR|BIBER_UPEN);/* ??? */
ubauda = &uda;
}
/* Init of this uda */
while ((*ra->ra_sa & MP_STEP1) == 0)
;
*ra->ra_sw = 0x8000;
while ((*ra->ra_sa & MP_STEP2) == 0)
;
*ra->ra_sw = johan;
while ((*ra->ra_sa & MP_STEP3) == 0)
;
*ra->ra_sw = johan2;
while ((*ra->ra_sa & MP_STEP4) == 0)
;
*ra->ra_sw = 0x0001;
uda.uda_ca.ca_rspdsc = (int)&ubauda->uda_rsp.mscp_cmdref;
uda.uda_ca.ca_cmddsc = (int)&ubauda->uda_cmd.mscp_cmdref;
command(M_OP_SETCTLRC);
uda.uda_cmd.mscp_unit = ra->unit;
command(M_OP_ONLINE);
err = rastrategy(ra,F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i);
if(err){
printf("reading disklabel: %s\n",strerror(err));
return 0;
}
msg = getdisklabel(io_buf+LABELOFFSET, lp);
if (msg)
printf("getdisklabel: %s\n", msg);
f->f_devdata = (void *)ra;
return(0);
}
static
command(cmd)
{
volatile int hej;
uda.uda_cmd.mscp_opcode = cmd;
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 = *ra_softc.ra_ip;
while(uda.uda_ca.ca_rspdsc<0)
;
}
rastrategy(ra, func, dblk, size, buf, rsize)
struct ra_softc *ra;
int func;
daddr_t dblk;
char *buf;
u_int size, *rsize;
{
volatile struct uba_regs *ur;
volatile struct udadevice *udadev;
volatile u_int *ptmapp;
struct disklabel *lp;
u_int i, j, pfnum, mapnr, nsize;
volatile int hej;
if (vax_cputype != VAX_8200) {
ur = (void *)ra->ubaddr;
udadev = (void*)ra->udaddr;
ptmapp = (u_int *)&ur->uba_map[0];
pfnum = (u_int)buf >> PGSHIFT;
for(mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG)
ptmapp[mapnr++] = PG_V | pfnum++;
uda.uda_cmd.mscp_seq.seq_buffer = ((u_int)buf) & 0x1ff;
} else
uda.uda_cmd.mscp_seq.seq_buffer = ((u_int)buf);
lp = &ralabel;
uda.uda_cmd.mscp_seq.seq_lbn =
dblk + lp->d_partitions[ra->part].p_offset;
uda.uda_cmd.mscp_seq.seq_bytecount = size;
uda.uda_cmd.mscp_unit = ra->unit;
if (func == F_WRITE)
command(M_OP_WRITE);
else
command(M_OP_READ);
*rsize = size;
return 0;
}

View File

@ -1,137 +0,0 @@
/* $NetBSD: str.s,v 1.4 1998/10/09 06:09:48 matt Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* 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 at Ludd, University of
* Lule}, Sweden and its contributors.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* Small versions of the most common functions not using any
* emulated instructions.
*/
#include "../include/asm.h"
/*
* atoi() used in devopen.
*/
ENTRY(atoi, 0);
movl 4(ap),r1
clrl r0
2: movzbl (r1)+,r2
cmpb r2,$48
blss 1f
cmpb r2,$57
bgtr 1f
subl2 $48,r2
mull2 $10,r0
addl2 r2,r0
brb 2b
1: ret
/*
* index() small and easy.
* doesnt work if we search for null.
*/
ENTRY(index, 0);
movq 4(ap),r0
1: cmpb (r0), r1
beql 2f
tstb (r0)+
bneq 1b
clrl r0
2: ret
/*
* cmpc3 is emulated on MVII.
*/
ENTRY(bcmp, 0);
movl 4(ap), r2
movl 8(ap), r1
movl 12(ap), r0
2: cmpb (r2)+, (r1)+
bneq 1f
decl r0
bneq 2b
1: ret
/*
* Is movc3/movc5 emulated on any CPU? I dont think so; use them here.
*/
ENTRY(bzero,0);
movc5 $0,*4(ap),$0,8(ap),*4(ap)
ret
ENTRY(bcopy,0);
movc3 12(ap), *4(ap), *8(ap)
ret
ENTRY(strlen, 0);
movl 4(ap), r0
1: tstb (r0)+
bneq 1b
decl r0
subl2 4(ap), r0
ret
ENTRY(strncmp, 0)
movl 12(ap), r3
brb 5f
ENTRY(strcmp, 0)
movl $250, r3 # max string len to compare
5: movl 4(ap), r2
movl 8(ap), r1
movl $1, r0
2: cmpb (r2),(r1)+
bneq 1f # something differ
tstb (r2)+
beql 4f # continue, strings unequal
decl r3 # max string len encountered?
bneq 2b
4: clrl r0 # We are done, strings equal.
ret
1: bgtr 3f
mnegl r0, r0
3: ret
ENTRY(strncpy, 0)
movl 4(ap), r1
movl 8(ap), r2
movl 12(ap), r3
bleq 2f
1: movb (r2)+, (r1)+
beql 2f
decl r3
bneq 1b
2: ret

View File

@ -1,202 +0,0 @@
/* $NetBSD: tmscp.c,v 1.5 1998/10/09 06:15:33 matt Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
* 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 at Ludd, University of Lule}.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/* All bugs are subject to removal without further notice */
#define NRSP 0 /* Kludge */
#define NCMD 0 /* Kludge */
#include "sys/param.h"
#include "sys/disklabel.h"
#include "lib/libsa/stand.h"
#include "../include/pte.h"
/*#include "../include/macros.h"*/
#include "../uba/ubareg.h"
#include "../uba/udareg.h"
#include "../mscp/mscp.h"
#include "../mscp/mscpreg.h"
#include "vaxstand.h"
static command(int,int);
/*
* These routines for TMSCP tape standalone boot is very simple,
* assuming a lots of thing like that we only working at one tape at
* a time, no separate routines for uba driver etc..
* This code is directly copied from ra disk driver.
*/
struct ra_softc {
int udaddr;
int ubaddr;
int unit;
};
static volatile struct uda {
struct mscp_1ca uda_ca; /* communications area */
struct mscp uda_rsp; /* response packets */
struct mscp uda_cmd; /* command packets */
} uda;
static volatile struct uda *ubauda;
static volatile struct udadevice *udacsr;
static struct ra_softc ra_softc;
tmscpopen(f, adapt, ctlr, unit, part)
struct open_file *f;
int ctlr, unit, part;
{
char *msg;
extern u_int tmsaddr;
volatile struct ra_softc *ra=&ra_softc;
volatile struct uba_regs *mr=(void *)ubaaddr[adapt];
volatile u_int *nisse;
unsigned short johan;
int i,err;
if(adapt>nuba) return(EADAPT);
if(ctlr>nuda) return(ECTLR);
ra->udaddr=uioaddr[adapt]+tmsaddr;
ra->ubaddr=(int)mr;
ra->unit=unit;
udacsr=(void*)ra->udaddr;
nisse=(u_int *)&mr->uba_map[0];
nisse[494]=PG_V|(((u_int)&uda)>>9);
nisse[495]=nisse[494]+1;
ubauda=(void*)0x3dc00+(((u_int)(&uda))&0x1ff);
/*
* Init of this tmscp ctlr.
*/
udacsr->udaip=0; /* Start init */
while((udacsr->udasa&MP_STEP1) == 0);
udacsr->udasa=0x8000;
while((udacsr->udasa&MP_STEP2) == 0);
johan=(((u_int)ubauda)&0xffff)+8;
udacsr->udasa=johan;
while((udacsr->udasa&MP_STEP3) == 0);
udacsr->udasa=3;
while((udacsr->udasa&MP_STEP4) == 0);
udacsr->udasa=0x0001;
uda.uda_ca.ca_rspdsc=(int)&ubauda->uda_rsp.mscp_cmdref;
uda.uda_ca.ca_cmddsc=(int)&ubauda->uda_cmd.mscp_cmdref;
uda.uda_cmd.mscp_un.un_seq.seq_addr = (long *)&uda.uda_ca.ca_cmddsc;
uda.uda_rsp.mscp_un.un_seq.seq_addr = (long *)&uda.uda_ca.ca_rspdsc;
uda.uda_cmd.mscp_vcid = 1;
uda.uda_cmd.mscp_un.un_sccc.sccc_ctlrflags = 0;
command(M_OP_SETCTLRC, 0);
uda.uda_cmd.mscp_unit=ra->unit;
command(M_OP_ONLINE, 0);
if (part) {
uda.uda_cmd.mscp_un.un_seq.seq_buffer = part;
command(M_OP_POS, 0);
uda.uda_cmd.mscp_un.un_seq.seq_buffer = 0;
}
f->f_devdata=(void *)ra;
return(0);
}
static
command(cmd, arg)
{
volatile int hej;
uda.uda_cmd.mscp_opcode = cmd;
uda.uda_cmd.mscp_modifier = arg;
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 = udacsr->udaip;
while (uda.uda_ca.ca_rspdsc < 0) {
if (uda.uda_ca.ca_cmdint)
uda.uda_ca.ca_cmdint = 0;
}
}
static int curblock = 0;
tmscpstrategy(ra, func, dblk, size, buf, rsize)
struct ra_softc *ra;
int func;
daddr_t dblk;
char *buf;
u_int size, *rsize;
{
u_int i,j,pfnum, mapnr, nsize, bn, cn, sn, tn;
volatile struct uba_regs *ur=(void *)ra->ubaddr;
volatile struct udadevice *udadev=(void*)ra->udaddr;
volatile u_int *ptmapp = (u_int *)&ur->uba_map[0];
volatile int hej;
pfnum=(u_int)buf>>PGSHIFT;
for(mapnr=0, nsize=size;(nsize+NBPG)>0;nsize-=NBPG)
ptmapp[mapnr++]=PG_V|pfnum++;
/*
* First position tape. Remember where we are.
*/
if (dblk < curblock) {
uda.uda_cmd.mscp_seq.seq_bytecount = curblock - dblk;
command(M_OP_POS, 12); /* 12 == step block backward */
} else {
uda.uda_cmd.mscp_seq.seq_bytecount = dblk - curblock;
command(M_OP_POS, 4); /* 4 == step block forward */
}
curblock = size/512 + dblk;
/*
* Read in the number of blocks we need.
* Why doesn't read of multiple blocks work?????
*/
for (i = 0 ; i < size/512 ; i++) {
uda.uda_cmd.mscp_seq.seq_lbn = 1;
uda.uda_cmd.mscp_seq.seq_bytecount = 512;
uda.uda_cmd.mscp_seq.seq_buffer =
(((u_int)buf) & 0x1ff) + i * 512;
uda.uda_cmd.mscp_unit = ra->unit;
command(M_OP_READ, 0);
}
*rsize=size;
return 0;
}

View File

@ -1,57 +0,0 @@
/* $NetBSD: vaxstand.h,v 1.6 1997/03/15 13:04:31 ragge Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
* 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 at Ludd, University of Lule}.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/* All bugs are subject to removal without further notice */
#define MAXNMBA 8 /* Massbussadapters */
#define MAXNUBA 8 /* Unibusadapters */
#define MAXMBAU 8 /* Units on an mba */
/* Variables used in autoconf */
extern int nmba, nuba, nbi, nsbi, nuda;
extern int *ubaaddr, *mbaaddr, *udaaddr, *uioaddr, *biaddr;
extern int cpunumber;
/* devsw type definitions, used in bootxx and conf */
#define SADEV(name,strategy,open,close,ioctl) \
{ (char *)name, \
(int(*)(void *, int ,daddr_t , size_t, void *, size_t *))strategy, \
(int(*)(struct open_file *, ...))open, \
(int(*)(struct open_file *))close, \
(int(*)(struct open_file *,u_long, void *))ioctl}
/*
* Easy-to-use definitions
*/
#define min(x,y) (x < y ? x : y)
char *index();