processor.h 4.7 KB

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