1*13569Ssam /* mba.c 4.10 83/07/01 */ 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" 1210332Shelge #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; 3811142Ssam if (io->i_flgs&F_SSI) 3910623Shelge drv->mbd_of |= HPOF_SSEI; 4010332Shelge switch (io->i_flgs & F_TYPEMASK) { 4110332Shelge 4210332Shelge case F_RDDATA: /* standard read */ 4310332Shelge drv->mbd_cs1 = MB_RCOM|MB_GO; 44*13569Ssam mbawait(io); 4510332Shelge return(0); 4610332Shelge 4710332Shelge case F_WRDATA: /* standard write */ 4810332Shelge drv->mbd_cs1 = MB_WCOM|MB_GO; 49*13569Ssam mbawait(io); 5010332Shelge return(0); 5110332Shelge 5210332Shelge /* the following commands apply to disks only */ 5310332Shelge 5410332Shelge case F_HDR|F_RDDATA: 5510332Shelge drv->mbd_cs1 = HP_RHDR|HP_GO; 5610332Shelge break; 5710332Shelge 5810332Shelge case F_HDR|F_WRDATA: 5910332Shelge drv->mbd_cs1 = HP_WHDR|HP_GO; 6010332Shelge break; 6110332Shelge 6210332Shelge case F_CHECK|F_WRDATA: 6310332Shelge case F_CHECK|F_RDDATA: 6410332Shelge drv->mbd_cs1 = HP_WCDATA|HP_GO; 6510332Shelge break; 6610332Shelge 6710332Shelge case F_HCHECK|F_WRDATA: 6810332Shelge case F_HCHECK|F_RDDATA: 6910332Shelge drv->mbd_cs1 = HP_WCHDR|HP_GO; 7010332Shelge break; 7110332Shelge 7210332Shelge default: 7311142Ssam goto error; 7410332Shelge } 75*13569Ssam mbawait(io); 7610332Shelge if ((drv->mbd_dt & MBDT_TAP) == 0) 7710332Shelge return (0); 7811142Ssam error: 7911142Ssam io->i_error = ECMD; 8011142Ssam io->i_flgs &= ~F_TYPEMASK; 8111142Ssam return (1); 82323Sbill } 83415Sbill 84*13569Ssam mbawait(io) 85*13569Ssam register struct iob *io; 86*13569Ssam { 87*13569Ssam struct mba_regs *mba = mbamba(io->i_unit); 88*13569Ssam struct mba_drv *drv = mbadrv(io->i_unit); 89*13569Ssam 90*13569Ssam while (mba->mba_sr & MBSR_DTBUSY) 91*13569Ssam DELAY(100); 92*13569Ssam } 93*13569Ssam 94415Sbill mbainit(mbanum) 95415Sbill int mbanum; 96415Sbill { 973262Swnj register struct mba_regs *mba = mbaddr[mbanum]; 98415Sbill 993262Swnj /* SHOULD BADADDR IT */ 1003262Swnj if (mbaact & (1<<mbanum)) 1013262Swnj return; 1023262Swnj mba->mba_cr = MBCR_INIT; 103415Sbill mbaact |= 1<<mbanum; 104415Sbill } 105