processor.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * Copyright (C) 2004-2006 Atmel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef __ASM_AVR32_PROCESSOR_H
  9. #define __ASM_AVR32_PROCESSOR_H
  10. #include <asm/page.h>
  11. #include <asm/cache.h>
  12. #define TASK_SIZE 0x80000000
  13. #ifdef __KERNEL__
  14. #define STACK_TOP TASK_SIZE
  15. #define STACK_TOP_MAX STACK_TOP
  16. #endif
  17. #ifndef __ASSEMBLY__
  18. static inline void *current_text_addr(void)
  19. {
  20. register void *pc asm("pc");
  21. return pc;
  22. }
  23. enum arch_type {
  24. ARCH_AVR32A,
  25. ARCH_AVR32B,
  26. ARCH_MAX
  27. };
  28. enum cpu_type {
  29. CPU_MORGAN,
  30. CPU_AT32AP,
  31. CPU_MAX
  32. };
  33. enum tlb_config {
  34. TLB_NONE,
  35. TLB_SPLIT,
  36. TLB_UNIFIED,
  37. TLB_INVALID
  38. };
  39. #define AVR32_FEATURE_RMW (1 << 0)
  40. #define AVR32_FEATURE_DSP (1 << 1)
  41. #define AVR32_FEATURE_SIMD (1 << 2)
  42. #define AVR32_FEATURE_OCD (1 << 3)
  43. #define AVR32_FEATURE_PCTR (1 << 4)
  44. #define AVR32_FEATURE_JAVA (1 << 5)
  45. #define AVR32_FEATURE_FPU (1 << 6)
  46. struct avr32_cpuinfo {
  47. struct clk *clk;
  48. unsigned long loops_per_jiffy;
  49. enum arch_type arch_type;
  50. enum cpu_type cpu_type;
  51. unsigned short arch_revision;
  52. unsigned short cpu_revision;
  53. enum tlb_config tlb_config;
  54. unsigned long features;
  55. u32 device_id;
  56. struct cache_info icache;
  57. struct cache_info dcache;
  58. };
  59. static inline unsigned int avr32_get_manufacturer_id(struct avr32_cpuinfo *cpu)
  60. {
  61. return (cpu->device_id >> 1) & 0x7f;
  62. }
  63. static inline unsigned int avr32_get_product_number(struct avr32_cpuinfo *cpu)
  64. {
  65. return (cpu->device_id >> 12) & 0xffff;
  66. }
  67. static inline unsigned int avr32_get_chip_revision(struct avr32_cpuinfo *cpu)
  68. {
  69. return (cpu->device_id >> 28) & 0x0f;
  70. }
  71. extern struct avr32_cpuinfo boot_cpu_data;
  72. #ifdef CONFIG_SMP
  73. extern struct avr32_cpuinfo cpu_data[];
  74. #define current_cpu_data cpu_data[smp_processor_id()]
  75. #else
  76. #define cpu_data (&boot_cpu_data)
  77. #define current_cpu_data boot_cpu_data
  78. #endif
  79. /* This decides where the kernel will search for a free chunk of vm
  80. * space during mmap's
  81. */
  82. #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
  83. #define cpu_relax() barrier()
  84. #define cpu_sync_pipeline() asm volatile("sub pc, -2" : : : "memory")
  85. struct cpu_context {
  86. unsigned long sr;
  87. unsigned long pc;
  88. unsigned long ksp; /* Kernel stack pointer */
  89. unsigned long r7;
  90. unsigned long r6;
  91. unsigned long r5;
  92. unsigned long r4;
  93. unsigned long r3;
  94. unsigned long r2;
  95. unsigned long r1;
  96. unsigned long r0;
  97. };
  98. /* This struct contains the CPU context as stored by switch_to() */
  99. struct thread_struct {
  100. struct cpu_context cpu_context;
  101. unsigned long single_step_addr;
  102. u16 single_step_insn;
  103. };
  104. #define INIT_THREAD { \
  105. .cpu_context = { \
  106. .ksp = sizeof(init_stack) + (long)&init_stack, \
  107. }, \
  108. }
  109. /*
  110. * Do necessary setup to start up a newly executed thread.
  111. */
  112. #define start_thread(regs, new_pc, new_sp) \
  113. do { \
  114. memset(regs, 0, sizeof(*regs)); \
  115. regs->sr = MODE_USER; \
  116. regs->pc = new_pc & ~1; \
  117. regs->sp = new_sp; \
  118. } while(0)
  119. struct task_struct;
  120. /* Free all resources held by a thread */
  121. extern void release_thread(struct task_struct *);
  122. /* Create a kernel thread without removing it from tasklists */
  123. extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  124. /* Prepare to copy thread state - unlazy all lazy status */
  125. #define prepare_to_copy(tsk) do { } while(0)
  126. /* Return saved PC of a blocked thread */
  127. #define thread_saved_pc(tsk) ((tsk)->thread.cpu_context.pc)
  128. struct pt_regs;
  129. extern unsigned long get_wchan(struct task_struct *p);
  130. extern void show_regs_log_lvl(struct pt_regs *regs, const char *log_lvl);
  131. extern void show_stack_log_lvl(struct task_struct *tsk, unsigned long sp,
  132. struct pt_regs *regs, const char *log_lvl);
  133. #define task_pt_regs(p) \
  134. ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
  135. #define KSTK_EIP(tsk) ((tsk)->thread.cpu_context.pc)
  136. #define KSTK_ESP(tsk) ((tsk)->thread.cpu_context.ksp)
  137. #define ARCH_HAS_PREFETCH
  138. static inline void prefetch(const void *x)
  139. {
  140. const char *c = x;
  141. asm volatile("pref %0" : : "r"(c));
  142. }
  143. #define PREFETCH_STRIDE L1_CACHE_BYTES
  144. #endif /* __ASSEMBLY__ */
  145. #endif /* __ASM_AVR32_PROCESSOR_H */