processor.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * linux/include/asm-arm26/processor.h
  3. *
  4. * Copyright (C) 1995 Russell King
  5. * Copyright (C) 2003 Ian Molton
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef __ASM_ARM_PROCESSOR_H
  12. #define __ASM_ARM_PROCESSOR_H
  13. /*
  14. * Default implementation of macro that returns current
  15. * instruction pointer ("program counter").
  16. */
  17. #define current_text_addr() ({ __label__ _l; _l: &&_l;})
  18. #ifdef __KERNEL__
  19. #include <asm/atomic.h>
  20. #include <asm/ptrace.h>
  21. #include <linux/string.h>
  22. #define KERNEL_STACK_SIZE 4096
  23. typedef struct {
  24. void (*put_byte)(void); /* Special calling convention */
  25. void (*get_byte)(void); /* Special calling convention */
  26. void (*put_half)(void); /* Special calling convention */
  27. void (*get_half)(void); /* Special calling convention */
  28. void (*put_word)(void); /* Special calling convention */
  29. void (*get_word)(void); /* Special calling convention */
  30. void (*put_dword)(void); /* Special calling convention */
  31. unsigned long (*copy_from_user)(void *to, const void *from, unsigned long sz);
  32. unsigned long (*copy_to_user)(void *to, const void *from, unsigned long sz);
  33. unsigned long (*clear_user)(void *addr, unsigned long sz);
  34. unsigned long (*strncpy_from_user)(char *to, const char *from, unsigned long sz);
  35. unsigned long (*strnlen_user)(const char *s, long n);
  36. } uaccess_t;
  37. extern uaccess_t uaccess_user, uaccess_kernel;
  38. #define EXTRA_THREAD_STRUCT \
  39. uaccess_t *uaccess; /* User access functions*/
  40. #define EXTRA_THREAD_STRUCT_INIT \
  41. .uaccess = &uaccess_kernel,
  42. // FIXME?!!
  43. #define start_thread(regs,pc,sp) \
  44. ({ \
  45. unsigned long *stack = (unsigned long *)sp; \
  46. set_fs(USER_DS); \
  47. memzero(regs->uregs, sizeof (regs->uregs)); \
  48. regs->ARM_pc = pc | ~0xfc000003; /* pc */ \
  49. regs->ARM_sp = sp; /* sp */ \
  50. regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
  51. regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
  52. regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
  53. })
  54. #define KSTK_EIP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1020])
  55. #define KSTK_ESP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1018])
  56. struct debug_entry {
  57. u32 address;
  58. u32 insn;
  59. };
  60. struct debug_info {
  61. int nsaved;
  62. struct debug_entry bp[2];
  63. };
  64. struct thread_struct {
  65. /* fault info */
  66. unsigned long address;
  67. unsigned long trap_no;
  68. unsigned long error_code;
  69. /* debugging */
  70. struct debug_info debug;
  71. EXTRA_THREAD_STRUCT
  72. };
  73. #define INIT_THREAD { \
  74. EXTRA_THREAD_STRUCT_INIT \
  75. }
  76. /* Forward declaration, a strange C thing */
  77. struct task_struct;
  78. /* Free all resources held by a thread. */
  79. extern void release_thread(struct task_struct *);
  80. unsigned long get_wchan(struct task_struct *p);
  81. #define cpu_relax() barrier()
  82. /* Prepare to copy thread state - unlazy all lazy status */
  83. #define prepare_to_copy(tsk) do { } while (0)
  84. /*
  85. * Create a new kernel thread
  86. */
  87. extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  88. #endif
  89. #endif /* __ASM_ARM_PROCESSOR_H */