gint/include/gint/mpu/mmu.h
Lephe d8886c7dbf
core: answer TLB misses and remove startup mapping (UNSTABLE)
This change adds a TLB miss handler that calls __TLB_LoadPTEH() and
removes the startu mapping of add-in pages in the explore() routine of
src/core/start.c.

Note that calling __TLB_LoadPTEH() manually might unexpectedly lead to a
TLB multihit problem as the requested page might be accidentally loaded
by a TLB miss in the code that loads it. A TLB multihit is a platform
reset, so this function should always be considered unsafe to call
(unless the calling code is in a combination of P1 space and ILRAM).

This change also moves a lot of functions out of the .pretext section,
notably topti, as this was designed to allow panic messages when the
add-in couldn't be mapped entirely. By contrast, a GMAPPED macro has
been defined to mark crucial kernel code and data that must remain
mapped at all times. This currently puts the data in ILRAM because
static RAM is not executable. An alternative will have to be found for
SH3-based fx9860g machines.

This version still does not allow TLB misses in timer callbacks and
breaks return-to-menu in a severe way! It is not suitable for any
stable application!
2020-06-14 18:22:20 +02:00

80 lines
1.3 KiB
C

//---
// gint:mpu:mmu - Memory Management Unit
//
// The MMU mainly exposes the contents of the TLB for us to inspect.
// Functions to manipulate these are exposed by <gint/mmu.h>.
//---
#ifndef GINT_MPU_MMU
#define GINT_MPU_MMU
#include <gint/defs/attributes.h>
#include <gint/defs/types.h>
//---
// SH7705 TLB. Refer to:
// "Renesas SH7705 Group Hardware Manual"
// Section 3: "Memory Management Unit (MMU)"
//---
/* tlb_addr_t - address part of a TLB entry */
typedef struct
{
uint VPN :22;
uint :1;
uint V :1;
uint ASID :8;
} GPACKED(4) tlb_addr_t;
/* tlb_data_t - data part of a TLB entry */
typedef struct
{
uint :3;
uint PPN :19;
uint :1;
uint V :1;
uint :1;
uint PR :2;
uint SZ :1;
uint C :1;
uint D :1;
uint SH :1;
uint :1;
} GPACKED(4) tlb_data_t;
//---
// SH7305 TLB. Refer to:
// "Renesas SH7724 User's Manual: Hardware"
// Section 7: "Memory Management Unit (MMU)"
//---
/* utlb_addr_t - address part of a UTLB entry */
typedef struct
{
uint VPN :22;
uint D :1;
uint V :1;
uint ASID :8;
} GPACKED(4) utlb_addr_t;
/* utlb_data_t - data part of a UTLB entry */
typedef struct
{
uint :3;
uint PPN :19;
uint :1;
uint V :1;
uint SZ1 :1;
uint PR :2;
uint SZ2 :1;
uint C :1;
uint D :1;
uint SH :1;
uint WT :1;
} GPACKED(4) utlb_data_t;
#endif /* GINT_MPU_MMU */