system.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. #ifndef __ALPHA_SYSTEM_H
  2. #define __ALPHA_SYSTEM_H
  3. #include <asm/pal.h>
  4. #include <asm/page.h>
  5. #include <asm/barrier.h>
  6. /*
  7. * System defines.. Note that this is included both from .c and .S
  8. * files, so it does only defines, not any C code.
  9. */
  10. /*
  11. * We leave one page for the initial stack page, and one page for
  12. * the initial process structure. Also, the console eats 3 MB for
  13. * the initial bootloader (one of which we can reclaim later).
  14. */
  15. #define BOOT_PCB 0x20000000
  16. #define BOOT_ADDR 0x20000000
  17. /* Remove when official MILO sources have ELF support: */
  18. #define BOOT_SIZE (16*1024)
  19. #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
  20. #define KERNEL_START_PHYS 0x300000 /* Old bootloaders hardcoded this. */
  21. #else
  22. #define KERNEL_START_PHYS 0x1000000 /* required: Wildfire/Titan/Marvel */
  23. #endif
  24. #define KERNEL_START (PAGE_OFFSET+KERNEL_START_PHYS)
  25. #define SWAPPER_PGD KERNEL_START
  26. #define INIT_STACK (PAGE_OFFSET+KERNEL_START_PHYS+0x02000)
  27. #define EMPTY_PGT (PAGE_OFFSET+KERNEL_START_PHYS+0x04000)
  28. #define EMPTY_PGE (PAGE_OFFSET+KERNEL_START_PHYS+0x08000)
  29. #define ZERO_PGE (PAGE_OFFSET+KERNEL_START_PHYS+0x0A000)
  30. #define START_ADDR (PAGE_OFFSET+KERNEL_START_PHYS+0x10000)
  31. /*
  32. * This is setup by the secondary bootstrap loader. Because
  33. * the zero page is zeroed out as soon as the vm system is
  34. * initialized, we need to copy things out into a more permanent
  35. * place.
  36. */
  37. #define PARAM ZERO_PGE
  38. #define COMMAND_LINE ((char*)(PARAM + 0x0000))
  39. #define INITRD_START (*(unsigned long *) (PARAM+0x100))
  40. #define INITRD_SIZE (*(unsigned long *) (PARAM+0x108))
  41. #ifndef __ASSEMBLY__
  42. #include <linux/kernel.h>
  43. #define AT_VECTOR_SIZE_ARCH 4 /* entries in ARCH_DLINFO */
  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. #define imb() \
  129. __asm__ __volatile__ ("call_pal %0 #imb" : : "i" (PAL_imb) : "memory")
  130. #define draina() \
  131. __asm__ __volatile__ ("call_pal %0 #draina" : : "i" (PAL_draina) : "memory")
  132. enum implver_enum {
  133. IMPLVER_EV4,
  134. IMPLVER_EV5,
  135. IMPLVER_EV6
  136. };
  137. #ifdef CONFIG_ALPHA_GENERIC
  138. #define implver() \
  139. ({ unsigned long __implver; \
  140. __asm__ ("implver %0" : "=r"(__implver)); \
  141. (enum implver_enum) __implver; })
  142. #else
  143. /* Try to eliminate some dead code. */
  144. #ifdef CONFIG_ALPHA_EV4
  145. #define implver() IMPLVER_EV4
  146. #endif
  147. #ifdef CONFIG_ALPHA_EV5
  148. #define implver() IMPLVER_EV5
  149. #endif
  150. #if defined(CONFIG_ALPHA_EV6)
  151. #define implver() IMPLVER_EV6
  152. #endif
  153. #endif
  154. enum amask_enum {
  155. AMASK_BWX = (1UL << 0),
  156. AMASK_FIX = (1UL << 1),
  157. AMASK_CIX = (1UL << 2),
  158. AMASK_MAX = (1UL << 8),
  159. AMASK_PRECISE_TRAP = (1UL << 9),
  160. };
  161. #define amask(mask) \
  162. ({ unsigned long __amask, __input = (mask); \
  163. __asm__ ("amask %1,%0" : "=r"(__amask) : "rI"(__input)); \
  164. __amask; })
  165. #define __CALL_PAL_R0(NAME, TYPE) \
  166. extern inline TYPE NAME(void) \
  167. { \
  168. register TYPE __r0 __asm__("$0"); \
  169. __asm__ __volatile__( \
  170. "call_pal %1 # " #NAME \
  171. :"=r" (__r0) \
  172. :"i" (PAL_ ## NAME) \
  173. :"$1", "$16", "$22", "$23", "$24", "$25"); \
  174. return __r0; \
  175. }
  176. #define __CALL_PAL_W1(NAME, TYPE0) \
  177. extern inline void NAME(TYPE0 arg0) \
  178. { \
  179. register TYPE0 __r16 __asm__("$16") = arg0; \
  180. __asm__ __volatile__( \
  181. "call_pal %1 # "#NAME \
  182. : "=r"(__r16) \
  183. : "i"(PAL_ ## NAME), "0"(__r16) \
  184. : "$1", "$22", "$23", "$24", "$25"); \
  185. }
  186. #define __CALL_PAL_W2(NAME, TYPE0, TYPE1) \
  187. extern inline void NAME(TYPE0 arg0, TYPE1 arg1) \
  188. { \
  189. register TYPE0 __r16 __asm__("$16") = arg0; \
  190. register TYPE1 __r17 __asm__("$17") = arg1; \
  191. __asm__ __volatile__( \
  192. "call_pal %2 # "#NAME \
  193. : "=r"(__r16), "=r"(__r17) \
  194. : "i"(PAL_ ## NAME), "0"(__r16), "1"(__r17) \
  195. : "$1", "$22", "$23", "$24", "$25"); \
  196. }
  197. #define __CALL_PAL_RW1(NAME, RTYPE, TYPE0) \
  198. extern inline RTYPE NAME(TYPE0 arg0) \
  199. { \
  200. register RTYPE __r0 __asm__("$0"); \
  201. register TYPE0 __r16 __asm__("$16") = arg0; \
  202. __asm__ __volatile__( \
  203. "call_pal %2 # "#NAME \
  204. : "=r"(__r16), "=r"(__r0) \
  205. : "i"(PAL_ ## NAME), "0"(__r16) \
  206. : "$1", "$22", "$23", "$24", "$25"); \
  207. return __r0; \
  208. }
  209. #define __CALL_PAL_RW2(NAME, RTYPE, TYPE0, TYPE1) \
  210. extern inline RTYPE NAME(TYPE0 arg0, TYPE1 arg1) \
  211. { \
  212. register RTYPE __r0 __asm__("$0"); \
  213. register TYPE0 __r16 __asm__("$16") = arg0; \
  214. register TYPE1 __r17 __asm__("$17") = arg1; \
  215. __asm__ __volatile__( \
  216. "call_pal %3 # "#NAME \
  217. : "=r"(__r16), "=r"(__r17), "=r"(__r0) \
  218. : "i"(PAL_ ## NAME), "0"(__r16), "1"(__r17) \
  219. : "$1", "$22", "$23", "$24", "$25"); \
  220. return __r0; \
  221. }
  222. __CALL_PAL_W1(cflush, unsigned long);
  223. __CALL_PAL_R0(rdmces, unsigned long);
  224. __CALL_PAL_R0(rdps, unsigned long);
  225. __CALL_PAL_R0(rdusp, unsigned long);
  226. __CALL_PAL_RW1(swpipl, unsigned long, unsigned long);
  227. __CALL_PAL_R0(whami, unsigned long);
  228. __CALL_PAL_W2(wrent, void*, unsigned long);
  229. __CALL_PAL_W1(wripir, unsigned long);
  230. __CALL_PAL_W1(wrkgp, unsigned long);
  231. __CALL_PAL_W1(wrmces, unsigned long);
  232. __CALL_PAL_RW2(wrperfmon, unsigned long, unsigned long, unsigned long);
  233. __CALL_PAL_W1(wrusp, unsigned long);
  234. __CALL_PAL_W1(wrvptptr, unsigned long);
  235. /*
  236. * TB routines..
  237. */
  238. #define __tbi(nr,arg,arg1...) \
  239. ({ \
  240. register unsigned long __r16 __asm__("$16") = (nr); \
  241. register unsigned long __r17 __asm__("$17"); arg; \
  242. __asm__ __volatile__( \
  243. "call_pal %3 #__tbi" \
  244. :"=r" (__r16),"=r" (__r17) \
  245. :"0" (__r16),"i" (PAL_tbi) ,##arg1 \
  246. :"$0", "$1", "$22", "$23", "$24", "$25"); \
  247. })
  248. #define tbi(x,y) __tbi(x,__r17=(y),"1" (__r17))
  249. #define tbisi(x) __tbi(1,__r17=(x),"1" (__r17))
  250. #define tbisd(x) __tbi(2,__r17=(x),"1" (__r17))
  251. #define tbis(x) __tbi(3,__r17=(x),"1" (__r17))
  252. #define tbiap() __tbi(-1, /* no second argument */)
  253. #define tbia() __tbi(-2, /* no second argument */)
  254. /*
  255. * Atomic exchange routines.
  256. */
  257. #define __ASM__MB
  258. #define ____xchg(type, args...) __xchg ## type ## _local(args)
  259. #define ____cmpxchg(type, args...) __cmpxchg ## type ## _local(args)
  260. #include <asm/xchg.h>
  261. #define xchg_local(ptr,x) \
  262. ({ \
  263. __typeof__(*(ptr)) _x_ = (x); \
  264. (__typeof__(*(ptr))) __xchg_local((ptr), (unsigned long)_x_, \
  265. sizeof(*(ptr))); \
  266. })
  267. #define cmpxchg_local(ptr, o, n) \
  268. ({ \
  269. __typeof__(*(ptr)) _o_ = (o); \
  270. __typeof__(*(ptr)) _n_ = (n); \
  271. (__typeof__(*(ptr))) __cmpxchg_local((ptr), (unsigned long)_o_, \
  272. (unsigned long)_n_, \
  273. sizeof(*(ptr))); \
  274. })
  275. #define cmpxchg64_local(ptr, o, n) \
  276. ({ \
  277. BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
  278. cmpxchg_local((ptr), (o), (n)); \
  279. })
  280. #ifdef CONFIG_SMP
  281. #undef __ASM__MB
  282. #define __ASM__MB "\tmb\n"
  283. #endif
  284. #undef ____xchg
  285. #undef ____cmpxchg
  286. #define ____xchg(type, args...) __xchg ##type(args)
  287. #define ____cmpxchg(type, args...) __cmpxchg ##type(args)
  288. #include <asm/xchg.h>
  289. #define xchg(ptr,x) \
  290. ({ \
  291. __typeof__(*(ptr)) _x_ = (x); \
  292. (__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, \
  293. sizeof(*(ptr))); \
  294. })
  295. #define cmpxchg(ptr, o, n) \
  296. ({ \
  297. __typeof__(*(ptr)) _o_ = (o); \
  298. __typeof__(*(ptr)) _n_ = (n); \
  299. (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
  300. (unsigned long)_n_, sizeof(*(ptr)));\
  301. })
  302. #define cmpxchg64(ptr, o, n) \
  303. ({ \
  304. BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
  305. cmpxchg((ptr), (o), (n)); \
  306. })
  307. #undef __ASM__MB
  308. #undef ____cmpxchg
  309. #define __HAVE_ARCH_CMPXCHG 1
  310. #endif /* __ASSEMBLY__ */
  311. #define arch_align_stack(x) (x)
  312. #endif