xref: /csrg-svn/sys/vax/stand/mba.c (revision 10332)
1*10332Shelge /*	mba.c	4.7	83/01/16	*/
2323Sbill 
39806Ssam #include "../machine/pte.h"
49806Ssam 
5323Sbill #include "../h/param.h"
6323Sbill #include "../h/inode.h"
77446Sroot #include "../h/fs.h"
8323Sbill #include "../h/vm.h"
99186Ssam 
109186Ssam #include "../vax/mtpr.h"
119186Ssam #include "../vaxmba/mbareg.h"
12*10332Shelge #include "../vaxmba/hpreg.h"
139186Ssam 
14323Sbill #include "saio.h"
153262Swnj #include "savax.h"
16323Sbill 
173262Swnj mbastart(io, func)
183262Swnj 	register struct iob *io;
193262Swnj 	int func;
20323Sbill {
213262Swnj 	struct mba_regs *mba = mbamba(io->i_unit);
223262Swnj 	struct mba_drv *drv = mbadrv(io->i_unit);
233262Swnj 	register struct pte *pte = mba->mba_map;
24323Sbill 	int npf;
25323Sbill 	unsigned v;
26323Sbill 	int o;
27323Sbill 	int vaddr;
28323Sbill 
29323Sbill 	v = btop(io->i_ma);
30323Sbill 	o = (int)io->i_ma & PGOFSET;
31323Sbill 	npf = btoc(io->i_cc + o);
323262Swnj 	vaddr = o;
33323Sbill 	while (--npf >= 0)
34323Sbill 		*(int *)pte++ = v++ | PG_V;
353262Swnj 	mba->mba_sr = -1;
363262Swnj 	mba->mba_bcr = -io->i_cc;
373262Swnj 	mba->mba_var = vaddr;
38*10332Shelge 	switch (io->i_flgs & F_TYPEMASK) {
39*10332Shelge 
40*10332Shelge 	case F_RDDATA:			/* standard read */
41*10332Shelge 		drv->mbd_cs1 = MB_RCOM|MB_GO;
42*10332Shelge 		return(0);
43*10332Shelge 
44*10332Shelge 	case F_WRDATA:			/* standard write */
45*10332Shelge 		drv->mbd_cs1 = MB_WCOM|MB_GO;
46*10332Shelge 		return(0);
47*10332Shelge 
48*10332Shelge 	/* the following commands apply to disks only */
49*10332Shelge 
50*10332Shelge 	case F_HDR|F_RDDATA:
51*10332Shelge 		drv->mbd_cs1 = HP_RHDR|HP_GO;
52*10332Shelge 		break;
53*10332Shelge 
54*10332Shelge 	case F_HDR|F_WRDATA:
55*10332Shelge 		drv->mbd_cs1 = HP_WHDR|HP_GO;
56*10332Shelge 		break;
57*10332Shelge 
58*10332Shelge 	case F_CHECK|F_WRDATA:
59*10332Shelge 	case F_CHECK|F_RDDATA:
60*10332Shelge 		drv->mbd_cs1 = HP_WCDATA|HP_GO;
61*10332Shelge 		break;
62*10332Shelge 
63*10332Shelge 	case F_HCHECK|F_WRDATA:
64*10332Shelge 	case F_HCHECK|F_RDDATA:
65*10332Shelge 		drv->mbd_cs1 = HP_WCHDR|HP_GO;
66*10332Shelge 		break;
67*10332Shelge 
68*10332Shelge 	default:
69*10332Shelge error:
70*10332Shelge 		io->i_error = ECMD;
71*10332Shelge 		io->i_flgs &= ~F_TYPEMASK;
72*10332Shelge 		return (1);
73*10332Shelge 	}
74*10332Shelge 
75*10332Shelge 	if ((drv->mbd_dt & MBDT_TAP) == 0)
76*10332Shelge 		return (0);
773262Swnj 	else
78*10332Shelge 		goto error;		/* if not a disk : error */
79323Sbill }
80415Sbill 
81415Sbill mbainit(mbanum)
82415Sbill 	int mbanum;
83415Sbill {
843262Swnj 	register struct mba_regs *mba = mbaddr[mbanum];
85415Sbill 
863262Swnj 	/* SHOULD BADADDR IT */
873262Swnj 	if (mbaact & (1<<mbanum))
883262Swnj 		return;
893262Swnj 	mba->mba_cr = MBCR_INIT;
90415Sbill 	mbaact |= 1<<mbanum;
91415Sbill }
92