How can we determine the base address of the L2 page table? (Using ARM Cortex-A9)
For example, if I have a programme which requires 7KB of data space and starts at the address 0x0, I need two pages of 4KB. To do that, I add an entry in the L1 page table which points to the L2 page table base address. Then I add two entries in the L2 page table like that (with addr = 0x0 for the first page and 0x1000 for the second one)
u32 *ptr;
u32 small_page;
small_page = addr / 0x1000;
ptr = small_page + L2_table_base_addr;
*ptr = (addr & 0xFFFFF) | attributes;
Now there is one thing that I still do not understand. How can I determine the L2 page table base address? Should I put the table right after the L1 page table?
Where can I store the address? I know that the base address of the L1 page table is stored in a coprocessor register but I did not find any register to store the L2 base address.
Another question to be sure, both coprocessor register TTBR0 and TTBR1 holds the base address of a L1 page. Each to its own. It is not TTBR0 for L1 and TTBR1 for L2, does it ?