ARM coarse table; sub-pages disabled; [SOLVED]
Posted: Fri Mar 28, 2014 8:32 am
Ok, I am sorry guys. I have spent the last few days trying to figure out what in the world is going on and I have just become more confused at the results. I think I have tried just about every bit. Basically, here is what I got going on.
I create a first level table. I identify map it.
Basically, (x << 20) | 0xc02.
That works great. No problems.
I decide well let me try a coarse table. This allows the electronic monkeys to come out.
That appears to work. It knows I am using a coarse take 1KB in size.
Looks, good. Should be mapping 4KB pages. At 1KB it has 256 4-byte entries.
Before, I turn on pages I do this for a debugging aid.
Now. I turn on paging with sub-pages disabled.
I have tried arm4_tlbsetmode(0) and arm4_tlbsetmode(1) just FYI. Just checked.
Now, I should have 4KB pages mapped... monkeys say otherwise.
Here is a debugging loop.
You would expect:
Wrong... I get:
It seems to have mapped 1KB pages.. Well don't worry the monkeys in my head are at it again. It gets worse.
Lets try a slightly different test. Notice the + 4 at the end of assignment to b.
If I add 8 I get 0x20.. and so forth... I have tried all sorts of bits. The only thing I can accomplish is getting 1KB pages mapped and then I get this crazy 0x10 physical offset for each 0x4 bytes of virtual offset. Not to mention I only have 256 entries so I can not map the entire 1MB region.
So I got two problems. Why am I getting that odd offset and why am I unable to map 4KB pages instead of 1KB pages?
I must be setting a bit somewhere wrong, but I can not seem to find it.
I create a first level table. I identify map it.
Code: Select all
for (x = 0; x < 1024; ++x) {
ktlb[x] = (x << 20) | TLB_AP_PRIVACCESS | TLB_SECTION;
}
That works great. No problems.
I decide well let me try a coarse table. This allows the electronic monkeys to come out.
Code: Select all
ktlb[3] = (uint32)tlbsub | TLB_COARSE;
Code: Select all
for (x = 0; x < 4096; ++x)
tlbsub[x] = 2 | (32 << 16) | 0x550;
Before, I turn on pages I do this for a debugging aid.
Code: Select all
a = (uint32*)(32 << 16);
for (x = 0; x < 1024 * 1024; ++x) {
a[x] = (uintptr)&a[x];
}
Now. I turn on paging with sub-pages disabled.
Code: Select all
arm4_tlbsetmode(2);
arm4_tlbset1((uintptr)utlb);
arm4_tlbset0((uintptr)ktlb);
/* set that all domains are checked against the TLB entry access permissions */
arm4_tlbsetdom(0x55555555);
/* enable TLB 0x1 and disable subpages 0x800000 */
arm4_tlbsetctrl(arm4_tlbgetctrl() | 0x1 | (1 << 23));
Now, I should have 4KB pages mapped... monkeys say otherwise.
Here is a debugging loop.
Code: Select all
for (x = 0; x < 256; ++x) {
b = (uint32*)0x300000 + x * 1024;
ksprintf(buf, "small[%x]:%x\n", x, b[0]);
kserdbg_puts(buf);
}
Code: Select all
small[0]:0x200000
small[1]:0x200400
small[2]:0x200800
small[3]:0x200c00
small[4]:0x200000
small[5]:0x200400
small[6]:0x200800
small[7]:0x200c00
Code: Select all
small[0]:0x200000
small[1]:0x200000
small[2]:0x200000
small[3]:0x200000
small[4]:0x200000
small[5]:0x200000
small[6]:0x200000
small[7]:0x200000
Lets try a slightly different test. Notice the + 4 at the end of assignment to b.
Code: Select all
for (x = 0; x < 256; ++x) {
b = (uint32*)0x300000 + x * 1024 + 4;
ksprintf(buf, "small[%x]:%x\n", x, b[0]);
kserdbg_puts(buf);
}
Code: Select all
small[0]:0x200010
small[1]:0x200010
small[2]:0x200010
small[3]:0x200010
small[4]:0x200010
small[5]:0x200010
small[6]:0x200010
small[7]:0x200010
So I got two problems. Why am I getting that odd offset and why am I unable to map 4KB pages instead of 1KB pages?
I must be setting a bit somewhere wrong, but I can not seem to find it.