system.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. #ifndef __ALPHA_SYSTEM_H
  2. #define __ALPHA_SYSTEM_H
  3. #include <linux/config.h>
  4. #include <asm/pal.h>
  5. #include <asm/page.h>
  6. #include <asm/barrier.h>
  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(&(N)->thread_info->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. static 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. static 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. static 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. static 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. static 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. #define IPL_MIN 0
  236. #define IPL_SW0 1
  237. #define IPL_SW1 2
  238. #define IPL_DEV0 3
  239. #define IPL_DEV1 4
  240. #define IPL_TIMER 5
  241. #define IPL_PERF 6
  242. #define IPL_POWERFAIL 6
  243. #define IPL_MCHECK 7
  244. #define IPL_MAX 7
  245. #ifdef CONFIG_ALPHA_BROKEN_IRQ_MASK
  246. #undef IPL_MIN
  247. #define IPL_MIN __min_ipl
  248. extern int __min_ipl;
  249. #endif
  250. #define getipl() (rdps() & 7)
  251. #define setipl(ipl) ((void) swpipl(ipl))
  252. #define local_irq_disable() do { setipl(IPL_MAX); barrier(); } while(0)
  253. #define local_irq_enable() do { barrier(); setipl(IPL_MIN); } while(0)
  254. #define local_save_flags(flags) ((flags) = rdps())
  255. #define local_irq_save(flags) do { (flags) = swpipl(IPL_MAX); barrier(); } while(0)
  256. #define local_irq_restore(flags) do { barrier(); setipl(flags); barrier(); } while(0)
  257. #define irqs_disabled() (getipl() == IPL_MAX)
  258. /*
  259. * TB routines..
  260. */
  261. #define __tbi(nr,arg,arg1...) \
  262. ({ \
  263. register unsigned long __r16 __asm__("$16") = (nr); \
  264. register unsigned long __r17 __asm__("$17"); arg; \
  265. __asm__ __volatile__( \
  266. "call_pal %3 #__tbi" \
  267. :"=r" (__r16),"=r" (__r17) \
  268. :"0" (__r16),"i" (PAL_tbi) ,##arg1 \
  269. :"$0", "$1", "$22", "$23", "$24", "$25"); \
  270. })
  271. #define tbi(x,y) __tbi(x,__r17=(y),"1" (__r17))
  272. #define tbisi(x) __tbi(1,__r17=(x),"1" (__r17))
  273. #define tbisd(x) __tbi(2,__r17=(x),"1" (__r17))
  274. #define tbis(x) __tbi(3,__r17=(x),"1" (__r17))
  275. #define tbiap() __tbi(-1, /* no second argument */)
  276. #define tbia() __tbi(-2, /* no second argument */)
  277. /*
  278. * Atomic exchange.
  279. * Since it can be used to implement critical sections
  280. * it must clobber "memory" (also for interrupts in UP).
  281. */
  282. static inline unsigned long
  283. __xchg_u8(volatile char *m, unsigned long val)
  284. {
  285. unsigned long ret, tmp, addr64;
  286. __asm__ __volatile__(
  287. " andnot %4,7,%3\n"
  288. " insbl %1,%4,%1\n"
  289. "1: ldq_l %2,0(%3)\n"
  290. " extbl %2,%4,%0\n"
  291. " mskbl %2,%4,%2\n"
  292. " or %1,%2,%2\n"
  293. " stq_c %2,0(%3)\n"
  294. " beq %2,2f\n"
  295. #ifdef CONFIG_SMP
  296. " mb\n"
  297. #endif
  298. ".subsection 2\n"
  299. "2: br 1b\n"
  300. ".previous"
  301. : "=&r" (ret), "=&r" (val), "=&r" (tmp), "=&r" (addr64)
  302. : "r" ((long)m), "1" (val) : "memory");
  303. return ret;
  304. }
  305. static inline unsigned long
  306. __xchg_u16(volatile short *m, unsigned long val)
  307. {
  308. unsigned long ret, tmp, addr64;
  309. __asm__ __volatile__(
  310. " andnot %4,7,%3\n"
  311. " inswl %1,%4,%1\n"
  312. "1: ldq_l %2,0(%3)\n"
  313. " extwl %2,%4,%0\n"
  314. " mskwl %2,%4,%2\n"
  315. " or %1,%2,%2\n"
  316. " stq_c %2,0(%3)\n"
  317. " beq %2,2f\n"
  318. #ifdef CONFIG_SMP
  319. " mb\n"
  320. #endif
  321. ".subsection 2\n"
  322. "2: br 1b\n"
  323. ".previous"
  324. : "=&r" (ret), "=&r" (val), "=&r" (tmp), "=&r" (addr64)
  325. : "r" ((long)m), "1" (val) : "memory");
  326. return ret;
  327. }
  328. static inline unsigned long
  329. __xchg_u32(volatile int *m, unsigned long val)
  330. {
  331. unsigned long dummy;
  332. __asm__ __volatile__(
  333. "1: ldl_l %0,%4\n"
  334. " bis $31,%3,%1\n"
  335. " stl_c %1,%2\n"
  336. " beq %1,2f\n"
  337. #ifdef CONFIG_SMP
  338. " mb\n"
  339. #endif
  340. ".subsection 2\n"
  341. "2: br 1b\n"
  342. ".previous"
  343. : "=&r" (val), "=&r" (dummy), "=m" (*m)
  344. : "rI" (val), "m" (*m) : "memory");
  345. return val;
  346. }
  347. static inline unsigned long
  348. __xchg_u64(volatile long *m, unsigned long val)
  349. {
  350. unsigned long dummy;
  351. __asm__ __volatile__(
  352. "1: ldq_l %0,%4\n"
  353. " bis $31,%3,%1\n"
  354. " stq_c %1,%2\n"
  355. " beq %1,2f\n"
  356. #ifdef CONFIG_SMP
  357. " mb\n"
  358. #endif
  359. ".subsection 2\n"
  360. "2: br 1b\n"
  361. ".previous"
  362. : "=&r" (val), "=&r" (dummy), "=m" (*m)
  363. : "rI" (val), "m" (*m) : "memory");
  364. return val;
  365. }
  366. /* This function doesn't exist, so you'll get a linker error
  367. if something tries to do an invalid xchg(). */
  368. extern void __xchg_called_with_bad_pointer(void);
  369. #define __xchg(ptr, x, size) \
  370. ({ \
  371. unsigned long __xchg__res; \
  372. volatile void *__xchg__ptr = (ptr); \
  373. switch (size) { \
  374. case 1: __xchg__res = __xchg_u8(__xchg__ptr, x); break; \
  375. case 2: __xchg__res = __xchg_u16(__xchg__ptr, x); break; \
  376. case 4: __xchg__res = __xchg_u32(__xchg__ptr, x); break; \
  377. case 8: __xchg__res = __xchg_u64(__xchg__ptr, x); break; \
  378. default: __xchg_called_with_bad_pointer(); __xchg__res = x; \
  379. } \
  380. __xchg__res; \
  381. })
  382. #define xchg(ptr,x) \
  383. ({ \
  384. __typeof__(*(ptr)) _x_ = (x); \
  385. (__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, sizeof(*(ptr))); \
  386. })
  387. #define tas(ptr) (xchg((ptr),1))
  388. /*
  389. * Atomic compare and exchange. Compare OLD with MEM, if identical,
  390. * store NEW in MEM. Return the initial value in MEM. Success is
  391. * indicated by comparing RETURN with OLD.
  392. *
  393. * The memory barrier should be placed in SMP only when we actually
  394. * make the change. If we don't change anything (so if the returned
  395. * prev is equal to old) then we aren't acquiring anything new and
  396. * we don't need any memory barrier as far I can tell.
  397. */
  398. #define __HAVE_ARCH_CMPXCHG 1
  399. static inline unsigned long
  400. __cmpxchg_u8(volatile char *m, long old, long new)
  401. {
  402. unsigned long prev, tmp, cmp, addr64;
  403. __asm__ __volatile__(
  404. " andnot %5,7,%4\n"
  405. " insbl %1,%5,%1\n"
  406. "1: ldq_l %2,0(%4)\n"
  407. " extbl %2,%5,%0\n"
  408. " cmpeq %0,%6,%3\n"
  409. " beq %3,2f\n"
  410. " mskbl %2,%5,%2\n"
  411. " or %1,%2,%2\n"
  412. " stq_c %2,0(%4)\n"
  413. " beq %2,3f\n"
  414. #ifdef CONFIG_SMP
  415. " mb\n"
  416. #endif
  417. "2:\n"
  418. ".subsection 2\n"
  419. "3: br 1b\n"
  420. ".previous"
  421. : "=&r" (prev), "=&r" (new), "=&r" (tmp), "=&r" (cmp), "=&r" (addr64)
  422. : "r" ((long)m), "Ir" (old), "1" (new) : "memory");
  423. return prev;
  424. }
  425. static inline unsigned long
  426. __cmpxchg_u16(volatile short *m, long old, long new)
  427. {
  428. unsigned long prev, tmp, cmp, addr64;
  429. __asm__ __volatile__(
  430. " andnot %5,7,%4\n"
  431. " inswl %1,%5,%1\n"
  432. "1: ldq_l %2,0(%4)\n"
  433. " extwl %2,%5,%0\n"
  434. " cmpeq %0,%6,%3\n"
  435. " beq %3,2f\n"
  436. " mskwl %2,%5,%2\n"
  437. " or %1,%2,%2\n"
  438. " stq_c %2,0(%4)\n"
  439. " beq %2,3f\n"
  440. #ifdef CONFIG_SMP
  441. " mb\n"
  442. #endif
  443. "2:\n"
  444. ".subsection 2\n"
  445. "3: br 1b\n"
  446. ".previous"
  447. : "=&r" (prev), "=&r" (new), "=&r" (tmp), "=&r" (cmp), "=&r" (addr64)
  448. : "r" ((long)m), "Ir" (old), "1" (new) : "memory");
  449. return prev;
  450. }
  451. static inline unsigned long
  452. __cmpxchg_u32(volatile int *m, int old, int new)
  453. {
  454. unsigned long prev, cmp;
  455. __asm__ __volatile__(
  456. "1: ldl_l %0,%5\n"
  457. " cmpeq %0,%3,%1\n"
  458. " beq %1,2f\n"
  459. " mov %4,%1\n"
  460. " stl_c %1,%2\n"
  461. " beq %1,3f\n"
  462. #ifdef CONFIG_SMP
  463. " mb\n"
  464. #endif
  465. "2:\n"
  466. ".subsection 2\n"
  467. "3: br 1b\n"
  468. ".previous"
  469. : "=&r"(prev), "=&r"(cmp), "=m"(*m)
  470. : "r"((long) old), "r"(new), "m"(*m) : "memory");
  471. return prev;
  472. }
  473. static inline unsigned long
  474. __cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new)
  475. {
  476. unsigned long prev, cmp;
  477. __asm__ __volatile__(
  478. "1: ldq_l %0,%5\n"
  479. " cmpeq %0,%3,%1\n"
  480. " beq %1,2f\n"
  481. " mov %4,%1\n"
  482. " stq_c %1,%2\n"
  483. " beq %1,3f\n"
  484. #ifdef CONFIG_SMP
  485. " mb\n"
  486. #endif
  487. "2:\n"
  488. ".subsection 2\n"
  489. "3: br 1b\n"
  490. ".previous"
  491. : "=&r"(prev), "=&r"(cmp), "=m"(*m)
  492. : "r"((long) old), "r"(new), "m"(*m) : "memory");
  493. return prev;
  494. }
  495. /* This function doesn't exist, so you'll get a linker error
  496. if something tries to do an invalid cmpxchg(). */
  497. extern void __cmpxchg_called_with_bad_pointer(void);
  498. static inline unsigned long
  499. __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
  500. {
  501. switch (size) {
  502. case 1:
  503. return __cmpxchg_u8(ptr, old, new);
  504. case 2:
  505. return __cmpxchg_u16(ptr, old, new);
  506. case 4:
  507. return __cmpxchg_u32(ptr, old, new);
  508. case 8:
  509. return __cmpxchg_u64(ptr, old, new);
  510. }
  511. __cmpxchg_called_with_bad_pointer();
  512. return old;
  513. }
  514. #define cmpxchg(ptr,o,n) \
  515. ({ \
  516. __typeof__(*(ptr)) _o_ = (o); \
  517. __typeof__(*(ptr)) _n_ = (n); \
  518. (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
  519. (unsigned long)_n_, sizeof(*(ptr))); \
  520. })
  521. #endif /* __ASSEMBLY__ */
  522. #define arch_align_stack(x) (x)
  523. #endif