That's only the structure. I haven't checked it, I trust you can compare it to the spec. What's more important, you should dump the translation table entry to see what values those bitfields have. Something like:
Code: Select all
void dump_entry(struct struct TARMV8MMU_LEVEL3_PAGE_DESCRIPTOR *entry)
printf("Entry at %lx: ", entry);
printf(" Value11: %d", etnry->Value11);
printf(" AttrIdx: %d", etnry->AttrIdx);
printf(" AP: %d", etnry->AP);
// ... und so weiter
And call it like:
Code: Select all
dump_entry((struct TARMV8MMU_LEVEL3_PAGE_DESCRIPTOR *)table[(vaddr>>T0SZ_LEVEL1)&LEVEL_MASK]);
Where 'table' is your paging table, 'T0SZ_LEVEL1' is the bitoffset of level1 in virtual address, and 'LEVEL_MASK' has as many 1s as one level in your configuration requires. (Sorry, I cannot be more specific, as ARM MMU is so flexible, there are so many ways to configure). To print out level2 entry, you should use the address in the level1 entry instead of 'table'.
I wouldn't call it a nice code 'cos I just put it together quickly, but here's a working example
with 4k pageframe and 3 levels. There to get level 1's entry index I do '(addr>>(12+9+9))&0x1FF'. The function 'dbg_pagingflags(entry)' dumps the bitfields of a paging table entry, and 'dbg_paging(addr)' walks through the translation table and prints out every entry along the path for a virtual address in 'addr'.
In this example the table is at physical address 0x82000, and virtual address selects the first (0th) entry which has the physical address 0x83000, at level 1 the first entry again, at level 2 the last (511th) entry, and finally the in page offset is 4024.
It worth mentioning that you can only read virtual memory, but (naturally) entries hold physical addresses, so unless you have an identity mapping, you have to map the appropriate part of the translation table, that's what 'vmm_map()' calls are for.