M carrera/screen.c => carrera/screen.c +7 -46
@@ 500,62 500,23 @@ extern cursorunlock(void);
* tile is at location r, first pixel in *data.
* tl is length of scan line to insert,
* l is amount to advance data after each scan line.
+ * gscreen.ldepth is known to be >= 3
*/
void
screenload(Rectangle r, uchar *data, int tl, int l)
{
uchar *q;
- int y, lpart, rpart, mx, m, mr;
+ int y;
if(!rectclip(&r, gscreen.r) || tl<=0)
return;
lock(&screenlock);
-
q = gbaddr(&gscreen, r.min);
- mx = 7>>gscreen.ldepth;
- lpart = (r.min.x & mx) << gscreen.ldepth;
- rpart = (r.max.x & mx) << gscreen.ldepth;
- m = 0xFF >> lpart;
- mr = 0xFF ^ (0xFF >> rpart);
- /* may need to do bit insertion on edges */
- if(l == 1){ /* all in one byte */
- if(rpart)
- m &= mr;
- for(y=r.min.y; y<r.max.y; y++){
- *q ^= (*data^*q) & m;
- q += gscreen.width*sizeof(ulong);
- data += l;
- }
- }else if(lpart==0 && rpart==0){ /* easy case */
- for(y=r.min.y; y<r.max.y; y++){
- memmove(q, data, tl);
- q += gscreen.width*sizeof(ulong);
- data += l;
- }
- }else if(rpart==0){
- for(y=r.min.y; y<r.max.y; y++){
- *q ^= (*data^*q) & m;
- if(tl > 1)
- memmove(q+1, data+1, tl-1);
- q += gscreen.width*sizeof(ulong);
- data += l;
- }
- }else if(lpart == 0){
- for(y=r.min.y; y<r.max.y; y++){
- if(tl > 1)
- memmove(q, data, tl-1);
- q[tl-1] ^= (data[tl-1]^q[tl-1]) & mr;
- q += gscreen.width*sizeof(ulong);
- data += l;
- }
- }else for(y=r.min.y; y<r.max.y; y++){
- *q ^= (*data^*q) & m;
- if(tl > 2)
- memmove(q+1, data+1, tl-2);
- q[tl-1] ^= (data[tl-1]^q[tl-1]) & mr;
- q += gscreen.width*sizeof(ulong);
- data += l;
- }
+ for(y=r.min.y; y<r.max.y; y++){
+ memmove(q, data, tl);
+ q += gscreen.width*sizeof(ulong);
+ data += l;
+ }
unlock(&screenlock);
}
M carrera/trap.c => carrera/trap.c +1 -1
@@ 603,7 603,7 @@ syscall(Ureg *aur)
if(waserror())
goto error;
- if(up->scallnr >= sizeof systab/sizeof systab[0]){
+ if(up->scallnr >= nsyscall){
pprint("bad sys call %d pc %lux\n", up->scallnr, ur->pc);
postnote(up, 1, "sys: bad sys call", NDebug);
error(Ebadarg);
M pc/devvga.c => pc/devvga.c +5 -5
@@ 531,7 531,9 @@ screenload(Rectangle r, uchar *data, int tl, int l)
m = 0xFF >> lpart;
mr = 0xFF ^ (0xFF >> rpart);
/* may need to do bit insertion on edges */
- if(l == 1){ /* all in one byte */
+ if(tl <= 0){
+ ;
+ }else if(tl == 1){ /* all in one byte */
if(rpart)
m &= mr;
for(y=r.min.y; y<r.max.y; y++){
@@ 548,15 550,13 @@ screenload(Rectangle r, uchar *data, int tl, int l)
}else if(rpart==0){
for(y=r.min.y; y<r.max.y; y++){
*q ^= (*data^*q) & m;
- if(tl > 1)
- memmove(q+1, data+1, tl-1);
+ memmove(q+1, data+1, tl-1);
q += gscreen.width*sizeof(ulong);
data += l;
}
}else if(lpart == 0){
for(y=r.min.y; y<r.max.y; y++){
- if(tl > 1)
- memmove(q, data, tl-1);
+ memmove(q, data, tl-1);
q[tl-1] ^= (data[tl-1]^q[tl-1]) & mr;
q += gscreen.width*sizeof(ulong);
data += l;
M pc/trap.c => pc/trap.c +2 -1
@@ 424,11 424,12 @@ syscall(Ureg *ur, void *arg)
up->nerrlab = 0;
ret = -1;
if(!waserror()){
- if(up->scallnr >= sizeof systab/BY2WD){
+ if(up->scallnr >= nsyscall){
pprint("bad sys call number %d pc %lux\n", up->scallnr, ur->pc);
postnote(up, 1, "sys: bad sys call", NDebug);
error(Ebadarg);
}
+ up->syscall[up->scallnr]++;
if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-(1+MAXSYSARG)*BY2WD))
validaddr(sp, (1+MAXSYSARG)*BY2WD, 0);
M port/devproc.c => port/devproc.c +3 -3
@@ 883,16 883,16 @@ readcounters(Proc *p, ulong offset, void *va, int n)
int i, j, m;
extern char *sysctab[];
- bp = smalloc((NSYSCALL+ncounter)*(NAMELEN+8));
+ bp = smalloc((nsyscall+ncounter)*(NAMELEN+8));
m = 0;
for(i = 0; i < Pcounter; i++)
if(counter[i])
m += sprint(bp+m, "%s\t%8d\n", counter[i], p->counter[i]);
j = 0;
- for(i = 0; i < NSYSCALL; i++)
+ for(i = 0; i < nsyscall; i++)
j += p->syscall[i];
m += sprint(bp+m, "syscall\t%8d\n", j);
- for(i = 0; i < NSYSCALL; i++)
+ for(i = 0; i < nsyscall; i++)
if(p->syscall[i])
m += sprint(bp+m, "%s\t%8d\n", sysctab[i], p->syscall[i]);
n = readstr(offset, va, n, bp);
M port/portdat.h => port/portdat.h +2 -2
@@ 487,7 487,6 @@ enum
NERR = 15,
NNOTE = 5,
- NSYSCALL = 39, /* MUST be equal to the real thing!!!! */
Pcounter = 6, /* per process counters */
CSCNTR = 0, /* sched counter */
FAULTCNTR = 1, /* fault counter */
@@ 579,7 578,7 @@ struct Proc
/* statistics */
ulong counter[Pcounter]; /* specialized per process counters */
- ulong syscall[NSYSCALL];
+ ulong *syscall;
/*
* machine specific MMU
@@ 694,3 693,4 @@ enum
extern int mouseshifted;
extern int mousetype;
extern int mouseswap;
+extern int nsyscall;
M port/proc.c => port/proc.c +3 -1
@@ 273,8 273,10 @@ procinit0(void) /* bad planning - clashes with devproc.c */
procalloc.arena = procalloc.free;
p = procalloc.free;
- for(i=0; i<conf.nproc-1; i++,p++)
+ for(i=0; i<conf.nproc-1; i++,p++){
p->qnext = p+1;
+ p->syscall = xalloc(nsyscall * sizeof(ulong));
+ }
p->qnext = 0;
}
M port/systab.h => port/systab.h +2 -0
@@ 127,3 127,5 @@ char *sysctab[]={
[WRITE9P] "Write9p",
[READ9P] "Read9p",
};
+
+int nsyscall = (sizeof systab/sizeof systab[0]);
M power/trap.c => power/trap.c +1 -1
@@ 512,7 512,7 @@ syscall(Ureg *aur)
sp = ur->sp;
ret = -1;
if(!waserror()){
- if(up->scallnr >= sizeof systab/sizeof systab[0]) {
+ if(up->scallnr >= nsyscall) {
pprint("bad sys call number %d pc %lux\n",
up->scallnr, ur->pc);
postnote(up, 1, "sys: bad sys call", NDebug);