processor.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. struct avr32_cpuinfo {
  36. struct clk *clk;
  37. unsigned long loops_per_jiffy;
  38. enum arch_type arch_type;
  39. enum cpu_type cpu_type;
  40. unsigned short arch_revision;
  41. unsigned short cpu_revision;
  42. enum tlb_config tlb_config;
  43. struct cache_info icache;
  44. struct cache_info dcache;
  45. };
  46. extern struct avr32_cpuinfo boot_cpu_data;
  47. #ifdef CONFIG_SMP
  48. extern struct avr32_cpuinfo cpu_data[];
  49. #define current_cpu_data cpu_data[smp_processor_id()]
  50. #else
  51. #define cpu_data (&boot_cpu_data)
  52. #define current_cpu_data boot_cpu_data
  53. #endif
  54. /* This decides where the kernel will search for a free chunk of vm
  55. * space during mmap's
  56. */
  57. #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
  58. #define cpu_relax() barrier()
  59. #define cpu_sync_pipeline() asm volatile("sub pc, -2" : : : "memory")
  60. struct cpu_context {
  61. unsigned long sr;
  62. unsigned long pc;
  63. unsigned long ksp; /* Kernel stack pointer */
  64. unsigned long r7;
  65. unsigned long r6;
  66. unsigned long r5;
  67. unsigned long r4;
  68. unsigned long r3;
  69. unsigned long r2;
  70. unsigned long r1;
  71. unsigned long r0;
  72. };
  73. /* This struct contains the CPU context as stored by switch_to() */
  74. struct thread_struct {
  75. struct cpu_context cpu_context;
  76. unsigned long single_step_addr;
  77. u16 single_step_insn;
  78. };
  79. #define INIT_THREAD { \
  80. .cpu_context = { \
  81. .ksp = sizeof(init_stack) + (long)&init_stack, \
  82. }, \
  83. }
  84. /*
  85. * Do necessary setup to start up a newly executed thread.
  86. */
  87. #define start_thread(regs, new_pc, new_sp) \
  88. do { \
  89. set_fs(USER_DS); \
  90. memset(regs, 0, sizeof(*regs)); \
  91. regs->sr = MODE_USER; \
  92. regs->pc = new_pc & ~1; \
  93. regs->sp = new_sp; \
  94. } while(0)
  95. struct task_struct;
  96. /* Free all resources held by a thread */
  97. extern void release_thread(struct task_struct *);
  98. /* Create a kernel thread without removing it from tasklists */
  99. extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  100. /* Prepare to copy thread state - unlazy all lazy status */
  101. #define prepare_to_copy(tsk) do { } while(0)
  102. /* Return saved PC of a blocked thread */
  103. #define thread_saved_pc(tsk) ((tsk)->thread.cpu_context.pc)
  104. struct pt_regs;
  105. void show_trace(struct task_struct *task, unsigned long *stack,
  106. struct pt_regs *regs);
  107. extern unsigned long get_wchan(struct task_struct *p);
  108. #define KSTK_EIP(tsk) ((tsk)->thread.cpu_context.pc)
  109. #define KSTK_ESP(tsk) ((tsk)->thread.cpu_context.ksp)
  110. #define ARCH_HAS_PREFETCH
  111. static inline void prefetch(const void *x)
  112. {
  113. const char *c = x;
  114. asm volatile("pref %0" : : "r"(c));
  115. }
  116. #define PREFETCH_STRIDE L1_CACHE_BYTES
  117. #endif /* __ASSEMBLY__ */
  118. #endif /* __ASM_AVR32_PROCESSOR_H */