processor.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C) 2006 Atmel Corporation
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __ASM_AVR32_PROCESSOR_H
  7. #define __ASM_AVR32_PROCESSOR_H
  8. #ifndef __ASSEMBLY__
  9. #define current_text_addr() ({ void *pc; __asm__("mov %0,pc" : "=r"(pc)); pc; })
  10. struct avr32_cpuinfo {
  11. unsigned long loops_per_jiffy;
  12. };
  13. extern struct avr32_cpuinfo boot_cpu_data;
  14. #ifdef CONFIG_SMP
  15. extern struct avr32_cpuinfo cpu_data[];
  16. #define current_cpu_data cpu_data[smp_processor_id()]
  17. #else
  18. #define cpu_data (&boot_cpu_data)
  19. #define current_cpu_data boot_cpu_data
  20. #endif
  21. /* TODO: Make configurable (2GB will serve as a reasonable default) */
  22. #define TASK_SIZE 0x80000000
  23. /* This decides where the kernel will search for a free chunk of vm
  24. * space during mmap's
  25. */
  26. #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
  27. #define cpu_relax() barrier()
  28. #define cpu_sync_pipeline() asm volatile("sub pc, -2" : : : "memory")
  29. /* This struct contains the CPU context as stored by switch_to() */
  30. struct thread_struct {
  31. unsigned long pc;
  32. unsigned long ksp; /* Kernel stack pointer */
  33. unsigned long r7;
  34. unsigned long r6;
  35. unsigned long r5;
  36. unsigned long r4;
  37. unsigned long r3;
  38. unsigned long r2;
  39. unsigned long r1;
  40. unsigned long r0;
  41. };
  42. #define INIT_THREAD { \
  43. .ksp = sizeof(init_stack) + (long)&init_stack, \
  44. }
  45. /*
  46. * Do necessary setup to start up a newly executed thread.
  47. */
  48. #define start_thread(regs, new_pc, new_sp) \
  49. set_fs(USER_DS); \
  50. regs->sr = 0; /* User mode. */ \
  51. regs->gr[REG_PC] = new_pc; \
  52. regs->gr[REG_SP] = new_sp
  53. struct task_struct;
  54. /* Free all resources held by a thread */
  55. extern void release_thread(struct task_struct *);
  56. /* Create a kernel thread without removing it from tasklists */
  57. extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  58. /* Prepare to copy thread state - unlazy all lazy status */
  59. #define prepare_to_copy(tsk) do { } while(0)
  60. /* Return saved PC of a blocked thread */
  61. #define thread_saved_pc(tsk) (tsk->thread.pc)
  62. #endif /* __ASSEMBLY__ */
  63. #endif /* __ASM_AVR32_PROCESSOR_H */