I have a small systems MMU that supports base/bound addressing and a page mapping table. I am wondering how this could be fit into the RISCV standard memory config. The satp and other register setting to use? This MMU is meant to support only a few MB at most. The MMU is always active for all operating modes. The test system is 512kB for instance. A four or five-bit ASID is in use. The page mapping table maps 1kB pages. There are two custom instructions for loading the base/bounds and mapping table ram. A more complete description is here: Cores/RISCV SSMMU Proposal.md at master · robfinch/Cores · GitHub
I have been working on an OS called Femtiki (originally FMTK for Finitron Multi-Tasking Kernel). Which is a simple multi-tasker based on time-slice interrupts. I think Linux would be too large. For the device in use xc7a15T there is only about 100kB of block RAM/ROM which the OS and other functionality is pre-loaded into. So, the core of LINUX would probably need to fit into 64kB. Possible? It may be possible to load some of the OS into external RAM from a serial prom. I anticipate that the PA where the SSMMU is used would likely be very much less than 38 bits. While the base/bounds registers allow a 38-bit address range the mapping table does not support the same range. In the SSMMU of the test system only 9 bits are allowed for the physical page number (PPN) in the mapping table. There is only 512kB ram in the system. So physical memory is limited to 19 bits max. For other systems memory may be a single 16MB cell ram chip for instance. I have used the SSMMU for a system with 256MB ram but it does not work very well since a very large page size is required (64kB+) to keep the mapping table small.
I think the ASID needs to be stored in the satp register. From RISC-V Privileged Architectures V1.12 draft: “For RV32, the satp encodings corresponding to MODE=Bare and ASID[8:7]=3 are designated for custom use,” So, I think that means I can use the satp for custom use by selecting mode=bare and ASID[8:7]=3. With custom use selected I assume its up to the implementation to decide how to use the remaining bits. There is no base address for the page table since its internal to the core. This field may be used to indicate the size of the mapping table.
I
had not thought about the sfence instruction as the core is in-order. But it makes
sense that it would be applied for the mvmap instruction. mvmap does a swap
operation. I wonder if it has the same semantics as an AMO swap? Having mvmap
do an automatic fence operation is another thought. All memory and IO operation
before mvmap need to be complete before mvmap can be done.