mem.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. * Memory and machine-specific definitions. Used in C and assembler.
  3. */
  4. /*
  5. * Sizes
  6. */
  7. #define BI2BY 8 /* bits per byte */
  8. #define BI2WD 32 /* bits per word */
  9. #define BY2WD 4 /* bytes per word */
  10. #define BY2V 8 /* bytes per double word */
  11. #define BY2PG 4096 /* bytes per page */
  12. #define WD2PG (BY2PG/BY2WD) /* words per page */
  13. #define PGSHIFT 12 /* log(BY2PG) */
  14. #define ROUND(s, sz) (((s)+(sz-1))&~(sz-1))
  15. #define PGROUND(s) ROUND(s, BY2PG)
  16. #define BLOCKALIGN 8
  17. #define MAXMACH 1 /* max # cpus system can run */
  18. /*
  19. * Time
  20. */
  21. #define HZ (20) /* clock frequency */
  22. #define MS2HZ (1000/HZ) /* millisec per clock tick */
  23. #define TK2SEC(t) ((t)/HZ) /* ticks to seconds */
  24. /*
  25. * Virtual addresses:
  26. *
  27. * We direct map all discovered DRAM and the area twixt 0xe0000000 and
  28. * 0xe8000000 used to provide zeros for cache flushing.
  29. *
  30. * Flash is mapped to 0xb0000000 and special registers are mapped
  31. * on demand to areas starting at 0xa0000000.
  32. *
  33. * The direct mapping is convenient but not necessary. It means
  34. * that we don't have to turn on the MMU till well into the
  35. * kernel. This can be changed by providing a mapping in l.s
  36. * before calling main.
  37. */
  38. #define UZERO 0 /* base of user address space */
  39. #define UTZERO (UZERO+BY2PG) /* first address in user text */
  40. #define KZERO 0xC0000000 /* base of kernel address space */
  41. #define KTZERO 0xC0008000 /* first address in kernel text */
  42. #define EMEMZERO 0x90000000 /* 256 meg for add on memory */
  43. #define EMEMTOP 0xA0000000 /* ... */
  44. #define REGZERO 0xA0000000 /* 128 meg for mapspecial regs */
  45. #define REGTOP 0xA8000000 /* ... */
  46. #define FLASHZERO 0xB0000000 /* 128 meg for flash */
  47. #define FLASHTOP 0xB8000000 /* ... */
  48. #define DRAMZERO 0xC0000000 /* 128 meg for dram */
  49. #define DRAMTOP 0xC8000000 /* ... */
  50. #define UCDRAMZERO 0xC8000000 /* 128 meg for dram (uncached/unbuffered) */
  51. #define UCDRAMTOP 0xD0000000 /* ... */
  52. #define NULLZERO 0xE0000000 /* 128 meg for cache flush zeroes */
  53. #define NULLTOP 0xE8000000 /* ... */
  54. #define USTKTOP 0x2000000 /* byte just beyond user stack */
  55. #define USTKSIZE (8*1024*1024) /* size of user stack */
  56. #define TSTKTOP (USTKTOP-USTKSIZE) /* end of new stack in sysexec */
  57. #define TSTKSIZ 100
  58. #define MACHADDR (KZERO+0x00001000)
  59. #define EVECTORS 0xFFFF0000 /* virt base of exception vectors */
  60. #define KSTACK (16*1024) /* Size of kernel stack */
  61. /*
  62. * Offsets into flash
  63. */
  64. #define Flash_bootldr (FLASHZERO+0x0) /* boot loader */
  65. #define Flash_kernel (FLASHZERO+0x10000) /* boot kernel */
  66. #define Flash_tar (FLASHZERO+0x200000) /* fs.sac (tar file) */
  67. /*
  68. * virtual MMU
  69. */
  70. #define PTEMAPMEM (1024*1024)
  71. #define PTEPERTAB (PTEMAPMEM/BY2PG)
  72. #define SEGMAPSIZE 1984
  73. #define SSEGMAPSIZE 16
  74. #define PPN(x) ((x)&~(BY2PG-1))
  75. /*
  76. * SA1110 definitions
  77. */
  78. /*
  79. * memory physical addresses
  80. */
  81. #define PHYSFLASH0 0x00000000
  82. #define PHYSDRAM0 0xC0000000
  83. #define PHYSNULL0 0xE0000000
  84. /*
  85. * peripheral control module physical addresses
  86. */
  87. #define USBREGS 0x80000000 /* serial port 0 - USB */
  88. #define UART1REGS 0x80010000 /* serial port 1 - UART */
  89. #define GPCLKREGS 0x80020060 /* serial port 1 - general purpose clock */
  90. #define UART2REGS 0x80030000 /* serial port 2 - low speed IR */
  91. #define HSSPREGS 0x80040060 /* serial port 2 - high speed IR */
  92. #define UART3REGS 0x80050000 /* serial port 3 - RS232 UART */
  93. #define MCPREGS 0x80060000 /* serial port 4 - multimedia comm port */
  94. #define SSPREGS 0x80070060 /* serial port 4 - synchronous serial port */
  95. #define OSTIMERREGS 0x90000000 /* operating system timer registers */
  96. #define POWERREGS 0x90020000 /* power management */
  97. #define RESETREGS 0x90030000 /* reset controller */
  98. #define GPIOREGS 0x90040000 /* 28 general purpose IO pins */
  99. #define INTRREGS 0x90050000 /* interrupt registers */
  100. #define PPCREGS 0x90060000 /* peripheral pin controller */
  101. #define MEMCONFREGS 0xA0000000 /* memory configuration */
  102. #define LCDREGS 0xB0100000 /* display */
  103. /*
  104. * PCMCIA addresses
  105. */
  106. #define PHYSPCM0REGS 0x20000000
  107. #define PYHSPCM0ATTR 0x28000000
  108. #define PYHSPCM0MEM 0x2C000000
  109. #define PHYSPCM1REGS 0x30000000
  110. #define PYHSPCM1ATTR 0x38000000
  111. #define PYHSPCM1MEM 0x3C000000
  112. /*
  113. * Program Status Registers
  114. */
  115. #define PsrMusr 0x00000010 /* mode */
  116. #define PsrMfiq 0x00000011
  117. #define PsrMirq 0x00000012
  118. #define PsrMsvc 0x00000013
  119. #define PsrMabt 0x00000017
  120. #define PsrMund 0x0000001B
  121. #define PsrMask 0x0000001F
  122. #define PsrDfiq 0x00000040 /* disable FIQ interrupts */
  123. #define PsrDirq 0x00000080 /* disable IRQ interrupts */
  124. #define PsrV 0x10000000 /* overflow */
  125. #define PsrC 0x20000000 /* carry/borrow/extend */
  126. #define PsrZ 0x40000000 /* zero */
  127. #define PsrN 0x80000000 /* negative/less than */
  128. /*
  129. * Coprocessors
  130. */
  131. #define CpMMU 15
  132. #define CpPWR 15
  133. /*
  134. * Internal MMU coprocessor registers
  135. */
  136. #define CpCPUID 0 /* R: */
  137. #define CpControl 1 /* RW: */
  138. #define CpTTB 2 /* RW: translation table base */
  139. #define CpDAC 3 /* RW: domain access control */
  140. #define CpFSR 5 /* RW: fault status */
  141. #define CpFAR 6 /* RW: fault address */
  142. #define CpCacheFlush 7 /* W: cache flushing, wb draining*/
  143. #define CpTLBFlush 8 /* W: TLB flushing */
  144. #define CpRBFlush 9 /* W: Read Buffer ops */
  145. #define CpPID 13 /* RW: PID for virtual mapping */
  146. #define CpBpt 14 /* W: Breakpoint register */
  147. #define CpTest 15 /* W: Test, Clock and Idle Control */
  148. /*
  149. * CpControl
  150. */
  151. #define CpCmmuena 0x00000001 /* M: MMU enable */
  152. #define CpCalign 0x00000002 /* A: alignment fault enable */
  153. #define CpCdcache 0x00000004 /* C: data cache on */
  154. #define CpCwb 0x00000008 /* W: write buffer turned on */
  155. #define CpCi32 0x00000010 /* P: 32-bit program space */
  156. #define CpCd32 0x00000020 /* D: 32-bit data space */
  157. #define CpCbe 0x00000080 /* B: big-endian operation */
  158. #define CpCsystem 0x00000100 /* S: system permission */
  159. #define CpCrom 0x00000200 /* R: ROM permission */
  160. #define CpCicache 0x00001000 /* I: instruction cache on */
  161. #define CpCvivec 0x00002000 /* X: virtual interrupt vector adjust */
  162. /*
  163. * fault codes
  164. */
  165. #define FCterm 0x2 /* terminal */
  166. #define FCvec 0x0 /* vector */
  167. #define FCalignf 0x1 /* unaligned full word data access */
  168. #define FCalignh 0x3 /* unaligned half word data access */
  169. #define FCl1abort 0xc /* level 1 external abort on translation */
  170. #define FCl2abort 0xe /* level 2 external abort on translation */
  171. #define FCtransSec 0x5 /* section translation */
  172. #define FCtransPage 0x7 /* page translation */
  173. #define FCdomainSec 0x9 /* section domain */
  174. #define FCdomainPage 0x11 /* page domain */
  175. #define FCpermSec 0x9 /* section permissions */
  176. #define FCpermPage 0x11 /* page permissions */
  177. #define FCabortLFSec 0x4 /* external abort on linefetch for section */
  178. #define FCabortLFPage 0x6 /* external abort on linefetch for page */
  179. #define FCabortNLFSec 0x8 /* external abort on non-linefetch for section */
  180. #define FCabortNLFPage 0xa /* external abort on non-linefetch for page */
  181. /*
  182. * PTE bits used by fault.h. mmu.c translates them to real values.
  183. */
  184. #define PTEVALID (1<<0)
  185. #define PTERONLY 0 /* this is implied by the absence of PTEWRITE */
  186. #define PTEWRITE (1<<1)
  187. #define PTEUNCACHED (1<<2)
  188. #define PTEKERNEL (1<<3) /* no user access */
  189. /*
  190. * H3650 specific definitions
  191. */
  192. #define EGPIOREGS 0x49000000 /* Additional GPIO register */
  193. /* Power management */
  194. #define PWR_rtc 0x80000000 /* resume on RTC */
  195. #define PWR_gpio0 0x00000001 /* resume on power button */
  196. #define RCSR_all 0x0000000f
  197. #define PCFR_opde 0x00000001 /* oscillator power-down enable */
  198. #define PCFR_suspend 0x00000001
  199. #define PCFR_fp 0x00000002 /* float pcmcia */
  200. #define PCFR_fs 0x00000004 /* float static memory */
  201. #define PCFR_fo 0x00000008
  202. #define MDREFR_k1db2 (1 << 22)
  203. #define MDREFR_slfrsh 0x80000000 /* self refresh */
  204. #define MDREFR_e1pin (1 << 20)
  205. #define MSC_rt 0x00030003
  206. #define MDCNFG_de0 0x00000001 /* dram enable */
  207. #define MDCNFG_de1 0x00000002
  208. #define MDCNFG_de2 0x00000004
  209. #define MDCNFG_de3 0x00000008
  210. #define MDCFNG_de 0x0000000f
  211. #define PMCR_sf 1