hppa.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * QuickThreads -- Threads-building toolkit.
  3. * Copyright (c) 1993 by David Keppel
  4. *
  5. * Permission to use, copy, modify and distribute this software and
  6. * its documentation for any purpose and without fee is hereby
  7. * granted, provided that the above copyright notice and this notice
  8. * appear in all copies. This software is provided as a
  9. * proof-of-concept and for demonstration purposes; there is no
  10. * representation about the suitability of this software for any
  11. * purpose.
  12. */
  13. /*
  14. * This file (pa-risc.h) is part of the port of QuickThreads for the
  15. * PA-RISC 1.1 architecture. This file is a machine dependent header
  16. * file. It was written in 1994 by Uwe Reder
  17. * (`uereder@cip.informatik.uni-erlangen.de') for the Operating Systems
  18. * Department (IMMD4) at the University of Erlangen/Nuernberg Germany.
  19. */
  20. #ifndef QT_PA_RISC_H
  21. #define QT_PA_RISC_H
  22. #include <qt.h>
  23. /* size of an integer-register (32 bit) */
  24. typedef unsigned long qt_word_t;
  25. /* PA-RISC's stack grows up */
  26. #define QT_GROW_UP
  27. /* Stack layout on PA-RISC according to PA-RISC Procedure Calling Conventions:
  28. Callee-save registers are: gr3-gr18, fr12-fr21.
  29. Also save gr2, return pointer.
  30. +---
  31. | fr12 Each floating register is a double word (8 bytes).
  32. | fr13 Floating registers are only saved if `qt_block' is
  33. | fr14 called, in which case it saves the floating-point
  34. | fr15 registers then calls `qt_blocki' to save the integer
  35. | fr16 registers.
  36. | fr17
  37. | fr18
  38. | fr19
  39. | fr20
  40. | fr21
  41. | <arg word 3> fixed arguments (must be allocated; may remain unused)
  42. | <arg word 2>
  43. | <arg word 1>
  44. | <arg word 0>
  45. | <LPT> frame marker
  46. | <LPT'>
  47. | <RP'>
  48. | <Current RP>
  49. | <Static Link>
  50. | <Clean Up>
  51. | <RP''>
  52. | <Previous SP>
  53. +---
  54. | gr3 word each (4 bytes)
  55. | gr4
  56. | gr5
  57. | gr6
  58. | gr7
  59. | gr8
  60. | gr9
  61. | gr10
  62. | gr11
  63. | gr12
  64. | gr13
  65. | gr14
  66. | gr15
  67. | gr16
  68. | gr17
  69. | gr18
  70. | <16 bytes filled in (sp has to be 64-bytes aligned)>
  71. | <arg word 3> fixed arguments (must be allocated; may remain unused)
  72. | <arg word 2>
  73. | <arg word 1>
  74. | <arg word 0>
  75. | <LPT> frame marker
  76. | <LPT'>
  77. | <RP'>
  78. | <Current RP>
  79. | <Static Link>
  80. | <Clean Up>
  81. | <RP''>
  82. | <Previous SP>
  83. +--- <--- sp
  84. */
  85. /* When a never-before-run thread is restored, the return pc points
  86. to a fragment of code that starts the thread running. For
  87. non-vargs functions, it just calls the client's `only' function.
  88. For varargs functions, it calls the startup, user, and cleanup
  89. functions. */
  90. /* Note: Procedue Labels on PA-RISC
  91. <--2--><-------28---------><1-><1->
  92. -----------------------------------
  93. | SID | Adress Part | L | X |
  94. -----------------------------------
  95. On HP-UX the L field is used to flag wheather the procedure
  96. label (plabel) is a pointer to an LT entry or to the entry point
  97. of the procedure (PA-RISC Procedure Calling Conventions Reference
  98. Manual, 5.3.2 Procedure Labels and Dynamic Calls). */
  99. #define QT_PA_RISC_READ_PLABEL(plabel) \
  100. ( (((int)plabel) & 2) ? \
  101. ( (*((int *)(((int)plabel) & 0xfffffffc)))) : ((int)plabel) )
  102. /* Stack must be 64 bytes aligned. */
  103. #define QT_STKALIGN (64)
  104. /* Internal helper for putting stuff on stack (negative index!). */
  105. #define QT_SPUT(top, at, val) \
  106. (((qt_word_t *)(top))[-(at)] = (qt_word_t)(val))
  107. /* Offsets of various registers which are modified on the stack.
  108. rp (return-pointer) has to be stored in the frame-marker-area
  109. of the "older" stack-segment. */
  110. #define QT_crp (12+4+16+5)
  111. #define QT_15 (12+4+4)
  112. #define QT_16 (12+4+3)
  113. #define QT_17 (12+4+2)
  114. #define QT_18 (12+4+1)
  115. /** This stuff is for NON-VARARGS. **/
  116. /* Stack looks like this (2 stack frames):
  117. <--- 64-bytes aligned --><------- 64-bytes aligned ------------>
  118. | || |
  119. <--16--><------48-------><----16*4-----><--16-><------48------->
  120. || | || | | ||
  121. ||filler|arg|frame-marker||register-save|filler|arg|frame-marker||
  122. ------------------------------------------------------------------
  123. */
  124. #define QT_STKBASE (16+48+(16*sizeof(qt_word_t))+16+48)
  125. /* The index, relative to sp, of where to put each value. */
  126. #define QT_ONLY_INDEX (QT_15)
  127. #define QT_USER_INDEX (QT_16)
  128. #define QT_ARGT_INDEX (QT_17)
  129. #define QT_ARGU_INDEX (QT_18)
  130. extern void qt_start(void);
  131. #define QT_ARGS_MD(sp) \
  132. (QT_SPUT (sp, QT_crp, QT_PA_RISC_READ_PLABEL(qt_start)))
  133. /** This is for VARARGS. **/
  134. #define QT_VARGS_DEFAULT
  135. /* Stack looks like this (2 stack frames):
  136. <------ 64-bytes aligned -------><--------- 64-bytes aligned ---------->
  137. | || |
  138. <---?--><--?---><16><----32-----><----16*4-----><-16--><16><----32----->
  139. || | | | || | | | ||
  140. ||filler|varargs|arg|frame-marker||register-save|filler|arg|frame-marker||
  141. --------------------------------------------------------------------------
  142. */
  143. /* Sp is moved to the end of the first stack frame. */
  144. #define QT_VARGS_MD0(sp, vasize) \
  145. ((qt_t *)(((char *)sp) + QT_STKROUNDUP(vasize + 4*4 + 32)))
  146. /* To reach the arguments from the end of the first stack frame use 32
  147. as a negative adjustment. */
  148. #define QT_VARGS_ADJUST(sp) ((qt_t *)(((char *)sp) - 32))
  149. /* Offset to reach the end of the second stack frame. */
  150. #define QT_VSTKBASE ((16*sizeof(qt_word_t)) + 16 + 4*4 + 32)
  151. extern void qt_vstart(void);
  152. #define QT_VARGS_MD1(sp) \
  153. (QT_SPUT (sp, QT_crp, QT_PA_RISC_READ_PLABEL(qt_vstart)))
  154. #define QT_VARGT_INDEX (QT_15)
  155. #define QT_VSTARTUP_INDEX (QT_16)
  156. #define QT_VUSERF_INDEX (QT_17)
  157. #define QT_VCLEANUP_INDEX (QT_18)
  158. #endif /* ndef QT_PA_RISC_H */