processor.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * OpenRISC Linux
  3. *
  4. * Linux architectural port borrowing liberally from similar works of
  5. * others. All original copyrights apply as per the original source
  6. * declaration.
  7. *
  8. * OpenRISC implementation:
  9. * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
  10. * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
  11. * et al.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. */
  18. #ifndef __ASM_OPENRISC_PROCESSOR_H
  19. #define __ASM_OPENRISC_PROCESSOR_H
  20. #include <asm/spr_defs.h>
  21. #include <asm/page.h>
  22. #include <asm/ptrace.h>
  23. #define STACK_TOP TASK_SIZE
  24. #define STACK_TOP_MAX STACK_TOP
  25. /* Kernel and user SR register setting */
  26. #define KERNEL_SR (SPR_SR_DME | SPR_SR_IME | SPR_SR_ICE \
  27. | SPR_SR_DCE | SPR_SR_SM)
  28. #define USER_SR (SPR_SR_DME | SPR_SR_IME | SPR_SR_ICE \
  29. | SPR_SR_DCE | SPR_SR_IEE | SPR_SR_TEE)
  30. /*
  31. * Default implementation of macro that returns current
  32. * instruction pointer ("program counter").
  33. */
  34. #define current_text_addr() ({ __label__ _l; _l: &&_l; })
  35. /*
  36. * User space process size. This is hardcoded into a few places,
  37. * so don't change it unless you know what you are doing.
  38. */
  39. #define TASK_SIZE (0x80000000UL)
  40. /* This decides where the kernel will search for a free chunk of vm
  41. * space during mmap's.
  42. */
  43. #define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
  44. #ifndef __ASSEMBLY__
  45. struct task_struct;
  46. struct thread_struct {
  47. };
  48. /*
  49. * At user->kernel entry, the pt_regs struct is stacked on the top of the
  50. * kernel-stack. This macro allows us to find those regs for a task.
  51. * Notice that subsequent pt_regs stackings, like recursive interrupts
  52. * occurring while we're in the kernel, won't affect this - only the first
  53. * user->kernel transition registers are reached by this (i.e. not regs
  54. * for running signal handler)
  55. */
  56. #define user_regs(thread_info) (((struct pt_regs *)((unsigned long)(thread_info) + THREAD_SIZE - STACK_FRAME_OVERHEAD)) - 1)
  57. /*
  58. * Dito but for the currently running task
  59. */
  60. #define task_pt_regs(task) user_regs(task_thread_info(task))
  61. #define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack)
  62. #define INIT_THREAD { }
  63. #define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
  64. #define KSTK_ESP(tsk) (task_pt_regs(tsk)->sp)
  65. void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp);
  66. void release_thread(struct task_struct *);
  67. unsigned long get_wchan(struct task_struct *p);
  68. /*
  69. * Free current thread data structures etc..
  70. */
  71. extern inline void exit_thread(void)
  72. {
  73. /* Nothing needs to be done. */
  74. }
  75. /*
  76. * Return saved PC of a blocked thread. For now, this is the "user" PC
  77. */
  78. extern unsigned long thread_saved_pc(struct task_struct *t);
  79. #define init_stack (init_thread_union.stack)
  80. #define cpu_relax() barrier()
  81. #define cpu_relax_lowlatency() cpu_relax()
  82. #endif /* __ASSEMBLY__ */
  83. #endif /* __ASM_OPENRISC_PROCESSOR_H */