2 * Copyright (C) 2008 Imagination Technologies
4 #ifndef __METAG_HWTHREAD_H
5 #define __METAG_HWTHREAD_H
10 #include <asm/metag_mem.h>
12 #define BAD_HWTHREAD_ID (0xFFU)
13 #define BAD_CPU_ID (0xFFU)
15 extern u8 cpu_2_hwthread_id[];
16 extern u8 hwthread_id_2_cpu[];
19 * Each hardware thread's Control Unit registers are memory-mapped
20 * and can therefore be accessed by any other hardware thread.
22 * This helper function returns the memory address where "thread"'s
23 * register "regnum" is mapped.
26 void __iomem *__CU_addr(unsigned int thread, unsigned int regnum)
28 unsigned int base, thread_offset, thread_regnum;
30 WARN_ON(thread == BAD_HWTHREAD_ID);
32 base = T0UCTREG0; /* Control unit base */
34 thread_offset = TnUCTRX_STRIDE * thread;
35 thread_regnum = TXUCTREGn_STRIDE * regnum;
37 return (void __iomem *)(base + thread_offset + thread_regnum);
40 #endif /* __METAG_HWTHREAD_H */