2 * Port on Texas Instruments TMS320C6x architecture
4 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 #ifndef _ASM_C6X_SYSTEM_H
12 #define _ASM_C6X_SYSTEM_H
14 #include <linux/linkage.h>
15 #include <linux/irqflags.h>
17 #define prepare_to_switch() do { } while (0)
21 asmlinkage
void *__switch_to(struct thread_struct
*prev
,
22 struct thread_struct
*next
,
23 struct task_struct
*tsk
);
25 #define switch_to(prev, next, last) \
27 current->thread.wchan = (u_long) __builtin_return_address(0); \
28 (last) = __switch_to(&(prev)->thread, \
29 &(next)->thread, (prev)); \
31 current->thread.wchan = 0; \
35 #define HARD_RESET_NOW()
37 #define get_creg(reg) \
38 ({ unsigned int __x; \
39 asm volatile ("mvc .s2 " #reg ",%0\n" : "=b"(__x)); __x; })
41 #define set_creg(reg, v) \
42 do { unsigned int __x = (unsigned int)(v); \
43 asm volatile ("mvc .s2 %0," #reg "\n" : : "b"(__x)); \
46 #define or_creg(reg, n) \
47 do { unsigned __x, __n = (unsigned)(n); \
48 asm volatile ("mvc .s2 " #reg ",%0\n" \
50 "mvc .s2 %0," #reg "\n" \
52 : "=&b"(__x) : "b"(__n)); \
55 #define and_creg(reg, n) \
56 do { unsigned __x, __n = (unsigned)(n); \
57 asm volatile ("mvc .s2 " #reg ",%0\n" \
58 "and .l2 %1,%0,%0\n" \
59 "mvc .s2 %0," #reg "\n" \
61 : "=&b"(__x) : "b"(__n)); \
64 #define get_coreid() (get_creg(DNUM) & 0xff)
67 #define set_ist(x) set_creg(ISTP, x)
68 #define get_ist() get_creg(ISTP)
71 * Exception management
73 asmlinkage
void enable_exception(void);
74 #define disable_exception()
75 #define get_except_type() get_creg(EFR)
76 #define ack_exception(type) set_creg(ECR, 1 << (type))
77 #define get_iexcept() get_creg(IERR)
78 #define set_iexcept(mask) set_creg(IERR, (mask))
83 #define nop() asm("NOP\n");
84 #define mb() barrier()
85 #define rmb() barrier()
86 #define wmb() barrier()
87 #define set_mb(var, value) do { var = value; mb(); } while (0)
88 #define set_wmb(var, value) do { var = value; wmb(); } while (0)
90 #define smp_mb() barrier()
91 #define smp_rmb() barrier()
92 #define smp_wmb() barrier()
93 #define smp_read_barrier_depends() do { } while (0)
95 #define xchg(ptr, x) \
96 ((__typeof__(*(ptr)))__xchg((unsigned int)(x), (void *) (ptr), \
98 #define tas(ptr) xchg((ptr), 1)
100 unsigned int _lmbd(unsigned int, unsigned int);
101 unsigned int _bitr(unsigned int);
103 struct __xchg_dummy
{ unsigned int a
[100]; };
104 #define __xg(x) ((volatile struct __xchg_dummy *)(x))
106 static inline unsigned int __xchg(unsigned int x
, volatile void *ptr
, int size
)
111 local_irq_save(flags
);
116 tmp
= *((unsigned char *) ptr
);
117 *((unsigned char *) ptr
) = (unsigned char) x
;
121 tmp
= *((unsigned short *) ptr
);
122 *((unsigned short *) ptr
) = x
;
126 tmp
= *((unsigned int *) ptr
);
127 *((unsigned int *) ptr
) = x
;
130 local_irq_restore(flags
);
134 #include <asm-generic/cmpxchg-local.h>
137 * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
140 #define cmpxchg_local(ptr, o, n) \
141 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), \
142 (unsigned long)(o), \
143 (unsigned long)(n), \
145 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
147 #include <asm-generic/cmpxchg.h>
149 #define _extu(x, s, e) \
150 ({ unsigned int __x; \
151 asm volatile ("extu .S2 %3,%1,%2,%0\n" : \
152 "=b"(__x) : "n"(s), "n"(e), "b"(x)); \
156 extern unsigned int c6x_core_freq
;
160 extern void die(char *str
, struct pt_regs
*fp
, int nr
);
161 extern asmlinkage
int process_exception(struct pt_regs
*regs
);
162 extern void time_init(void);
163 extern void free_initmem(void);
165 extern void (*c6x_restart
)(void);
166 extern void (*c6x_halt
)(void);
168 #endif /* _ASM_C6X_SYSTEM_H */