M gnot/fns.h => gnot/fns.h +1 -0
@@ 61,3 61,4 @@ int tas(char*);
void touser(void);
#define waserror() (u->nerrlab++, setlabel(&u->errlab[u->nerrlab-1]))
#define kmapperm(x) kmap(x)
+#define getcallerpc(x) (*(ulong*)(x))
M pc/fns.h => pc/fns.h +2 -1
@@ 57,9 57,10 @@ void setvec(int, void (*)(Ureg*));
void systrap(void);
void touser(void);
void trapinit(void);
-int tas(Lock*);
+int tas(void*);
void uartclock(void);
void uartintr0(Ureg*);
void vgainit(void);
#define waserror() (u->nerrlab++, setlabel(&u->errlab[u->nerrlab-1]))
#define kmapperm(x) kmap(x)
+#define getcallerpc(x) (*(ulong*)(x))
M pc/kbd.c => pc/kbd.c +8 -4
@@ 296,8 296,8 @@ middle(int newval)
/*
* keyboard interrupt
*/
-void
-kbdintr(Ureg *ur)
+int
+kbdintr0(void)
{
int s, c, i, nk, nc;
static int esc1, esc2;
@@ 309,8 309,6 @@ kbdintr(Ureg *ur)
static uchar kc[5];
int keyup;
- USED(ur);
-
/*
* get status
*/
@@ 450,3 448,9 @@ dochar:
kbdputc(&kbdq, c);
return 0;
}
+
+void
+kbdintr(Ureg *ur)
+{
+ kbdintr0();
+}
M port/portdat.h => port/portdat.h +1 -0
@@ 107,6 107,7 @@ struct Block
uchar *base; /* start of the buffer */
uchar flags;
uchar type;
+ ulong pc; /* pc of caller */
};
struct Blist {
M port/stream.c => port/stream.c +5 -2
@@ 235,9 235,12 @@ freeb(Block *bp)
Block *nbp;
Bclass *bcp;
int x;
+ ulong pc;
- if((bp->flags&S_CLASS) >= Nclass)
- panic("freeb class");
+ pc = getcallerpc(((uchar*)&bp) - sizeof(bp));
+ if((bp->flags&S_CLASS) >= Nclass) /* Check for double free */
+ panic("freeb class last(%lux) this(%lux)", bp->pc, pc);
+ bp->pc = pc;
for(; bp; bp = nbp){
bcp = &bclass[bp->flags & S_CLASS];
R gnot/lock.c => port/taslock.c +8 -6
@@ 5,18 5,20 @@
#include "fns.h"
#include "../port/error.h"
-#define PCOFF -1
-
void
lock(Lock *l)
{
+ Lock *ll = l;
int i;
+ ulong pc;
+
+ pc = getcallerpc(((uchar*)&l) - sizeof(l));
for(i = 0; i < 1000000; i++){
- if (tas(&l->key) == 0){
+ if (tas(&ll->key) == 0){
if(u)
u->p->hasspin = 1;
- l->pc = ((ulong*)&l)[PCOFF];
+ ll->pc = pc;
return;
}
if(u && u->p->state == Running)
@@ 26,7 28,7 @@ lock(Lock *l)
l->key = 0;
panic("lock loop 0x%lux key 0x%lux pc 0x%lux held by pc 0x%lux\n", l, i,
- ((ulong*)&l)[PCOFF], l->pc);
+ pc, l->pc);
}
int
@@ 34,7 36,7 @@ canlock(Lock *l)
{
if(tas(&l->key))
return 0;
- l->pc = ((ulong*)&l)[PCOFF];
+ l->pc = getcallerpc(((uchar*)&l) - sizeof(l));
if(u && u->p)
u->p->hasspin = 1;
return 1;
M power/fns.h => power/fns.h +1 -1
@@ 25,7 25,7 @@ void flushmmu(void);
void gettlb(int, ulong*);
ulong gettlbvirt(int);
void gotopc(ulong);
-ulong getcallerpc(void);
+ulong getcallerpc(void*);
void icflush(void *, ulong);
void ioboardinit(void);
void intr(Ureg*);
M power/l.s => power/l.s +1 -1
@@ 151,7 151,7 @@ TEXT gotolabel(SB), $-4
TEXT getcallerpc(SB), $0
- MOVW (SP), R1
+ MOVW 4(SP), R1
RET
TEXT gotopc(SB), $8
M power/lock.c => power/lock.c +4 -4
@@ 132,16 132,16 @@ lock(Lock *l)
* Try the fast grab first
*/
if((*sbsem&1) == 0){
- l->pc = getcallerpc();
+ l->pc = getcallerpc(l);
return;
}
for(i=0; i<10000000; i++)
if((*sbsem&1) == 0){
- l->pc = getcallerpc();
+ l->pc = getcallerpc(l);
return;
}
*sbsem = 0;
- print("lock loop %lux pc %lux held by pc %lux\n", l, getcallerpc(), l->pc);
+ print("lock loop %lux pc %lux held by pc %lux\n", l, getcallerpc(l), l->pc);
dumpstack();
}
@@ 168,7 168,7 @@ canlock(Lock *l)
}
if(*sbsem & 1)
return 0;
- l->pc = getcallerpc();
+ l->pc = getcallerpc(l);
return 1;
}
M ss/fns.h => ss/fns.h +2 -1
@@ 61,9 61,10 @@ void screeninit(void);
void screenputc(int);
void screenputs(char*, int);
void spldone(void);
-ulong swap1(ulong*);
+ulong tas(ulong*);
void touser(ulong);
void trap(Ureg*);
void trapinit(void);
#define wbflush() /* mips compatibility */
#define waserror() (u->nerrlab++, setlabel(&u->errlab[u->nerrlab-1]))
+#define getcallerpc(x) (*(ulong*)(x))
M ss/l.s => ss/l.s +1 -1
@@ 55,7 55,7 @@ TEXT startvirt(SB), $-4
MOVW (R0), R0
RETURN
-TEXT swap1(SB), $0
+TEXT tas(SB), $0
TAS (R7), R7 /* LDSTUB, thank you ken */
RETURN