fix autoconf, move code to isa.c, remove debugging, drop redundant tlbflushes, macros...
authorBill Joy <bill@ucbvax.Berkeley.EDU>
Mon, 19 Nov 1990 03:30:17 +0000 (19:30 -0800)
committerBill Joy <bill@ucbvax.Berkeley.EDU>
Mon, 19 Nov 1990 03:30:17 +0000 (19:30 -0800)
SCCS-vsn: sys/i386/i386/autoconf.c 5.5
SCCS-vsn: sys/i386/i386/mem.c 5.4
SCCS-vsn: sys/i386/i386/locore.s 5.5
SCCS-vsn: sys/i386/i386/machdep.c 5.4
SCCS-vsn: sys/i386/include/vmparam.h 5.3
SCCS-vsn: sys/i386/i386/vm_machdep.c 5.4
SCCS-vsn: sys/i386/i386/trap.c 5.4

usr/src/sys/i386/i386/autoconf.c
usr/src/sys/i386/i386/locore.s
usr/src/sys/i386/i386/machdep.c
usr/src/sys/i386/i386/mem.c
usr/src/sys/i386/i386/trap.c
usr/src/sys/i386/i386/vm_machdep.c
usr/src/sys/i386/include/vmparam.h

index 2c4b8da..bce054f 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.386.c%
  *
  *
  * %sccs.include.386.c%
  *
- *     @(#)autoconf.c  5.4 (Berkeley) %G%
+ *     @(#)autoconf.c  5.5 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -43,6 +43,7 @@ int   cold;           /* cold start flag initialized in locore.s */
  */
 configure()
 {
  */
 configure()
 {
+
 #include "isa.h"
 #if NISA > 0
        isa_configure();
 #include "isa.h"
 #if NISA > 0
        isa_configure();
@@ -63,60 +64,6 @@ configure()
        cold = 0;
 }
 
        cold = 0;
 }
 
-#if NISA > 0
-#include "machine/isa/device.h"
-#include "machine/isa/icu.h"
-isa_configure() {
-       struct isa_device *dvp;
-       struct isa_driver *dp;
-
-       splhigh();
-       INTREN(IRQ_SLAVE);
-       for (dvp = isa_devtab_bio; config_isadev(dvp,&biomask); dvp++);
-       for (dvp = isa_devtab_tty; config_isadev(dvp,&ttymask); dvp++);
-       for (dvp = isa_devtab_net; config_isadev(dvp,&netmask); dvp++);
-       for (dvp = isa_devtab_null; config_isadev(dvp,0); dvp++);
-#include "sl.h"
-#if NSL > 0
-       netmask |= ttymask;
-       ttymask |= netmask;
-#endif
-       /* biomask |= ttymask ;  can some tty devices use buffers? */
-       printf("biomask %x ttymask %x netmask %x\n", biomask, ttymask, netmask);
-       splnone();
-}
-
-config_isadev(isdp, mp)
-       struct isa_device *isdp;
-       int *mp;
-{
-       struct isa_driver *dp;
-       if (dp = isdp->id_driver) {
-               if (isdp->id_maddr) {
-                       extern int atdevbase[];
-
-                       isdp->id_maddr -= 0xa0000;
-                       isdp->id_maddr += (int)&atdevbase;
-               }
-               isdp->id_alive = (*dp->probe)(isdp);
-               if (isdp->id_alive) {
-                       printf("%s%d", dp->name, isdp->id_unit);
-                       (*dp->attach)(isdp);
-                       printf(" at 0x%x ", isdp->id_iobase);
-                       if(isdp->id_irq) {
-                               printf("irq %d ", ffs(isdp->id_irq)-1);
-                               INTREN(isdp->id_irq);
-                               if(mp)INTRMASK(*mp,isdp->id_irq);
-                       }
-                       if (isdp->id_drq != -1) printf("drq %d ", isdp->id_drq);
-                       printf("on isa0\n");
-               }
-               return (1);
-       } else  return(0);
-}
-#endif
-
 /*
  * Configure swap space and related parameters.
  */
 /*
  * Configure swap space and related parameters.
  */
index 2fe95c0..120f3e3 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.386.c%
  *
  *
  * %sccs.include.386.c%
  *
- *     @(#)locore.s    5.4 (Berkeley) %G%
+ *     @(#)locore.s    5.5 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -361,11 +361,11 @@ begin:
        movl    %ecx,PCB_P1BR(%eax)     # p1br: P1PAGES from end of PT
        movl    $ P1PAGES-UPAGES,PCB_P1LR(%eax) # p1lr: vax style
        movl    $ CLSIZE,PCB_SZPT(%eax) # page table size
        movl    %ecx,PCB_P1BR(%eax)     # p1br: P1PAGES from end of PT
        movl    $ P1PAGES-UPAGES,PCB_P1LR(%eax) # p1lr: vax style
        movl    $ CLSIZE,PCB_SZPT(%eax) # page table size
-       fninit
-       pushl   $0x262
-       fldcw   0(%esp)
-       popl    %ecx
-       fnsave  PCB_SAVEFPU(%eax)
+       fninit
+       # pushl $0x262
+       # fldcw 0(%esp)
+       # popl  %ecx
+       # fnsave        PCB_SAVEFPU(%eax)
        movl    %edi,PCB_CR3(%eax)
        pushl   %edi    # cr3
        movl    %esi,%eax
        movl    %edi,PCB_CR3(%eax)
        pushl   %edi    # cr3
        movl    %esi,%eax
@@ -993,9 +993,9 @@ sw2:
        movl    %eax,_Swtchmap
        movl    4(%edx),%eax
        movl    %eax,_Swtchmap+4
        movl    %eax,_Swtchmap
        movl    4(%edx),%eax
        movl    %eax,_Swtchmap+4
-       movl    %cr3,%eax
-       orl     $ I386_CR3PAT,%eax
-       movl    %eax,%cr3
+       # movl  %cr3,%eax
+       # orl   $ I386_CR3PAT,%eax
+       # movl  %eax,%cr3
        movl    _Swtchbase+PCB_CR3,%edx
 
  # pushal; pushl %edx ; pushl P_CR3(%ecx); pushl $l2; call _pg; popl %eax ; popl %eax; popl %eax ; popal ; .data ; l2: .asciz "s %x %x " ; .text
        movl    _Swtchbase+PCB_CR3,%edx
 
  # pushal; pushl %edx ; pushl P_CR3(%ecx); pushl $l2; call _pg; popl %eax ; popl %eax; popl %eax ; popal ; .data ; l2: .asciz "s %x %x " ; .text
@@ -1110,21 +1110,148 @@ _doadump:
 _physaddr:
        .byte 0xcc
 
 _physaddr:
        .byte 0xcc
 
-/* Paranoiaa - never happens, right? */
-       .globl  _svfpsp,_rsfpsp
-_svfpsp:
-       popl %eax
-       movl    %esp,svesp
-       movl    %ebp,svebp
-       pushl %eax
-       ret
+#define        IDTVEC(name)    .align 4; .globl _X/**/name; _X/**/name:
+/*#define      PANIC(msg)      xorl %eax,%eax; movl %eax,_waittime; pushl 1f; \
+                       call _panic; 1: .asciz msg*/
+#define        PRINTF(n,msg)   pushal ; pushl 1f; call _printf; MSG(msg) ; popl %eax ; popal
+#define        MSG(msg)        .data; 1: .asciz msg; .text
 
 
-_rsfpsp:
-       popl %eax
-       movl    svesp,%esp
-       movl    svebp,%ebp
-       pushl %eax
-       ret
+       .text
+
+/*
+ * Trap and fault vector routines
+ */ 
+#define        TRAP(a) pushl $ a; jmp alltraps
+
+IDTVEC(div)
+       pushl $0; TRAP(T_DIVIDE)
+IDTVEC(dbg)
+       pushl $0; TRAP(T_TRCTRAP)
+IDTVEC(nmi)
+       pushl $0; TRAP(T_NMI)
+IDTVEC(bpt)
+       pushl $0; TRAP(T_BPTFLT)
+IDTVEC(ofl)
+       pushl $0; TRAP(T_OFLOW)
+IDTVEC(bnd)
+       pushl $0; TRAP(T_BOUND)
+IDTVEC(ill)
+       pushl $0; TRAP(T_PRIVINFLT)
+IDTVEC(dna)
+       pushl $0; TRAP(T_DNA)
+IDTVEC(dble)
+       TRAP(T_DOUBLEFLT)
+       /*PANIC("Double Fault");*/
+IDTVEC(fpusegm)
+       pushl $0; TRAP(T_FPOPFLT)
+IDTVEC(tss)
+       TRAP(T_TSSFLT)
+       /*PANIC("TSS not valid");*/
+IDTVEC(missing)
+       TRAP(T_SEGNPFLT)
+IDTVEC(stk)
+       TRAP(T_STKFLT)
+IDTVEC(prot)
+       TRAP(T_PROTFLT)
+IDTVEC(page)
+       TRAP(T_PAGEFLT)
+IDTVEC(rsvd)
+       pushl $0; TRAP(T_RESERVED)
+IDTVEC(fpu)
+       pushl $0; TRAP(T_ARITHTRAP)
+       /* 17 - 31 reserved for future exp */
+IDTVEC(rsvd0)
+       pushl $0; TRAP(17)
+IDTVEC(rsvd1)
+       pushl $0; TRAP(18)
+IDTVEC(rsvd2)
+       pushl $0; TRAP(19)
+IDTVEC(rsvd3)
+       pushl $0; TRAP(20)
+IDTVEC(rsvd4)
+       pushl $0; TRAP(21)
+IDTVEC(rsvd5)
+       pushl $0; TRAP(22)
+IDTVEC(rsvd6)
+       pushl $0; TRAP(23)
+IDTVEC(rsvd7)
+       pushl $0; TRAP(24)
+IDTVEC(rsvd8)
+       pushl $0; TRAP(25)
+IDTVEC(rsvd9)
+       pushl $0; TRAP(26)
+IDTVEC(rsvd10)
+       pushl $0; TRAP(27)
+IDTVEC(rsvd11)
+       pushl $0; TRAP(28)
+IDTVEC(rsvd12)
+       pushl $0; TRAP(29)
+IDTVEC(rsvd13)
+       pushl $0; TRAP(30)
+IDTVEC(rsvd14)
+       pushl $0; TRAP(31)
+
+alltraps:
+       pushal
+       push %ds
+       push %es
+       movw    $0x10,%ax
+       movw    %ax,%ds
+       movw    %ax,%es
+       incl    _cnt+V_TRAP
+       call    _trap
+
+#ifdef junk
+       cmpl    $0xfc000000,12*4(%esp)  # is it a user pc
+       ja      1f 
+       cmpw    $0x1f,13*4(%esp)        # is it a user cs
+       je      1f 
+       .data   ; lx: .asciz "t user cs %x?" ; .text
+2:
+       movl    13*4(%esp),%eax
+       pushl   %eax
+       pushl   $lx
+       call    _pg
+       popl %eax ; popl %eax
+       jmp     2b
+1:
+#endif junk
+
+       pop %es
+       pop %ds
+       popal
+       addl    $8,%esp                 # pop type, code
+       iret
+
+/*
+ * Call gate entry for syscall
+ */
+
+IDTVEC(syscall)
+       pushfl  # only for stupid carry bit and more stupid wait3 cc kludge
+       pushal  # only need eax,ecx,edx - trap resaves others
+       movw    $0x10,%ax       # switch to kernel segments
+       movw    %ax,%ds
+       movw    %ax,%es
+       call    _syscall
+
+#ifdef notdef
+       cmpw    $0x1f,10*4(%esp)        # is user cs what it should be?
+       jz      1f
+       .data   ; lz: .asciz "s user cs %x?" ; .text
+2:
+       movl    10*4(%esp),%eax
+       pushl   %eax
+       pushl   $lz
+       call    _pg
+       jmp     2b
+1:
+#endif
+
+       movw    __udatasel,%ax  # switch back to user segments
+       movw    %ax,%ds
+       movw    %ax,%es
+       popal
+       popfl
+       lret                    # back we go, we hope!
 
 
-svesp: .long 0
-svebp: .long 0
index 11ea405..fba45f8 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.386.c%
  *
  *
  * %sccs.include.386.c%
  *
- *     @(#)machdep.c   5.3 (Berkeley) %G%
+ *     @(#)machdep.c   5.4 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -58,8 +58,9 @@ int kernmem;
 /*
  * Machine-dependent startup code
  */
 /*
  * Machine-dependent startup code
  */
-extern char Sysbase;
-caddr_t sbase = { &Sysbase };
+/*extern char Sysbase;
+caddr_t sbase = { &Sysbase };*/
+extern char    Sysbase[];
 /* extern struct pte   EMCmap[];
 extern char            EMCbase[]; */
 int boothowto = 0, Maxmem = 0;
 /* extern struct pte   EMCmap[];
 extern char            EMCbase[]; */
 int boothowto = 0, Maxmem = 0;
@@ -73,8 +74,8 @@ extern cyloffset;
 
 caddr_t bypasshole(b,t) caddr_t b,t; {
 
 
 caddr_t bypasshole(b,t) caddr_t b,t; {
 
-       if (b <= sbase + 0xa0000 && t > sbase + 0xa0000)
-               return(sbase + 0x100000);
+       if (b <= Sysbase + 0xa0000 && t > Sysbase + 0xa0000)
+               return(Sysbase + 0x100000);
        return(b);
 }
 
        return(b);
 }
 
@@ -140,6 +141,8 @@ How about starting cmap normally following valloc space, and then
 write a routine than allocs only phys pages in the 0xa0000-0x100000
 hole?
 
 write a routine than allocs only phys pages in the 0xa0000-0x100000
 hole?
 
+Temporary fix for beta, if we only have 640K, then cmap follows valloc
+up to 640K.
 */
        maxmem -= btoc(sizeof (struct msgbuf));
        pte = msgbufmap;
 */
        maxmem -= btoc(sizeof (struct msgbuf));
        pte = msgbufmap;
@@ -176,7 +179,7 @@ hole?
         * An index into the kernel page table corresponding to the
         * virtual memory address maintained in "v" is kept in "mapaddr".
         */
         * An index into the kernel page table corresponding to the
         * virtual memory address maintained in "v" is kept in "mapaddr".
         */
-       v = (caddr_t)(sbase + (firstaddr * NBPG));
+       v = (caddr_t)(Sysbase + (firstaddr * NBPG));
        /*v = sbase + (firstaddr * NBPG);*/
 #define        valloc(name, type, num) \
                v = bypasshole (v, v + (int) ((name)+(num))) ; \
        /*v = sbase + (firstaddr * NBPG);*/
 #define        valloc(name, type, num) \
                v = bypasshole (v, v + (int) ((name)+(num))) ; \
@@ -228,10 +231,10 @@ hole?
         * Now the amount of virtual memory remaining for buffers
         * can be calculated, estimating needs for the cmap.
         */
         * Now the amount of virtual memory remaining for buffers
         * can be calculated, estimating needs for the cmap.
         */
-       ncmap = (maxmem*NBPG  - ((int)(v - sbase))) /
+       ncmap = (maxmem*NBPG  - ((int)(v - Sysbase))) /
                (CLBYTES + sizeof(struct cmap)) + 2;
        maxbufs = ((SYSPTSIZE * NBPG) -
                (CLBYTES + sizeof(struct cmap)) + 2;
        maxbufs = ((SYSPTSIZE * NBPG) -
-               ((int)(v - sbase + ncmap * sizeof(struct cmap)))) /
+               ((int)(v - Sysbase + ncmap * sizeof(struct cmap)))) /
                (MAXBSIZE + sizeof(struct buf));
        if (maxbufs < 16)
                panic("sys pt too small");
                (MAXBSIZE + sizeof(struct buf));
        if (maxbufs < 16)
                panic("sys pt too small");
@@ -253,7 +256,7 @@ hole?
         * Add 2: 1 because the 0th entry is unused, 1 for rounding.
         */
        /*ncmap = (maxmem*NBPG - ((int)((v - sbase) + bufpages*CLBYTES))) /*/
         * Add 2: 1 because the 0th entry is unused, 1 for rounding.
         */
        /*ncmap = (maxmem*NBPG - ((int)((v - sbase) + bufpages*CLBYTES))) /*/
-       ncmap = (maxmem*NBPG - ((int)((v - sbase) + bufpages*CLBYTES))) /
+       ncmap = (maxmem*NBPG - ((int)((v - Sysbase) + bufpages*CLBYTES))) /
                (CLBYTES + sizeof(struct cmap)) + 2;
        valloclim(cmap, struct cmap, ncmap, ecmap);
 
                (CLBYTES + sizeof(struct cmap)) + 2;
        valloclim(cmap, struct cmap, ncmap, ecmap);
 
@@ -261,7 +264,7 @@ hole?
         * Clear space allocated thus far, and make r/w entries
         * for the space in the kernel map.
         */
         * Clear space allocated thus far, and make r/w entries
         * for the space in the kernel map.
         */
-       unixsize = btoc((int)(v - sbase));
+       unixsize = btoc((int)(v - Sysbase));
        while (firstaddr < unixsize) {
                *(int *)(&Sysmap[firstaddr]) = PG_V | PG_KW | ctob(firstaddr);
                clearseg((unsigned)firstaddr);
        while (firstaddr < unixsize) {
                *(int *)(&Sysmap[firstaddr]) = PG_V | PG_KW | ctob(firstaddr);
                clearseg((unsigned)firstaddr);
@@ -278,7 +281,7 @@ hole?
        valloc(buffers, char, MAXBSIZE * nbuf);
        base = bufpages / nbuf;
        residual = bufpages % nbuf;
        valloc(buffers, char, MAXBSIZE * nbuf);
        base = bufpages / nbuf;
        residual = bufpages % nbuf;
-       mapaddr = firstaddr = btoc((unsigned) buffers - (unsigned)sbase);
+       mapaddr = firstaddr = btoc((unsigned) buffers - (unsigned)Sysbase);
        for (i = 0; i < residual; i++) {
                for (j = 0; j < (base + 1) * CLSIZE; j++) {
                        *(int *)(&Sysmap[mapaddr+j]) = PG_V | PG_KW | ctob(firstaddr);
        for (i = 0; i < residual; i++) {
                for (j = 0; j < (base + 1) * CLSIZE; j++) {
                        *(int *)(&Sysmap[mapaddr+j]) = PG_V | PG_KW | ctob(firstaddr);
@@ -296,7 +299,7 @@ hole?
                mapaddr += MAXBSIZE / NBPG;
        }
 
                mapaddr += MAXBSIZE / NBPG;
        }
 
-       unixsize = btoc((int)(v - sbase));
+       unixsize = btoc((int)(v - Sysbase));
        if (firstaddr >= physmem - 8*UPAGES)
                panic("no memory");
 
        if (firstaddr >= physmem - 8*UPAGES)
                panic("no memory");
 
@@ -590,9 +593,8 @@ boot(arghowto)
        devtype = major(rootdev);
        if (howto&RB_HALT) {
                printf("halting (in tight loop); hit reset\n\n");
        devtype = major(rootdev);
        if (howto&RB_HALT) {
                printf("halting (in tight loop); hit reset\n\n");
-reset_cpu();
-               for (;;)
-                       ;
+               reset_cpu();
+               for (;;) ;
        } else {
                if (howto & RB_DUMP) {
                        doadump();              /* CPBOOT's itsself */
        } else {
                if (howto & RB_DUMP) {
                        doadump();              /* CPBOOT's itsself */
@@ -603,9 +605,8 @@ reset_cpu();
        dummy = 0; dummy = dummy;
        printf("howto %d, devtype %d\n", arghowto, devtype);
 #endif
        dummy = 0; dummy = dummy;
        printf("howto %d, devtype %d\n", arghowto, devtype);
 #endif
-reset_cpu();
-       for (;;)
-               /*asm("hlt")*/;
+       reset_cpu();
+       for(;;) ;
        /*NOTREACHED*/
 }
 
        /*NOTREACHED*/
 }
 
@@ -882,56 +883,14 @@ setidt(idx, func, typ, dpl) char *func; {
 }
 
 #define        IDTVEC(name)    X/**/name
 }
 
 #define        IDTVEC(name)    X/**/name
-extern
-IDTVEC(div),
-IDTVEC(dbg),
-IDTVEC(nmi),
-IDTVEC(bpt),
-IDTVEC(ofl),
-IDTVEC(bnd),
-IDTVEC(ill),
-IDTVEC(dna),
- IDTVEC(dble),         /* XXX needs to be handled by task gate */
-IDTVEC(fpusegm),
- IDTVEC(tss),          /* XXX needs to be handled by task gate */
- IDTVEC(missing),      /* XXX needs to be handled by task gate */
- IDTVEC(stk),          /* XXX needs to be handled by task gate */
-IDTVEC(prot),
-IDTVEC(page),
-IDTVEC(rsvd),
-IDTVEC(fpu),
-IDTVEC(rsvd0),
-IDTVEC(rsvd1),
-IDTVEC(rsvd2),
-IDTVEC(rsvd3),
-IDTVEC(rsvd4),
-IDTVEC(rsvd5),
-IDTVEC(rsvd6),
-IDTVEC(rsvd7),
-IDTVEC(rsvd8),
-IDTVEC(rsvd9),
-IDTVEC(rsvd10),
-IDTVEC(rsvd11),
-IDTVEC(rsvd12),
-IDTVEC(rsvd13),
-IDTVEC(rsvd14),
-IDTVEC(rsvd14),
-IDTVEC(intr0),
-IDTVEC(intr1),
-IDTVEC(intr3),
-IDTVEC(intr4),
-IDTVEC(intr5),
-IDTVEC(intr6),
-IDTVEC(intr7),
-IDTVEC(intr8),
-IDTVEC(intr9),
-IDTVEC(intr10),
-IDTVEC(intr11),
-IDTVEC(intr12),
-IDTVEC(intr13),
-IDTVEC(intr14),
-IDTVEC(intr15),
-IDTVEC(syscall);
+extern IDTVEC(div), IDTVEC(dbg), IDTVEC(nmi), IDTVEC(bpt), IDTVEC(ofl),
+       IDTVEC(bnd), IDTVEC(ill), IDTVEC(dna), IDTVEC(dble), IDTVEC(fpusegm),
+       IDTVEC(tss), IDTVEC(missing), IDTVEC(stk), IDTVEC(prot),
+       IDTVEC(page), IDTVEC(rsvd), IDTVEC(fpu), IDTVEC(rsvd0),
+       IDTVEC(rsvd1), IDTVEC(rsvd2), IDTVEC(rsvd3), IDTVEC(rsvd4),
+       IDTVEC(rsvd5), IDTVEC(rsvd6), IDTVEC(rsvd7), IDTVEC(rsvd8),
+       IDTVEC(rsvd9), IDTVEC(rsvd10), IDTVEC(rsvd11), IDTVEC(rsvd12),
+       IDTVEC(rsvd13), IDTVEC(rsvd14), IDTVEC(rsvd14), IDTVEC(syscall);
 
 int lcr0(), lcr3(), rcr0(), rcr2();
 int _udatasel, _ucodesel, _gsel_tss;
 
 int lcr0(), lcr3(), rcr0(), rcr2();
 int _udatasel, _ucodesel, _gsel_tss;
@@ -944,17 +903,17 @@ init386(first) { extern ssdtosd(), lgdt(), lidt(), lldt(), etext;
        gdt_segs[GCODE_SEL].ssd_limit = btoc((int) &etext + NBPG);
        for (x=0; x < 6; x++) ssdtosd(gdt_segs+x, gdt+x);
        /* make ldt memory segments */
        gdt_segs[GCODE_SEL].ssd_limit = btoc((int) &etext + NBPG);
        for (x=0; x < 6; x++) ssdtosd(gdt_segs+x, gdt+x);
        /* make ldt memory segments */
-       ldt_segs[LUCODE_SEL].ssd_limit = btoc((int) &Sysbase);
-       /*ldt_segs[LUDATA_SEL].ssd_limit = btoc((int) &Sysbase); */
+       ldt_segs[LUCODE_SEL].ssd_limit = btoc((int) Sysbase);
+       /*ldt_segs[LUDATA_SEL].ssd_limit = btoc((int) Sysbase); */
        ldt_segs[LUDATA_SEL].ssd_limit = btoc(0xfffff000);
        ldt_segs[LUDATA_SEL].ssd_limit = btoc(0xfffff000);
-       for (x=0; x < 5; x++) ssdtosd(ldt_segs+x, ldt+x);
 /* Note. eventually want private ldts per process */
 /* Note. eventually want private ldts per process */
+       for (x=0; x < 5; x++) ssdtosd(ldt_segs+x, ldt+x);
 
 /* exceptions */
        setidt(0, &IDTVEC(div),  SDT_SYS386TGT, SEL_KPL);
        setidt(1, &IDTVEC(dbg),  SDT_SYS386TGT, SEL_KPL);
        setidt(2, &IDTVEC(nmi),  SDT_SYS386TGT, SEL_KPL);
 
 /* exceptions */
        setidt(0, &IDTVEC(div),  SDT_SYS386TGT, SEL_KPL);
        setidt(1, &IDTVEC(dbg),  SDT_SYS386TGT, SEL_KPL);
        setidt(2, &IDTVEC(nmi),  SDT_SYS386TGT, SEL_KPL);
-         setidt(3, &IDTVEC(bpt),  SDT_SYS386TGT, SEL_UPL);
+       setidt(3, &IDTVEC(bpt),  SDT_SYS386TGT, SEL_UPL);
        setidt(4, &IDTVEC(ofl),  SDT_SYS386TGT, SEL_KPL);
        setidt(5, &IDTVEC(bnd),  SDT_SYS386TGT, SEL_KPL);
        setidt(6, &IDTVEC(ill),  SDT_SYS386TGT, SEL_KPL);
        setidt(4, &IDTVEC(ofl),  SDT_SYS386TGT, SEL_KPL);
        setidt(5, &IDTVEC(bnd),  SDT_SYS386TGT, SEL_KPL);
        setidt(6, &IDTVEC(ill),  SDT_SYS386TGT, SEL_KPL);
@@ -984,25 +943,10 @@ init386(first) { extern ssdtosd(), lgdt(), lidt(), lldt(), etext;
        setidt(30, &IDTVEC(rsvd13),  SDT_SYS386TGT, SEL_KPL);
        setidt(31, &IDTVEC(rsvd14),  SDT_SYS386TGT, SEL_KPL);
 
        setidt(30, &IDTVEC(rsvd13),  SDT_SYS386TGT, SEL_KPL);
        setidt(31, &IDTVEC(rsvd14),  SDT_SYS386TGT, SEL_KPL);
 
-/* first icu */
-       setidt(32, &IDTVEC(intr0),  SDT_SYS386IGT, SEL_KPL);
-       setidt(33, &IDTVEC(intr1),  SDT_SYS386IGT, SEL_KPL);
-       setidt(34, &IDTVEC(intr9),  SDT_SYS386IGT, SEL_KPL); /* note: never happens */
-       setidt(35, &IDTVEC(intr3),  SDT_SYS386IGT, SEL_KPL);
-       setidt(36, &IDTVEC(intr4),  SDT_SYS386IGT, SEL_KPL);
-       setidt(37, &IDTVEC(intr5),  SDT_SYS386IGT, SEL_KPL);
-       setidt(38, &IDTVEC(intr6),  SDT_SYS386IGT, SEL_KPL);
-       setidt(39, &IDTVEC(intr7),  SDT_SYS386IGT, SEL_KPL);
-
-/* second icu */
-       setidt(40, &IDTVEC(intr8),  SDT_SYS386IGT, SEL_KPL);
-       setidt(41, &IDTVEC(intr9),  SDT_SYS386IGT, SEL_KPL);
-       setidt(42, &IDTVEC(intr10),  SDT_SYS386IGT, SEL_KPL);
-       setidt(43, &IDTVEC(intr11),  SDT_SYS386IGT, SEL_KPL);
-       setidt(44, &IDTVEC(intr12),  SDT_SYS386IGT, SEL_KPL);
-       setidt(45, &IDTVEC(intr13),  SDT_SYS386IGT, SEL_KPL);
-       setidt(46, &IDTVEC(intr14),  SDT_SYS386IGT, SEL_KPL);
-       setidt(47, &IDTVEC(intr15),  SDT_SYS386IGT, SEL_KPL);
+#include       "isa.h"
+#if    NISA >0
+       isa_defaultirq();
+#endif
 
        lgdt(gdt, sizeof(gdt)-1);
        lidt(idt, sizeof(idt)-1);
 
        lgdt(gdt, sizeof(gdt)-1);
        lidt(idt, sizeof(idt)-1);
@@ -1031,21 +975,6 @@ init386(first) { extern ssdtosd(), lgdt(), lidt(), lldt(), etext;
 
        _ucodesel = LSEL(LUCODE_SEL, SEL_UPL);
        _udatasel = LSEL(LUDATA_SEL, SEL_UPL);
 
        _ucodesel = LSEL(LUCODE_SEL, SEL_UPL);
        _udatasel = LSEL(LUDATA_SEL, SEL_UPL);
-
-       /* initialize 8259's */
-       outb(0xf1,0);
-       outb(0x20,0x11);
-       outb(0x21,32);
-       outb(0x21,4);
-       outb(0x21,1);
-       outb(0x21,0xff);
-
-       outb(0xa0,0x11);
-       outb(0xa1,40);
-       outb(0xa1,2);
-       outb(0xa1,1);
-       outb(0xa1,0xff);
-
 }
 
 /*
 }
 
 /*
@@ -1072,12 +1001,6 @@ copyseg(frm, n) {
        bcopy(frm, &CADDR2,NBPG);
 }
 
        bcopy(frm, &CADDR2,NBPG);
 }
 
-strayintr(d) {
-static x;
-       /* for some reason, get bursts of intr #7, though not enabled! */
-       pg("%d strayintr %x", x++,d);
-}
-
 aston() {
        schednetisr(NETISR_AST);
 }
 aston() {
        schednetisr(NETISR_AST);
 }
@@ -1191,8 +1114,3 @@ ovbcopy(from, to, bytes)
                        *to-- = *from--;
        }
 }
                        *to-- = *from--;
        }
 }
-
-redstack() { int i;
-
-       if ((u_int)&u+sizeof(u)+100 >= (u_int)&i) pg("redstack");
-}
index f3e69cd..82a33cb 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.noredist.c%
  *
  *
  * %sccs.include.noredist.c%
  *
- *     @(#)mem.c       5.3 (Berkeley) %G%
+ *     @(#)mem.c       5.4 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -71,7 +71,7 @@ mmrw(dev, uio, rw)
                                goto fault;
                        *(int *)mmap = ctob(v) | PG_V |
                                (rw == UIO_READ ? PG_KR : PG_KW);
                                goto fault;
                        *(int *)mmap = ctob(v) | PG_V |
                                (rw == UIO_READ ? PG_KR : PG_KW);
-                       load_cr3(_cr3());
+                       tlbflush();
                        o = (int)uio->uio_offset & PGOFSET;
                        c = (u_int)(NBPG - ((int)iov->iov_base & PGOFSET));
                        c = MIN(c, (u_int)(NBPG - o));
                        o = (int)uio->uio_offset & PGOFSET;
                        c = (u_int)(NBPG - ((int)iov->iov_base & PGOFSET));
                        c = MIN(c, (u_int)(NBPG - o));
index c8caa57..cdf8191 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.386.c%
  *
  *
  * %sccs.include.386.c%
  *
- *     @(#)trap.c      5.3 (Berkeley) %G%
+ *     @(#)trap.c      5.4 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -41,7 +41,6 @@
 
 struct sysent sysent[];
 int    nsysent;
 
 struct sysent sysent[];
 int    nsysent;
-#include "dbg.h"
 /*
  * Called from the trap handler when a processor trap occurs.
  */
 /*
  * Called from the trap handler when a processor trap occurs.
  */
@@ -54,36 +53,20 @@ trap(frame)
 #define code frame.tf_err
 #define pc frame.tf_eip
 {
 #define code frame.tf_err
 #define pc frame.tf_eip
 {
-       register int *locr0 = ((int *)&frame)/*-PS*/;
+       register int *locr0 = ((int *)&frame);
        register int i;
        register struct proc *p;
        struct timeval syst;
        extern int nofault;
 
        register int i;
        register struct proc *p;
        struct timeval syst;
        extern int nofault;
 
-#ifdef DEBUG
-dprintf(DALLTRAPS, "%d. trap",u.u_procp->p_pid);
-dprintf(DALLTRAPS, "\npc:%x cs:%x ds:%x eflags:%x isp %x\n",
-               frame.tf_eip, frame.tf_cs, frame.tf_ds, frame.tf_eflags,
-               frame.tf_isp);
-dprintf(DALLTRAPS, "edi %x esi %x ebp %x ebx %x esp %x\n",
-               frame.tf_edi, frame.tf_esi, frame.tf_ebp,
-               frame.tf_ebx, frame.tf_esp);
-dprintf(DALLTRAPS, "edx %x ecx %x eax %x\n",
-               frame.tf_edx, frame.tf_ecx, frame.tf_eax);
-dprintf(DALLTRAPS|DPAUSE, "ec %x type %x cr0 %x cr2 %x cpl %x \n",
-               frame.tf_err, frame.tf_trapno, rcr0(), rcr2(), cpl);
-#endif
 
        locr0[tEFLAGS] &= ~PSL_NT;      /* clear nested trap XXX */
 
        locr0[tEFLAGS] &= ~PSL_NT;      /* clear nested trap XXX */
-if(nofault && frame.tf_trapno != 0xc)
-       { locr0[tEIP] = nofault; return;}
+       if(nofault && frame.tf_trapno != 0xc) {
+               locr0[tEIP] = nofault; return;
+       }
 
        syst = u.u_ru.ru_stime;
 
        syst = u.u_ru.ru_stime;
-       if (ISPL(locr0[tCS]) == SEL_UPL /*&& cpl == 0*/) {
-#ifdef DEBUG
-if(cpl) pg("user cpl %x trap %d", cpl, frame.tf_trapno);
-if(((unsigned)frame.tf_eip) >= 0xfe000000) pg("user eip %x", frame.tf_eip);
-#endif
+       if (ISPL(locr0[tCS]) == SEL_UPL) {
                type |= USER;
                u.u_ar0 = locr0;
        }
                type |= USER;
                u.u_ar0 = locr0;
        }
@@ -95,8 +78,8 @@ bit_sucker:
                if (kdb_trap(&psl))
                        return;
 #endif
                if (kdb_trap(&psl))
                        return;
 #endif
-splhigh();
-               printf("trap type %d, code = %x, pc = %x cs = %x, eflags = %x\n", type, code, pc, frame.tf_cs, frame.tf_eflags);
+               printf("trap type %d code %x pc %x cs %x eflags %x\n",
+                       type, code, pc, frame.tf_cs, frame.tf_eflags);
                type &= ~USER;
                panic("trap");
                /*NOTREACHED*/
                type &= ~USER;
                panic("trap");
                /*NOTREACHED*/
@@ -148,14 +131,14 @@ splhigh();
                u.u_code = code;
                i = SIGFPE;
                break;
                u.u_code = code;
                i = SIGFPE;
                break;
-
+#ifdef notdef
        /*
         * If the user SP is above the stack segment,
         * grow the stack automatically.
         */
        case T_STKFLT + USER:
        case T_SEGFLT + USER:
        /*
         * If the user SP is above the stack segment,
         * grow the stack automatically.
         */
        case T_STKFLT + USER:
        case T_SEGFLT + USER:
-               if (grow((unsigned)locr0[tESP]) /*|| grow(code)*/)
+               if (grow((unsigned)locr0[tESP]))
                        goto out;
                u.u_code = code;
                i = SIGSEGV;
                        goto out;
                u.u_code = code;
                i = SIGSEGV;
@@ -164,56 +147,43 @@ splhigh();
        case T_TABLEFLT:                /* allow page table faults in kernel */
        case T_TABLEFLT + USER:         /* page table fault */
                panic("ptable fault");
        case T_TABLEFLT:                /* allow page table faults in kernel */
        case T_TABLEFLT + USER:         /* page table fault */
                panic("ptable fault");
+#endif
 
        case T_PAGEFLT:                 /* allow page faults in kernel mode */
        case T_PAGEFLT + USER:          /* page fault */
 
        case T_PAGEFLT:                 /* allow page faults in kernel mode */
        case T_PAGEFLT + USER:          /* page fault */
-                       { register u_int vp;
-                       struct pte *pte;
+               {       register u_int vp;
+                       u_int ea;
+
+                       ea = (u_int)rcr2();
 
 
-                       if(u.u_procp->p_pid == 2) goto bit_sucker;
-#define PGEX_P 0x01
-                       if (rcr2() >= &Sysbase || code & PGEX_P) {
+                       /* out of bounds reference */
+                       if (ea >= &Sysbase && code & PGEX_P) {
                                u.u_code = code + BUS_PAGE_FAULT;
                                i = SIGBUS;
                                break;
                                u.u_code = code + BUS_PAGE_FAULT;
                                i = SIGBUS;
                                break;
-                       } else {
-                               vp = btop((int)rcr2());
-                               if (vp >= dptov(u.u_procp, u.u_procp->p_dsize)
-                               && vp < sptov(u.u_procp, u.u_procp->p_ssize-1)){
-                                       if (grow((unsigned)locr0[tESP])
-                                       || grow(rcr2()))
-                                               goto out;
-                                       else    if (nofault) {
-                                               locr0[tEIP] = nofault;
-                                               return;
-                                       }
-#ifdef DEBUG
-pg("didnt ");
-printf("\npc:%x cs:%x ds:%x eflags:%x isp %x\n",
-               frame.tf_eip, frame.tf_cs, frame.tf_ds, frame.tf_eflags,
-               frame.tf_isp);
-printf("edi %x esi %x ebp %x ebx %x esp %x\n",
-               frame.tf_edi, frame.tf_esi, frame.tf_ebp,
-               frame.tf_ebx, frame.tf_esp);
-printf("edx %x ecx %x eax %x\n",
-               frame.tf_edx, frame.tf_ecx, frame.tf_eax);
-printf("ec %x type %x cr0 %x cr2 %x cpl %x \n",
-               frame.tf_err, frame.tf_trapno, rcr0(), rcr2(), cpl);
-#endif
-                                       i = SIGSEGV;
-                                       break;
-                               }
-                               i = u.u_error;
-                               pagein(rcr2(), 0);
-                               u.u_error = i;
-                               if (type == T_PAGEFLT) return;
+                       }
 
 
-                               if(nofault) {
+                       /* stack reference to the running process? */
+                       vp = btop(ea);
+                       if (vp >= dptov(u.u_procp, u.u_procp->p_dsize)
+                       && vp < sptov(u.u_procp, u.u_procp->p_ssize-1)){
+                               /* attempt to grow stack */
+                               if (grow((unsigned)locr0[tESP]) || grow(ea)) {
+                                       if (type == T_PAGEFLT) return;
+                                       goto out;
+                               } else  if (nofault) {
                                        locr0[tEIP] = nofault;
                                        return;
                                }
                                        locr0[tEIP] = nofault;
                                        return;
                                }
-                               goto out;
+                               i = SIGSEGV;
+                               break;
                        }
                        }
+
+                       i = u.u_error;
+                       pagein(ea, 0);
+                       u.u_error = i;
+                       if (type == T_PAGEFLT) return;
+                       goto out;
                }
 
        case T_TRCTRAP:  /* trace trap -- someone single stepping lcall's */
                }
 
        case T_TRCTRAP:  /* trace trap -- someone single stepping lcall's */
@@ -227,6 +197,7 @@ printf("ec %x type %x cr0 %x cr2 %x cpl %x \n",
                i = SIGTRAP;
                break;
 
                i = SIGTRAP;
                break;
 
+#ifdef notdef
        /*
         * For T_KSPNOTVAL and T_BUSERR, can not allow spl to
         * drop to 0 as clock could go off and we would end up
        /*
         * For T_KSPNOTVAL and T_BUSERR, can not allow spl to
         * drop to 0 as clock could go off and we would end up
@@ -250,6 +221,15 @@ printf("ec %x type %x cr0 %x cr2 %x cpl %x \n",
                u.u_code = code;
                psignal(u.u_procp, SIGBUS);
                return;
                u.u_code = code;
                psignal(u.u_procp, SIGBUS);
                return;
+#endif
+
+#include "isa.h"
+#if    NISA > 0
+       case T_NMI:
+       case T_NMI + USER:
+               if(isa_nmi(code) == 0) return;
+               else goto bit_sucker;
+#endif
        }
        psignal(u.u_procp, i);
 out:
        }
        psignal(u.u_procp, i);
 out:
@@ -297,7 +277,7 @@ syscall(frame)
 #define code frame.sf_eax      /* note: written over! */
 #define pc frame.sf_eip
 {
 #define code frame.sf_eax      /* note: written over! */
 #define pc frame.sf_eip
 {
-       register int *locr0 = ((int *)&frame)/*-PS*/;
+       register int *locr0 = ((int *)&frame);
        register caddr_t params;
        register int i;
        register struct sysent *callp;
        register caddr_t params;
        register int i;
        register struct sysent *callp;
@@ -310,19 +290,7 @@ syscall(frame)
 #endif
        syst = u.u_ru.ru_stime;
        if (ISPL(locr0[sCS]) != SEL_UPL)
 #endif
        syst = u.u_ru.ru_stime;
        if (ISPL(locr0[sCS]) != SEL_UPL)
-{
-printf("\npc:%x cs:%x eflags:%x\n",
-               frame.sf_eip, frame.sf_cs, frame.sf_eflags);
-printf("edi %x esi %x ebp %x ebx %x esp %x\n",
-               frame.sf_edi, frame.sf_esi, frame.sf_ebp,
-               frame.sf_ebx, frame.sf_esp);
-printf("edx %x ecx %x eax %x\n", frame.sf_edx, frame.sf_ecx, frame.sf_eax);
-printf("cr0 %x cr2 %x cpl %x \n", rcr0(), rcr2(), cpl);
                panic("syscall");
                panic("syscall");
-}
-#ifdef DEBUG
-if(cpl) pg("User cpl %x", cpl);
-#endif
        u.u_ar0 = locr0;
        params = (caddr_t)locr0[sESP] + NBPW ;
        u.u_error = 0;
        u.u_ar0 = locr0;
        params = (caddr_t)locr0[sESP] + NBPW ;
        u.u_error = 0;
@@ -336,7 +304,6 @@ if(cpl) pg("User cpl %x", cpl);
                params += NBPW;
                callp = (code >= nsysent) ? &sysent[63] : &sysent[code];
        }
                params += NBPW;
                callp = (code >= nsysent) ? &sysent[63] : &sysent[code];
        }
-dprintf(DALLSYSC,"%d. call %d\n", u.u_procp->p_pid, code);
        if ((i = callp->sy_narg * sizeof (int)) &&
            (u.u_error = copyin(params, (caddr_t)u.u_arg, (u_int)i)) != 0) {
                locr0[sEAX] = u.u_error;
        if ((i = callp->sy_narg * sizeof (int)) &&
            (u.u_error = copyin(params, (caddr_t)u.u_arg, (u_int)i)) != 0) {
                locr0[sEAX] = u.u_error;
@@ -354,7 +321,6 @@ dprintf(DALLSYSC,"%d. call %d\n", u.u_procp->p_pid, code);
        }
        if (u.u_eosys == NORMALRETURN) {
                if (u.u_error) {
        }
        if (u.u_eosys == NORMALRETURN) {
                if (u.u_error) {
-/*dprintf(DSYSFAIL,"%d. fail %d %d\n",u.u_procp->p_pid,  code, u.u_error);*/
                        locr0[sEAX] = u.u_error;
                        locr0[sEFLAGS] |= PSL_C;        /* carry bit */
                } else {
                        locr0[sEAX] = u.u_error;
                        locr0[sEFLAGS] |= PSL_C;        /* carry bit */
                } else {
@@ -396,14 +362,6 @@ done:
                        addupc(opc, &u.u_prof, ticks);
        }
        curpri = p->p_pri;
                        addupc(opc, &u.u_prof, ticks);
        }
        curpri = p->p_pri;
-dprintf(DALLSYSC,"%d. rtn to %x %x\n",
-       u.u_procp->p_pid, frame.sf_eip, frame.sf_cs);
-#ifdef DEBUG
-if(cpl) {
- printf("uSer cpl %x syscall %d\n", cpl, callp - sysent);
- spl0();
-}
-#endif
 }
 
 /*
 }
 
 /*
@@ -424,5 +382,4 @@ nosys()
  */
 nullsys()
 {
  */
 nullsys()
 {
-
 }
 }
index 5e07b81..fd7d5f7 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.386.c%
  *
  *
  * %sccs.include.386.c%
  *
- *     @(#)vm_machdep.c        5.3 (Berkeley) %G%
+ *     @(#)vm_machdep.c        5.4 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
 
 #include "buf.h"
 
 
 #include "buf.h"
 
-#include "dbg.h"
-
-#define load_cr3(s)    {long phys; \
-       phys = (long)(s) /*| 0x80000000 */ ;\
-       __asm ( "movl %0,%%eax; movl %%eax,%%cr3" : : "g" (phys) : "ax" ) ; }
-
 /*
  * Set a red zone in the kernel stack after the u. area.
  */
 /*
  * Set a red zone in the kernel stack after the u. area.
  */
@@ -98,7 +92,7 @@ newptes(pte, v, size)
 #ifdef lint
        pte = pte;
 #endif
 #ifdef lint
        pte = pte;
 #endif
-       load_cr3(u.u_pcb.pcb_ptd);
+       tlbflush();
 }
 
 /*
 }
 
 /*
@@ -130,7 +124,7 @@ chgprot(addr, tprot)
        }
        *(u_int *)pte &= ~PG_PROT;
        *(u_int *)pte |= tprot;
        }
        *(u_int *)pte &= ~PG_PROT;
        *(u_int *)pte |= tprot;
-       load_cr3(u.u_pcb.pcb_ptd);
+       tlbflush();
        return (1);
 }
 
        return (1);
 }
 
@@ -144,7 +138,7 @@ settprot(tprot)
                ptaddr[i] &= ~PG_PROT;
                ptaddr[i] |= tprot;
        }
                ptaddr[i] &= ~PG_PROT;
                ptaddr[i] |= tprot;
        }
-       load_cr3(u.u_pcb.pcb_ptd);
+       tlbflush();
 }
 
 /*
 }
 
 /*
@@ -167,20 +161,17 @@ setptlr(region, nlen)
                u.u_pcb.pcb_p1lr = nlen;
                nlen = P1PAGES - nlen;
        }
                u.u_pcb.pcb_p1lr = nlen;
                nlen = P1PAGES - nlen;
        }
-/*pg("setptlr(%x,%x), was %d",region, nlen, olen);*/
        if ((change = olen - nlen) <= 0)
                return;
        if (region == 0)
                pte = u.u_pcb.pcb_p0br + u.u_pcb.pcb_p0lr;
        else
                pte = u.u_pcb.pcb_p1br + u.u_pcb.pcb_p1lr - change;
        if ((change = olen - nlen) <= 0)
                return;
        if (region == 0)
                pte = u.u_pcb.pcb_p0br + u.u_pcb.pcb_p0lr;
        else
                pte = u.u_pcb.pcb_p1br + u.u_pcb.pcb_p1lr - change;
-/*printf("p0b %x p0l %x", u.u_pcb.pcb_p0br, u.u_pcb.pcb_p0lr);
-printf("p1b %x p1l %x pte %x", u.u_pcb.pcb_p1br, u.u_pcb.pcb_p1lr, pte);*/
        do {
                *(u_int *)pte++ = 0;
        } while (--change);
        /* short cut newptes */
        do {
                *(u_int *)pte++ = 0;
        } while (--change);
        /* short cut newptes */
-       load_cr3(u.u_pcb.pcb_ptd);
+       tlbflush();
 }
 
 /*
 }
 
 /*
@@ -201,7 +192,7 @@ physaccess(pte, paddr, size, prot)
                page += NBPG;
                pte++;
        }
                page += NBPG;
                pte++;
        }
-       load_cr3(u.u_pcb.pcb_ptd);
+       tlbflush();
 }
 
 /*
 }
 
 /*
@@ -226,7 +217,7 @@ pagemove(from, to, size)
                to += NBPG;
                size -= NBPG;
        }
                to += NBPG;
                size -= NBPG;
        }
-       load_cr3(u.u_pcb.pcb_ptd);
+       tlbflush();
 }
 
 /*
 }
 
 /*
@@ -259,11 +250,7 @@ probew(addr)
        p = u.u_procp;
        page = btop(addr);
        if (page < dptov(p, p->p_dsize) || page > sptov(p, p->p_ssize))
        p = u.u_procp;
        page = btop(addr);
        if (page < dptov(p, p->p_dsize) || page > sptov(p, p->p_ssize))
-/*
-{
-dprintf(DPHYS,"vtopte %x %x\n", vtopte(p, page), *(int *)vtopte(p, page) );*/
                return((*(int *)vtopte(p, page) & PG_PROT) == PG_UW);
                return((*(int *)vtopte(p, page) & PG_PROT) == PG_UW);
-/*}*/
        return(0);
 }
 
        return(0);
 }
 
@@ -280,7 +267,6 @@ kernacc(addr, count, rw)
        register int ix, cnt;
        extern long Syssize;
 
        register int ix, cnt;
        extern long Syssize;
 
-/*dprintf(DPHYS,"kernacc %x count %d rw %d", addr, count, rw);*/
        if (count <= 0)
                return(0);
        pde = (struct pde *)((u_int)u.u_procp->p_p0br + u.u_procp->p_szpt * NBPG);
        if (count <= 0)
                return(0);
        pde = (struct pde *)((u_int)u.u_procp->p_p0br + u.u_procp->p_szpt * NBPG);
@@ -289,25 +275,15 @@ kernacc(addr, count, rw)
        cnt -= ix;
        for (pde += ix; cnt; cnt--, pde++)
                if (pde->pd_v == 0)
        cnt -= ix;
        for (pde += ix; cnt; cnt--, pde++)
                if (pde->pd_v == 0)
-/*{
-dprintf(DPHYS,"nope pde %x, idx %x\n", pde, ix);*/
                        return(0);
                        return(0);
-/*}*/
        ix = btop(addr-0xfe000000);
        cnt = btop(addr-0xfe000000+count+NBPG-1);
        if (cnt > (int)&Syssize)
        ix = btop(addr-0xfe000000);
        cnt = btop(addr-0xfe000000+count+NBPG-1);
        if (cnt > (int)&Syssize)
-/*{
-dprintf(DPHYS,"nope cnt %x\n", cnt);*/
                return(0);
                return(0);
-/*}*/
        cnt -= ix;
        for (pte = &Sysmap[ix]; cnt; cnt--, pte++)
                if (pte->pg_v == 0 /*|| (rw == B_WRITE && pte->pg_prot == 1)*/) 
        cnt -= ix;
        for (pte = &Sysmap[ix]; cnt; cnt--, pte++)
                if (pte->pg_v == 0 /*|| (rw == B_WRITE && pte->pg_prot == 1)*/) 
-/*{
-dprintf(DPHYS,"nope pte %x %x, idx %x\n", pte, *(int *)pte, ix);*/
                        return(0);
                        return(0);
-/*}
-dprintf(DPHYS,"yup\n");*/
        return(1);
 }
 
        return(1);
 }
 
@@ -319,7 +295,6 @@ useracc(addr, count, rw)
        register u_int addr2;
        extern int prober(), probew();
 
        register u_int addr2;
        extern int prober(), probew();
 
-/*dprintf(DPHYS,"useracc %x count %d rw %d", addr, count, rw);*/
        if (count <= 0)
                return(0);
        addr2 = addr;
        if (count <= 0)
                return(0);
        addr2 = addr;
@@ -327,13 +302,9 @@ useracc(addr, count, rw)
        func = (rw == B_READ) ? prober : probew;
        do {
                if ((*func)(addr2) == 0)
        func = (rw == B_READ) ? prober : probew;
        do {
                if ((*func)(addr2) == 0)
-/*{
-dprintf(DPHYS,"nope %x\n", addr);*/
                        return(0);
                        return(0);
-/*}*/
                addr2 = (addr2 + NBPG) & ~PGOFSET;
        } while (addr2 < addr);
                addr2 = (addr2 + NBPG) & ~PGOFSET;
        } while (addr2 < addr);
-/*dprintf(DPHYS,"yup\n", addr);*/
        return(1);
 }
 
        return(1);
 }
 
@@ -383,7 +354,6 @@ initpdt(p)
        extern struct pde *vtopde();
        extern Sysbase;
 
        extern struct pde *vtopde();
        extern Sysbase;
 
-/*pg("initpdt");*/
        /* clear entire map */
        pde = vtopde(p, 0);
        /*bzero(pde, NBPG); */
        /* clear entire map */
        pde = vtopde(p, 0);
        /*bzero(pde, NBPG); */
@@ -397,8 +367,6 @@ initpdt(p)
        pde = vtopde(p, &u);
        *(int *)pde = PG_UW | PG_V;
        pde->pd_pfnum = Usrptmap[btokmx(p->p_addr)].pg_pfnum;
        pde = vtopde(p, &u);
        *(int *)pde = PG_UW | PG_V;
        pde->pd_pfnum = Usrptmap[btokmx(p->p_addr)].pg_pfnum;
-/*printf("%d.u. pde %x pfnum %x virt %x\n", p->p_pid, pde, pde->pd_pfnum,
-p->p_addr);*/
 
        /* otherwise, fill in user map */
        k = btokmx(p->p_p0br);
 
        /* otherwise, fill in user map */
        k = btokmx(p->p_p0br);
@@ -407,11 +375,9 @@ p->p_addr);*/
 
        /* text and data */
        sz = ctopt(p->p_tsize + p->p_dsize);
 
        /* text and data */
        sz = ctopt(p->p_tsize + p->p_dsize);
-/*dprintf(DEXPAND,"textdata 0 to %d\n",sz-1);*/
        for (i = 0; i < sz; i++, pde++) {
                *(int *)pde = PG_UW | PG_V;
                pde->pd_pfnum = Usrptmap[k++].pg_pfnum;
        for (i = 0; i < sz; i++, pde++) {
                *(int *)pde = PG_UW | PG_V;
                pde->pd_pfnum = Usrptmap[k++].pg_pfnum;
-/*dprintf(DEXPAND,"%d.pde %x pf %x\n", p->p_pid, pde, *(int *)pde);*/
        }
        /*
         * Bogus!  The kernelmap may map unused PT pages
        }
        /*
         * Bogus!  The kernelmap may map unused PT pages
@@ -424,21 +390,13 @@ p->p_addr);*/
                k += p->p_szpt - sz;
        /* hole */
        sz = NPTEPG - ctopt(p->p_ssize + UPAGES + btoc(&Sysbase));
                k += p->p_szpt - sz;
        /* hole */
        sz = NPTEPG - ctopt(p->p_ssize + UPAGES + btoc(&Sysbase));
-/*dprintf(DEXPAND,"zero %d upto %d\n", i, sz-1);*/
        for ( ; i < sz; i++, pde++)
        for ( ; i < sz; i++, pde++)
-/* definite bug here... does not hit all entries, but point moot due
-to bzero above XXX*/
-{
                *(int *)pde = 0;
                *(int *)pde = 0;
-/*pg("pde %x pf %x", pde, *(int *)pde);*/
-}
        /* stack and u-area */
        sz = NPTEPG - ctopt(UPAGES + btoc(&Sysbase));
        /* stack and u-area */
        sz = NPTEPG - ctopt(UPAGES + btoc(&Sysbase));
-/*dprintf(DEXPAND,"stack %d upto %d\n", i, sz-1);*/
        for ( ; i < sz; i++, pde++) {
                *(int *)pde = PG_UW | PG_V;
                pde->pd_pfnum = Usrptmap[k++].pg_pfnum;
        for ( ; i < sz; i++, pde++) {
                *(int *)pde = PG_UW | PG_V;
                pde->pd_pfnum = Usrptmap[k++].pg_pfnum;
-/*pg("pde %x pf %x", pde, *(int *)pde);*/
        }
        return(initcr3(p));
 }
        }
        return(initcr3(p));
 }
@@ -537,7 +495,7 @@ vmapbuf(bp)
                iopte++, pte++;
                a++;
        }
                iopte++, pte++;
                a++;
        }
-       load_cr3(u.u_pcb.pcb_ptd);
+       tlbflush();
 }
 
 /*
 }
 
 /*
@@ -577,5 +535,5 @@ vunmapbuf(bp)
                a = ((bp - swbuf) * CLSIZE) * KLMAX;
                bp->b_un.b_addr = (caddr_t)ctob(dptov(&proc[2], a));
        }
                a = ((bp - swbuf) * CLSIZE) * KLMAX;
                bp->b_un.b_addr = (caddr_t)ctob(dptov(&proc[2], a));
        }
-       load_cr3(u.u_pcb.pcb_ptd);
+       tlbflush();
 }
 }
index f949267..403e731 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.noredist.c%
  *
  *
  * %sccs.include.noredist.c%
  *
- *     @(#)vmparam.h   5.2 (Berkeley) %G%
+ *     @(#)vmparam.h   5.3 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
 #define        LOTSOFMEM       2
 
 #define        mapin(pte, v, pfnum, prot) \
 #define        LOTSOFMEM       2
 
 #define        mapin(pte, v, pfnum, prot) \
-       (*(int *)(pte) = ((pfnum)<<PGSHIFT) | (prot))
+       {(*(int *)(pte) = ((pfnum)<<PGSHIFT) | (prot)); tlbflush(); }
 
 /*
  * Invalidate a cluster (optimized here for standard CLSIZE).
 
 /*
  * Invalidate a cluster (optimized here for standard CLSIZE).
 #define        tbiscl(v)
 #endif
 
 #define        tbiscl(v)
 #endif
 
+/*
+ * inline assembler macros
+ */
+
 /*
  * Flush MMU TLB
  */
 
 /*
  * Flush MMU TLB
  */
 
-#define        tlbflush()      asm(" movl %cr3,%eax; movl %eax,%cr3 " /*, "ax" */)
+#define        tlbflush()      asm(" movl %%cr3,%%eax; movl %%eax,%%cr3 " ::: "ax")
+
+#ifndef I386_CR3PAT
+#define        I386_CR3PAT     0x0
+#endif
+
+#define _cr3() ({u_long rtn; \
+       asm (" movl %%cr3,%%eax; movl %%eax,%0 " \
+               : "=g" (rtn) \
+               : \
+               : "ax"); \
+       rtn; \
+})
+
+#define load_cr3(s) ({ u_long val; \
+       val = (s) | I386_CR3PAT; \
+       asm ("movl %0,%%eax; movl %%eax,%%cr3" \
+               :  \
+               : "g" (val) \
+               : "ax"); \
+})