processor.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. /* No SMP support so far */
  73. #define current_cpu_data boot_cpu_data
  74. /* This decides where the kernel will search for a free chunk of vm
  75. * space during mmap's
  76. */
  77. #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
  78. #define cpu_relax() barrier()
  79. #define cpu_relax_lowlatency() cpu_relax()
  80. #define cpu_sync_pipeline() asm volatile("sub pc, -2" : : : "memory")
  81. struct cpu_context {
  82. unsigned long sr;
  83. unsigned long pc;
  84. unsigned long ksp; /* Kernel stack pointer */
  85. unsigned long r7;
  86. unsigned long r6;
  87. unsigned long r5;
  88. unsigned long r4;
  89. unsigned long r3;
  90. unsigned long r2;
  91. unsigned long r1;
  92. unsigned long r0;
  93. };
  94. /* This struct contains the CPU context as stored by switch_to() */
  95. struct thread_struct {
  96. struct cpu_context cpu_context;
  97. unsigned long single_step_addr;
  98. u16 single_step_insn;
  99. };
  100. #define INIT_THREAD { \
  101. .cpu_context = { \
  102. .ksp = sizeof(init_stack) + (long)&init_stack, \
  103. }, \
  104. }
  105. /*
  106. * Do necessary setup to start up a newly executed thread.
  107. */
  108. #define start_thread(regs, new_pc, new_sp) \
  109. do { \
  110. memset(regs, 0, sizeof(*regs)); \
  111. regs->sr = MODE_USER; \
  112. regs->pc = new_pc & ~1; \
  113. regs->sp = new_sp; \
  114. } while(0)
  115. struct task_struct;
  116. /* Free all resources held by a thread */
  117. extern void release_thread(struct task_struct *);
  118. /* Return saved PC of a blocked thread */
  119. #define thread_saved_pc(tsk) ((tsk)->thread.cpu_context.pc)
  120. struct pt_regs;
  121. extern unsigned long get_wchan(struct task_struct *p);
  122. extern void show_regs_log_lvl(struct pt_regs *regs, const char *log_lvl);
  123. extern void show_stack_log_lvl(struct task_struct *tsk, unsigned long sp,
  124. struct pt_regs *regs, const char *log_lvl);
  125. #define task_pt_regs(p) \
  126. ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
  127. #define KSTK_EIP(tsk) ((tsk)->thread.cpu_context.pc)
  128. #define KSTK_ESP(tsk) ((tsk)->thread.cpu_context.ksp)
  129. #define ARCH_HAS_PREFETCH
  130. static inline void prefetch(const void *x)
  131. {
  132. const char *c = x;
  133. asm volatile("pref %0" : : "r"(c));
  134. }
  135. #define PREFETCH_STRIDE L1_CACHE_BYTES
  136. #endif /* __ASSEMBLY__ */
  137. #endif /* __ASM_AVR32_PROCESSOR_H */