processor.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  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. * vineetg: March 2009
  9. * -Implemented task_pt_regs( )
  10. *
  11. * Amit Bhor, Sameer Dhavale, Ashwin Chaugule: Codito Technologies 2004
  12. */
  13. #ifndef __ASM_ARC_PROCESSOR_H
  14. #define __ASM_ARC_PROCESSOR_H
  15. #ifdef __KERNEL__
  16. #ifndef __ASSEMBLY__
  17. #include <asm/arcregs.h> /* for STATUS_E1_MASK et all */
  18. /* Arch specific stuff which needs to be saved per task.
  19. * However these items are not so important so as to earn a place in
  20. * struct thread_info
  21. */
  22. struct thread_struct {
  23. unsigned long ksp; /* kernel mode stack pointer */
  24. unsigned long callee_reg; /* pointer to callee regs */
  25. unsigned long fault_address; /* dbls as brkpt holder as well */
  26. unsigned long cause_code; /* Exception Cause Code (ECR) */
  27. #ifdef CONFIG_ARC_CURR_IN_REG
  28. unsigned long user_r25;
  29. #endif
  30. #ifdef CONFIG_ARC_FPU_SAVE_RESTORE
  31. struct arc_fpu fpu;
  32. #endif
  33. };
  34. #define INIT_THREAD { \
  35. .ksp = sizeof(init_stack) + (unsigned long) init_stack, \
  36. }
  37. /* Forward declaration, a strange C thing */
  38. struct task_struct;
  39. /*
  40. * Return saved PC of a blocked thread.
  41. */
  42. unsigned long thread_saved_pc(struct task_struct *t);
  43. #define task_pt_regs(p) \
  44. ((struct pt_regs *)(THREAD_SIZE - 4 + (void *)task_stack_page(p)) - 1)
  45. /* Free all resources held by a thread. */
  46. #define release_thread(thread) do { } while (0)
  47. /* Prepare to copy thread state - unlazy all lazy status */
  48. #define prepare_to_copy(tsk) do { } while (0)
  49. /*
  50. * A lot of busy-wait loops in SMP are based off of non-volatile data otherwise
  51. * get optimised away by gcc
  52. */
  53. #ifdef CONFIG_SMP
  54. #define cpu_relax() __asm__ __volatile__ ("" : : : "memory")
  55. #else
  56. #define cpu_relax() do { } while (0)
  57. #endif
  58. #define copy_segments(tsk, mm) do { } while (0)
  59. #define release_segments(mm) do { } while (0)
  60. #define KSTK_EIP(tsk) (task_pt_regs(tsk)->ret)
  61. /*
  62. * Where abouts of Task's sp, fp, blink when it was last seen in kernel mode.
  63. * These can't be derived from pt_regs as that would give correp user-mode val
  64. */
  65. #define KSTK_ESP(tsk) (tsk->thread.ksp)
  66. #define KSTK_BLINK(tsk) (*((unsigned int *)((KSTK_ESP(tsk)) + (13+1+1)*4)))
  67. #define KSTK_FP(tsk) (*((unsigned int *)((KSTK_ESP(tsk)) + (13+1)*4)))
  68. /*
  69. * Do necessary setup to start up a newly executed thread.
  70. *
  71. * E1,E2 so that Interrupts are enabled in user mode
  72. * L set, so Loop inhibited to begin with
  73. * lp_start and lp_end seeded with bogus non-zero values so to easily catch
  74. * the ARC700 sr to lp_start hardware bug
  75. */
  76. #define start_thread(_regs, _pc, _usp) \
  77. do { \
  78. set_fs(USER_DS); /* reads from user space */ \
  79. (_regs)->ret = (_pc); \
  80. /* Interrupts enabled in User Mode */ \
  81. (_regs)->status32 = STATUS_U_MASK | STATUS_L_MASK \
  82. | STATUS_E1_MASK | STATUS_E2_MASK; \
  83. (_regs)->sp = (_usp); \
  84. /* bogus seed values for debugging */ \
  85. (_regs)->lp_start = 0x10; \
  86. (_regs)->lp_end = 0x80; \
  87. } while (0)
  88. extern unsigned int get_wchan(struct task_struct *p);
  89. /*
  90. * Default implementation of macro that returns current
  91. * instruction pointer ("program counter").
  92. * Should the PC register be read instead ? This macro does not seem to
  93. * be used in many places so this wont be all that bad.
  94. */
  95. #define current_text_addr() ({ __label__ _l; _l: &&_l; })
  96. #endif /* !__ASSEMBLY__ */
  97. /* Kernels Virtual memory area.
  98. * Unlike other architectures(MIPS, sh, cris ) ARC 700 does not have a
  99. * "kernel translated" region (like KSEG2 in MIPS). So we use a upper part
  100. * of the translated bottom 2GB for kernel virtual memory and protect
  101. * these pages from user accesses by disabling Ru, Eu and Wu.
  102. */
  103. #define VMALLOC_SIZE (0x10000000) /* 256M */
  104. #define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
  105. #define VMALLOC_END (PAGE_OFFSET)
  106. /* Most of the architectures seem to be keeping some kind of padding between
  107. * userspace TASK_SIZE and PAGE_OFFSET. i.e TASK_SIZE != PAGE_OFFSET.
  108. */
  109. #define USER_KERNEL_GUTTER 0x10000000
  110. /* User address space:
  111. * On ARC700, CPU allows the entire lower half of 32 bit address space to be
  112. * translated. Thus potentially 2G (0:0x7FFF_FFFF) could be User vaddr space.
  113. * However we steal 256M for kernel addr (0x7000_0000:0x7FFF_FFFF) and another
  114. * 256M (0x6000_0000:0x6FFF_FFFF) is gutter between user/kernel spaces
  115. * Thus total User vaddr space is (0:0x5FFF_FFFF)
  116. */
  117. #define TASK_SIZE (PAGE_OFFSET - VMALLOC_SIZE - USER_KERNEL_GUTTER)
  118. #define STACK_TOP TASK_SIZE
  119. #define STACK_TOP_MAX STACK_TOP
  120. /* This decides where the kernel will search for a free chunk of vm
  121. * space during mmap's.
  122. */
  123. #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
  124. #endif /* __KERNEL__ */
  125. #endif /* __ASM_ARC_PROCESSOR_H */