kernel: allocate DMA bounce buffers early; various comment / print fixes
[rsc] --rw-rw-r-- M 951118 glenda sys 532 Mar 21 11:31 sys/src/9/alphapc/apccpu
/n/sourcesdump/2006/0321/plan9/sys/src/9/alphapc/apccpu:33,39 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/alphapc/apccpu:33,39
arch164
sdata pci sdscsi
- sd53c8xx pci sdscsi
+ # sd53c8xx pci sdscsi
uarti8250
[rsc] --rw-rw-r-- M 951118 glenda sys 3805 Mar 21 11:28 sys/src/9/mtx/dat.h
/n/sourcesdump/2006/0321/plan9/sys/src/9/mtx/dat.h:30,36 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/mtx/dat.h:30,36
struct Lock
{
- ulong key; /* semaphore (non-zero = locked) */
+ ulong key;
ulong sr;
ulong pc;
Proc *p;
[rsc] --rw-rw-r-- M 951118 glenda sys 6628 Mar 21 11:25 sys/src/9/pc/dat.h
/n/sourcesdump/2006/0321/plan9/sys/src/9/pc/dat.h:113,119 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/pc/dat.h:113,119
Page* mmuused; /* used page table pages */
Page* kmaptable; /* page table used by kmap */
uint lastkmap; /* last entry used by kmap */
- int nkmap; /* number of current kmaps */
+ int nkmap; /* number of current kmaps */
};
/*
/n/sourcesdump/2006/0321/plan9/sys/src/9/pc/dat.h:136,142 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/pc/dat.h:136,142
ulong ss1; /* privilege level 1 stack selector */
ulong esp2; /* privilege level 2 stack pointer */
ulong ss2; /* privilege level 2 stack selector */
- ulong cr3; /* page directory base register */
+ ulong xcr3; /* page directory base register - not used because we don't use trap gates */
ulong eip; /* instruction pointer */
ulong eflags; /* flags register */
ulong eax; /* general registers */
[rsc] --rw-rw-r-- M 951118 glenda sys 20139 Mar 21 11:25 sys/src/9/pc/devfloppy.c
/n/sourcesdump/2006/0321/plan9/sys/src/9/pc/devfloppy.c:180,185 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/pc/devfloppy.c:180,190
maxtsize = t->tsize;
}
+ /*
+ * Should check if this fails. Can do so
+ * if there is no space <= 16MB for the DMA
+ * bounce buffer.
+ */
dmainit(DMAchan, maxtsize);
/*
[jmk] --rw-rw-r-- M 951118 glenda sys 5332 Mar 21 13:39 sys/src/9/pc/dma.c
/n/sourcesdump/2006/0321/plan9/sys/src/9/pc/dma.c:62,72 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/pc/dma.c:62,107
1 },
};
+ extern int i8237dma;
+ static void* i8237bva[2];
+ static int i8237used;
+
/*
* DMA must be in the first 16MB. This gets called early by the
* initialisation routines of any devices which require DMA to ensure
* the allocated bounce buffers are below the 16MB limit.
*/
+ void
+ _i8237alloc(void)
+ {
+ void* bva;
+
+ if(i8237dma <= 0)
+ return;
+ if(i8237dma > 2)
+ i8237dma = 2;
+
+ bva = xspanalloc(64*1024*i8237dma, BY2PG, 64*1024);
+ if(bva == nil || PADDR(bva)+64*1024*i8237dma > 16*MB){
+ /*
+ * This will panic with the current
+ * implementation of xspanalloc().
+ if(bva != nil)
+ xfree(bva);
+ */
+ return;
+ }
+
+ i8237bva[0] = bva;
+ if(i8237dma == 2)
+ i8237bva[1] = ((uchar*)i8237bva[0])+64*1024;
+ }
+
+ /*
+ * DMA must be in the first 16MB. This gets called early by the
+ * initialisation routines of any devices which require DMA to ensure
+ * the allocated bounce buffers are below the 16MB limit.
+ */
int
dmainit(int chan, int maxtransfer)
{
/n/sourcesdump/2006/0321/plan9/sys/src/9/pc/dma.c:94,112 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/pc/dma.c:129,140
return 0;
}
- xp->bva = xspanalloc(maxtransfer, BY2PG, 64*1024);
- if(xp->bva == nil)
+ if(i8237used >= i8237dma || i8237bva[i8237used] == nil){
+ print("no i8237 DMA bounce buffer < 16MB\n");
return 1;
- xp->bpa = PADDR(xp->bva);
- if(xp->bpa >= 16*MB){
- /*
- * This will panic with the current
- * implementation of xspanalloc().
- xfree(xp->bva);
- */
- xp->bva = nil;
- return 1;
}
+ xp->bva = i8237bva[i8237used++];
+ xp->bpa = PADDR(xp->bva);
xp->blen = maxtransfer;
xp->len = 0;
xp->isread = 0;
[rsc] --rw-rw-r-- M 951118 glenda sys 15304 Mar 21 11:25 sys/src/9/pc/main.c
/n/sourcesdump/2006/0321/plan9/sys/src/9/pc/main.c:70,76 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/pc/main.c:70,78
}
}
- void mmuinit0(void);
+ extern void mmuinit0(void);
+ extern void (*i8237alloc)(void);
+
void
main(void)
{
/n/sourcesdump/2006/0321/plan9/sys/src/9/pc/main.c:93,98 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/pc/main.c:95,102
confinit();
archinit();
xinit();
+ if(i8237alloc != nil)
+ i8237alloc();
trapinit();
printinit();
cpuidprint();
[rsc] --rwxrwxr-x M 951118 glenda sys 4242 Mar 21 11:24 sys/src/9/port/mkdevc
/n/sourcesdump/2006/0321/plan9/sys/src/9/port/mkdevc:25,30 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/port/mkdevc:25,34
devuart = 1;
else if($1 ~ "vga")
devvga = 1;
+ for(i = 2; i <= NF; i++){
+ if($i ~ "dma" && objtype ~ "(386|alpha|amd64)")
+ i8237dma++;
+ }
}
collect && section ~ "ip"{
ip[nip++] = $1;
/n/sourcesdump/2006/0321/plan9/sys/src/9/port/mkdevc:84,89 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/port/mkdevc:88,102
printf "\t&%sdevtab,\n", dev[i];
printf "\tnil,\n};\n\n";
+ if(objtype ~ "(386|alpha|amd64)"){
+ alloc = "nil";
+ if(i8237dma){
+ printf "extern void _i8237alloc(void);\n";
+ alloc = "_i8237alloc";
+ }
+ printf "void (*i8237alloc)(void) = %s;\n", alloc;
+ printf "int i8237dma = %d;\n\n", i8237dma;
+ }
for(i = 0; i < nlink; i++)
printf "extern void %slink(void);\n", link[i];
[rsc] --rw-rw-r-- M 951118 glenda sys 3928 Mar 21 11:17 sys/src/9/port/taslock.c
/n/sourcesdump/2006/0321/plan9/sys/src/9/port/taslock.c:26,32 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/port/taslock.c:26,32
x = _xdec(&r->ref);
if(x < 0)
- panic("decref pc=0x%lux", getcallerpc(&r));
+ panic("deccnt pc=0x%lux", getcallerpc(&r));
return x;
}
[rsc] --rw-rw-r-- M 951118 glenda sys 3804 Mar 21 12:07 sys/src/9/pc/mkfile
/n/sourcesdump/2006/0321/plan9/sys/src/9/pc/mkfile:77,84 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/pc/mkfile:77,94
$LD -o $target -T$KTZERO -l $OBJ $CONF.$O $LIB
size $target
- $p$CONF.gz: $p$CONF
- strip -o /fd/1 $p$CONF | gzip -9 > $p$CONF.gz
+ # don't strip the gzipped kernels -- too frustrating when that's all you have!
+ $p%.gz: $p%
+ gzip -9 <$p$stem >$p$stem.gz
+
+
+ # pcflop and pccd need all the space they can get
+ 9pcflop.gz: 9pcflop
+ strip -o /fd/1 9pcflop | gzip -9 >9pcflop.gz
+
+ 9pccd.gz: 9pccd
+ strip -o /fd/1 9pccd | gzip -9 >9pccd.gz
+
install:V: $p$CONF $p$CONF.gz
cp $p$CONF $p$CONF.gz /$objtype/
[jmk] --rw-rw-r-- M 951118 glenda sys 6526 Mar 21 13:39 sys/src/9/alphapc/dma.c
/n/sourcesdump/2006/0321/plan9/sys/src/9/alphapc/dma.c:64,69 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/alphapc/dma.c:64,104
1 },
};
+ extern int i8237dma;
+ static void* i8237bva[2];
+ static int i8237used;
+
+ /*
+ * DMA must be in the first 16MB. This gets called early by the
+ * initialisation routines of any devices which require DMA to ensure
+ * the allocated bounce buffers are below the 16MB limit.
+ */
+ void
+ _i8237alloc(void)
+ {
+ void* bva;
+
+ if(i8237dma <= 0)
+ return;
+ if(i8237dma > 2)
+ i8237dma = 2;
+
+ bva = xspanalloc(64*1024*i8237dma, BY2PG, 64*1024);
+ if(bva == nil || PADDR(bva)+64*1024*i8237dma > 16*MB){
+ /*
+ * This will panic with the current
+ * implementation of xspanalloc().
+ if(bva != nil)
+ xfree(bva);
+ */
+ return;
+ }
+
+ i8237bva[0] = bva;
+ if(i8237dma == 2)
+ i8237bva[1] = ((uchar*)i8237bva[0])+64*1024;
+ }
+
static void
dmastatus(DMA *dp, int chan, char c)
{
/n/sourcesdump/2006/0321/plan9/sys/src/9/alphapc/dma.c:83,93 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/alphapc/dma.c:118,123
print("%c: addr %uX len %uX stat %uX\n", c, a, l, s);
}
- /*
- * DMA must be in the first 16MB. This gets called early by the
- * initialisation routines of any devices which require DMA to ensure
- * the allocated bounce buffers are below the 16MB limit.
- */
int
dmainit(int chan, int maxtransfer)
{
/n/sourcesdump/2006/0321/plan9/sys/src/9/alphapc/dma.c:121,139 -
/n/sourcesdump/2006/0322/plan9/sys/src/9/alphapc/dma.c:151,162
}
//dmastatus(dp, chan, 'I');
- xp->bva = xspanalloc(maxtransfer, BY2PG, 64*1024);
- if(xp->bva == nil)
+ if(i8237used >= i8237dma || i8237bva[i8237used] == nil){
+ print("no i8237 DMA bounce buffer < 16MB\n");
return 1;
- xp->bpa = PADDR(xp->bva);
- if(xp->bpa >= 16*MB){
- /*
- * This will panic with the current
- * implementation of xspanalloc().
- xfree(xp->bva);
- */
- xp->bva = nil;
- return 1;
}
+ xp->bva = i8237bva[i8237used++];
+ xp->bpa = PADDR(xp->bva);
xp->blen = maxtransfer;
xp->len = 0;
xp->isread = 0;
[jmk] --rw-rw-r-- M 951118 glenda sys 5332 Mar 21 13:39 sys/src/9/pc/dma.c
|