10.6 Managing the Translation Lookaside Buffer

Although most applications will find the direct mapped KSEG0 address space of the CPU sufficient, it is possible to use the mapped address space by setting appropriate Translation Lookaside Buffer (TLB) entries.

Perhaps the biggest restriction with using the TLB is that individual entries operate only on relatively large, aligned memory regions (pages). Nevertheless, it may be helpful for memory protection or relocation of CPU addresses. In addition, TLBs can be used as yet another method to reconcile SP segment addresses with CPU addresses, since SP addresses fall within the range of the mapped CPU address space.

The translation lookaside buffer (TLB) of N64 CPU has 32 entries, each of which maps two physical pages. The TLB is fully associative, which means each entry is essentially independent--the index number implies nothing about the mapping and any entry can hold any mapping. A number of page sizes are supported: 4 KB, 16 KB, 64 KB, 256 KB, 1MB, and 16MB. Each TLB entry may map a different page size. The following routines are used to manage the TLB:

osMapTLB
This function sets the contents of a single TLB entry to the given virtual address, even and odd physical address, page size, and address space identifier.
osUnmapTLB
This function invalidates both the odd and even physical page mappings of a given TLB entry.
osUnmapTLBAll
This function invalidates all mappings in the TLB. This should be done by the application prior to using the TLB.
osSetTLBASID
This function sets the current address space identifier register.

Using the TLB requires some care. The following paragraphs describe some problem areas.

Finally, no support is provided for handling and recovering from TLB misses. A TLB miss is an unrecoverable fault to the Nintendo 64 system.

More information about these topics can be found in the MIPS R4300 documentation.

UP