HPMMU.notes revision 1.6
11.6Sandvar$NetBSD: HPMMU.notes,v 1.6 2023/09/08 18:51:19 andvar Exp $ 21.2Scgd 31.1SmycroftOverview: 41.1Smycroft-------- 51.1Smycroft 61.1Smycroft (Some of this is gleaned from an article in the September 1986 71.1Smycroft Hewlett-Packard Journal and info in the July 1987 HP Communicator) 81.1Smycroft 91.1Smycroft Page and segment table entries mimic the Motorola 68851 PMMU, 101.1Smycroft in an effort at upward compatibility. The HP MMU uses a two 111.3Swiz level translation scheme. There are separate (but equal!) 121.1Smycroft translation tables for both supervisor and user modes. At the 131.1Smycroft lowest level are page tables. Each page table consists of one 141.1Smycroft or more 4k pages of 1024x4 byte page table entries. Each PTE 151.1Smycroft maps one 4k page of VA space. At the highest level is the 161.1Smycroft segment table. The segment table is a single 4K page of 1024x4 171.1Smycroft byte entries. Each entry points to a 4k page of PTEs. Hence 181.1Smycroft one STE maps 4Mb of VA space and one page of STEs is sufficient 191.1Smycroft to map the entire 4Gb address space (what a coincidence!). The 201.1Smycroft unused valid bit in page and segment table entries must be 211.1Smycroft zero. 221.1Smycroft 231.3Swiz There are separate translation lookaside buffers for the user 241.1Smycroft and supervisor modes, each containing 1024 entries. 251.1Smycroft 261.1Smycroft To augment the 68020's instruction cache, the HP CPU has an 271.1Smycroft external cache. A direct-mapped, virtual cache implementation 281.1Smycroft is used with 16 Kbytes of cache on 320 systems and 32 Kbytes on 291.1Smycroft 350 systems. Each cache entry can contain instructions or data, 301.5Swiz from either user or supervisor space. Separate valid bits are 311.1Smycroft kept for user and supervisor entries, allowing for descriminatory 321.1Smycroft flushing of the cache. 331.1Smycroft 341.1Smycroft MMU translation and cache-miss detection are done in parallel. 351.1Smycroft 361.1Smycroft 371.1SmycroftSegment table entries: 381.1Smycroft------- ----- ------- 391.1Smycroft 401.1Smycroft bits 31-12: Physical page frame number of PT page 411.1Smycroft bits 11-4: Reserved at zero 421.1Smycroft (can software use them?) 431.1Smycroft bit 3: Reserved at one 441.1Smycroft bit 2: Set to 1 if segment is read-only, ow read-write 451.1Smycroft bits 1-0: Valid bits 461.1Smycroft (hardware uses bit 1) 471.1Smycroft 481.1Smycroft 491.1SmycroftPage table entries: 501.1Smycroft---- ----- ------- 511.1Smycroft 521.1Smycroft bits 31-12: Physical page frame number of page 531.1Smycroft bits 11-7: Available for software use 541.1Smycroft bit 6: If 1, inhibits caching of data in this page. 551.1Smycroft (both instruction and external cache) 561.1Smycroft bit 5: Reserved at zero 571.1Smycroft bit 4: Hardware modify bit 581.1Smycroft bit 3: Hardware reference bit 591.1Smycroft bit 2: Set to 1 if page is read-only, ow read-write 601.1Smycroft bits 1-0: Valid bits 611.1Smycroft (hardware uses bit 0) 621.1Smycroft 631.1Smycroft 641.1SmycroftHardware registers: 651.1Smycroft-------- --------- 661.1Smycroft 671.1Smycroft The hardware has four longword registers controlling the MMU. 681.1Smycroft The registers can be accessed as shortwords also (remember to 691.1Smycroft add 2 to addresses given below). 701.1Smycroft 711.1Smycroft 5F4000: Supervisor mode segment table pointer. Loaded (as longword) 721.1Smycroft with page frame number (i.e. Physaddr >> 12) of the segment 731.1Smycroft table mapping supervisor space. 741.1Smycroft 5F4004: User mode segment table pointer. Loaded (as longword) with 751.1Smycroft page frame number of the segment table mapping user space. 761.1Smycroft 5F4008: TLB control register. Used to invalid large sections of the 771.1Smycroft TLB. More info below. 781.1Smycroft 5F400C: MMU command/status register. Defined as follows: 791.1Smycroft 801.4Swiz bit 15: If 1, indicates a page table fault occurred 811.4Swiz bit 14: If 1, indicates a page fault occurred 821.1Smycroft bit 13: If 1, indicates a protection fault (write to RO page) 831.1Smycroft bit 6: MC68881 enable. Tied to chip enable line. 841.1Smycroft (set this bit to enable) 851.6Sandvar bit 5: MC68020 instruction cache enable. Tied to Instruction 861.1Smycroft cache disable line. (set this bit to enable) 871.4Swiz bit 3: If 1, indicates an MMU related bus error occurred. 881.1Smycroft Bits 13-15 are now valid. 891.1Smycroft bit 2: External cache enable. (set this bit to enable) 901.1Smycroft bit 1: Supervisor mapping enable. Enables translation of 911.1Smycroft supervisor space VAs. 921.1Smycroft bit 0: User mapping enable. Enables translation of user 931.1Smycroft space VAs. 941.1Smycroft 951.1Smycroft 961.1Smycroft Any bits set by the hardware are cleared only by software. 971.1Smycroft (i.e. bits 3,13,14,15) 981.1Smycroft 991.1SmycroftInvalidating TLB: 1001.1Smycroft------------ --- 1011.1Smycroft 1021.1Smycroft All translations: 1031.1Smycroft Read the TLB control register (5F4008) as a longword. 1041.1Smycroft 1051.1Smycroft User translations only: 1061.1Smycroft Write a longword 0 to TLB register or set the user 1071.1Smycroft segment table pointer. 1081.1Smycroft 1091.1Smycroft Supervisor translations only: 1101.1Smycroft Write a longword 0x8000 to TLB register or set the 1111.1Smycroft supervisor segment table pointer. 1121.1Smycroft 1131.1Smycroft A particular VA translation: 1141.1Smycroft Set destination function code to 3 ("purge" space), 1151.1Smycroft write a longword 0 to the VA whose translation we are to 1161.1Smycroft invalidate, and restore function code. This apparently 1171.1Smycroft invalidates any translation for that VA in both the user 1181.1Smycroft and supervisor LB. Here is what I did: 1191.1Smycroft 1201.1Smycroft #define FC_PURGE 3 1211.1Smycroft #define FC_USERD 1 1221.1Smycroft _TBIS: 1231.1Smycroft movl sp@(4),a0 | VA to invalidate 1241.1Smycroft moveq #FC_PURGE,d0 | change address space 1251.1Smycroft movc d0,dfc | for destination 1261.1Smycroft moveq #0,d0 | zero to invalidate? 1271.1Smycroft movsl d0,a0@ | hit it 1281.1Smycroft moveq #FC_USERD,d0 | back to old 1291.1Smycroft movc d0,dfc | address space 1301.1Smycroft rts | done 1311.1Smycroft 1321.1Smycroft 1331.1SmycroftInvalidating the external cache: 1341.1Smycroft------------ --- -------- ----- 1351.1Smycroft 1361.1Smycroft Everything: 1371.1Smycroft Toggle the cache enable bit (bit 2) in the MMU control 1381.1Smycroft register (5F400C). Can be done by ANDing and ORing the 1391.1Smycroft register location. 1401.1Smycroft 1411.1Smycroft User: 1421.1Smycroft Change the user segment table pointer register (5F4004), 1431.1Smycroft i.e. read the current value and write it back. 1441.1Smycroft 1451.1Smycroft Supervisor: 1461.1Smycroft Change the supervisor segment table pointer register 1471.1Smycroft (5F4000), i.e. read the current value and write it back. 148