arm.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * QuickThreads -- Threads-building toolkit.
  3. * Copyright (c) 1993 by David Keppel
  4. * Copyright (c) 2002 by Marius Vollmer
  5. *
  6. * Permission to use, copy, modify and distribute this software and
  7. * its documentation for any purpose and without fee is hereby
  8. * granted, provided that the above copyright notice and this notice
  9. * appear in all copies. This software is provided as a
  10. * proof-of-concept and for demonstration purposes; there is no
  11. * representation about the suitability of this software for any
  12. * purpose.
  13. */
  14. #ifndef QT_ARM_H
  15. #define QT_ARM_H
  16. typedef unsigned long qt_word_t;
  17. #define QT_GROW_DOWN
  18. /* Stack layout on the ARM:
  19. Callee-save registers are: r4-r11 (f4-f7)
  20. Also save r14, link register, and restore as pc.
  21. +---
  22. | lr/pc
  23. | r11
  24. | r10
  25. | r9
  26. | r8
  27. | r7
  28. | r6
  29. | r5
  30. | r4 <- sp of a suspended thread
  31. +---
  32. Startup:
  33. +---
  34. | only
  35. | user
  36. | argt
  37. | argu <- sp on entry to qt_start
  38. +---
  39. | pc == qt_start
  40. | r11
  41. | r10
  42. | r9
  43. | r8
  44. | r7
  45. | r6
  46. | r5
  47. | r4
  48. +---
  49. */
  50. /* Stack must be word aligned. */
  51. #define QT_STKALIGN (4) /* Doubleword aligned. */
  52. /* How much space is allocated to hold all the crud for
  53. initialization: r4-r11, r14, and the four args for qt_start. */
  54. #define QT_STKBASE ((9+4)*4)
  55. /* Offsets of various registers, in words, relative to final value of SP. */
  56. #define QT_LR 8
  57. #define QT_11 7
  58. #define QT_10 6
  59. #define QT_9 5
  60. #define QT_8 4
  61. #define QT_7 3
  62. #define QT_6 2
  63. #define QT_5 1
  64. #define QT_4 0
  65. /* When a never-before-run thread is restored, the return pc points
  66. to a fragment of code that starts the thread running. For
  67. non-vargs functions, it just calls the client's `only' function.
  68. */
  69. extern void qt_start(void);
  70. #define QT_ARGS_MD(sp) (QT_SPUT (sp, QT_LR, qt_start))
  71. /* The *index* (positive offset) of where to put each value. */
  72. #define QT_ONLY_INDEX (12)
  73. #define QT_USER_INDEX (11)
  74. #define QT_ARGT_INDEX (10)
  75. #define QT_ARGU_INDEX (9)
  76. #endif /* ndef QT_ARM_H */