processor.h 4.6 KB

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