processor.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (C) 2006 Atmel Corporation
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #ifndef __ASM_AVR32_PROCESSOR_H
  23. #define __ASM_AVR32_PROCESSOR_H
  24. #ifndef __ASSEMBLY__
  25. #define current_text_addr() ({ void *pc; __asm__("mov %0,pc" : "=r"(pc)); pc; })
  26. struct avr32_cpuinfo {
  27. unsigned long loops_per_jiffy;
  28. };
  29. extern struct avr32_cpuinfo boot_cpu_data;
  30. #ifdef CONFIG_SMP
  31. extern struct avr32_cpuinfo cpu_data[];
  32. #define current_cpu_data cpu_data[smp_processor_id()]
  33. #else
  34. #define cpu_data (&boot_cpu_data)
  35. #define current_cpu_data boot_cpu_data
  36. #endif
  37. /* TODO: Make configurable (2GB will serve as a reasonable default) */
  38. #define TASK_SIZE 0x80000000
  39. /* This decides where the kernel will search for a free chunk of vm
  40. * space during mmap's
  41. */
  42. #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
  43. #define cpu_relax() barrier()
  44. #define cpu_sync_pipeline() asm volatile("sub pc, -2" : : : "memory")
  45. /* This struct contains the CPU context as stored by switch_to() */
  46. struct thread_struct {
  47. unsigned long pc;
  48. unsigned long ksp; /* Kernel stack pointer */
  49. unsigned long r7;
  50. unsigned long r6;
  51. unsigned long r5;
  52. unsigned long r4;
  53. unsigned long r3;
  54. unsigned long r2;
  55. unsigned long r1;
  56. unsigned long r0;
  57. };
  58. #define INIT_THREAD { \
  59. .ksp = sizeof(init_stack) + (long)&init_stack, \
  60. }
  61. /*
  62. * Do necessary setup to start up a newly executed thread.
  63. */
  64. #define start_thread(regs, new_pc, new_sp) \
  65. set_fs(USER_DS); \
  66. regs->sr = 0; /* User mode. */ \
  67. regs->gr[REG_PC] = new_pc; \
  68. regs->gr[REG_SP] = new_sp
  69. struct task_struct;
  70. /* Free all resources held by a thread */
  71. extern void release_thread(struct task_struct *);
  72. /* Create a kernel thread without removing it from tasklists */
  73. extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  74. /* Prepare to copy thread state - unlazy all lazy status */
  75. #define prepare_to_copy(tsk) do { } while(0)
  76. /* Return saved PC of a blocked thread */
  77. #define thread_saved_pc(tsk) (tsk->thread.pc)
  78. #endif /* __ASSEMBLY__ */
  79. #endif /* __ASM_AVR32_PROCESSOR_H */