processor.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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_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 - 4 + (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. #define cpu_relax() do { } while (0)
  47. #define copy_segments(tsk, mm) do { } while (0)
  48. #define release_segments(mm) do { } while (0)
  49. #define KSTK_EIP(tsk) (task_pt_regs(tsk)->ret)
  50. /*
  51. * Where abouts of Task's sp, fp, blink when it was last seen in kernel mode.
  52. * These can't be derived from pt_regs as that would give correp user-mode val
  53. */
  54. #define KSTK_ESP(tsk) (tsk->thread.ksp)
  55. #define KSTK_BLINK(tsk) (*((unsigned int *)((KSTK_ESP(tsk)) + (13+1+1)*4)))
  56. #define KSTK_FP(tsk) (*((unsigned int *)((KSTK_ESP(tsk)) + (13+1)*4)))
  57. /*
  58. * Do necessary setup to start up a newly executed thread.
  59. *
  60. * E1,E2 so that Interrupts are enabled in user mode
  61. * L set, so Loop inhibited to begin with
  62. * lp_start and lp_end seeded with bogus non-zero values so to easily catch
  63. * the ARC700 sr to lp_start hardware bug
  64. */
  65. #define start_thread(_regs, _pc, _usp) \
  66. do { \
  67. set_fs(USER_DS); /* reads from user space */ \
  68. (_regs)->ret = (_pc); \
  69. /* Interrupts enabled in User Mode */ \
  70. (_regs)->status32 = STATUS_U_MASK | STATUS_L_MASK \
  71. | STATUS_E1_MASK | STATUS_E2_MASK; \
  72. (_regs)->sp = (_usp); \
  73. /* bogus seed values for debugging */ \
  74. (_regs)->lp_start = 0x10; \
  75. (_regs)->lp_end = 0x80; \
  76. } while (0)
  77. extern unsigned int get_wchan(struct task_struct *p);
  78. /*
  79. * Default implementation of macro that returns current
  80. * instruction pointer ("program counter").
  81. * Should the PC register be read instead ? This macro does not seem to
  82. * be used in many places so this wont be all that bad.
  83. */
  84. #define current_text_addr() ({ __label__ _l; _l: &&_l; })
  85. #endif /* !__ASSEMBLY__ */
  86. /* Kernels Virtual memory area.
  87. * Unlike other architectures(MIPS, sh, cris ) ARC 700 does not have a
  88. * "kernel translated" region (like KSEG2 in MIPS). So we use a upper part
  89. * of the translated bottom 2GB for kernel virtual memory and protect
  90. * these pages from user accesses by disabling Ru, Eu and Wu.
  91. */
  92. #define VMALLOC_SIZE (0x10000000) /* 256M */
  93. #define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
  94. #define VMALLOC_END (PAGE_OFFSET)
  95. /* Most of the architectures seem to be keeping some kind of padding between
  96. * userspace TASK_SIZE and PAGE_OFFSET. i.e TASK_SIZE != PAGE_OFFSET.
  97. */
  98. #define USER_KERNEL_GUTTER 0x10000000
  99. /* User address space:
  100. * On ARC700, CPU allows the entire lower half of 32 bit address space to be
  101. * translated. Thus potentially 2G (0:0x7FFF_FFFF) could be User vaddr space.
  102. * However we steal 256M for kernel addr (0x7000_0000:0x7FFF_FFFF) and another
  103. * 256M (0x6000_0000:0x6FFF_FFFF) is gutter between user/kernel spaces
  104. * Thus total User vaddr space is (0:0x5FFF_FFFF)
  105. */
  106. #define TASK_SIZE (PAGE_OFFSET - VMALLOC_SIZE - USER_KERNEL_GUTTER)
  107. #define STACK_TOP TASK_SIZE
  108. #define STACK_TOP_MAX STACK_TOP
  109. /* This decides where the kernel will search for a free chunk of vm
  110. * space during mmap's.
  111. */
  112. #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
  113. #endif /* __KERNEL__ */
  114. #endif /* __ASM_ARC_PROCESSOR_H */