dirkwhoffmann / Moira

A Motorola 68000 emulator written in C++
https://dirkwhoffmann.github.io/Moira
Other
109 stars 13 forks source link

MMU: Address mapping if table index is zero #12

Closed dirkwhoffmann closed 2 years ago

dirkwhoffmann commented 2 years ago

I've began to implement some experimental MMU address mapping code and got stuck here (68030 user manual):

Table Index (TIA, TIB, TIC, and TID) These 4-bit fields specify the numbers of logical address bits used as the indexes for the four possible levels of the translation tables (not including the optional level indexed by the function codes). The index into the highest level table (following the function code, when used) is specified by TIA, and the lowest level, by TID. The fields contain integers, 0-15. When a zero value in a TIx field is encountered during a table search operation, the search is over unless the indexed descriptor is a table (indirect) descriptor.

What I need to know is what "the search is over" exactly means in this context (over aka an exception is thrown, direct translation is used, etc.).

My favorite MMU article is also not clear on this point:

When setting up the TC register, it is worth remember that

IS + TIA + TIB + TIC + TID + PS = 32

These values must always sum to 32, as there are 32 bits in a logical address. TIA must always be greater than zero, and if TIB is zero it must be a minimum of two. If any of the TIn values contain zeroes, the tables at a lower level is ignored. So if you set TIC to zero, you must also set TID to zero.

mras0 commented 2 years ago

I don't have any experience with the 030 MMU but I've noticed that the manuals on NXP's site seem to be missing figures (and have some obviously wrong numbers). Might be worth also checking an older version (§9.1.1 and the later flowcharts in particular).

dirkwhoffmann commented 2 years ago
Bildschirmfoto 2022-09-17 um 16 41 40

I think I got it. When a pointer to a sub-table is given (e.g., table D) and TID equals 0, the "NO MORE Tix fields" branch is taken. This means the pointer is treated as an 'indirect descriptor'. I've set up a test case which indicates that it works that way (although I don't trust my test cases that much at the moment).