mem.h 7.2 KB

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