aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2012-10-05 11:22:14 -0400
committerJames Hogan <james.hogan@imgtec.com>2013-03-02 15:09:52 -0500
commit1e57372eaccdd5959b8ae00bf99aa10d330f207d (patch)
treeaec9b42d31ba4026b7a6e24772f5877af984e973
parente8de3486a4b06389d4f996eb2dda678a39f20115 (diff)
metag: Various other headers
Add the remaining metag header files: - byteorder.h, swab.h (byte order and swapping) - barrier.h, cpu.h. hwthread.h, processor.h (hardware thread related) - bug.h, elf.h, gpio.h, linkage.h, resource.h (other) Signed-off-by: James Hogan <james.hogan@imgtec.com>
-rw-r--r--arch/metag/include/asm/barrier.h85
-rw-r--r--arch/metag/include/asm/bug.h12
-rw-r--r--arch/metag/include/asm/cpu.h14
-rw-r--r--arch/metag/include/asm/elf.h128
-rw-r--r--arch/metag/include/asm/gpio.h4
-rw-r--r--arch/metag/include/asm/hwthread.h40
-rw-r--r--arch/metag/include/asm/linkage.h7
-rw-r--r--arch/metag/include/asm/processor.h202
-rw-r--r--arch/metag/include/uapi/asm/byteorder.h1
-rw-r--r--arch/metag/include/uapi/asm/resource.h7
-rw-r--r--arch/metag/include/uapi/asm/swab.h26
11 files changed, 526 insertions, 0 deletions
diff --git a/arch/metag/include/asm/barrier.h b/arch/metag/include/asm/barrier.h
new file mode 100644
index 000000000000..c90bfc6bf648
--- /dev/null
+++ b/arch/metag/include/asm/barrier.h
@@ -0,0 +1,85 @@
1#ifndef _ASM_METAG_BARRIER_H
2#define _ASM_METAG_BARRIER_H
3
4#include <asm/metag_mem.h>
5
6#define nop() asm volatile ("NOP")
7#define mb() wmb()
8#define rmb() barrier()
9
10#ifdef CONFIG_METAG_META21
11
12/* HTP and above have a system event to fence writes */
13static inline void wr_fence(void)
14{
15 volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_FENCE;
16 barrier();
17 *flushptr = 0;
18}
19
20#else /* CONFIG_METAG_META21 */
21
22/*
23 * ATP doesn't have system event to fence writes, so it is necessary to flush
24 * the processor write queues as well as possibly the write combiner (depending
25 * on the page being written).
26 * To ensure the write queues are flushed we do 4 writes to a system event
27 * register (in this case write combiner flush) which will also flush the write
28 * combiner.
29 */
30static inline void wr_fence(void)
31{
32 volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_COMBINE_FLUSH;
33 barrier();
34 *flushptr = 0;
35 *flushptr = 0;
36 *flushptr = 0;
37 *flushptr = 0;
38}
39
40#endif /* !CONFIG_METAG_META21 */
41
42static inline void wmb(void)
43{
44 /* flush writes through the write combiner */
45 wr_fence();
46}
47
48#define read_barrier_depends() do { } while (0)
49
50#ifndef CONFIG_SMP
51#define fence() do { } while (0)
52#define smp_mb() barrier()
53#define smp_rmb() barrier()
54#define smp_wmb() barrier()
55#else
56
57#ifdef CONFIG_METAG_SMP_WRITE_REORDERING
58/*
59 * Write to the atomic memory unlock system event register (command 0). This is
60 * needed before a write to shared memory in a critical section, to prevent
61 * external reordering of writes before the fence on other threads with writes
62 * after the fence on this thread (and to prevent the ensuing cache-memory
63 * incoherence). It is therefore ineffective if used after and on the same
64 * thread as a write.
65 */
66static inline void fence(void)
67{
68 volatile int *flushptr = (volatile int *) LINSYSEVENT_WR_ATOMIC_UNLOCK;
69 barrier();
70 *flushptr = 0;
71}
72#define smp_mb() fence()
73#define smp_rmb() fence()
74#define smp_wmb() barrier()
75#else
76#define fence() do { } while (0)
77#define smp_mb() barrier()
78#define smp_rmb() barrier()
79#define smp_wmb() barrier()
80#endif
81#endif
82#define smp_read_barrier_depends() do { } while (0)
83#define set_mb(var, value) do { var = value; smp_mb(); } while (0)
84
85#endif /* _ASM_METAG_BARRIER_H */
diff --git a/arch/metag/include/asm/bug.h b/arch/metag/include/asm/bug.h
new file mode 100644
index 000000000000..d04b48cefecc
--- /dev/null
+++ b/arch/metag/include/asm/bug.h
@@ -0,0 +1,12 @@
1#ifndef _ASM_METAG_BUG_H
2#define _ASM_METAG_BUG_H
3
4#include <asm-generic/bug.h>
5
6struct pt_regs;
7
8extern const char *trap_name(int trapno);
9extern void die(const char *str, struct pt_regs *regs, long err,
10 unsigned long addr) __attribute__ ((noreturn));
11
12#endif
diff --git a/arch/metag/include/asm/cpu.h b/arch/metag/include/asm/cpu.h
new file mode 100644
index 000000000000..decf12969268
--- /dev/null
+++ b/arch/metag/include/asm/cpu.h
@@ -0,0 +1,14 @@
1#ifndef _ASM_METAG_CPU_H
2#define _ASM_METAG_CPU_H
3
4#include <linux/percpu.h>
5
6struct cpuinfo_metag {
7 struct cpu cpu;
8#ifdef CONFIG_SMP
9 unsigned long loops_per_jiffy;
10#endif
11};
12
13DECLARE_PER_CPU(struct cpuinfo_metag, cpu_data);
14#endif /* _ASM_METAG_CPU_H */
diff --git a/arch/metag/include/asm/elf.h b/arch/metag/include/asm/elf.h
new file mode 100644
index 000000000000..d63b9d0e57dd
--- /dev/null
+++ b/arch/metag/include/asm/elf.h
@@ -0,0 +1,128 @@
1#ifndef __ASM_METAG_ELF_H
2#define __ASM_METAG_ELF_H
3
4#define EM_METAG 174
5
6/* Meta relocations */
7#define R_METAG_HIADDR16 0
8#define R_METAG_LOADDR16 1
9#define R_METAG_ADDR32 2
10#define R_METAG_NONE 3
11#define R_METAG_RELBRANCH 4
12#define R_METAG_GETSETOFF 5
13
14/* Backward compatability */
15#define R_METAG_REG32OP1 6
16#define R_METAG_REG32OP2 7
17#define R_METAG_REG32OP3 8
18#define R_METAG_REG16OP1 9
19#define R_METAG_REG16OP2 10
20#define R_METAG_REG16OP3 11
21#define R_METAG_REG32OP4 12
22
23#define R_METAG_HIOG 13
24#define R_METAG_LOOG 14
25
26/* GNU */
27#define R_METAG_GNU_VTINHERIT 30
28#define R_METAG_GNU_VTENTRY 31
29
30/* PIC relocations */
31#define R_METAG_HI16_GOTOFF 32
32#define R_METAG_LO16_GOTOFF 33
33#define R_METAG_GETSET_GOTOFF 34
34#define R_METAG_GETSET_GOT 35
35#define R_METAG_HI16_GOTPC 36
36#define R_METAG_LO16_GOTPC 37
37#define R_METAG_HI16_PLT 38
38#define R_METAG_LO16_PLT 39
39#define R_METAG_RELBRANCH_PLT 40
40#define R_METAG_GOTOFF 41
41#define R_METAG_PLT 42
42#define R_METAG_COPY 43
43#define R_METAG_JMP_SLOT 44
44#define R_METAG_RELATIVE 45
45#define R_METAG_GLOB_DAT 46
46
47/*
48 * ELF register definitions.
49 */
50
51#include <asm/page.h>
52#include <asm/processor.h>
53#include <asm/ptrace.h>
54#include <asm/user.h>
55
56typedef unsigned long elf_greg_t;
57
58#define ELF_NGREG (sizeof(struct user_gp_regs) / sizeof(elf_greg_t))
59typedef elf_greg_t elf_gregset_t[ELF_NGREG];
60
61typedef unsigned long elf_fpregset_t;
62
63/*
64 * This is used to ensure we don't load something for the wrong architecture.
65 */
66#define elf_check_arch(x) ((x)->e_machine == EM_METAG)
67
68/*
69 * These are used to set parameters in the core dumps.
70 */
71#define ELF_CLASS ELFCLASS32
72#define ELF_DATA ELFDATA2LSB
73#define ELF_ARCH EM_METAG
74
75#define ELF_PLAT_INIT(_r, load_addr) \
76 do { _r->ctx.AX[0].U0 = 0; } while (0)
77
78#define USE_ELF_CORE_DUMP
79#define CORE_DUMP_USE_REGSET
80#define ELF_EXEC_PAGESIZE PAGE_SIZE
81
82/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
83 use of this is to invoke "./ld.so someprog" to test out a new version of
84 the loader. We need to make sure that it is out of the way of the program
85 that it will "exec", and that there is sufficient room for the brk. */
86
87#define ELF_ET_DYN_BASE 0x08000000UL
88
89#define ELF_CORE_COPY_REGS(_dest, _regs) \
90 memcpy((char *)&_dest, (char *)_regs, sizeof(struct pt_regs));
91
92/* This yields a mask that user programs can use to figure out what
93 instruction set this cpu supports. */
94
95#define ELF_HWCAP (0)
96
97/* This yields a string that ld.so will use to load implementation
98 specific libraries for optimization. This is more specific in
99 intent than poking at uname or /proc/cpuinfo. */
100
101#define ELF_PLATFORM (NULL)
102
103#define SET_PERSONALITY(ex) \
104 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
105
106#define STACK_RND_MASK (0)
107
108#ifdef CONFIG_METAG_USER_TCM
109
110struct elf32_phdr;
111struct file;
112
113unsigned long __metag_elf_map(struct file *filep, unsigned long addr,
114 struct elf32_phdr *eppnt, int prot, int type,
115 unsigned long total_size);
116
117static inline unsigned long metag_elf_map(struct file *filep,
118 unsigned long addr,
119 struct elf32_phdr *eppnt, int prot,
120 int type, unsigned long total_size)
121{
122 return __metag_elf_map(filep, addr, eppnt, prot, type, total_size);
123}
124#define elf_map metag_elf_map
125
126#endif
127
128#endif
diff --git a/arch/metag/include/asm/gpio.h b/arch/metag/include/asm/gpio.h
new file mode 100644
index 000000000000..b3799d88ffcf
--- /dev/null
+++ b/arch/metag/include/asm/gpio.h
@@ -0,0 +1,4 @@
1#ifndef __LINUX_GPIO_H
2#warning Include linux/gpio.h instead of asm/gpio.h
3#include <linux/gpio.h>
4#endif
diff --git a/arch/metag/include/asm/hwthread.h b/arch/metag/include/asm/hwthread.h
new file mode 100644
index 000000000000..8f9786619b1d
--- /dev/null
+++ b/arch/metag/include/asm/hwthread.h
@@ -0,0 +1,40 @@
1/*
2 * Copyright (C) 2008 Imagination Technologies
3 */
4#ifndef __METAG_HWTHREAD_H
5#define __METAG_HWTHREAD_H
6
7#include <linux/bug.h>
8#include <linux/io.h>
9
10#include <asm/metag_mem.h>
11
12#define BAD_HWTHREAD_ID (0xFFU)
13#define BAD_CPU_ID (0xFFU)
14
15extern u8 cpu_2_hwthread_id[];
16extern u8 hwthread_id_2_cpu[];
17
18/*
19 * Each hardware thread's Control Unit registers are memory-mapped
20 * and can therefore be accessed by any other hardware thread.
21 *
22 * This helper function returns the memory address where "thread"'s
23 * register "regnum" is mapped.
24 */
25static inline
26void __iomem *__CU_addr(unsigned int thread, unsigned int regnum)
27{
28 unsigned int base, thread_offset, thread_regnum;
29
30 WARN_ON(thread == BAD_HWTHREAD_ID);
31
32 base = T0UCTREG0; /* Control unit base */
33
34 thread_offset = TnUCTRX_STRIDE * thread;
35 thread_regnum = TXUCTREGn_STRIDE * regnum;
36
37 return (void __iomem *)(base + thread_offset + thread_regnum);
38}
39
40#endif /* __METAG_HWTHREAD_H */
diff --git a/arch/metag/include/asm/linkage.h b/arch/metag/include/asm/linkage.h
new file mode 100644
index 000000000000..73bf25ba4e18
--- /dev/null
+++ b/arch/metag/include/asm/linkage.h
@@ -0,0 +1,7 @@
1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H
3
4#define __ALIGN .p2align 2
5#define __ALIGN_STR ".p2align 2"
6
7#endif
diff --git a/arch/metag/include/asm/processor.h b/arch/metag/include/asm/processor.h
new file mode 100644
index 000000000000..b7e25289f3a3
--- /dev/null
+++ b/arch/metag/include/asm/processor.h
@@ -0,0 +1,202 @@
1/*
2 * Copyright (C) 2005,2006,2007,2008 Imagination Technologies
3 */
4
5#ifndef __ASM_METAG_PROCESSOR_H
6#define __ASM_METAG_PROCESSOR_H
7
8#include <linux/atomic.h>
9
10#include <asm/page.h>
11#include <asm/ptrace.h>
12#include <asm/metag_regs.h>
13
14/*
15 * Default implementation of macro that returns current
16 * instruction pointer ("program counter").
17 */
18#define current_text_addr() ({ __label__ _l; _l: &&_l; })
19
20/* The task stops where the kernel starts */
21#define TASK_SIZE PAGE_OFFSET
22/* Add an extra page of padding at the top of the stack for the guard page. */
23#define STACK_TOP (TASK_SIZE - PAGE_SIZE)
24#define STACK_TOP_MAX STACK_TOP
25
26/* This decides where the kernel will search for a free chunk of vm
27 * space during mmap's.
28 */
29#define TASK_UNMAPPED_BASE META_MEMORY_BASE
30
31typedef struct {
32 unsigned long seg;
33} mm_segment_t;
34
35#ifdef CONFIG_METAG_FPU
36struct meta_fpu_context {
37 TBICTXEXTFPU fpstate;
38 union {
39 struct {
40 TBICTXEXTBB4 fx8_15;
41 TBICTXEXTFPACC fpacc;
42 } fx8_15;
43 struct {
44 TBICTXEXTFPACC fpacc;
45 TBICTXEXTBB4 unused;
46 } nofx8_15;
47 } extfpstate;
48 bool needs_restore;
49};
50#else
51struct meta_fpu_context {};
52#endif
53
54#ifdef CONFIG_METAG_DSP
55struct meta_ext_context {
56 struct {
57 TBIEXTCTX ctx;
58 TBICTXEXTBB8 bb8;
59 TBIDUAL ax[TBICTXEXTAXX_BYTES / sizeof(TBIDUAL)];
60 TBICTXEXTHL2 hl2;
61 TBICTXEXTTDPR ext;
62 TBICTXEXTRP6 rp;
63 } regs;
64
65 /* DSPRAM A and B save areas. */
66 void *ram[2];
67
68 /* ECH encoded size of DSPRAM save areas. */
69 unsigned int ram_sz[2];
70};
71#else
72struct meta_ext_context {};
73#endif
74
75struct thread_struct {
76 PTBICTX kernel_context;
77 /* A copy of the user process Sig.SaveMask. */
78 unsigned int user_flags;
79 struct meta_fpu_context *fpu_context;
80 void __user *tls_ptr;
81 unsigned short int_depth;
82 unsigned short txdefr_failure;
83 struct meta_ext_context *dsp_context;
84};
85
86#define INIT_THREAD { \
87 NULL, /* kernel_context */ \
88 0, /* user_flags */ \
89 NULL, /* fpu_context */ \
90 NULL, /* tls_ptr */ \
91 1, /* int_depth - we start in kernel */ \
92 0, /* txdefr_failure */ \
93 NULL, /* dsp_context */ \
94}
95
96/* Needed to make #define as we are referencing 'current', that is not visible
97 * yet.
98 *
99 * Stack layout is as below.
100
101 argc argument counter (integer)
102 argv[0] program name (pointer)
103 argv[1...N] program args (pointers)
104 argv[argc-1] end of args (integer)
105 NULL
106 env[0...N] environment variables (pointers)
107 NULL
108
109 */
110#define start_thread(regs, pc, usp) do { \
111 unsigned int *argc = (unsigned int *) bprm->exec; \
112 set_fs(USER_DS); \
113 current->thread.int_depth = 1; \
114 /* Force this process down to user land */ \
115 regs->ctx.SaveMask = TBICTX_PRIV_BIT; \
116 regs->ctx.CurrPC = pc; \
117 regs->ctx.AX[0].U0 = usp; \
118 regs->ctx.DX[3].U1 = *((int *)argc); /* argc */ \
119 regs->ctx.DX[3].U0 = (int)((int *)argc + 1); /* argv */ \
120 regs->ctx.DX[2].U1 = (int)((int *)argc + \
121 regs->ctx.DX[3].U1 + 2); /* envp */ \
122 regs->ctx.DX[2].U0 = 0; /* rtld_fini */ \
123} while (0)
124
125/* Forward declaration, a strange C thing */
126struct task_struct;
127
128/* Free all resources held by a thread. */
129static inline void release_thread(struct task_struct *dead_task)
130{
131}
132
133#define copy_segments(tsk, mm) do { } while (0)
134#define release_segments(mm) do { } while (0)
135
136extern void exit_thread(void);
137
138/*
139 * Return saved PC of a blocked thread.
140 */
141#define thread_saved_pc(tsk) \
142 ((unsigned long)(tsk)->thread.kernel_context->CurrPC)
143#define thread_saved_sp(tsk) \
144 ((unsigned long)(tsk)->thread.kernel_context->AX[0].U0)
145#define thread_saved_fp(tsk) \
146 ((unsigned long)(tsk)->thread.kernel_context->AX[1].U0)
147
148unsigned long get_wchan(struct task_struct *p);
149
150#define KSTK_EIP(tsk) ((tsk)->thread.kernel_context->CurrPC)
151#define KSTK_ESP(tsk) ((tsk)->thread.kernel_context->AX[0].U0)
152
153#define user_stack_pointer(regs) ((regs)->ctx.AX[0].U0)
154
155#define cpu_relax() barrier()
156
157extern void setup_txprivext(void);
158
159static inline unsigned int hard_processor_id(void)
160{
161 unsigned int id;
162
163 asm volatile ("MOV %0, TXENABLE\n"
164 "AND %0, %0, %1\n"
165 "LSR %0, %0, %2\n"
166 : "=&d" (id)
167 : "I" (TXENABLE_THREAD_BITS),
168 "K" (TXENABLE_THREAD_S)
169 );
170
171 return id;
172}
173
174#define OP3_EXIT 0
175
176#define HALT_OK 0
177#define HALT_PANIC -1
178
179/*
180 * Halt (stop) the hardware thread. This instruction sequence is the
181 * standard way to cause a Meta hardware thread to exit. The exit code
182 * is pushed onto the stack which is interpreted by the debug adapter.
183 */
184static inline void hard_processor_halt(int exit_code)
185{
186 asm volatile ("MOV D1Ar1, %0\n"
187 "MOV D0Ar6, %1\n"
188 "MSETL [A0StP],D0Ar6,D0Ar4,D0Ar2\n"
189 "1:\n"
190 "SWITCH #0xC30006\n"
191 "B 1b\n"
192 : : "r" (exit_code), "K" (OP3_EXIT));
193}
194
195/* Set these hooks to call SoC specific code to restart/halt/power off. */
196extern void (*soc_restart)(char *cmd);
197extern void (*soc_halt)(void);
198
199extern void show_trace(struct task_struct *tsk, unsigned long *sp,
200 struct pt_regs *regs);
201
202#endif
diff --git a/arch/metag/include/uapi/asm/byteorder.h b/arch/metag/include/uapi/asm/byteorder.h
new file mode 100644
index 000000000000..9558416d578b
--- /dev/null
+++ b/arch/metag/include/uapi/asm/byteorder.h
@@ -0,0 +1 @@
#include <linux/byteorder/little_endian.h>
diff --git a/arch/metag/include/uapi/asm/resource.h b/arch/metag/include/uapi/asm/resource.h
new file mode 100644
index 000000000000..526d23cc3054
--- /dev/null
+++ b/arch/metag/include/uapi/asm/resource.h
@@ -0,0 +1,7 @@
1#ifndef _UAPI_METAG_RESOURCE_H
2#define _UAPI_METAG_RESOURCE_H
3
4#define _STK_LIM_MAX (1 << 28)
5#include <asm-generic/resource.h>
6
7#endif /* _UAPI_METAG_RESOURCE_H */
diff --git a/arch/metag/include/uapi/asm/swab.h b/arch/metag/include/uapi/asm/swab.h
new file mode 100644
index 000000000000..1076b3a6387a
--- /dev/null
+++ b/arch/metag/include/uapi/asm/swab.h
@@ -0,0 +1,26 @@
1#ifndef __ASM_METAG_SWAB_H
2#define __ASM_METAG_SWAB_H
3
4#include <linux/compiler.h>
5#include <linux/types.h>
6#include <asm-generic/swab.h>
7
8static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
9{
10 return __builtin_metag_bswaps(x);
11}
12#define __arch_swab16 __arch_swab16
13
14static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
15{
16 return __builtin_metag_bswap(x);
17}
18#define __arch_swab32 __arch_swab32
19
20static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
21{
22 return __builtin_metag_bswapll(x);
23}
24#define __arch_swab64 __arch_swab64
25
26#endif /* __ASM_METAG_SWAB_H */