/* * Memory and machine-specific definitions. Used in C and assembler. */ #define KiB 1024u /* Kibi 0x0000000000000400 */ #define MiB 1048576u /* Mebi 0x0000000000100000 */ #define GiB 1073741824u /* Gibi 000000000040000000 */ #define TiB 1099511627776ull /* Tebi 0x0000010000000000 */ #define PiB 1125899906842624ull /* Pebi 0x0004000000000000 */ #define EiB 1152921504606846976ull /* Exbi 0x1000000000000000 */ /* * Sizes */ #define BI2BY 8 /* bits per byte */ #define BI2WD 32 /* bits per word */ #define BY2WD 4 /* bytes per word */ #define BY2V 8 /* bytes per vlong */ #define BY2SE 4 /* bytes per stack element */ #define BY2PG 4096 /* bytes per page */ #define PGSHIFT 12 /* log(BY2PG) */ #define STACKALIGN(sp) ((sp) & ~7) /* bug: assure with alloc */ #define SEGALIGN (1024*1024) /* alignment for segments */ #define BY2PTE 8 /* bytes per pte entry */ #define BY2PTEG 64 /* bytes per pte group */ #define ICACHESIZE 32768 /* 0, 4, 8, 16, or 32 KB */ #define ICACHEWAYSIZE (ICACHESIZE/64) /* 64-way set associative */ #define ICACHELINELOG 5 /* 8 words (4 bytes) per line */ #define ICACHELINESZ (1< */ #define USER 29 /* R29 is up-> */ /* * Virtual MMU */ #define PTEMAPMEM (1024*1024) #define PTEPERTAB (PTEMAPMEM/BY2PG) #define SEGMAPSIZE 1984 #define SSEGMAPSIZE 16 #define PPN(x) ((x)&~(BY2PG-1)) #define PTEVALID (1<<0) #define PTEWRITE (1<<1) #define PTERONLY (0<<1) #define PTEUNCACHED (1<<2) /* * Physical MMU */ #define NTLB 64 /* number of entries */ #define NTLBPID 256 /* number of hardware pids (0 = global) */ /* TLBHI */ #define TLBEPN(x) ((x) & ~0x3FF) #define TLB1K (0<<4) #define TLB4K (1<<4) #define TLB16K (2<<4) #define TLB64K (3<<4) #define TLB256K (4<<4) #define TLB1MB (5<<4) /* 4Mbyte not implemented */ #define TLB16MB (7<<4) /* 32Mbyte not implemented */ #define TLB256MB (9<<4) #define TLBVALID (1<<9) #define TLBTS (1<<8) /* Translation address space */ /* TLBMID */ #define TLBRPN(x) ((x) & ~0x3FF) #define TLBERPN(uv) (((uv)>>32)&0xF) /* with full address as uvlong */ /* TLBLO */ #define TLBU0 (1<<15) /* user definable */ #define TLBU1 (1<<14) /* user definable */ #define TLBU2 (1<<13) /* user definable */ #define TLBU3 (1<<12) /* user definable */ #define TLBW (1<<11) /* write-through? */ #define TLBI (1<<10) /* cache inhibit */ #define TLBM (1<<9) /* memory coherent */ #define TLBG (1<<8) /* guarded */ #define TLBLE (1<<7) /* little endian mode */ #define TLBUX (1<<5) /* user execute enable */ #define TLBUW (1<<4) /* user writable */ #define TLBUR (1<<3) /* user readable */ #define TLBSX (1<<2) /* supervisor execute enable */ #define TLBSW (1<<1) /* supervisor writable */ #define TLBSR (1<<0) /* supervisor readable */ #define TLBWR (TLBSW|TLBSR) /* * software TLB (for quick reload by [id]tlbmiss) */ #define STLBLOG 10 #define STLBSIZE (1<