From b7acd877ae1c91c02f5e78a6843ce3e01257dee8 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 30 Apr 2002 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2002-04-30 --- bitsy/fns.h | 2 ++ bitsy/l.s | 25 ++++++++++++++++++++++++- bitsy/trap.c | 9 +++++++-- pc/devvga.c | 8 ++++---- pc/mmu.c | 1 + port/devproc.c | 3 +++ 6 files changed, 41 insertions(+), 7 deletions(-) diff --git a/bitsy/fns.h b/bitsy/fns.h index 65fbff23b59866e7541b9003b5c2505e7281f42f..6fe8dd2f5668fe5bf9c0fb9a4f47a073f0c41e4a 100644 --- a/bitsy/fns.h +++ b/bitsy/fns.h @@ -43,6 +43,8 @@ ulong getsp(void); void gpiointrenable(ulong, int, void (*)(Ureg*, void*), void*, char*); void h3650uartsetup(void); int havetimer(void); +void _hibernate(void); +void (*hibernate)(void); void icacheinvalidate(void); void idle(void); void idlehands(void); diff --git a/bitsy/l.s b/bitsy/l.s index a7516c9bb974697fa5cae749ba791580567b1922..8ab29d04cf8c907c46c3cd01cb470cb740629f5c 100644 --- a/bitsy/l.s +++ b/bitsy/l.s @@ -722,15 +722,38 @@ l14: SUB $1,R0 MOVW 0x2c(R3),R2 AND $(~0x00030003),R2 MOVW R2,0x2c(R3) - MOVW R0,R0 /* filler */ + MOVW R0,R0 + MOVW R0,R0 + MOVW R0,R0 + MOVW R0,R0 + MOVW R0,R0 + MOVW R0,R0 + MOVW R0,R0 + MOVW R0,R0 + MOVW R0,R0 + /* align this on a cache-line boundary */ MOVW $1,R2 MOVW R4,0x1c(R3) MOVW R6,0x1c(R3) MOVW R12,0x0(R3) MOVW R11,0x1c(R3) MOVW R2,0x0(R5) +xlloop: + B xlloop /* loop waiting for sleep */ +/* The first instruction of this function needs to be on a cache-line + * boundary; to make this happen, it will be copied (in trap.c). + * + * Hibernate puts the machine into hibernation. + */ +TEXT _hibernate(SB), $-4 + MOVW $1,R2 + MOVW R4,0x1c(R3) + MOVW R6,0x1c(R3) + MOVW R12,0x0(R3) + MOVW R11,0x1c(R3) + MOVW R2,0x0(R5) slloop: B slloop /* loop waiting for sleep */ diff --git a/bitsy/trap.c b/bitsy/trap.c index 126df3fd0c481e1530ea8a0975acca629ab12799..3602ca91032f8b9cc37c5505372f5be64aaf6038 100644 --- a/bitsy/trap.c +++ b/bitsy/trap.c @@ -31,9 +31,10 @@ typedef struct Vpage0 { Vpage0 *vpage0; /* - * An cached line for the doze code + * A cached line for the doze and hibernate code */ void (*doze)(void); +void (*hibernate)(void); static void irq(Ureg*); static void gpiointr(Ureg*, void*); @@ -65,9 +66,13 @@ trapinit(void) memmove(vpage0->vectors, vectors, sizeof(vpage0->vectors)); memmove(vpage0->vtable, vtable, sizeof(vpage0->vtable)); - /* relocate the doze routine to a cache line boundary in cached mem */ + /* relocate the doze and hibernate routines + * to a cache line boundary in cached mem + */ doze = xspanalloc(12*sizeof(long), 16, 0); memmove(doze, _doze, 12*sizeof(long)); + hibernate = xspanalloc(8*sizeof(long), 16, 0); + memmove(hibernate, _hibernate, 8*sizeof(long)); wbflush(); /* use exception vectors at 0xFFFF0000 */ diff --git a/pc/devvga.c b/pc/devvga.c index 13a6f8473659bf63b0b7b622b313fd84df777c38..765eb83d673251e961c20ce54f8c258be5b614fc 100644 --- a/pc/devvga.c +++ b/pc/devvga.c @@ -97,7 +97,7 @@ vgaopen(Chan* c, int omode) scr = &vgascreen[0]; if ((ulong)c->qid.path == Qvgaovlctl) { - if (scr->dev->ovlctl) + if (scr->dev && scr->dev->ovlctl) scr->dev->ovlctl(scr, c, openctl, strlen(openctl)); else error(Enonexist); @@ -113,7 +113,7 @@ vgaclose(Chan* c) scr = &vgascreen[0]; if((ulong)c->qid.path == Qvgaovlctl) - if(scr->dev->ovlctl){ + if(scr->dev && scr->dev->ovlctl){ if(waserror()){ print("ovlctl error: %s\n", up->errstr); return; @@ -418,7 +418,7 @@ vgawrite(Chan* c, void* a, long n, vlong off) case Qvgaovl: scr = &vgascreen[0]; - if (scr->dev->ovlwrite == nil) { + if (scr->dev == nil || scr->dev->ovlwrite == nil) { error(Enooverlay); break; } @@ -426,7 +426,7 @@ vgawrite(Chan* c, void* a, long n, vlong off) case Qvgaovlctl: scr = &vgascreen[0]; - if (scr->dev->ovlctl == nil) { + if (scr->dev == nil || scr->dev->ovlctl == nil) { error(Enooverlay); break; } diff --git a/pc/mmu.c b/pc/mmu.c index 3e7080e8a9152181e7a33dd91c465195b69e9e95..4a2a0ed1f8c59b324bc24c228a63918c51967a75 100644 --- a/pc/mmu.c +++ b/pc/mmu.c @@ -56,6 +56,7 @@ memglobal(void) int i, j; ulong *pde, *pte; +return; /* only need to do this once, on bootstrap processor */ if(m->machno != 0) return; diff --git a/port/devproc.c b/port/devproc.c index a0e8e32b20a1c8ef6d0148e6da9aa00448e262ec..d0fedbdaf1a453270a766fa9e915abe13af23a76 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -556,6 +556,9 @@ procread(Chan *c, void *va, long n, vlong off) || (offset >= USTKTOP-USTKSIZE && offset < USTKTOP)) return procctlmemio(p, offset, n, va, 1); + if(!iseve()) + error(Eperm); + /* validate kernel addresses */ if(offset < (ulong)end) { if(offset+n > (ulong)end)