at v2.6.31-rc4 154 lines 3.5 kB view raw
1#ifndef __ASM_BFIN_PROCESSOR_H 2#define __ASM_BFIN_PROCESSOR_H 3 4/* 5 * Default implementation of macro that returns current 6 * instruction pointer ("program counter"). 7 */ 8#define current_text_addr() ({ __label__ _l; _l: &&_l;}) 9 10#include <asm/ptrace.h> 11#include <asm/blackfin.h> 12 13static inline unsigned long rdusp(void) 14{ 15 unsigned long usp; 16 17 __asm__ __volatile__("%0 = usp;\n\t":"=da"(usp)); 18 return usp; 19} 20 21static inline void wrusp(unsigned long usp) 22{ 23 __asm__ __volatile__("usp = %0;\n\t"::"da"(usp)); 24} 25 26static inline unsigned long __get_SP(void) 27{ 28 unsigned long sp; 29 30 __asm__ __volatile__("%0 = sp;\n\t" : "=da"(sp)); 31 return sp; 32} 33 34/* 35 * User space process size: 1st byte beyond user address space. 36 * Fairly meaningless on nommu. Parts of user programs can be scattered 37 * in a lot of places, so just disable this by setting it to 0xFFFFFFFF. 38 */ 39#define TASK_SIZE 0xFFFFFFFF 40 41#ifdef __KERNEL__ 42#define STACK_TOP TASK_SIZE 43#endif 44 45#define TASK_UNMAPPED_BASE 0 46 47struct thread_struct { 48 unsigned long ksp; /* kernel stack pointer */ 49 unsigned long usp; /* user stack pointer */ 50 unsigned short seqstat; /* saved status register */ 51 unsigned long esp0; /* points to SR of stack frame pt_regs */ 52 unsigned long pc; /* instruction pointer */ 53 void * debuggerinfo; 54}; 55 56#define INIT_THREAD { \ 57 sizeof(init_stack) + (unsigned long) init_stack, 0, \ 58 PS_S, 0, 0 \ 59} 60 61extern void start_thread(struct pt_regs *regs, unsigned long new_ip, 62 unsigned long new_sp); 63 64/* Forward declaration, a strange C thing */ 65struct task_struct; 66 67/* Free all resources held by a thread. */ 68static inline void release_thread(struct task_struct *dead_task) 69{ 70} 71 72#define prepare_to_copy(tsk) do { } while (0) 73 74extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags); 75 76/* 77 * Free current thread data structures etc.. 78 */ 79static inline void exit_thread(void) 80{ 81} 82 83/* 84 * Return saved PC of a blocked thread. 85 */ 86#define thread_saved_pc(tsk) (tsk->thread.pc) 87 88unsigned long get_wchan(struct task_struct *p); 89 90#define KSTK_EIP(tsk) \ 91 ({ \ 92 unsigned long eip = 0; \ 93 if ((tsk)->thread.esp0 > PAGE_SIZE && \ 94 MAP_NR((tsk)->thread.esp0) < max_mapnr) \ 95 eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \ 96 eip; }) 97#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp) 98 99#define cpu_relax() smp_mb() 100 101 102/* Get the Silicon Revision of the chip */ 103static inline uint32_t __pure bfin_revid(void) 104{ 105 /* Always use CHIPID, to work around ANOMALY_05000234 */ 106 uint32_t revid = (bfin_read_CHIPID() & CHIPID_VERSION) >> 28; 107 108#ifdef _BOOTROM_GET_DXE_ADDRESS_TWI 109 /* 110 * ANOMALY_05000364 111 * Incorrect Revision Number in DSPID Register 112 */ 113 if (ANOMALY_05000364 && 114 bfin_read16(_BOOTROM_GET_DXE_ADDRESS_TWI) == 0x2796) 115 revid = 1; 116#endif 117 118 return revid; 119} 120 121static inline uint16_t __pure bfin_cpuid(void) 122{ 123 return (bfin_read_CHIPID() & CHIPID_FAMILY) >> 12; 124} 125 126static inline uint32_t __pure bfin_dspid(void) 127{ 128 return bfin_read_DSPID(); 129} 130 131static inline uint32_t __pure bfin_compiled_revid(void) 132{ 133#if defined(CONFIG_BF_REV_0_0) 134 return 0; 135#elif defined(CONFIG_BF_REV_0_1) 136 return 1; 137#elif defined(CONFIG_BF_REV_0_2) 138 return 2; 139#elif defined(CONFIG_BF_REV_0_3) 140 return 3; 141#elif defined(CONFIG_BF_REV_0_4) 142 return 4; 143#elif defined(CONFIG_BF_REV_0_5) 144 return 5; 145#elif defined(CONFIG_BF_REV_0_6) 146 return 6; 147#elif defined(CONFIG_BF_REV_ANY) 148 return 0xffff; 149#else 150 return -1; 151#endif 152} 153 154#endif