processor.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * linux/arch/unicore32/include/asm/processor.h
  3. *
  4. * Code specific to PKUnity SoC and UniCore ISA
  5. *
  6. * Copyright (C) 2001-2010 GUAN Xue-tao
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef __UNICORE_PROCESSOR_H__
  13. #define __UNICORE_PROCESSOR_H__
  14. /*
  15. * Default implementation of macro that returns current
  16. * instruction pointer ("program counter").
  17. */
  18. #define current_text_addr() ({ __label__ _l; _l: &&_l; })
  19. #ifdef __KERNEL__
  20. #include <asm/ptrace.h>
  21. #include <asm/types.h>
  22. #ifdef __KERNEL__
  23. #define STACK_TOP TASK_SIZE
  24. #define STACK_TOP_MAX TASK_SIZE
  25. #endif
  26. struct debug_entry {
  27. u32 address;
  28. u32 insn;
  29. };
  30. struct debug_info {
  31. int nsaved;
  32. struct debug_entry bp[2];
  33. };
  34. struct thread_struct {
  35. /* fault info */
  36. unsigned long address;
  37. unsigned long trap_no;
  38. unsigned long error_code;
  39. /* debugging */
  40. struct debug_info debug;
  41. };
  42. #define INIT_THREAD { }
  43. #define start_thread(regs, pc, sp) \
  44. ({ \
  45. unsigned long *stack = (unsigned long *)sp; \
  46. memset(regs->uregs, 0, sizeof(regs->uregs)); \
  47. regs->UCreg_asr = USER_MODE; \
  48. regs->UCreg_pc = pc & ~1; /* pc */ \
  49. regs->UCreg_sp = sp; /* sp */ \
  50. regs->UCreg_02 = stack[2]; /* r2 (envp) */ \
  51. regs->UCreg_01 = stack[1]; /* r1 (argv) */ \
  52. regs->UCreg_00 = stack[0]; /* r0 (argc) */ \
  53. })
  54. /* Forward declaration, a strange C thing */
  55. struct task_struct;
  56. /* Free all resources held by a thread. */
  57. extern void release_thread(struct task_struct *);
  58. unsigned long get_wchan(struct task_struct *p);
  59. #define cpu_relax() barrier()
  60. #define cpu_relax_lowlatency() cpu_relax()
  61. #define task_pt_regs(p) \
  62. ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
  63. #define KSTK_EIP(tsk) (task_pt_regs(tsk)->UCreg_pc)
  64. #define KSTK_ESP(tsk) (task_pt_regs(tsk)->UCreg_sp)
  65. #endif
  66. #endif /* __UNICORE_PROCESSOR_H__ */