system.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. #ifndef __ALPHA_SYSTEM_H
  2. #define __ALPHA_SYSTEM_H
  3. #include <asm/pal.h>
  4. #define PAGE_SHIFT 13
  5. #define PAGE_SIZE (1UL << PAGE_SHIFT)
  6. #define PAGE_OFFSET 0xfffffc0000000000UL
  7. /*
  8. * System defines.. Note that this is included both from .c and .S
  9. * files, so it does only defines, not any C code.
  10. */
  11. /*
  12. * We leave one page for the initial stack page, and one page for
  13. * the initial process structure. Also, the console eats 3 MB for
  14. * the initial bootloader (one of which we can reclaim later).
  15. */
  16. #define BOOT_PCB 0x20000000
  17. #define BOOT_ADDR 0x20000000
  18. /* Remove when official MILO sources have ELF support: */
  19. #define BOOT_SIZE (16*1024)
  20. #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
  21. #define KERNEL_START_PHYS 0x300000 /* Old bootloaders hardcoded this. */
  22. #else
  23. #define KERNEL_START_PHYS 0x1000000 /* required: Wildfire/Titan/Marvel */
  24. #endif
  25. #define KERNEL_START (PAGE_OFFSET+KERNEL_START_PHYS)
  26. #define SWAPPER_PGD KERNEL_START
  27. #define INIT_STACK (PAGE_OFFSET+KERNEL_START_PHYS+0x02000)
  28. #define EMPTY_PGT (PAGE_OFFSET+KERNEL_START_PHYS+0x04000)
  29. #define EMPTY_PGE (PAGE_OFFSET+KERNEL_START_PHYS+0x08000)
  30. #define ZERO_PGE (PAGE_OFFSET+KERNEL_START_PHYS+0x0A000)
  31. #define START_ADDR (PAGE_OFFSET+KERNEL_START_PHYS+0x10000)
  32. /*
  33. * This is setup by the secondary bootstrap loader. Because
  34. * the zero page is zeroed out as soon as the vm system is
  35. * initialized, we need to copy things out into a more permanent
  36. * place.
  37. */
  38. #define PARAM ZERO_PGE
  39. #define COMMAND_LINE ((char*)(PARAM + 0x0000))
  40. #define INITRD_START (*(unsigned long *) (PARAM+0x100))
  41. #define INITRD_SIZE (*(unsigned long *) (PARAM+0x108))
  42. #ifndef __ASSEMBLY__
  43. #include <linux/kernel.h>
  44. /*
  45. * This is the logout header that should be common to all platforms
  46. * (assuming they are running OSF/1 PALcode, I guess).
  47. */
  48. struct el_common {
  49. unsigned int size; /* size in bytes of logout area */
  50. unsigned int sbz1 : 30; /* should be zero */
  51. unsigned int err2 : 1; /* second error */
  52. unsigned int retry : 1; /* retry flag */
  53. unsigned int proc_offset; /* processor-specific offset */
  54. unsigned int sys_offset; /* system-specific offset */
  55. unsigned int code; /* machine check code */
  56. unsigned int frame_rev; /* frame revision */
  57. };
  58. /* Machine Check Frame for uncorrectable errors (Large format)
  59. * --- This is used to log uncorrectable errors such as
  60. * double bit ECC errors.
  61. * --- These errors are detected by both processor and systems.
  62. */
  63. struct el_common_EV5_uncorrectable_mcheck {
  64. unsigned long shadow[8]; /* Shadow reg. 8-14, 25 */
  65. unsigned long paltemp[24]; /* PAL TEMP REGS. */
  66. unsigned long exc_addr; /* Address of excepting instruction*/
  67. unsigned long exc_sum; /* Summary of arithmetic traps. */
  68. unsigned long exc_mask; /* Exception mask (from exc_sum). */
  69. unsigned long pal_base; /* Base address for PALcode. */
  70. unsigned long isr; /* Interrupt Status Reg. */
  71. unsigned long icsr; /* CURRENT SETUP OF EV5 IBOX */
  72. unsigned long ic_perr_stat; /* I-CACHE Reg. <11> set Data parity
  73. <12> set TAG parity*/
  74. unsigned long dc_perr_stat; /* D-CACHE error Reg. Bits set to 1:
  75. <2> Data error in bank 0
  76. <3> Data error in bank 1
  77. <4> Tag error in bank 0
  78. <5> Tag error in bank 1 */
  79. unsigned long va; /* Effective VA of fault or miss. */
  80. unsigned long mm_stat; /* Holds the reason for D-stream
  81. fault or D-cache parity errors */
  82. unsigned long sc_addr; /* Address that was being accessed
  83. when EV5 detected Secondary cache
  84. failure. */
  85. unsigned long sc_stat; /* Helps determine if the error was
  86. TAG/Data parity(Secondary Cache)*/
  87. unsigned long bc_tag_addr; /* Contents of EV5 BC_TAG_ADDR */
  88. unsigned long ei_addr; /* Physical address of any transfer
  89. that is logged in EV5 EI_STAT */
  90. unsigned long fill_syndrome; /* For correcting ECC errors. */
  91. unsigned long ei_stat; /* Helps identify reason of any
  92. processor uncorrectable error
  93. at its external interface. */
  94. unsigned long ld_lock; /* Contents of EV5 LD_LOCK register*/
  95. };
  96. struct el_common_EV6_mcheck {
  97. unsigned int FrameSize; /* Bytes, including this field */
  98. unsigned int FrameFlags; /* <31> = Retry, <30> = Second Error */
  99. unsigned int CpuOffset; /* Offset to CPU-specific info */
  100. unsigned int SystemOffset; /* Offset to system-specific info */
  101. unsigned int MCHK_Code;
  102. unsigned int MCHK_Frame_Rev;
  103. unsigned long I_STAT; /* EV6 Internal Processor Registers */
  104. unsigned long DC_STAT; /* (See the 21264 Spec) */
  105. unsigned long C_ADDR;
  106. unsigned long DC1_SYNDROME;
  107. unsigned long DC0_SYNDROME;
  108. unsigned long C_STAT;
  109. unsigned long C_STS;
  110. unsigned long MM_STAT;
  111. unsigned long EXC_ADDR;
  112. unsigned long IER_CM;
  113. unsigned long ISUM;
  114. unsigned long RESERVED0;
  115. unsigned long PAL_BASE;
  116. unsigned long I_CTL;
  117. unsigned long PCTX;
  118. };
  119. extern void halt(void) __attribute__((noreturn));
  120. #define __halt() __asm__ __volatile__ ("call_pal %0 #halt" : : "i" (PAL_halt))
  121. #define switch_to(P,N,L) \
  122. do { \
  123. (L) = alpha_switch_to(virt_to_phys(&task_thread_info(N)->pcb), (P)); \
  124. check_mmu_context(); \
  125. } while (0)
  126. struct task_struct;
  127. extern struct task_struct *alpha_switch_to(unsigned long, struct task_struct*);
  128. /*
  129. * On SMP systems, when the scheduler does migration-cost autodetection,
  130. * it needs a way to flush as much of the CPU's caches as possible.
  131. *
  132. * TODO: fill this in!
  133. */
  134. static inline void sched_cacheflush(void)
  135. {
  136. }
  137. #define imb() \
  138. __asm__ __volatile__ ("call_pal %0 #imb" : : "i" (PAL_imb) : "memory")
  139. #define draina() \
  140. __asm__ __volatile__ ("call_pal %0 #draina" : : "i" (PAL_draina) : "memory")
  141. enum implver_enum {
  142. IMPLVER_EV4,
  143. IMPLVER_EV5,
  144. IMPLVER_EV6
  145. };
  146. #ifdef CONFIG_ALPHA_GENERIC
  147. #define implver() \
  148. ({ unsigned long __implver; \
  149. __asm__ ("implver %0" : "=r"(__implver)); \
  150. (enum implver_enum) __implver; })
  151. #else
  152. /* Try to eliminate some dead code. */
  153. #ifdef CONFIG_ALPHA_EV4
  154. #define implver() IMPLVER_EV4
  155. #endif
  156. #ifdef CONFIG_ALPHA_EV5
  157. #define implver() IMPLVER_EV5
  158. #endif
  159. #if defined(CONFIG_ALPHA_EV6)
  160. #define implver() IMPLVER_EV6
  161. #endif
  162. #endif
  163. enum amask_enum {
  164. AMASK_BWX = (1UL << 0),
  165. AMASK_FIX = (1UL << 1),
  166. AMASK_CIX = (1UL << 2),
  167. AMASK_MAX = (1UL << 8),
  168. AMASK_PRECISE_TRAP = (1UL << 9),
  169. };
  170. #define amask(mask) \
  171. ({ unsigned long __amask, __input = (mask); \
  172. __asm__ ("amask %1,%0" : "=r"(__amask) : "rI"(__input)); \
  173. __amask; })
  174. #define __CALL_PAL_R0(NAME, TYPE) \
  175. static inline TYPE NAME(void) \
  176. { \
  177. register TYPE __r0 __asm__("$0"); \
  178. __asm__ __volatile__( \
  179. "call_pal %1 # " #NAME \
  180. :"=r" (__r0) \
  181. :"i" (PAL_ ## NAME) \
  182. :"$1", "$16", "$22", "$23", "$24", "$25"); \
  183. return __r0; \
  184. }
  185. #define __CALL_PAL_W1(NAME, TYPE0) \
  186. static inline void NAME(TYPE0 arg0) \
  187. { \
  188. register TYPE0 __r16 __asm__("$16") = arg0; \
  189. __asm__ __volatile__( \
  190. "call_pal %1 # "#NAME \
  191. : "=r"(__r16) \
  192. : "i"(PAL_ ## NAME), "0"(__r16) \
  193. : "$1", "$22", "$23", "$24", "$25"); \
  194. }
  195. #define __CALL_PAL_W2(NAME, TYPE0, TYPE1) \
  196. static inline void NAME(TYPE0 arg0, TYPE1 arg1) \
  197. { \
  198. register TYPE0 __r16 __asm__("$16") = arg0; \
  199. register TYPE1 __r17 __asm__("$17") = arg1; \
  200. __asm__ __volatile__( \
  201. "call_pal %2 # "#NAME \
  202. : "=r"(__r16), "=r"(__r17) \
  203. : "i"(PAL_ ## NAME), "0"(__r16), "1"(__r17) \
  204. : "$1", "$22", "$23", "$24", "$25"); \
  205. }
  206. #define __CALL_PAL_RW1(NAME, RTYPE, TYPE0) \
  207. static inline RTYPE NAME(TYPE0 arg0) \
  208. { \
  209. register RTYPE __r0 __asm__("$0"); \
  210. register TYPE0 __r16 __asm__("$16") = arg0; \
  211. __asm__ __volatile__( \
  212. "call_pal %2 # "#NAME \
  213. : "=r"(__r16), "=r"(__r0) \
  214. : "i"(PAL_ ## NAME), "0"(__r16) \
  215. : "$1", "$22", "$23", "$24", "$25"); \
  216. return __r0; \
  217. }
  218. #define __CALL_PAL_RW2(NAME, RTYPE, TYPE0, TYPE1) \
  219. static inline RTYPE NAME(TYPE0 arg0, TYPE1 arg1) \
  220. { \
  221. register RTYPE __r0 __asm__("$0"); \
  222. register TYPE0 __r16 __asm__("$16") = arg0; \
  223. register TYPE1 __r17 __asm__("$17") = arg1; \
  224. __asm__ __volatile__( \
  225. "call_pal %3 # "#NAME \
  226. : "=r"(__r16), "=r"(__r17), "=r"(__r0) \
  227. : "i"(PAL_ ## NAME), "0"(__r16), "1"(__r17) \
  228. : "$1", "$22", "$23", "$24", "$25"); \
  229. return __r0; \
  230. }
  231. __CALL_PAL_W1(cflush, unsigned long);
  232. __CALL_PAL_R0(rdmces, unsigned long);
  233. __CALL_PAL_R0(rdps, unsigned long);
  234. __CALL_PAL_R0(rdusp, unsigned long);
  235. __CALL_PAL_RW1(swpipl, unsigned long, unsigned long);
  236. __CALL_PAL_R0(whami, unsigned long);
  237. __CALL_PAL_W2(wrent, void*, unsigned long);
  238. __CALL_PAL_W1(wripir, unsigned long);
  239. __CALL_PAL_W1(wrkgp, unsigned long);
  240. __CALL_PAL_W1(wrmces, unsigned long);
  241. __CALL_PAL_RW2(wrperfmon, unsigned long, unsigned long, unsigned long);
  242. __CALL_PAL_W1(wrusp, unsigned long);
  243. __CALL_PAL_W1(wrvptptr, unsigned long);
  244. #define IPL_MIN 0
  245. #define IPL_SW0 1
  246. #define IPL_SW1 2
  247. #define IPL_DEV0 3
  248. #define IPL_DEV1 4
  249. #define IPL_TIMER 5
  250. #define IPL_PERF 6
  251. #define IPL_POWERFAIL 6
  252. #define IPL_MCHECK 7
  253. #define IPL_MAX 7
  254. #ifdef CONFIG_ALPHA_BROKEN_IRQ_MASK
  255. #undef IPL_MIN
  256. #define IPL_MIN __min_ipl
  257. extern int __min_ipl;
  258. #endif
  259. #define getipl() (rdps() & 7)
  260. #define setipl(ipl) ((void) swpipl(ipl))
  261. #define local_irq_disable() do { setipl(IPL_MAX); barrier(); } while(0)
  262. #define local_irq_enable() do { barrier(); setipl(IPL_MIN); } while(0)
  263. #define local_save_flags(flags) ((flags) = rdps())
  264. #define local_irq_save(flags) do { (flags) = swpipl(IPL_MAX); barrier(); } while(0)
  265. #define local_irq_restore(flags) do { barrier(); setipl(flags); barrier(); } while(0)
  266. #define irqs_disabled() (getipl() == IPL_MAX)
  267. /*
  268. * TB routines..
  269. */
  270. #define __tbi(nr,arg,arg1...) \
  271. ({ \
  272. register unsigned long __r16 __asm__("$16") = (nr); \
  273. register unsigned long __r17 __asm__("$17"); arg; \
  274. __asm__ __volatile__( \
  275. "call_pal %3 #__tbi" \
  276. :"=r" (__r16),"=r" (__r17) \
  277. :"0" (__r16),"i" (PAL_tbi) ,##arg1 \
  278. :"$0", "$1", "$22", "$23", "$24", "$25"); \
  279. })
  280. #define tbi(x,y) __tbi(x,__r17=(y),"1" (__r17))
  281. #define tbisi(x) __tbi(1,__r17=(x),"1" (__r17))
  282. #define tbisd(x) __tbi(2,__r17=(x),"1" (__r17))
  283. #define tbis(x) __tbi(3,__r17=(x),"1" (__r17))
  284. #define tbiap() __tbi(-1, /* no second argument */)
  285. #define tbia() __tbi(-2, /* no second argument */)
  286. #endif /* __ASSEMBLY__ */
  287. #define arch_align_stack(x) (x)
  288. #endif