From 85db0cc9f328a488b24d728dcea52388a7ba4a88 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 7 May 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-05-07 --- alphapc/arch164.c | 8 +++++--- alphapc/audio.h | 2 +- alphapc/devfloppy.c | 4 ++-- alphapc/dma.c | 18 +++++++++++++++++- alphapc/ether2114x.c | 3 ++- alphapc/io.h | 35 ++++++++++++++++++++++++++--------- alphapc/main.c | 8 ++++++-- alphapc/pci.c | 25 +++++++++++++++---------- pc/devfloppy.c | 2 +- pc/scsi.c | 12 ++++++------ port/devsd.c | 2 +- port/portfns.h | 12 ++++++------ 12 files changed, 88 insertions(+), 43 deletions(-) diff --git a/alphapc/arch164.c b/alphapc/arch164.c index e6a146d2855c851a6c2f85aea1ed8af22be3f69e..d0762f2acf05abdec392413c7b4db8908f4c3fe0 100644 --- a/alphapc/arch164.c +++ b/alphapc/arch164.c @@ -42,9 +42,11 @@ sginit(void) for(pa = 0; pa < 8*1024*1024; pa += BY2PG) *pte++ = ((pa>>PGSHIFT)<<1)|1; - wind[0x400/4] = ISAWINDOW|4|2|1; + wind[0x400/4] = ISAWINDOW|2|1; wind[0x440/4] = 0x00700000; - wind[0x480/4] = PADDR(sgmap); + wind[0x480/4] = PADDR(sgmap)>>2; + + wind[0x100/4] = 3; /* invalidate tlb cache */ } static void * @@ -110,7 +112,7 @@ ciaerror(void) static void corehello(void) { - print("cpu%d: CIA revision %d; cnfg %lux cntrl %lux\n", + print("cpu%d: CIA revision %ld; cnfg %lux cntrl %lux\n", 0, /* BUG */ core[0x80/4] & 0x7f, core[0x140/4], core[0x100/4]); print("cpu%d: HAE_IO %lux\n", 0, core[0x440/4]); diff --git a/alphapc/audio.h b/alphapc/audio.h index bcf4c4171235bda65068f6b46ba325ed2ef587b4..3085a2cea414925712fbbbd699ce5d7777d1fd93 100644 --- a/alphapc/audio.h +++ b/alphapc/audio.h @@ -2,7 +2,7 @@ enum { Bufsize = 16*1024, /* 92 ms each */ Nbuf = 16, /* 1.5 seconds total */ - Dma = 1, + Dma = 5, IrqAUDIO = 5, SBswab = 0, }; diff --git a/alphapc/devfloppy.c b/alphapc/devfloppy.c index 8b831416746d23238c53aad1614ec43eaea92b73..dbb1e246cb707c36a764cc7779df7a39a9b26765 100644 --- a/alphapc/devfloppy.c +++ b/alphapc/devfloppy.c @@ -56,14 +56,12 @@ enum FType floppytype[] = { { "3½HD", T1440kb, 512, 18, 2, 1, 80, 0x1B, 0x54, 0, }, -/* { "3½DD", T1440kb, 512, 9, 2, 1, 80, 0x1B, 0x54, 2, }, { "3½DD", T720kb, 512, 9, 2, 1, 80, 0x1B, 0x54, 2, }, { "5¼HD", T1200kb, 512, 15, 2, 1, 80, 0x2A, 0x50, 0, }, { "5¼DD", T1200kb, 512, 9, 2, 2, 40, 0x2A, 0x50, 1, }, { "ATT3B1", T1200kb, 512, 8, 2, 2, 48, 0x2A, 0x50, 1, }, { "5¼DD", T360kb, 512, 9, 2, 1, 40, 0x2A, 0x50, 2, }, - */ }; /* @@ -806,6 +804,8 @@ floppyxfer(FDrive *dp, int cmd, void *a, long off, long n) return 0; if(off + n > dp->t->cap) n = dp->t->cap - off; +if(cmd == Fread) + memset(a, 0x55, n); /* retry on error (until it gets ridiculous) */ tries = 0; diff --git a/alphapc/dma.c b/alphapc/dma.c index 2ad5ad9c7c57727919251918ab4d1da462d26c26..59ec5dcce923a14653ee5c1fcdc48454c9e24d95 100644 --- a/alphapc/dma.c +++ b/alphapc/dma.c @@ -4,6 +4,8 @@ #include "dat.h" #include "fns.h" +#include "io.h" + typedef struct DMAport DMAport; typedef struct DMA DMA; typedef struct DMAxfer DMAxfer; @@ -166,13 +168,13 @@ dmasetup(int chan, void *va, long len, int isread) dp = &dma[(chan>>2)&1]; chan = chan & 3; + xp = &dp->x[chan]; //print("va%lux+", va); #define tryPCI #ifndef PCIWADDR #define PCIWADDR(va) PADDR(va) #endif /* PCIWADDR */ #ifdef notdef - xp = &dp->x[chan]; /* * if this isn't kernel memory or crossing 64k boundary or above 16 meg @@ -201,6 +203,20 @@ dmasetup(int chan, void *va, long len, int isread) #endif /* tryISA */ #ifdef tryPCI pa = PCIWADDR(va); + if((((ulong)va)&0xF0000000) != KZERO){ + if(xp->bva == nil) + return -1; + if(len > xp->blen) + len = xp->blen; + if(!isread) + memmove(xp->bva, va, len); + xp->va = va; + xp->len = len; + xp->isread = isread; + pa = PCIWADDR(xp->bva); + } + else + xp->len = 0; #endif /* tryPCI */ /* diff --git a/alphapc/ether2114x.c b/alphapc/ether2114x.c index e6f41e879e7d10b5e47fac7d6beebbbb54987a7d..ac97a589512556b9cf56bbb159908350c24cbd5d 100644 --- a/alphapc/ether2114x.c +++ b/alphapc/ether2114x.c @@ -1326,6 +1326,7 @@ reset(Ether* ether) uchar ea[Eaddrlen]; static int scandone; +pcihinv(nil); if(scandone == 0){ dec2114xpci(); scandone = 1; @@ -1418,5 +1419,5 @@ reset(Ether* ether) void ether2114xlink(void) { - addethercard("21140", reset); + addethercard("2114x", reset); } diff --git a/alphapc/io.h b/alphapc/io.h index e9aeebd51aedda8f280ab346fe2c036979dd78aa..b8fe902d7311db74ff7dce1964b09b6ce9c24eca 100644 --- a/alphapc/io.h +++ b/alphapc/io.h @@ -152,11 +152,12 @@ typedef struct Pcidev { struct { ulong bar; /* base address */ int size; - } mem[3]; + } mem[6]; uchar intl; /* interrupt line */ - ushort ccru; - + uchar ccrp; + uchar ccru; + uchar ccrb; Pcidev* list; Pcidev* bridge; /* down a bus */ @@ -182,12 +183,18 @@ struct PCMmap { * SCSI bus */ enum { - MaxScsi = 8, - NTarget = 8, /* should be 16... */ + MaxTarget = 16, }; -struct Target { + +typedef struct Scsi Scsi; +typedef struct Target Target; +typedef struct SCSIdev SCSIdev; + +typedef struct Target { int ctlrno; - int target; + Scsi* ctlr; + int targetno; + uchar* inq; uchar* scratch; @@ -196,11 +203,21 @@ struct Target { int ok; }; -typedef int (*Scsiio)(Target*, int, uchar*, int, void*, int*); +typedef struct Scsi { + ISAConf; + int ctlrno; + Pcidev* pcidev; + int (*io)(Target*, int, uchar*, int, void*, int*); + void *ctlr; + int ntarget; + + Scsi* next; +} Scsi; typedef struct SCSIdev { char* type; - Scsiio (*reset)(int, ISAConf*); + Scsi* (*pnp)(void); + int (*reset)(Scsi*); } SCSIdev; #define PCIWINDOW 0x40000000 diff --git a/alphapc/main.c b/alphapc/main.c index c84aacafb7cf091d1cd5b89e15ace03ea59e1125..e5716414cab2a02f0ee0d7531fc0d49fc2273ab5 100644 --- a/alphapc/main.c +++ b/alphapc/main.c @@ -274,14 +274,18 @@ char *confname[] = { "ether0", "scsi0", + "scsi1", + "scsi2", "audio0", }; char *confval[] = { - "type=21140", - "type=aic7xxx", + "type=2114x", + "type=ata", + "type=ata", + "type=ata", "type=sb16", }; diff --git a/alphapc/pci.c b/alphapc/pci.c index 2a6f6e085eb638cc0e2ac15963a80616946b3664..45c8df1ac23e59d7365ed8d4183dcdd2fdaa3a0f 100644 --- a/alphapc/pci.c +++ b/alphapc/pci.c @@ -40,11 +40,12 @@ pciscan(int bno, Pcidev** list) maxfno = 0; for(fno = 0; fno <= maxfno; fno++){ /* - * For this possible device, form the bus+device+function - * triplet needed to address it and try to read the vendor - * and device ID. If successful, allocate a device struct - * and start to fill it in with some useful information from - * the device's configuration space. + * For this possible device, form the + * bus+device+function triplet needed to address it + * and try to read the vendor and device ID. + * If successful, allocate a device struct and + * start to fill it in with some useful information + * from the device's configuration space. */ tbdf = MKBUS(BusPCI, bno, dno, fno); l = pcicfgrw32(tbdf, PciVID, 0, 1); @@ -70,7 +71,9 @@ pciscan(int bno, Pcidev** list) pcitail = p; p->intl = pcicfgr8(p, PciINTL); - p->ccru = pcicfgr16(p, PciCCRu); + p->ccrp = pcicfgr8(p, PciCCRp); + p->ccru = pcicfgr8(p, PciCCRu); + p->ccrb = pcicfgr8(p, PciCCRb); /* * If the device is a multi-function device adjust the @@ -84,7 +87,7 @@ pciscan(int bno, Pcidev** list) * If appropriate, read the base address registers * and work out the sizes. */ - switch(p->ccru>>8){ + switch(p->ccrb){ case 0x01: /* mass storage controller */ case 0x02: /* network controller */ @@ -129,7 +132,7 @@ pciscan(int bno, Pcidev** list) /* * Find PCI-PCI bridges and recursively descend the tree. */ - if(p->ccru != ((0x06<<8)|0x04)) + if(p->ccrb != 0x06 || p->ccru != 0x04) continue; /* @@ -311,14 +314,16 @@ pcihinv(Pcidev* p) int i; Pcidev *t; + if(pcicfgmode == -1) + pcicfginit(); if(p == nil) { p = pciroot; print("bus dev type vid did intl memory\n"); } for(t = p; t != nil; t = t->link) { - print("%d %2d/%d %.4ux %.4ux %.4ux %2d ", + print("%d %2d/%d %.2ux %.2ux %.2ux %.4ux %.4ux %2d ", BUSBNO(t->tbdf), BUSDNO(t->tbdf), BUSFNO(t->tbdf), - t->ccru, t->vid, t->did, t->intl); + t->ccrb, t->ccru, t->ccrp, t->vid, t->did, t->intl); for(i = 0; i < nelem(p->mem); i++) { if(t->mem[i].size == 0) diff --git a/pc/devfloppy.c b/pc/devfloppy.c index 0fc8b78a22af0ee1112ef844ca2c09ff8236215c..173d3f502c032392e5dda99b9da98799923dbdf9 100644 --- a/pc/devfloppy.c +++ b/pc/devfloppy.c @@ -682,7 +682,7 @@ floppyrecal(FDrive *dp) /* * if the controller or a specific drive is in a confused state, - * reset it and get back to a kown state + * reset it and get back to a known state */ static void floppyrevive(void) diff --git a/pc/scsi.c b/pc/scsi.c index 14115f209535a9b0e2855754da3bce03734bdaa3..3eb3ee8529d66206fc975a1d133fb79bdae5f5bb 100644 --- a/pc/scsi.c +++ b/pc/scsi.c @@ -222,7 +222,7 @@ scsiinv(int devno, int *type, Target **rt, uchar **inq, char *id) } int -scsitest(Target *t, char lun) +scsitest(Target *t, int lun) { uchar cmd[6]; @@ -233,7 +233,7 @@ scsitest(Target *t, char lun) } int -scsistart(Target *t, char lun, int s) +scsistart(Target *t, int lun, int s) { uchar cmd[6]; @@ -245,7 +245,7 @@ scsistart(Target *t, char lun, int s) } int -scsiinquiry(Target *t, char lun, void *data, int *datalen) +scsiinquiry(Target *t, int lun, void *data, int *datalen) { uchar cmd[6]; @@ -257,7 +257,7 @@ scsiinquiry(Target *t, char lun, void *data, int *datalen) } int -scsicap(Target *t, char lun, ulong *size, ulong *bsize) +scsicap(Target *t, int lun, ulong *size, ulong *bsize) { int s, nbytes; uchar cmd[10], *d; @@ -281,7 +281,7 @@ scsicap(Target *t, char lun, ulong *size, ulong *bsize) } int -scsibio(Target *t, char lun, int dir, void *b, long n, long bsize, long bno) +scsibio(Target *t, int lun, int dir, void *b, long n, long bsize, long bno) { uchar cmd[10]; int s, cdbsiz, nbytes; @@ -331,7 +331,7 @@ static char *key[] = }; int -scsireqsense(Target *t, char lun, void *data, int *nbytes, int quiet) +scsireqsense(Target *t, int lun, void *data, int *nbytes, int quiet) { char *s; int n, status, try; diff --git a/port/devsd.c b/port/devsd.c index 051560d75c4f546e8b070cd7d9e697f5df0ecd79..e43acdff85711e8933964f0f410dd7db1e5db47d 100644 --- a/port/devsd.c +++ b/port/devsd.c @@ -42,7 +42,7 @@ struct Disk { QLock; Target* t; - uchar lun; + int lun; char id[NAMELEN]; char vol[NAMELEN]; diff --git a/port/portfns.h b/port/portfns.h index fcf0791ca6677c338a4c2be0d34a50ff49e4720c..a0dbb62d7ee7830686b7996449a2287525b9fca6 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -271,16 +271,16 @@ void scheddump(void); void schedinit(void); int screenbits(void); #define scsialloc(n) mallocz((n)+512, 0) -int scsibio(Target*, char, int, void*, long, long, long); -int scsicap(Target*, char, ulong*, ulong*); +int scsibio(Target*, int, int, void*, long, long, long); +int scsicap(Target*, int, ulong*, ulong*); int scsierrstr(int); int scsiexec(Target*, int, uchar*, int, void*, int*); #define scsifree(p) free(p) -int scsiinquiry(Target*, char, void*, int*); +int scsiinquiry(Target*, int, void*, int*); int scsiinv(int, int*, Target**, uchar**, char*); -int scsireqsense(Target*, char, void*, int*, int); -int scsistart(Target*, char, int); -int scsitest(Target*, char); +int scsireqsense(Target*, int, void*, int*, int); +int scsistart(Target*, int, int); +int scsitest(Target*, int); Target* scsiunit(int, int); long seconds(void); ulong segattach(Proc*, ulong, char *, ulong, ulong);