Port-atari archive

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

Re: Weird calculation for kernel L2 segment table



On Fri, Jan 2, 2009 at 4:15 PM, Frank Wille <frank%phoenix.owl.de@localhost> 
wrote:
> Izumi Tsutsui wrote:
>
>> sys/arch/amiga/amiga/amiga_init.c (and recently sync'ed atari_init.c)
>> has the following calculations to get the level2 segment table
>> for the kernel Sysptmap:
>>
>> ---
>>       /*
>>        * Kernel segment table at end of next level 2 table
>>        */
>>       /* XXX fix calculations XXX */
>>       i = ((((ptsize >> PGSHIFT) + 3) & -2) - 1) * (NPTEPG / SG4_LEV3SIZE);
>>       sg = &((st_entry_t *)(RELOC(Sysseg_pa, u_int)))[SG4_LEV1SIZE + i];
>>       esg = &sg[NPTEPG / SG4_LEV3SIZE];
>>       sg_proto = Sysptmap_pa | SG_U | SG_RW | SG_V;
>>       while (sg < esg) {
>>           *sg++ = sg_proto;
>>           sg_proto += (SG4_LEV3SIZE * sizeof (st_entry_t));
>>       }
>> ---
>>
>> I think this could be rewritten more meaningfully as following:
>>
>> ---
>>       nl2desc = (ptsize >> PGSHIFT) * (NPTEPG / SG4_LEV3SIZE);
>>   :
>>       nl1desc = roundup(nl2desc, SG4_LEV2SIZE) / SG4_LEV2SIZE;
>>   :
>>       /*
>>        * Kernel segment table at end of next level 2 table
>>        */
>>       i = SG4_LEV1SIZE + (nl1desc * SG4_LEV2SIZE);
>>       sg = (st_entry_t *)RELOC(Sysseg_pa, u_int);
>>       sg = &sg[i + SG4_LEV2SIZE - (NPTEPG / SG4_LEV3SIZE)];
>>       esg = &sg[NPTEPG / SG4_LEV3SIZE];
>>   :
>> ---
>>
>> With a quick test program, both offset values against Sysseg_pa
>> look identical.
>
> Without rereading the 040/060 manuals and without knowing about the current
> layout of segment and page tables (first lev1 tables, then lev2, etc.?) in 
> both
> ports, I only got headaches after 30 minutes, so I decided to make a test! :)
>
> I patched the NetBSD/amiga 4.0 release kernel with your changes and tried it
> for some time on my A3000 with 68060. Booting, starting X11, compiling pkgsrc.
>
> Works fine for me!

I patched NetBSD/Atari current with Tsutsui's changes and I also made just
test using my Falcon with 68060; system booted up fine and I copied some files
around disks.

Works fine :)

-Tuomo


Home | Main Index | Thread Index | Old Index