processor.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. #ifndef __ASSEMBLY__
  14. static inline void *current_text_addr(void)
  15. {
  16. register void *pc asm("pc");
  17. return pc;
  18. }
  19. enum arch_type {
  20. ARCH_AVR32A,
  21. ARCH_AVR32B,
  22. ARCH_MAX
  23. };
  24. enum cpu_type {
  25. CPU_MORGAN,
  26. CPU_AT32AP,
  27. CPU_MAX
  28. };
  29. enum tlb_config {
  30. TLB_NONE,
  31. TLB_SPLIT,
  32. TLB_UNIFIED,
  33. TLB_INVALID
  34. };
  35. #define AVR32_FEATURE_RMW (1 << 0)
  36. #define AVR32_FEATURE_DSP (1 << 1)
  37. #define AVR32_FEATURE_SIMD (1 << 2)
  38. #define AVR32_FEATURE_OCD (1 << 3)
  39. #define AVR32_FEATURE_PCTR (1 << 4)
  40. #define AVR32_FEATURE_JAVA (1 << 5)
  41. #define AVR32_FEATURE_FPU (1 << 6)
  42. struct avr32_cpuinfo {
  43. struct clk *clk;
  44. unsigned long loops_per_jiffy;
  45. enum arch_type arch_type;
  46. enum cpu_type cpu_type;
  47. unsigned short arch_revision;
  48. unsigned short cpu_revision;
  49. enum tlb_config tlb_config;
  50. unsigned long features;
  51. u32 device_id;
  52. struct cache_info icache;
  53. struct cache_info dcache;
  54. };
  55. static inline unsigned int avr32_get_manufacturer_id(struct avr32_cpuinfo *cpu)
  56. {
  57. return (cpu->device_id >> 1) & 0x7f;
  58. }
  59. static inline unsigned int avr32_get_product_number(struct avr32_cpuinfo *cpu)
  60. {
  61. return (cpu->device_id >> 12) & 0xffff;
  62. }
  63. static inline unsigned int avr32_get_chip_revision(struct avr32_cpuinfo *cpu)
  64. {
  65. return (cpu->device_id >> 28) & 0x0f;
  66. }
  67. extern struct avr32_cpuinfo boot_cpu_data;
  68. #ifdef CONFIG_SMP
  69. extern struct avr32_cpuinfo cpu_data[];
  70. #define current_cpu_data cpu_data[smp_processor_id()]
  71. #else
  72. #define cpu_data (&boot_cpu_data)
  73. #define current_cpu_data boot_cpu_data
  74. #endif
  75. /* This decides where the kernel will search for a free chunk of vm
  76. * space during mmap's
  77. */
  78. #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
  79. #define cpu_relax() barrier()
  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. set_fs(USER_DS); \
  111. memset(regs, 0, sizeof(*regs)); \
  112. regs->sr = MODE_USER; \
  113. regs->pc = new_pc & ~1; \
  114. regs->sp = new_sp; \
  115. } while(0)
  116. struct task_struct;
  117. /* Free all resources held by a thread */
  118. extern void release_thread(struct task_struct *);
  119. /* Create a kernel thread without removing it from tasklists */
  120. extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  121. /* Prepare to copy thread state - unlazy all lazy status */
  122. #define prepare_to_copy(tsk) do { } while(0)
  123. /* Return saved PC of a blocked thread */
  124. #define thread_saved_pc(tsk) ((tsk)->thread.cpu_context.pc)
  125. struct pt_regs;
  126. extern unsigned long get_wchan(struct task_struct *p);
  127. extern void show_regs_log_lvl(struct pt_regs *regs, const char *log_lvl);
  128. extern void show_stack_log_lvl(struct task_struct *tsk, unsigned long sp,
  129. struct pt_regs *regs, const char *log_lvl);
  130. #define task_pt_regs(p) \
  131. ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
  132. #define KSTK_EIP(tsk) ((tsk)->thread.cpu_context.pc)
  133. #define KSTK_ESP(tsk) ((tsk)->thread.cpu_context.ksp)
  134. #define ARCH_HAS_PREFETCH
  135. static inline void prefetch(const void *x)
  136. {
  137. const char *c = x;
  138. asm volatile("pref %0" : : "r"(c));
  139. }
  140. #define PREFETCH_STRIDE L1_CACHE_BYTES
  141. #endif /* __ASSEMBLY__ */
  142. #endif /* __ASM_AVR32_PROCESSOR_H */