Port-atari archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Current kernel with http://gnats.netbsd.org/39965 and pmap patches



I wrote:

> I don't understand what XXX calculations in amiga_init.c do and
> how they map PA of Sysmap (Sysptmap_pa) into VM_MAX_KERNEL_ADDRESS
> in mmu040_setup() case... (it's a bit different from other m68k ports)

Is this what those calculations intend?
(though I'm still being confused a bit)


--- atari/atari_init.c.0        2008-12-17 19:12:51.000000000 +0900
+++ atari/atari_init.c  2008-12-18 02:22:18.000000000 +0900
@@ -959,15 +965,15 @@
        u_int           sysptmap_pa;    /* System page table            */
        u_int           kbase;
 {
-       int             i;
+       int             num1, num2;
        st_entry_t      sg_proto, *sg, *esg;
-       pt_entry_t      pg_proto;
+       pt_entry_t      pg_proto, *pg, *epg;
 
        /*
         * First invalidate the entire "segment table" pages
         * (levels 1 and 2 have the same "invalid" values).
         */
-       sg  = (u_int *)Sysseg_pa;
+       sg  = (st_entry_t *)Sysseg_pa;
        esg = &sg[kstsize * NPTEPG];
        while (sg < esg)
                *sg++ = SG_NV;
@@ -981,24 +987,24 @@
         * pages of PTEs.  Note that we set the "used" bit
         * now to save the HW the expense of doing it.
         */
-       i   = (ptsize >> PGSHIFT) * (NPTEPG / SG4_LEV3SIZE);
-       sg  = &((u_int *)Sysseg_pa)[SG4_LEV1SIZE];
-       esg = &sg[i];
+       num2 = (ptsize >> PGSHIFT) * (NPTEPG / SG4_LEV3SIZE);
+       sg  = &((st_entry_t *)Sysseg_pa)[SG4_LEV1SIZE];
+       esg = &sg[num2];
        sg_proto = ((u_int)pt + kbase) | SG_U | SG_RW | SG_V;
        while (sg < esg) {
                *sg++     = sg_proto;
-               sg_proto += (SG4_LEV3SIZE * sizeof (st_entry_t));
+               sg_proto += (SG4_LEV3SIZE * sizeof(st_entry_t));
        }
 
        /*
         * Initialize level 1 descriptors.  We need:
-        *      roundup(num, SG4_LEV2SIZE) / SG4_LEVEL2SIZE
-        * level 1 descriptors to map the 'num' level 2's.
+        *      roundup(num2, SG4_LEV2SIZE) / SG4_LEVEL2SIZE
+        * level 1 descriptors to map the 'num2' level 2's.
         */
-       i = roundup(i, SG4_LEV2SIZE) / SG4_LEV2SIZE;
-       protostfree = (-1 << (i + 2)) /* & ~(-1 << MAXKL2SIZE) */;
+       num1 = roundup(num2, SG4_LEV2SIZE) / SG4_LEV2SIZE;
+       protostfree = (-1 << (num1 + 1)) /* & ~(-1 << MAXKL2SIZE) */;
        sg  = (u_int *)Sysseg_pa;
-       esg = &sg[i];
+       esg = &sg[num1];
        sg_proto = ((u_int)&sg[SG4_LEV1SIZE] + kbase) | SG_U | SG_RW |SG_V;
        while (sg < esg) {
                *sg++     = sg_proto;
@@ -1013,9 +1019,7 @@
        /*
         * Kernel segment table at end of next level 2 table
         */
-       /* XXX fix calculations XXX */
-       i = ((((ptsize >> PGSHIFT) + 3) & -2) - 1) * (NPTEPG / SG4_LEV3SIZE);
-       sg = &((u_int *)Sysseg_pa)[SG4_LEV1SIZE + i];
+       sg = &((st_entry_t *)Sysseg_pa)[SG4_LEV1SIZE + num1 * SG4_LEV2SIZE];
        esg = &sg[NPTEPG / SG4_LEV3SIZE];
        sg_proto = sysptmap_pa | SG_U | SG_RW | SG_V;
        while (sg < esg) {
@@ -1026,23 +1030,25 @@
        /*
         * Initialize Sysptmap
         */
-       sg = (u_int *) sysptmap_pa;
-       esg = &sg[ptsize >> PGSHIFT];
+       pg = (pt_entry_t *) sysptmap_pa;
+       epg = &sg[ptsize >> PGSHIFT];
        pg_proto = ((u_int)pt + kbase) | PG_RW | PG_CI | PG_V;
-       while (sg < esg) {
-               *sg++ = pg_proto;
+       while (pg < epg) {
+               *pg++ = pg_proto;
                pg_proto += PAGE_SIZE;
        }
 
        /*
         * Invalidate rest of Sysptmap page
         */
-       esg = (u_int *)(sysptmap_pa + PAGE_SIZE - sizeof(st_entry_t));
-       while (sg < esg)
-               *sg++ = SG_NV;
-       sg = (u_int *) Sysptmap;
-       sg = &sg[256 - 1];              /* XXX */
-       *sg = sysptmap_pa | PG_RW | PG_CI | PG_V;
+       epg = (pt_entry_t *)(sysptmap_pa + (NPTEPG - 1) * sizeof(pt_entry_t));
+       while (pg < epg)
+               *pg++ = SG_NV;
+
+       /*
+        * Initialize the last one to point to Sysptmap.
+        */
+       *pg = sysptmap_pa | PG_RW | PG_CI | PG_V;
 }
 #endif /* M68040 */
 


---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index