From 0752cc4b8cda40c60912d24e54453b9a0699626f Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Thu, 7 Apr 2022 12:43:47 -0500 Subject: [PATCH] do a little test to see if memory mapping works This code creates a shared mapping in high ram, makes sure that that works, and also makes sure that the memory which is mapped over is left unchanged. --- sw/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sw/main.c b/sw/main.c index ba39470..4f894d8 100644 --- a/sw/main.c +++ b/sw/main.c @@ -22,6 +22,30 @@ int main() { cprintf("Enabling Mapper\n"); mapper_enable(1); + cprintf("Writing 0xcccc to 0x4000\n"); + *(unsigned int*)(0x4000) = 0xcccc; + + cprintf("Writing 0xdddd to 0x5000\n"); + *(unsigned int*)(0x5000) = 0xdddd; + + cprintf("Mapping %1xxxx to %2xxxx\n", 4, 16); + mapper_write(16, 4); + + cprintf("Mapping %1xxxx to %2xxxx\n", 5, 16); + mapper_write(16, 5); + + cprintf("Writing 0xa5a5 to 0x4000\n"); + *(unsigned int*)(0x4000) = 0xa5a5; + + cprintf("Reading from 0x5000: %x\n", *(unsigned int*)(0x5000)); + + cprintf("Resetting map\n"); + mapper_write(4, 4); + mapper_write(5, 5); + + cprintf("Reading from 0x4000: %x\n", *(unsigned int*)(0x4000)); + cprintf("Reading from 0x5000: %x\n", *(unsigned int*)(0x5000)); + while (1) { sw = sw_read();