1
0
mirror of https://github.com/antonblanchard/microwatt.git synced 2026-04-25 03:55:09 +00:00

MMU: Implement a vestigial partition table

This implements a 1-entry partition table, so that instead of getting
the process table base address from the PRTBL SPR, the MMU now reads
the doubleword pointed to by the PTCR register plus 8 to get the
process table base address.  The partition table entry is cached.

Having the PTCR and the vestigial partition table reduces the amount
of software change required in Linux for Microwatt support.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
This commit is contained in:
Paul Mackerras
2021-06-17 20:01:32 +10:00
parent 84473eda1b
commit 18120f153d
14 changed files with 67 additions and 27 deletions

View File

@@ -24,7 +24,7 @@ static inline void do_tlbie(unsigned long rb, unsigned long rs)
#define SRR0 26
#define SRR1 27
#define PID 48
#define PRTBL 720
#define PTCR 464
static inline unsigned long mfspr(int sprnum)
{
@@ -115,15 +115,18 @@ void zero_memory(void *ptr, unsigned long nbytes)
*/
unsigned long *pgdir = (unsigned long *) 0x10000;
unsigned long *proc_tbl = (unsigned long *) 0x12000;
unsigned long free_ptr = 0x13000;
unsigned long *part_tbl = (unsigned long *) 0x13000;
unsigned long free_ptr = 0x14000;
void *eas_mapped[4];
int neas_mapped;
void init_mmu(void)
{
/* set up partition table */
store_pte(&part_tbl[1], (unsigned long)proc_tbl);
/* set up process table */
zero_memory(proc_tbl, 512 * sizeof(unsigned long));
mtspr(PRTBL, (unsigned long)proc_tbl);
mtspr(PTCR, (unsigned long)part_tbl);
mtspr(PID, 1);
zero_memory(pgdir, 1024 * sizeof(unsigned long));
/* RTS = 0 (2GB address space), RPDS = 10 (1024-entry top level) */

View File

@@ -33,7 +33,7 @@ static inline void do_tlbie(unsigned long rb, unsigned long rs)
#define SPRG0 272
#define SPRG1 273
#define SPRG3 275
#define PRTBL 720
#define PTCR 464
static inline unsigned long mfspr(int sprnum)
{
@@ -121,15 +121,18 @@ void zero_memory(void *ptr, unsigned long nbytes)
* Set up an MMU translation tree using memory starting at the 64k point.
* We use 3 levels, mapping 512GB, with 4kB PGD/PMD/PTE pages.
*/
unsigned long *proc_tbl = (unsigned long *) 0x10000;
unsigned long *pgdir = (unsigned long *) 0x11000;
unsigned long free_ptr = 0x12000;
unsigned long *part_tbl = (unsigned long *) 0x10000;
unsigned long *proc_tbl = (unsigned long *) 0x11000;
unsigned long *pgdir = (unsigned long *) 0x12000;
unsigned long free_ptr = 0x13000;
void init_mmu(void)
{
/* set up partition table */
store_pte(&part_tbl[1], (unsigned long)proc_tbl);
/* set up process table */
zero_memory(proc_tbl, 512 * sizeof(unsigned long));
mtspr(PRTBL, (unsigned long)proc_tbl);
mtspr(PTCR, (unsigned long)part_tbl);
mtspr(PID, 1);
zero_memory(pgdir, 512 * sizeof(unsigned long));
/* RTS = 8 (512GB address space), RPDS = 9 (512-entry top level) */

View File

@@ -14,7 +14,7 @@ extern int call_with_msr(unsigned long arg, int (*fn)(unsigned long), unsigned l
#define SRR0 26
#define SRR1 27
#define PID 48
#define PRTBL 720
#define PTCR 464
#define PVR 287
static inline unsigned long mfspr(int sprnum)
@@ -106,15 +106,18 @@ void zero_memory(void *ptr, unsigned long nbytes)
*/
unsigned long *pgdir = (unsigned long *) 0x10000;
unsigned long *proc_tbl = (unsigned long *) 0x12000;
unsigned long free_ptr = 0x13000;
unsigned long *part_tbl = (unsigned long *) 0x13000;
unsigned long free_ptr = 0x14000;
void init_mmu(void)
{
/* set up partition table */
store_pte(&part_tbl[1], (unsigned long)proc_tbl);
/* set up process table */
zero_memory(proc_tbl, 512 * sizeof(unsigned long));
/* RTS = 0 (2GB address space), RPDS = 10 (1024-entry top level) */
store_pte(&proc_tbl[2 * 1], (unsigned long) pgdir | 10);
mtspr(PRTBL, (unsigned long)proc_tbl);
mtspr(PTCR, (unsigned long)part_tbl);
mtspr(PID, 1);
zero_memory(pgdir, 1024 * sizeof(unsigned long));
}

View File

@@ -18,7 +18,6 @@ extern unsigned long do_stqcx(unsigned long dst, unsigned long regs);
#define PID 48
#define SPRG0 272
#define SPRG1 273
#define PRTBL 720
static inline unsigned long mfspr(int sprnum)
{

View File

@@ -38,7 +38,7 @@ void print_test(char *str)
#define SPR_HSPRG0 304
#define SPR_HSPRG1 305
#define SPR_PID 48
#define SPR_PRTBL 720
#define SPR_PTCR 464
#define SPR_PVR 287
#define __stringify_1(x...) #x
@@ -83,7 +83,7 @@ int main(void)
DO_ONE(SPR_HSPRG0);
DO_ONE(SPR_HSPRG1);
DO_ONE(SPR_PID);
DO_ONE(SPR_PRTBL);
DO_ONE(SPR_PTCR);
DO_ONE(SPR_PVR);
puts(PASS);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -20,6 +20,6 @@ Test SPR_SPRG3U:PASS
Test SPR_HSPRG0:PASS
Test SPR_HSPRG1:PASS
Test SPR_PID:PASS
Test SPR_PRTBL:PASS
Test SPR_PTCR:PASS
Test SPR_PVR:PASS
PASS