musl.xtensa 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429
  1. From be7942d8dbce223ed6a75dfdf8d2cd1beb04e2eb Mon Sep 17 00:00:00 2001
  2. From: Max Filippov <jcmvbkbc@gmail.com>
  3. Date: Tue, 22 Mar 2016 02:35:58 +0300
  4. Subject: [PATCH 242/242] xtensa: add port
  5. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
  6. Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
  7. ---
  8. arch/xtensa/atomic_arch.h | 30 ++
  9. arch/xtensa/bits/alltypes.h.in | 30 ++
  10. arch/xtensa/bits/endian.h | 7 +
  11. arch/xtensa/bits/float.h | 16 +
  12. arch/xtensa/bits/ioctl.h | 227 ++++++++++++
  13. arch/xtensa/bits/limits.h | 7 +
  14. arch/xtensa/bits/mman.h | 57 +++
  15. arch/xtensa/bits/posix.h | 2 +
  16. arch/xtensa/bits/reg.h | 2 +
  17. arch/xtensa/bits/setjmp.h | 1 +
  18. arch/xtensa/bits/signal.h | 88 +++++
  19. arch/xtensa/bits/stat.h | 21 ++
  20. arch/xtensa/bits/stdint.h | 20 +
  21. arch/xtensa/bits/syscall.h | 679 ++++++++++++++++++++++++++++++++++
  22. arch/xtensa/bits/termios.h | 168 +++++++++
  23. arch/xtensa/bits/user.h | 4 +
  24. arch/xtensa/bits/xtensa-config.h | 46 +++
  25. arch/xtensa/crt_arch.h | 26 ++
  26. arch/xtensa/pthread_arch.h | 11 +
  27. arch/xtensa/reloc.h | 21 ++
  28. arch/xtensa/syscall_arch.h | 102 +++++
  29. configure | 1 +
  30. crt/xtensa/crti.s | 11 +
  31. crt/xtensa/crtn.s | 5 +
  32. include/elf.h | 58 +++
  33. ldso/dlstart.c | 13 +-
  34. ldso/dynlink.c | 41 +-
  35. src/internal/xtensa/syscall.s | 15 +
  36. src/ldso/xtensa/tlsdesc.s | 22 ++
  37. src/setjmp/xtensa/longjmp.s | 73 ++++
  38. src/setjmp/xtensa/setjmp.s | 13 +
  39. src/signal/xtensa/restore.s | 10 +
  40. src/signal/xtensa/sigsetjmp.s | 69 ++++
  41. src/signal/xtensa/windowspill.s | 78 ++++
  42. src/thread/xtensa/__set_thread_area.s | 8 +
  43. src/thread/xtensa/__unmapself.s | 10 +
  44. src/thread/xtensa/clone.s | 39 ++
  45. src/thread/xtensa/syscall_cp.s | 37 ++
  46. 38 files changed, 2066 insertions(+), 2 deletions(-)
  47. create mode 100644 arch/xtensa/atomic_arch.h
  48. create mode 100644 arch/xtensa/bits/alltypes.h.in
  49. create mode 100644 arch/xtensa/bits/endian.h
  50. create mode 100644 arch/xtensa/bits/float.h
  51. create mode 100644 arch/xtensa/bits/ioctl.h
  52. create mode 100644 arch/xtensa/bits/limits.h
  53. create mode 100644 arch/xtensa/bits/mman.h
  54. create mode 100644 arch/xtensa/bits/posix.h
  55. create mode 100644 arch/xtensa/bits/reg.h
  56. create mode 100644 arch/xtensa/bits/setjmp.h
  57. create mode 100644 arch/xtensa/bits/signal.h
  58. create mode 100644 arch/xtensa/bits/stat.h
  59. create mode 100644 arch/xtensa/bits/stdint.h
  60. create mode 100644 arch/xtensa/bits/syscall.h
  61. create mode 100644 arch/xtensa/bits/termios.h
  62. create mode 100644 arch/xtensa/bits/user.h
  63. create mode 100644 arch/xtensa/bits/xtensa-config.h
  64. create mode 100644 arch/xtensa/crt_arch.h
  65. create mode 100644 arch/xtensa/pthread_arch.h
  66. create mode 100644 arch/xtensa/reloc.h
  67. create mode 100644 arch/xtensa/syscall_arch.h
  68. create mode 100644 crt/xtensa/crti.s
  69. create mode 100644 crt/xtensa/crtn.s
  70. create mode 100644 src/internal/xtensa/syscall.s
  71. create mode 100644 src/ldso/xtensa/tlsdesc.s
  72. create mode 100644 src/setjmp/xtensa/longjmp.s
  73. create mode 100644 src/setjmp/xtensa/setjmp.s
  74. create mode 100644 src/signal/xtensa/restore.s
  75. create mode 100644 src/signal/xtensa/sigsetjmp.s
  76. create mode 100644 src/signal/xtensa/windowspill.s
  77. create mode 100644 src/thread/xtensa/__set_thread_area.s
  78. create mode 100644 src/thread/xtensa/__unmapself.s
  79. create mode 100644 src/thread/xtensa/clone.s
  80. create mode 100644 src/thread/xtensa/syscall_cp.s
  81. diff --git a/arch/xtensa/atomic_arch.h b/arch/xtensa/atomic_arch.h
  82. new file mode 100644
  83. index 0000000..476814b
  84. --- /dev/null
  85. +++ b/arch/xtensa/atomic_arch.h
  86. @@ -0,0 +1,30 @@
  87. +#ifndef _INTERNAL_ATOMIC_H
  88. +#define _INTERNAL_ATOMIC_H
  89. +
  90. +#include <stdint.h>
  91. +
  92. +#define a_cas a_cas
  93. +static inline int a_cas(volatile int *p, int t, int s)
  94. +{
  95. + __asm__ __volatile__(
  96. + " wsr %1, scompare1\n"
  97. + " s32c1i %0, %2, 0\n"
  98. + : "+a"(s)
  99. + : "a"(t), "a"(p)
  100. + : "memory" );
  101. + return s;
  102. +}
  103. +
  104. +#define a_barrier a_barrier
  105. +static inline void a_barrier()
  106. +{
  107. + __asm__ __volatile__ ("memw" : : : "memory");
  108. +}
  109. +
  110. +#define a_crash a_crash
  111. +static inline void a_crash()
  112. +{
  113. + __asm__ __volatile__ ("ill" : : : "memory");
  114. +}
  115. +
  116. +#endif
  117. diff --git a/arch/xtensa/bits/alltypes.h.in b/arch/xtensa/bits/alltypes.h.in
  118. new file mode 100644
  119. index 0000000..1e2a8c1
  120. --- /dev/null
  121. +++ b/arch/xtensa/bits/alltypes.h.in
  122. @@ -0,0 +1,30 @@
  123. +#define _Addr int
  124. +#define _Int64 long long
  125. +#define _Reg int
  126. +
  127. +TYPEDEF __builtin_va_list va_list;
  128. +TYPEDEF __builtin_va_list __isoc_va_list;
  129. +
  130. +#ifndef __cplusplus
  131. +#ifdef __WCHAR_TYPE__
  132. +TYPEDEF __WCHAR_TYPE__ wchar_t;
  133. +#else
  134. +TYPEDEF unsigned wchar_t;
  135. +#endif
  136. +#endif
  137. +
  138. +TYPEDEF float float_t;
  139. +TYPEDEF double double_t;
  140. +
  141. +TYPEDEF struct { long long __ll; long double __ld; } max_align_t;
  142. +
  143. +TYPEDEF long time_t;
  144. +TYPEDEF long suseconds_t;
  145. +
  146. +TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t;
  147. +TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
  148. +TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
  149. +TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t;
  150. +TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t;
  151. +TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t;
  152. +TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t;
  153. diff --git a/arch/xtensa/bits/endian.h b/arch/xtensa/bits/endian.h
  154. new file mode 100644
  155. index 0000000..d719907
  156. --- /dev/null
  157. +++ b/arch/xtensa/bits/endian.h
  158. @@ -0,0 +1,7 @@
  159. +#if __XTENSA_EB__
  160. +#define __BYTE_ORDER __BIG_ENDIAN
  161. +#elif __XTENSA_EL__
  162. +#define __BYTE_ORDER __LITTLE_ENDIAN
  163. +#else
  164. +#error Unknown endianness
  165. +#endif
  166. diff --git a/arch/xtensa/bits/float.h b/arch/xtensa/bits/float.h
  167. new file mode 100644
  168. index 0000000..c4a655e
  169. --- /dev/null
  170. +++ b/arch/xtensa/bits/float.h
  171. @@ -0,0 +1,16 @@
  172. +#define FLT_EVAL_METHOD 0
  173. +
  174. +#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
  175. +#define LDBL_MIN 2.22507385850720138309e-308L
  176. +#define LDBL_MAX 1.79769313486231570815e+308L
  177. +#define LDBL_EPSILON 2.22044604925031308085e-16L
  178. +
  179. +#define LDBL_MANT_DIG 53
  180. +#define LDBL_MIN_EXP (-1021)
  181. +#define LDBL_MAX_EXP 1024
  182. +
  183. +#define LDBL_DIG 15
  184. +#define LDBL_MIN_10_EXP (-307)
  185. +#define LDBL_MAX_10_EXP 308
  186. +
  187. +#define DECIMAL_DIG 17
  188. diff --git a/arch/xtensa/bits/ioctl.h b/arch/xtensa/bits/ioctl.h
  189. new file mode 100644
  190. index 0000000..e1ab80e
  191. --- /dev/null
  192. +++ b/arch/xtensa/bits/ioctl.h
  193. @@ -0,0 +1,227 @@
  194. +#define _IOC(a,b,c,d) ( ((a)<<30) | ((b)<<8) | (c) | ((d)<<16) )
  195. +#define _IOC_NONE 0U
  196. +#define _IOC_READ 2U
  197. +#define _IOC_WRITE 1U
  198. +
  199. +#define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
  200. +#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
  201. +#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
  202. +#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c))
  203. +
  204. +#define FIOCLEX _IO('f', 1)
  205. +#define FIONCLEX _IO('f', 2)
  206. +#define FIOASYNC _IOW('f', 125, int)
  207. +#define FIONBIO _IOW('f', 126, int)
  208. +#define FIONREAD _IOR('f', 127, int)
  209. +#define TIOCINQ FIONREAD
  210. +#define FIOQSIZE _IOR('f', 128, loff_t)
  211. +
  212. +#define TCGETS 0x5401
  213. +#define TCSETS 0x5402
  214. +#define TCSETSW 0x5403
  215. +#define TCSETSF 0x5404
  216. +
  217. +#define TCGETA 0x80127417 /* _IOR('t', 23, struct termio) */
  218. +#define TCSETA 0x40127418 /* _IOW('t', 24, struct termio) */
  219. +#define TCSETAW 0x40127419 /* _IOW('t', 25, struct termio) */
  220. +#define TCSETAF 0x4012741C /* _IOW('t', 28, struct termio) */
  221. +
  222. +#define TCSBRK _IO('t', 29)
  223. +#define TCXONC _IO('t', 30)
  224. +#define TCFLSH _IO('t', 31)
  225. +
  226. +#define TIOCSWINSZ 0x40087467 /* _IOW('t', 103, struct winsize) */
  227. +#define TIOCGWINSZ 0x80087468 /* _IOR('t', 104, struct winsize) */
  228. +#define TIOCSTART _IO('t', 110) /* start output, like ^Q */
  229. +#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
  230. +#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
  231. +
  232. +#define TIOCSPGRP _IOW('t', 118, int)
  233. +#define TIOCGPGRP _IOR('t', 119, int)
  234. +
  235. +#define TIOCEXCL _IO('T', 12)
  236. +#define TIOCNXCL _IO('T', 13)
  237. +#define TIOCSCTTY _IO('T', 14)
  238. +
  239. +#define TIOCSTI _IOW('T', 18, char)
  240. +#define TIOCMGET _IOR('T', 21, unsigned int)
  241. +#define TIOCMBIS _IOW('T', 22, unsigned int)
  242. +#define TIOCMBIC _IOW('T', 23, unsigned int)
  243. +#define TIOCMSET _IOW('T', 24, unsigned int)
  244. +# define TIOCM_LE 0x001
  245. +# define TIOCM_DTR 0x002
  246. +# define TIOCM_RTS 0x004
  247. +# define TIOCM_ST 0x008
  248. +# define TIOCM_SR 0x010
  249. +# define TIOCM_CTS 0x020
  250. +# define TIOCM_CAR 0x040
  251. +# define TIOCM_RNG 0x080
  252. +# define TIOCM_DSR 0x100
  253. +# define TIOCM_CD TIOCM_CAR
  254. +# define TIOCM_RI TIOCM_RNG
  255. +
  256. +#define TIOCGSOFTCAR _IOR('T', 25, unsigned int)
  257. +#define TIOCSSOFTCAR _IOW('T', 26, unsigned int)
  258. +#define TIOCLINUX _IOW('T', 28, char)
  259. +#define TIOCCONS _IO('T', 29)
  260. +#define TIOCGSERIAL 0x803C541E /*_IOR('T', 30, struct serial_struct)*/
  261. +#define TIOCSSERIAL 0x403C541F /*_IOW('T', 31, struct serial_struct)*/
  262. +#define TIOCPKT _IOW('T', 32, int)
  263. +# define TIOCPKT_DATA 0
  264. +# define TIOCPKT_FLUSHREAD 1
  265. +# define TIOCPKT_FLUSHWRITE 2
  266. +# define TIOCPKT_STOP 4
  267. +# define TIOCPKT_START 8
  268. +# define TIOCPKT_NOSTOP 16
  269. +# define TIOCPKT_DOSTOP 32
  270. +# define TIOCPKT_IOCTL 64
  271. +
  272. +
  273. +#define TIOCNOTTY _IO('T', 34)
  274. +#define TIOCSETD _IOW('T', 35, int)
  275. +#define TIOCGETD _IOR('T', 36, int)
  276. +#define TCSBRKP _IOW('T', 37, int) /* Needed for POSIX tcsendbreak()*/
  277. +#define TIOCSBRK _IO('T', 39) /* BSD compatibility */
  278. +#define TIOCCBRK _IO('T', 40) /* BSD compatibility */
  279. +#define TIOCGSID _IOR('T', 41, pid_t) /* Return the session ID of FD*/
  280. +#define TCGETS2 _IOR('T', 42, struct termios2)
  281. +#define TCSETS2 _IOW('T', 43, struct termios2)
  282. +#define TCSETSW2 _IOW('T', 44, struct termios2)
  283. +#define TCSETSF2 _IOW('T', 45, struct termios2)
  284. +#define TIOCGRS485 _IOR('T', 46, struct serial_rs485)
  285. +#define TIOCSRS485 _IOWR('T', 47, struct serial_rs485)
  286. +#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
  287. +#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
  288. +#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */
  289. +#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
  290. +#define TIOCVHANGUP _IO('T', 0x37)
  291. +#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */
  292. +#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
  293. +#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */
  294. +
  295. +#define TIOCSERCONFIG _IO('T', 83)
  296. +#define TIOCSERGWILD _IOR('T', 84, int)
  297. +#define TIOCSERSWILD _IOW('T', 85, int)
  298. +#define TIOCGLCKTRMIOS 0x5456
  299. +#define TIOCSLCKTRMIOS 0x5457
  300. +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
  301. +#define TIOCSERGETLSR _IOR('T', 89, unsigned int) /* Get line status reg. */
  302. + /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
  303. +# define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
  304. +#define TIOCSERGETMULTI 0x80a8545a /* Get multiport config */
  305. + /* _IOR('T', 90, struct serial_multiport_struct) */
  306. +#define TIOCSERSETMULTI 0x40a8545b /* Set multiport config */
  307. + /* _IOW('T', 91, struct serial_multiport_struct) */
  308. +
  309. +#define TIOCMIWAIT _IO('T', 92) /* wait for a change on serial input line(s) */
  310. +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
  311. +
  312. +struct winsize {
  313. + unsigned short ws_row;
  314. + unsigned short ws_col;
  315. + unsigned short ws_xpixel;
  316. + unsigned short ws_ypixel;
  317. +};
  318. +
  319. +#define TIOCM_LE 0x001
  320. +#define TIOCM_DTR 0x002
  321. +#define TIOCM_RTS 0x004
  322. +#define TIOCM_ST 0x008
  323. +#define TIOCM_SR 0x010
  324. +#define TIOCM_CTS 0x020
  325. +#define TIOCM_CAR 0x040
  326. +#define TIOCM_RNG 0x080
  327. +#define TIOCM_DSR 0x100
  328. +#define TIOCM_CD TIOCM_CAR
  329. +#define TIOCM_RI TIOCM_RNG
  330. +#define TIOCM_OUT1 0x2000
  331. +#define TIOCM_OUT2 0x4000
  332. +#define TIOCM_LOOP 0x8000
  333. +#define TIOCM_MODEM_BITS TIOCM_OUT2
  334. +
  335. +#define N_TTY 0
  336. +#define N_SLIP 1
  337. +#define N_MOUSE 2
  338. +#define N_PPP 3
  339. +#define N_STRIP 4
  340. +#define N_AX25 5
  341. +#define N_X25 6
  342. +#define N_6PACK 7
  343. +#define N_MASC 8
  344. +#define N_R3964 9
  345. +#define N_PROFIBUS_FDL 10
  346. +#define N_IRDA 11
  347. +#define N_SMSBLOCK 12
  348. +#define N_HDLC 13
  349. +#define N_SYNC_PPP 14
  350. +#define N_HCI 15
  351. +
  352. +#define FIOGETOWN _IOR('f', 123, int)
  353. +#define FIOSETOWN _IOW('f', 124, int)
  354. +#define SIOCATMARK _IOR('s', 7, int)
  355. +#define SIOCSPGRP _IOW('s', 8, pid_t)
  356. +#define SIOCGPGRP _IOR('s', 9, pid_t)
  357. +#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
  358. +#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
  359. +
  360. +#define SIOCADDRT 0x890B
  361. +#define SIOCDELRT 0x890C
  362. +#define SIOCRTMSG 0x890D
  363. +
  364. +#define SIOCGIFNAME 0x8910
  365. +#define SIOCSIFLINK 0x8911
  366. +#define SIOCGIFCONF 0x8912
  367. +#define SIOCGIFFLAGS 0x8913
  368. +#define SIOCSIFFLAGS 0x8914
  369. +#define SIOCGIFADDR 0x8915
  370. +#define SIOCSIFADDR 0x8916
  371. +#define SIOCGIFDSTADDR 0x8917
  372. +#define SIOCSIFDSTADDR 0x8918
  373. +#define SIOCGIFBRDADDR 0x8919
  374. +#define SIOCSIFBRDADDR 0x891a
  375. +#define SIOCGIFNETMASK 0x891b
  376. +#define SIOCSIFNETMASK 0x891c
  377. +#define SIOCGIFMETRIC 0x891d
  378. +#define SIOCSIFMETRIC 0x891e
  379. +#define SIOCGIFMEM 0x891f
  380. +#define SIOCSIFMEM 0x8920
  381. +#define SIOCGIFMTU 0x8921
  382. +#define SIOCSIFMTU 0x8922
  383. +#define SIOCSIFHWADDR 0x8924
  384. +#define SIOCGIFENCAP 0x8925
  385. +#define SIOCSIFENCAP 0x8926
  386. +#define SIOCGIFHWADDR 0x8927
  387. +#define SIOCGIFSLAVE 0x8929
  388. +#define SIOCSIFSLAVE 0x8930
  389. +#define SIOCADDMULTI 0x8931
  390. +#define SIOCDELMULTI 0x8932
  391. +#define SIOCGIFINDEX 0x8933
  392. +#define SIOGIFINDEX SIOCGIFINDEX
  393. +#define SIOCSIFPFLAGS 0x8934
  394. +#define SIOCGIFPFLAGS 0x8935
  395. +#define SIOCDIFADDR 0x8936
  396. +#define SIOCSIFHWBROADCAST 0x8937
  397. +#define SIOCGIFCOUNT 0x8938
  398. +
  399. +#define SIOCGIFBR 0x8940
  400. +#define SIOCSIFBR 0x8941
  401. +
  402. +#define SIOCGIFTXQLEN 0x8942
  403. +#define SIOCSIFTXQLEN 0x8943
  404. +
  405. +#define SIOCDARP 0x8953
  406. +#define SIOCGARP 0x8954
  407. +#define SIOCSARP 0x8955
  408. +
  409. +#define SIOCDRARP 0x8960
  410. +#define SIOCGRARP 0x8961
  411. +#define SIOCSRARP 0x8962
  412. +
  413. +#define SIOCGIFMAP 0x8970
  414. +#define SIOCSIFMAP 0x8971
  415. +
  416. +#define SIOCADDDLCI 0x8980
  417. +#define SIOCDELDLCI 0x8981
  418. +
  419. +#define SIOCDEVPRIVATE 0x89F0
  420. +#define SIOCPROTOPRIVATE 0x89E0
  421. diff --git a/arch/xtensa/bits/limits.h b/arch/xtensa/bits/limits.h
  422. new file mode 100644
  423. index 0000000..fbc6d23
  424. --- /dev/null
  425. +++ b/arch/xtensa/bits/limits.h
  426. @@ -0,0 +1,7 @@
  427. +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  428. + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  429. +#define LONG_BIT 32
  430. +#endif
  431. +
  432. +#define LONG_MAX 0x7fffffffL
  433. +#define LLONG_MAX 0x7fffffffffffffffLL
  434. diff --git a/arch/xtensa/bits/mman.h b/arch/xtensa/bits/mman.h
  435. new file mode 100644
  436. index 0000000..3125fc2
  437. --- /dev/null
  438. +++ b/arch/xtensa/bits/mman.h
  439. @@ -0,0 +1,57 @@
  440. +#define MAP_FAILED ((void *) -1)
  441. +
  442. +#define PROT_NONE 0
  443. +#define PROT_READ 1
  444. +#define PROT_WRITE 2
  445. +#define PROT_EXEC 4
  446. +#define PROT_GROWSDOWN 0x01000000
  447. +#define PROT_GROWSUP 0x02000000
  448. +
  449. +#define MAP_SHARED 0x01
  450. +#define MAP_PRIVATE 0x02
  451. +#define MAP_FIXED 0x10
  452. +
  453. +#define MAP_TYPE 0x0f
  454. +#define MAP_FILE 0x00
  455. +#define MAP_ANON 0x800
  456. +#define MAP_ANONYMOUS MAP_ANON
  457. +#define MAP_NORESERVE 0x0400
  458. +#define MAP_GROWSDOWN 0x1000
  459. +#define MAP_DENYWRITE 0x2000
  460. +#define MAP_EXECUTABLE 0x4000
  461. +#define MAP_LOCKED 0x8000
  462. +#define MAP_POPULATE 0x10000
  463. +#define MAP_NONBLOCK 0x20000
  464. +#define MAP_STACK 0x40000
  465. +#define MAP_HUGETLB 0x80000
  466. +
  467. +#define POSIX_MADV_NORMAL 0
  468. +#define POSIX_MADV_RANDOM 1
  469. +#define POSIX_MADV_SEQUENTIAL 2
  470. +#define POSIX_MADV_WILLNEED 3
  471. +#define POSIX_MADV_DONTNEED 0
  472. +
  473. +#define MS_ASYNC 1
  474. +#define MS_INVALIDATE 2
  475. +#define MS_SYNC 4
  476. +
  477. +#define MCL_CURRENT 1
  478. +#define MCL_FUTURE 2
  479. +
  480. +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  481. +#define MADV_NORMAL 0
  482. +#define MADV_RANDOM 1
  483. +#define MADV_SEQUENTIAL 2
  484. +#define MADV_WILLNEED 3
  485. +#define MADV_DONTNEED 4
  486. +#define MADV_REMOVE 9
  487. +#define MADV_DONTFORK 10
  488. +#define MADV_DOFORK 11
  489. +#define MADV_MERGEABLE 12
  490. +#define MADV_UNMERGEABLE 13
  491. +#define MADV_HUGEPAGE 14
  492. +#define MADV_NOHUGEPAGE 15
  493. +#define MADV_DONTDUMP 16
  494. +#define MADV_DODUMP 17
  495. +#define MADV_HWPOISON 100
  496. +#endif
  497. diff --git a/arch/xtensa/bits/posix.h b/arch/xtensa/bits/posix.h
  498. new file mode 100644
  499. index 0000000..30a3871
  500. --- /dev/null
  501. +++ b/arch/xtensa/bits/posix.h
  502. @@ -0,0 +1,2 @@
  503. +#define _POSIX_V6_ILP32_OFFBIG 1
  504. +#define _POSIX_V7_ILP32_OFFBIG 1
  505. diff --git a/arch/xtensa/bits/reg.h b/arch/xtensa/bits/reg.h
  506. new file mode 100644
  507. index 0000000..0192a29
  508. --- /dev/null
  509. +++ b/arch/xtensa/bits/reg.h
  510. @@ -0,0 +1,2 @@
  511. +#undef __WORDSIZE
  512. +#define __WORDSIZE 32
  513. diff --git a/arch/xtensa/bits/setjmp.h b/arch/xtensa/bits/setjmp.h
  514. new file mode 100644
  515. index 0000000..b2bd974
  516. --- /dev/null
  517. +++ b/arch/xtensa/bits/setjmp.h
  518. @@ -0,0 +1 @@
  519. +typedef unsigned long __jmp_buf[18];
  520. diff --git a/arch/xtensa/bits/signal.h b/arch/xtensa/bits/signal.h
  521. new file mode 100644
  522. index 0000000..545ffd3
  523. --- /dev/null
  524. +++ b/arch/xtensa/bits/signal.h
  525. @@ -0,0 +1,88 @@
  526. +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  527. + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  528. +
  529. +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  530. +#define MINSIGSTKSZ 2048
  531. +#define SIGSTKSZ 8192
  532. +#endif
  533. +
  534. +typedef struct sigcontext
  535. +{
  536. + unsigned long sc_pc;
  537. + unsigned long sc_ps;
  538. + unsigned long sc_lbeg;
  539. + unsigned long sc_lend;
  540. + unsigned long sc_lcount;
  541. + unsigned long sc_sar;
  542. + unsigned long sc_acclo;
  543. + unsigned long sc_acchi;
  544. + unsigned long sc_a[16];
  545. + void *sc_xtregs;
  546. +} mcontext_t;
  547. +
  548. +struct sigaltstack {
  549. + void *ss_sp;
  550. + int ss_flags;
  551. + size_t ss_size;
  552. +};
  553. +
  554. +typedef struct __ucontext {
  555. + unsigned long uc_flags;
  556. + struct __ucontext *uc_link;
  557. + stack_t uc_stack;
  558. + mcontext_t uc_mcontext;
  559. + sigset_t uc_sigmask;
  560. +} ucontext_t;
  561. +
  562. +#define SA_NOCLDSTOP 0x00000001
  563. +#define SA_NOCLDWAIT 0x00000002 /* not supported yet */
  564. +#define SA_SIGINFO 0x00000004
  565. +#define SA_ONSTACK 0x08000000
  566. +#define SA_RESTART 0x10000000
  567. +#define SA_NODEFER 0x40000000
  568. +#define SA_RESETHAND 0x80000000
  569. +
  570. +#define SA_NOMASK SA_NODEFER
  571. +#define SA_ONESHOT SA_RESETHAND
  572. +
  573. +#define SA_RESTORER 0x04000000
  574. +
  575. +#endif
  576. +
  577. +#define SIGHUP 1
  578. +#define SIGINT 2
  579. +#define SIGQUIT 3
  580. +#define SIGILL 4
  581. +#define SIGTRAP 5
  582. +#define SIGABRT 6
  583. +#define SIGIOT 6
  584. +#define SIGBUS 7
  585. +#define SIGFPE 8
  586. +#define SIGKILL 9
  587. +#define SIGUSR1 10
  588. +#define SIGSEGV 11
  589. +#define SIGUSR2 12
  590. +#define SIGPIPE 13
  591. +#define SIGALRM 14
  592. +#define SIGTERM 15
  593. +#define SIGSTKFLT 16
  594. +#define SIGCHLD 17
  595. +#define SIGCONT 18
  596. +#define SIGSTOP 19
  597. +#define SIGTSTP 20
  598. +#define SIGTTIN 21
  599. +#define SIGTTOU 22
  600. +#define SIGURG 23
  601. +#define SIGXCPU 24
  602. +#define SIGXFSZ 25
  603. +#define SIGVTALRM 26
  604. +#define SIGPROF 27
  605. +#define SIGWINCH 28
  606. +#define SIGIO 29
  607. +#define SIGPOLL SIGIO
  608. +/* #define SIGLOST 29 */
  609. +#define SIGPWR 30
  610. +#define SIGSYS 31
  611. +#define SIGUNUSED 31
  612. +
  613. +#define _NSIG 64
  614. diff --git a/arch/xtensa/bits/stat.h b/arch/xtensa/bits/stat.h
  615. new file mode 100644
  616. index 0000000..24231f8
  617. --- /dev/null
  618. +++ b/arch/xtensa/bits/stat.h
  619. @@ -0,0 +1,21 @@
  620. +/* copied from kernel definition, but with padding replaced
  621. + * by the corresponding correctly-sized userspace types. */
  622. +
  623. +struct stat
  624. +{
  625. + dev_t st_dev;
  626. + ino_t st_ino;
  627. + mode_t st_mode;
  628. + nlink_t st_nlink;
  629. + uid_t st_uid;
  630. + gid_t st_gid;
  631. + dev_t st_rdev;
  632. + off_t st_size;
  633. + blksize_t st_blksize;
  634. + long __st_padding1;
  635. + blkcnt_t st_blocks;
  636. + struct timespec st_atim;
  637. + struct timespec st_mtim;
  638. + struct timespec st_ctim;
  639. + long __st_padding2[2];
  640. +};
  641. diff --git a/arch/xtensa/bits/stdint.h b/arch/xtensa/bits/stdint.h
  642. new file mode 100644
  643. index 0000000..d1b2712
  644. --- /dev/null
  645. +++ b/arch/xtensa/bits/stdint.h
  646. @@ -0,0 +1,20 @@
  647. +typedef int32_t int_fast16_t;
  648. +typedef int32_t int_fast32_t;
  649. +typedef uint32_t uint_fast16_t;
  650. +typedef uint32_t uint_fast32_t;
  651. +
  652. +#define INT_FAST16_MIN INT32_MIN
  653. +#define INT_FAST32_MIN INT32_MIN
  654. +
  655. +#define INT_FAST16_MAX INT32_MAX
  656. +#define INT_FAST32_MAX INT32_MAX
  657. +
  658. +#define UINT_FAST16_MAX UINT32_MAX
  659. +#define UINT_FAST32_MAX UINT32_MAX
  660. +
  661. +#define INTPTR_MIN INT32_MIN
  662. +#define INTPTR_MAX INT32_MAX
  663. +#define UINTPTR_MAX UINT32_MAX
  664. +#define PTRDIFF_MIN INT32_MIN
  665. +#define PTRDIFF_MAX INT32_MAX
  666. +#define SIZE_MAX UINT32_MAX
  667. diff --git a/arch/xtensa/bits/syscall.h b/arch/xtensa/bits/syscall.h
  668. new file mode 100644
  669. index 0000000..df8c2ab
  670. --- /dev/null
  671. +++ b/arch/xtensa/bits/syscall.h
  672. @@ -0,0 +1,679 @@
  673. +#define __NR_spill 0
  674. +#define __NR_xtensa 1
  675. +#define __NR_available4 2
  676. +#define __NR_available5 3
  677. +#define __NR_available6 4
  678. +#define __NR_available7 5
  679. +#define __NR_available8 6
  680. +#define __NR_available9 7
  681. +#define __NR_open 8
  682. +#define __NR_close 9
  683. +#define __NR_dup 10
  684. +#define __NR_dup2 11
  685. +#define __NR_read 12
  686. +#define __NR_write 13
  687. +#define __NR_select 14
  688. +#define __NR_lseek 15
  689. +#define __NR_poll 16
  690. +#define __NR__llseek 17
  691. +#define __NR_epoll_wait 18
  692. +#define __NR_epoll_ctl 19
  693. +#define __NR_epoll_create 20
  694. +#define __NR_creat 21
  695. +#define __NR_truncate 22
  696. +#define __NR_ftruncate 23
  697. +#define __NR_readv 24
  698. +#define __NR_writev 25
  699. +#define __NR_fsync 26
  700. +#define __NR_fdatasync 27
  701. +#define __NR_truncate64 28
  702. +#define __NR_ftruncate64 29
  703. +#define __NR_pread64 30
  704. +#define __NR_pwrite64 31
  705. +#define __NR_link 32
  706. +#define __NR_rename 33
  707. +#define __NR_symlink 34
  708. +#define __NR_readlink 35
  709. +#define __NR_mknod 36
  710. +#define __NR_pipe 37
  711. +#define __NR_unlink 38
  712. +#define __NR_rmdir 39
  713. +#define __NR_mkdir 40
  714. +#define __NR_chdir 41
  715. +#define __NR_fchdir 42
  716. +#define __NR_getcwd 43
  717. +#define __NR_chmod 44
  718. +#define __NR_chown 45
  719. +#define __NR_stat 46
  720. +#define __NR_stat64 47
  721. +#define __NR_lchown 48
  722. +#define __NR_lstat 49
  723. +#define __NR_lstat64 50
  724. +#define __NR_available51 51
  725. +#define __NR_fchmod 52
  726. +#define __NR_fchown 53
  727. +#define __NR_fstat 54
  728. +#define __NR_fstat64 55
  729. +#define __NR_flock 56
  730. +#define __NR_access 57
  731. +#define __NR_umask 58
  732. +#define __NR_getdents 59
  733. +#define __NR_getdents64 60
  734. +#define __NR_fcntl64 61
  735. +#define __NR_fallocate 62
  736. +#define __NR_fadvise64_64 63
  737. +#define __NR_utime 64 /* glibc 2.3.3 ?? */
  738. +#define __NR_utimes 65
  739. +#define __NR_ioctl 66
  740. +#define __NR_fcntl 67
  741. +#define __NR_setxattr 68
  742. +#define __NR_getxattr 69
  743. +#define __NR_listxattr 70
  744. +#define __NR_removexattr 71
  745. +#define __NR_lsetxattr 72
  746. +#define __NR_lgetxattr 73
  747. +#define __NR_llistxattr 74
  748. +#define __NR_lremovexattr 75
  749. +#define __NR_fsetxattr 76
  750. +#define __NR_fgetxattr 77
  751. +#define __NR_flistxattr 78
  752. +#define __NR_fremovexattr 79
  753. +#define __NR_mmap2 80
  754. +#define __NR_munmap 81
  755. +#define __NR_mprotect 82
  756. +#define __NR_brk 83
  757. +#define __NR_mlock 84
  758. +#define __NR_munlock 85
  759. +#define __NR_mlockall 86
  760. +#define __NR_munlockall 87
  761. +#define __NR_mremap 88
  762. +#define __NR_msync 89
  763. +#define __NR_mincore 90
  764. +#define __NR_madvise 91
  765. +#define __NR_shmget 92
  766. +#define __NR_shmat 93
  767. +#define __NR_shmctl 94
  768. +#define __NR_shmdt 95
  769. +#define __NR_socket 96
  770. +#define __NR_setsockopt 97
  771. +#define __NR_getsockopt 98
  772. +#define __NR_shutdown 99
  773. +#define __NR_bind 100
  774. +#define __NR_connect 101
  775. +#define __NR_listen 102
  776. +#define __NR_accept 103
  777. +#define __NR_getsockname 104
  778. +#define __NR_getpeername 105
  779. +#define __NR_sendmsg 106
  780. +#define __NR_recvmsg 107
  781. +#define __NR_send 108
  782. +#define __NR_recv 109
  783. +#define __NR_sendto 110
  784. +#define __NR_recvfrom 111
  785. +#define __NR_socketpair 112
  786. +#define __NR_sendfile 113
  787. +#define __NR_sendfile64 114
  788. +#define __NR_sendmmsg 115
  789. +#define __NR_clone 116
  790. +#define __NR_execve 117
  791. +#define __NR_exit 118
  792. +#define __NR_exit_group 119
  793. +#define __NR_getpid 120
  794. +#define __NR_wait4 121
  795. +#define __NR_waitid 122
  796. +#define __NR_kill 123
  797. +#define __NR_tkill 124
  798. +#define __NR_tgkill 125
  799. +#define __NR_set_tid_address 126
  800. +#define __NR_gettid 127
  801. +#define __NR_setsid 128
  802. +#define __NR_getsid 129
  803. +#define __NR_prctl 130
  804. +#define __NR_personality 131
  805. +#define __NR_getpriority 132
  806. +#define __NR_setpriority 133
  807. +#define __NR_setitimer 134
  808. +#define __NR_getitimer 135
  809. +#define __NR_setuid 136
  810. +#define __NR_getuid 137
  811. +#define __NR_setgid 138
  812. +#define __NR_getgid 139
  813. +#define __NR_geteuid 140
  814. +#define __NR_getegid 141
  815. +#define __NR_setreuid 142
  816. +#define __NR_setregid 143
  817. +#define __NR_setresuid 144
  818. +#define __NR_getresuid 145
  819. +#define __NR_setresgid 146
  820. +#define __NR_getresgid 147
  821. +#define __NR_setpgid 148
  822. +#define __NR_getpgid 149
  823. +#define __NR_getppid 150
  824. +#define __NR_getpgrp 151
  825. +#define __NR_reserved152 152 /* set_thread_area */
  826. +#define __NR_reserved153 153 /* get_thread_area */
  827. +#define __NR_times 154
  828. +#define __NR_acct 155
  829. +#define __NR_sched_setaffinity 156
  830. +#define __NR_sched_getaffinity 157
  831. +#define __NR_capget 158
  832. +#define __NR_capset 159
  833. +#define __NR_ptrace 160
  834. +#define __NR_semtimedop 161
  835. +#define __NR_semget 162
  836. +#define __NR_semop 163
  837. +#define __NR_semctl 164
  838. +#define __NR_available165 165
  839. +#define __NR_msgget 166
  840. +#define __NR_msgsnd 167
  841. +#define __NR_msgrcv 168
  842. +#define __NR_msgctl 169
  843. +#define __NR_available170 170
  844. +#define __NR_umount2 171
  845. +#define __NR_mount 172
  846. +#define __NR_swapon 173
  847. +#define __NR_chroot 174
  848. +#define __NR_pivot_root 175
  849. +#define __NR_umount 176
  850. +#define __NR_swapoff 177
  851. +#define __NR_sync 178
  852. +#define __NR_syncfs 179
  853. +#define __NR_setfsuid 180
  854. +#define __NR_setfsgid 181
  855. +#define __NR_sysfs 182
  856. +#define __NR_ustat 183
  857. +#define __NR_statfs 184
  858. +#define __NR_fstatfs 185
  859. +#define __NR_statfs64 186
  860. +#define __NR_fstatfs64 187
  861. +#define __NR_setrlimit 188
  862. +#define __NR_getrlimit 189
  863. +#define __NR_getrusage 190
  864. +#define __NR_futex 191
  865. +#define __NR_gettimeofday 192
  866. +#define __NR_settimeofday 193
  867. +#define __NR_adjtimex 194
  868. +#define __NR_nanosleep 195
  869. +#define __NR_getgroups 196
  870. +#define __NR_setgroups 197
  871. +#define __NR_sethostname 198
  872. +#define __NR_setdomainname 199
  873. +#define __NR_syslog 200
  874. +#define __NR_vhangup 201
  875. +#define __NR_uselib 202
  876. +#define __NR_reboot 203
  877. +#define __NR_quotactl 204
  878. +#define __NR_nfsservctl 205
  879. +#define __NR__sysctl 206
  880. +#define __NR_bdflush 207
  881. +#define __NR_uname 208
  882. +#define __NR_sysinfo 209
  883. +#define __NR_init_module 210
  884. +#define __NR_delete_module 211
  885. +#define __NR_sched_setparam 212
  886. +#define __NR_sched_getparam 213
  887. +#define __NR_sched_setscheduler 214
  888. +#define __NR_sched_getscheduler 215
  889. +#define __NR_sched_get_priority_max 216
  890. +#define __NR_sched_get_priority_min 217
  891. +#define __NR_sched_rr_get_interval 218
  892. +#define __NR_sched_yield 219
  893. +#define __NR_available222 222
  894. +#define __NR_restart_syscall 223
  895. +#define __NR_sigaltstack 224
  896. +#define __NR_rt_sigreturn 225
  897. +#define __NR_rt_sigaction 226
  898. +#define __NR_rt_sigprocmask 227
  899. +#define __NR_rt_sigpending 228
  900. +#define __NR_rt_sigtimedwait 229
  901. +#define __NR_rt_sigqueueinfo 230
  902. +#define __NR_rt_sigsuspend 231
  903. +#define __NR_mq_open 232
  904. +#define __NR_mq_unlink 233
  905. +#define __NR_mq_timedsend 234
  906. +#define __NR_mq_timedreceive 235
  907. +#define __NR_mq_notify 236
  908. +#define __NR_mq_getsetattr 237
  909. +#define __NR_available238 238
  910. +#define __NR_io_setup 239
  911. +#define __NR_io_destroy 240
  912. +#define __NR_io_submit 241
  913. +#define __NR_io_getevents 242
  914. +#define __NR_io_cancel 243
  915. +#define __NR_clock_settime 244
  916. +#define __NR_clock_gettime 245
  917. +#define __NR_clock_getres 246
  918. +#define __NR_clock_nanosleep 247
  919. +#define __NR_timer_create 248
  920. +#define __NR_timer_delete 249
  921. +#define __NR_timer_settime 250
  922. +#define __NR_timer_gettime 251
  923. +#define __NR_timer_getoverrun 252
  924. +#define __NR_reserved253 253
  925. +#define __NR_lookup_dcookie 254
  926. +#define __NR_available255 255
  927. +#define __NR_add_key 256
  928. +#define __NR_request_key 257
  929. +#define __NR_keyctl 258
  930. +#define __NR_available259 259
  931. +#define __NR_readahead 260
  932. +#define __NR_remap_file_pages 261
  933. +#define __NR_migrate_pages 262
  934. +#define __NR_mbind 263
  935. +#define __NR_get_mempolicy 264
  936. +#define __NR_set_mempolicy 265
  937. +#define __NR_unshare 266
  938. +#define __NR_move_pages 267
  939. +#define __NR_splice 268
  940. +#define __NR_tee 269
  941. +#define __NR_vmsplice 270
  942. +#define __NR_available271 271
  943. +#define __NR_pselect6 272
  944. +#define __NR_ppoll 273
  945. +#define __NR_epoll_pwait 274
  946. +#define __NR_epoll_create1 275
  947. +#define __NR_inotify_init 276
  948. +#define __NR_inotify_add_watch 277
  949. +#define __NR_inotify_rm_watch 278
  950. +#define __NR_inotify_init1 279
  951. +#define __NR_getcpu 280
  952. +#define __NR_kexec_load 281
  953. +#define __NR_ioprio_set 282
  954. +#define __NR_ioprio_get 283
  955. +#define __NR_set_robust_list 284
  956. +#define __NR_get_robust_list 285
  957. +#define __NR_available286 286
  958. +#define __NR_available287 287
  959. +#define __NR_openat 288
  960. +#define __NR_mkdirat 289
  961. +#define __NR_mknodat 290
  962. +#define __NR_unlinkat 291
  963. +#define __NR_renameat 292
  964. +#define __NR_linkat 293
  965. +#define __NR_symlinkat 294
  966. +#define __NR_readlinkat 295
  967. +#define __NR_utimensat 296
  968. +#define __NR_fchownat 297
  969. +#define __NR_futimesat 298
  970. +#define __NR_fstatat64 299
  971. +#define __NR_fchmodat 300
  972. +#define __NR_faccessat 301
  973. +#define __NR_available302 302
  974. +#define __NR_available303 303
  975. +#define __NR_signalfd 304
  976. +#define __NR_eventfd 306
  977. +#define __NR_recvmmsg 307
  978. +#define __NR_setns 308
  979. +#define __NR_signalfd4 309
  980. +#define __NR_dup3 310
  981. +#define __NR_pipe2 311
  982. +#define __NR_timerfd_create 312
  983. +#define __NR_timerfd_settime 313
  984. +#define __NR_timerfd_gettime 314
  985. +#define __NR_available315 315
  986. +#define __NR_eventfd2 316
  987. +#define __NR_preadv 317
  988. +#define __NR_pwritev 318
  989. +#define __NR_available319 319
  990. +#define __NR_fanotify_init 320
  991. +#define __NR_fanotify_mark 321
  992. +#define __NR_process_vm_readv 322
  993. +#define __NR_process_vm_writev 323
  994. +#define __NR_name_to_handle_at 324
  995. +#define __NR_open_by_handle_at 325
  996. +#define __NR_sync_file_range2 326
  997. +#define __NR_perf_event_open 327
  998. +#define __NR_rt_tgsigqueueinfo 328
  999. +#define __NR_clock_adjtime 329
  1000. +#define __NR_prlimit64 330
  1001. +#define __NR_kcmp 331
  1002. +#define __NR_finit_module 332
  1003. +#define __NR_accept4 333
  1004. +#define __NR_sched_setattr 334
  1005. +#define __NR_sched_getattr 335
  1006. +#define __NR_renameat2 336
  1007. +#define __NR_seccomp 337
  1008. +#define __NR_getrandom 338
  1009. +#define __NR_memfd_create 339
  1010. +#define __NR_bpf 340
  1011. +#define __NR_execveat 341
  1012. +
  1013. +#define SYS_spill 0
  1014. +#define SYS_xtensa 1
  1015. +#define SYS_available4 2
  1016. +#define SYS_available5 3
  1017. +#define SYS_available6 4
  1018. +#define SYS_available7 5
  1019. +#define SYS_available8 6
  1020. +#define SYS_available9 7
  1021. +#define SYS_open 8
  1022. +#define SYS_close 9
  1023. +#define SYS_dup 10
  1024. +#define SYS_dup2 11
  1025. +#define SYS_read 12
  1026. +#define SYS_write 13
  1027. +#define SYS_select 14
  1028. +#define SYS_lseek 15
  1029. +#define SYS_poll 16
  1030. +#define SYS__llseek 17
  1031. +#define SYS_epoll_wait 18
  1032. +#define SYS_epoll_ctl 19
  1033. +#define SYS_epoll_create 20
  1034. +#define SYS_creat 21
  1035. +#define SYS_truncate 22
  1036. +#define SYS_ftruncate 23
  1037. +#define SYS_readv 24
  1038. +#define SYS_writev 25
  1039. +#define SYS_fsync 26
  1040. +#define SYS_fdatasync 27
  1041. +#define SYS_truncate64 28
  1042. +#define SYS_ftruncate64 29
  1043. +#define SYS_pread64 30
  1044. +#define SYS_pwrite64 31
  1045. +#define SYS_link 32
  1046. +#define SYS_rename 33
  1047. +#define SYS_symlink 34
  1048. +#define SYS_readlink 35
  1049. +#define SYS_mknod 36
  1050. +#define SYS_pipe 37
  1051. +#define SYS_unlink 38
  1052. +#define SYS_rmdir 39
  1053. +#define SYS_mkdir 40
  1054. +#define SYS_chdir 41
  1055. +#define SYS_fchdir 42
  1056. +#define SYS_getcwd 43
  1057. +#define SYS_chmod 44
  1058. +#define SYS_chown 45
  1059. +#define SYS_stat 46
  1060. +#define SYS_stat64 47
  1061. +#define SYS_lchown 48
  1062. +#define SYS_lstat 49
  1063. +#define SYS_lstat64 50
  1064. +#define SYS_available51 51
  1065. +#define SYS_fchmod 52
  1066. +#define SYS_fchown 53
  1067. +#define SYS_fstat 54
  1068. +#define SYS_fstat64 55
  1069. +#define SYS_flock 56
  1070. +#define SYS_access 57
  1071. +#define SYS_umask 58
  1072. +#define SYS_getdents 59
  1073. +#define SYS_getdents64 60
  1074. +#define SYS_fcntl64 61
  1075. +#define SYS_fallocate 62
  1076. +#define SYS_fadvise64_64 63
  1077. +#define SYS_utime 64 /* glibc 2.3.3 ?? */
  1078. +#define SYS_utimes 65
  1079. +#define SYS_ioctl 66
  1080. +#define SYS_fcntl 67
  1081. +#define SYS_setxattr 68
  1082. +#define SYS_getxattr 69
  1083. +#define SYS_listxattr 70
  1084. +#define SYS_removexattr 71
  1085. +#define SYS_lsetxattr 72
  1086. +#define SYS_lgetxattr 73
  1087. +#define SYS_llistxattr 74
  1088. +#define SYS_lremovexattr 75
  1089. +#define SYS_fsetxattr 76
  1090. +#define SYS_fgetxattr 77
  1091. +#define SYS_flistxattr 78
  1092. +#define SYS_fremovexattr 79
  1093. +#define SYS_mmap2 80
  1094. +#define SYS_munmap 81
  1095. +#define SYS_mprotect 82
  1096. +#define SYS_brk 83
  1097. +#define SYS_mlock 84
  1098. +#define SYS_munlock 85
  1099. +#define SYS_mlockall 86
  1100. +#define SYS_munlockall 87
  1101. +#define SYS_mremap 88
  1102. +#define SYS_msync 89
  1103. +#define SYS_mincore 90
  1104. +#define SYS_madvise 91
  1105. +#define SYS_shmget 92
  1106. +#define SYS_shmat 93
  1107. +#define SYS_shmctl 94
  1108. +#define SYS_shmdt 95
  1109. +#define SYS_socket 96
  1110. +#define SYS_setsockopt 97
  1111. +#define SYS_getsockopt 98
  1112. +#define SYS_shutdown 99
  1113. +#define SYS_bind 100
  1114. +#define SYS_connect 101
  1115. +#define SYS_listen 102
  1116. +#define SYS_accept 103
  1117. +#define SYS_getsockname 104
  1118. +#define SYS_getpeername 105
  1119. +#define SYS_sendmsg 106
  1120. +#define SYS_recvmsg 107
  1121. +#define SYS_send 108
  1122. +#define SYS_recv 109
  1123. +#define SYS_sendto 110
  1124. +#define SYS_recvfrom 111
  1125. +#define SYS_socketpair 112
  1126. +#define SYS_sendfile 113
  1127. +#define SYS_sendfile64 114
  1128. +#define SYS_sendmmsg 115
  1129. +#define SYS_clone 116
  1130. +#define SYS_execve 117
  1131. +#define SYS_exit 118
  1132. +#define SYS_exit_group 119
  1133. +#define SYS_getpid 120
  1134. +#define SYS_wait4 121
  1135. +#define SYS_waitid 122
  1136. +#define SYS_kill 123
  1137. +#define SYS_tkill 124
  1138. +#define SYS_tgkill 125
  1139. +#define SYS_set_tid_address 126
  1140. +#define SYS_gettid 127
  1141. +#define SYS_setsid 128
  1142. +#define SYS_getsid 129
  1143. +#define SYS_prctl 130
  1144. +#define SYS_personality 131
  1145. +#define SYS_getpriority 132
  1146. +#define SYS_setpriority 133
  1147. +#define SYS_setitimer 134
  1148. +#define SYS_getitimer 135
  1149. +#define SYS_setuid 136
  1150. +#define SYS_getuid 137
  1151. +#define SYS_setgid 138
  1152. +#define SYS_getgid 139
  1153. +#define SYS_geteuid 140
  1154. +#define SYS_getegid 141
  1155. +#define SYS_setreuid 142
  1156. +#define SYS_setregid 143
  1157. +#define SYS_setresuid 144
  1158. +#define SYS_getresuid 145
  1159. +#define SYS_setresgid 146
  1160. +#define SYS_getresgid 147
  1161. +#define SYS_setpgid 148
  1162. +#define SYS_getpgid 149
  1163. +#define SYS_getppid 150
  1164. +#define SYS_getpgrp 151
  1165. +#define SYS_reserved152 152 /* set_thread_area */
  1166. +#define SYS_reserved153 153 /* get_thread_area */
  1167. +#define SYS_times 154
  1168. +#define SYS_acct 155
  1169. +#define SYS_sched_setaffinity 156
  1170. +#define SYS_sched_getaffinity 157
  1171. +#define SYS_capget 158
  1172. +#define SYS_capset 159
  1173. +#define SYS_ptrace 160
  1174. +#define SYS_semtimedop 161
  1175. +#define SYS_semget 162
  1176. +#define SYS_semop 163
  1177. +#define SYS_semctl 164
  1178. +#define SYS_available165 165
  1179. +#define SYS_msgget 166
  1180. +#define SYS_msgsnd 167
  1181. +#define SYS_msgrcv 168
  1182. +#define SYS_msgctl 169
  1183. +#define SYS_available170 170
  1184. +#define SYS_umount2 171
  1185. +#define SYS_mount 172
  1186. +#define SYS_swapon 173
  1187. +#define SYS_chroot 174
  1188. +#define SYS_pivot_root 175
  1189. +#define SYS_umount 176
  1190. +#define SYS_swapoff 177
  1191. +#define SYS_sync 178
  1192. +#define SYS_syncfs 179
  1193. +#define SYS_setfsuid 180
  1194. +#define SYS_setfsgid 181
  1195. +#define SYS_sysfs 182
  1196. +#define SYS_ustat 183
  1197. +#define SYS_statfs 184
  1198. +#define SYS_fstatfs 185
  1199. +#define SYS_statfs64 186
  1200. +#define SYS_fstatfs64 187
  1201. +#define SYS_setrlimit 188
  1202. +#define SYS_getrlimit 189
  1203. +#define SYS_getrusage 190
  1204. +#define SYS_futex 191
  1205. +#define SYS_gettimeofday 192
  1206. +#define SYS_settimeofday 193
  1207. +#define SYS_adjtimex 194
  1208. +#define SYS_nanosleep 195
  1209. +#define SYS_getgroups 196
  1210. +#define SYS_setgroups 197
  1211. +#define SYS_sethostname 198
  1212. +#define SYS_setdomainname 199
  1213. +#define SYS_syslog 200
  1214. +#define SYS_vhangup 201
  1215. +#define SYS_uselib 202
  1216. +#define SYS_reboot 203
  1217. +#define SYS_quotactl 204
  1218. +#define SYS_nfsservctl 205
  1219. +#define SYS__sysctl 206
  1220. +#define SYS_bdflush 207
  1221. +#define SYS_uname 208
  1222. +#define SYS_sysinfo 209
  1223. +#define SYS_init_module 210
  1224. +#define SYS_delete_module 211
  1225. +#define SYS_sched_setparam 212
  1226. +#define SYS_sched_getparam 213
  1227. +#define SYS_sched_setscheduler 214
  1228. +#define SYS_sched_getscheduler 215
  1229. +#define SYS_sched_get_priority_max 216
  1230. +#define SYS_sched_get_priority_min 217
  1231. +#define SYS_sched_rr_get_interval 218
  1232. +#define SYS_sched_yield 219
  1233. +#define SYS_available222 222
  1234. +#define SYS_restart_syscall 223
  1235. +#define SYS_sigaltstack 224
  1236. +#define SYS_rt_sigreturn 225
  1237. +#define SYS_rt_sigaction 226
  1238. +#define SYS_rt_sigprocmask 227
  1239. +#define SYS_rt_sigpending 228
  1240. +#define SYS_rt_sigtimedwait 229
  1241. +#define SYS_rt_sigqueueinfo 230
  1242. +#define SYS_rt_sigsuspend 231
  1243. +#define SYS_mq_open 232
  1244. +#define SYS_mq_unlink 233
  1245. +#define SYS_mq_timedsend 234
  1246. +#define SYS_mq_timedreceive 235
  1247. +#define SYS_mq_notify 236
  1248. +#define SYS_mq_getsetattr 237
  1249. +#define SYS_available238 238
  1250. +#define SYS_io_setup 239
  1251. +#define SYS_io_destroy 240
  1252. +#define SYS_io_submit 241
  1253. +#define SYS_io_getevents 242
  1254. +#define SYS_io_cancel 243
  1255. +#define SYS_clock_settime 244
  1256. +#define SYS_clock_gettime 245
  1257. +#define SYS_clock_getres 246
  1258. +#define SYS_clock_nanosleep 247
  1259. +#define SYS_timer_create 248
  1260. +#define SYS_timer_delete 249
  1261. +#define SYS_timer_settime 250
  1262. +#define SYS_timer_gettime 251
  1263. +#define SYS_timer_getoverrun 252
  1264. +#define SYS_reserved253 253
  1265. +#define SYS_lookup_dcookie 254
  1266. +#define SYS_available255 255
  1267. +#define SYS_add_key 256
  1268. +#define SYS_request_key 257
  1269. +#define SYS_keyctl 258
  1270. +#define SYS_available259 259
  1271. +#define SYS_readahead 260
  1272. +#define SYS_remap_file_pages 261
  1273. +#define SYS_migrate_pages 262
  1274. +#define SYS_mbind 263
  1275. +#define SYS_get_mempolicy 264
  1276. +#define SYS_set_mempolicy 265
  1277. +#define SYS_unshare 266
  1278. +#define SYS_move_pages 267
  1279. +#define SYS_splice 268
  1280. +#define SYS_tee 269
  1281. +#define SYS_vmsplice 270
  1282. +#define SYS_available271 271
  1283. +#define SYS_pselect6 272
  1284. +#define SYS_ppoll 273
  1285. +#define SYS_epoll_pwait 274
  1286. +#define SYS_epoll_create1 275
  1287. +#define SYS_inotify_init 276
  1288. +#define SYS_inotify_add_watch 277
  1289. +#define SYS_inotify_rm_watch 278
  1290. +#define SYS_inotify_init1 279
  1291. +#define SYS_getcpu 280
  1292. +#define SYS_kexec_load 281
  1293. +#define SYS_ioprio_set 282
  1294. +#define SYS_ioprio_get 283
  1295. +#define SYS_set_robust_list 284
  1296. +#define SYS_get_robust_list 285
  1297. +#define SYS_available286 286
  1298. +#define SYS_available287 287
  1299. +#define SYS_openat 288
  1300. +#define SYS_mkdirat 289
  1301. +#define SYS_mknodat 290
  1302. +#define SYS_unlinkat 291
  1303. +#define SYS_renameat 292
  1304. +#define SYS_linkat 293
  1305. +#define SYS_symlinkat 294
  1306. +#define SYS_readlinkat 295
  1307. +#define SYS_utimensat 296
  1308. +#define SYS_fchownat 297
  1309. +#define SYS_futimesat 298
  1310. +#define SYS_fstatat64 299
  1311. +#define SYS_fchmodat 300
  1312. +#define SYS_faccessat 301
  1313. +#define SYS_available302 302
  1314. +#define SYS_available303 303
  1315. +#define SYS_signalfd 304
  1316. +#define SYS_eventfd 306
  1317. +#define SYS_recvmmsg 307
  1318. +#define SYS_setns 308
  1319. +#define SYS_signalfd4 309
  1320. +#define SYS_dup3 310
  1321. +#define SYS_pipe2 311
  1322. +#define SYS_timerfd_create 312
  1323. +#define SYS_timerfd_settime 313
  1324. +#define SYS_timerfd_gettime 314
  1325. +#define SYS_available315 315
  1326. +#define SYS_eventfd2 316
  1327. +#define SYS_preadv 317
  1328. +#define SYS_pwritev 318
  1329. +#define SYS_available319 319
  1330. +#define SYS_fanotify_init 320
  1331. +#define SYS_fanotify_mark 321
  1332. +#define SYS_process_vm_readv 322
  1333. +#define SYS_process_vm_writev 323
  1334. +#define SYS_name_to_handle_at 324
  1335. +#define SYS_open_by_handle_at 325
  1336. +#define SYS_sync_file_range2 326
  1337. +#define SYS_perf_event_open 327
  1338. +#define SYS_rt_tgsigqueueinfo 328
  1339. +#define SYS_clock_adjtime 329
  1340. +#define SYS_prlimit64 330
  1341. +#define SYS_kcmp 331
  1342. +#define SYS_finit_module 332
  1343. +#define SYS_accept4 333
  1344. +#define SYS_sched_setattr 334
  1345. +#define SYS_sched_getattr 335
  1346. +#define SYS_renameat2 336
  1347. +#define SYS_seccomp 337
  1348. +#define SYS_getrandom 338
  1349. +#define SYS_memfd_create 339
  1350. +#define SYS_bpf 340
  1351. +#define SYS_execveat 341
  1352. diff --git a/arch/xtensa/bits/termios.h b/arch/xtensa/bits/termios.h
  1353. new file mode 100644
  1354. index 0000000..f1b32e0
  1355. --- /dev/null
  1356. +++ b/arch/xtensa/bits/termios.h
  1357. @@ -0,0 +1,168 @@
  1358. +struct termios
  1359. +{
  1360. + tcflag_t c_iflag;
  1361. + tcflag_t c_oflag;
  1362. + tcflag_t c_cflag;
  1363. + tcflag_t c_lflag;
  1364. + cc_t c_line;
  1365. + cc_t c_cc[NCCS];
  1366. + speed_t __c_ispeed;
  1367. + speed_t __c_ospeed;
  1368. +};
  1369. +
  1370. +#define VINTR 0
  1371. +#define VQUIT 1
  1372. +#define VERASE 2
  1373. +#define VKILL 3
  1374. +#define VEOF 4
  1375. +#define VTIME 5
  1376. +#define VMIN 6
  1377. +#define VSWTC 7
  1378. +#define VSTART 8
  1379. +#define VSTOP 9
  1380. +#define VSUSP 10
  1381. +#define VEOL 11
  1382. +#define VREPRINT 12
  1383. +#define VDISCARD 13
  1384. +#define VWERASE 14
  1385. +#define VLNEXT 15
  1386. +#define VEOL2 16
  1387. +
  1388. +#define IGNBRK 0000001
  1389. +#define BRKINT 0000002
  1390. +#define IGNPAR 0000004
  1391. +#define PARMRK 0000010
  1392. +#define INPCK 0000020
  1393. +#define ISTRIP 0000040
  1394. +#define INLCR 0000100
  1395. +#define IGNCR 0000200
  1396. +#define ICRNL 0000400
  1397. +#define IUCLC 0001000
  1398. +#define IXON 0002000
  1399. +#define IXANY 0004000
  1400. +#define IXOFF 0010000
  1401. +#define IMAXBEL 0020000
  1402. +#define IUTF8 0040000
  1403. +
  1404. +#define OPOST 0000001
  1405. +#define OLCUC 0000002
  1406. +#define ONLCR 0000004
  1407. +#define OCRNL 0000010
  1408. +#define ONOCR 0000020
  1409. +#define ONLRET 0000040
  1410. +#define OFILL 0000100
  1411. +#define OFDEL 0000200
  1412. +#define NLDLY 0000400
  1413. +#define NL0 0000000
  1414. +#define NL1 0000400
  1415. +#define CRDLY 0003000
  1416. +#define CR0 0000000
  1417. +#define CR1 0001000
  1418. +#define CR2 0002000
  1419. +#define CR3 0003000
  1420. +#define TABDLY 0014000
  1421. +#define TAB0 0000000
  1422. +#define TAB1 0004000
  1423. +#define TAB2 0010000
  1424. +#define TAB3 0014000
  1425. +#define XTABS 0014000
  1426. +#define BSDLY 0020000
  1427. +#define BS0 0000000
  1428. +#define BS1 0020000
  1429. +#define VTDLY 0040000
  1430. +#define VT0 0000000
  1431. +#define VT1 0040000
  1432. +#define FFDLY 0100000
  1433. +#define FF0 0000000
  1434. +#define FF1 0100000
  1435. +
  1436. +#define B0 0000000
  1437. +#define B50 0000001
  1438. +#define B75 0000002
  1439. +#define B110 0000003
  1440. +#define B134 0000004
  1441. +#define B150 0000005
  1442. +#define B200 0000006
  1443. +#define B300 0000007
  1444. +#define B600 0000010
  1445. +#define B1200 0000011
  1446. +#define B1800 0000012
  1447. +#define B2400 0000013
  1448. +#define B4800 0000014
  1449. +#define B9600 0000015
  1450. +#define B19200 0000016
  1451. +#define B38400 0000017
  1452. +#define EXTA 0000016
  1453. +#define EXTB 0000017
  1454. +
  1455. +#define BOTHER 0010000
  1456. +#define B57600 0010001
  1457. +#define B115200 0010002
  1458. +#define B230400 0010003
  1459. +#define B460800 0010004
  1460. +#define B500000 0010005
  1461. +#define B576000 0010006
  1462. +#define B921600 0010007
  1463. +#define B1000000 0010010
  1464. +#define B1152000 0010011
  1465. +#define B1500000 0010012
  1466. +#define B2000000 0010013
  1467. +#define B2500000 0010014
  1468. +#define B3000000 0010015
  1469. +#define B3500000 0010016
  1470. +#define B4000000 0010017
  1471. +
  1472. +#define CBAUD 0010017
  1473. +
  1474. +#define CSIZE 0000060
  1475. +#define CS5 0000000
  1476. +#define CS6 0000020
  1477. +#define CS7 0000040
  1478. +#define CS8 0000060
  1479. +#define CSTOPB 0000100
  1480. +#define CREAD 0000200
  1481. +#define PARENB 0000400
  1482. +#define PARODD 0001000
  1483. +#define HUPCL 0002000
  1484. +#define CLOCAL 0004000
  1485. +
  1486. +#define ISIG 0000001
  1487. +#define ICANON 0000002
  1488. +#define XCASE 0000004
  1489. +#define ECHO 0000010
  1490. +#define ECHOE 0000020
  1491. +#define ECHOK 0000040
  1492. +#define ECHONL 0000100
  1493. +#define NOFLSH 0000200
  1494. +#define TOSTOP 0000400
  1495. +#define ECHOCTL 0001000
  1496. +#define ECHOPRT 0002000
  1497. +#define ECHOKE 0004000
  1498. +#define FLUSHO 0010000
  1499. +#define PENDIN 0040000
  1500. +#define IEXTEN 0100000
  1501. +#define EXTPROC 0200000
  1502. +
  1503. +#define TCOOFF 0
  1504. +#define TCOON 1
  1505. +#define TCIOFF 2
  1506. +#define TCION 3
  1507. +
  1508. +#define TCIFLUSH 0
  1509. +#define TCOFLUSH 1
  1510. +#define TCIOFLUSH 2
  1511. +
  1512. +#define TCSANOW 0
  1513. +#define TCSADRAIN 1
  1514. +#define TCSAFLUSH 2
  1515. +
  1516. +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  1517. +#define CBAUDEX 0010000
  1518. +#define CIBAUD 002003600000
  1519. +#define IBSHIFT 16
  1520. +#define CMSPAR 010000000000
  1521. +#define CRTSCTS 020000000000
  1522. +#define EXTPROC 0200000
  1523. +#define XTABS 0014000
  1524. +#define TIOCSER_TEMT 1
  1525. +#endif
  1526. diff --git a/arch/xtensa/bits/user.h b/arch/xtensa/bits/user.h
  1527. new file mode 100644
  1528. index 0000000..8ac7526
  1529. --- /dev/null
  1530. +++ b/arch/xtensa/bits/user.h
  1531. @@ -0,0 +1,4 @@
  1532. +#define ELF_NGREG 128
  1533. +#define ELF_NFPREG 18
  1534. +typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
  1535. +typedef unsigned int elf_fpreg_t, elf_fpregset_t[ELF_NFPREG];
  1536. diff --git a/arch/xtensa/bits/xtensa-config.h b/arch/xtensa/bits/xtensa-config.h
  1537. new file mode 100644
  1538. index 0000000..2e60af9
  1539. --- /dev/null
  1540. +++ b/arch/xtensa/bits/xtensa-config.h
  1541. @@ -0,0 +1,46 @@
  1542. +/* Xtensa configuration settings.
  1543. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
  1544. + Free Software Foundation, Inc.
  1545. + Contributed by Bob Wilson (bwilson@tensilica.com) at Tensilica.
  1546. +
  1547. + The GNU C Library is free software; you can redistribute it and/or
  1548. + modify it under the terms of the GNU Lesser General Public
  1549. + License as published by the Free Software Foundation; either
  1550. + version 2.1 of the License, or (at your option) any later version.
  1551. +
  1552. + The GNU C Library is distributed in the hope that it will be useful,
  1553. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  1554. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1555. + Lesser General Public License for more details.
  1556. +
  1557. + You should have received a copy of the GNU Lesser General Public
  1558. + License along with the GNU C Library; if not, see
  1559. + <http://www.gnu.org/licenses/>. */
  1560. +
  1561. +#ifndef XTENSA_CONFIG_H
  1562. +#define XTENSA_CONFIG_H
  1563. +
  1564. +/* The macros defined here match those with the same names in the Xtensa
  1565. + compile-time HAL (Hardware Abstraction Layer). Please refer to the
  1566. + Xtensa System Software Reference Manual for documentation of these
  1567. + macros. */
  1568. +
  1569. +/* The following macros reflect the default expectations for Xtensa
  1570. + processor configurations that can run glibc. If you want to try
  1571. + building glibc for an Xtensa configuration that is missing these
  1572. + options, you will at least need to change the values of these
  1573. + macros. */
  1574. +
  1575. +#undef XCHAL_HAVE_NSA
  1576. +#define XCHAL_HAVE_NSA 1
  1577. +
  1578. +#undef XCHAL_HAVE_LOOPS
  1579. +#define XCHAL_HAVE_LOOPS 1
  1580. +
  1581. +/* Assume the maximum number of AR registers. This currently only affects
  1582. + the __window_spill function, and it is always safe to flush extra. */
  1583. +
  1584. +#undef XCHAL_NUM_AREGS
  1585. +#define XCHAL_NUM_AREGS 64
  1586. +
  1587. +#endif /* !XTENSA_CONFIG_H */
  1588. diff --git a/arch/xtensa/crt_arch.h b/arch/xtensa/crt_arch.h
  1589. new file mode 100644
  1590. index 0000000..dc6ddaa
  1591. --- /dev/null
  1592. +++ b/arch/xtensa/crt_arch.h
  1593. @@ -0,0 +1,26 @@
  1594. +__asm__(
  1595. +".begin no-transform\n"
  1596. +".text \n"
  1597. +".global _" START "\n"
  1598. +".global " START "\n"
  1599. +".type _" START ", @function\n"
  1600. +".type " START ", @function\n"
  1601. +"_" START ":\n"
  1602. +"" START ":\n"
  1603. +" call0 2f\n"
  1604. +"1:\n"
  1605. +".align 4\n"
  1606. +".weak _DYNAMIC\n"
  1607. +".hidden _DYNAMIC\n"
  1608. +" .literal .L0, _DYNAMIC\n"
  1609. +" .literal .L1, 1b\n"
  1610. +"2:\n"
  1611. +" mov a6, a1\n"
  1612. +" l32r a7, .L0\n"
  1613. +" l32r a5, .L1\n"
  1614. +" add a7, a7, a0\n"
  1615. +" sub a7, a7, a5\n"
  1616. +" movi a0, 0\n"
  1617. +" call4 " START "_c\n"
  1618. +".end no-transform\n"
  1619. +);
  1620. diff --git a/arch/xtensa/pthread_arch.h b/arch/xtensa/pthread_arch.h
  1621. new file mode 100644
  1622. index 0000000..35c752e
  1623. --- /dev/null
  1624. +++ b/arch/xtensa/pthread_arch.h
  1625. @@ -0,0 +1,11 @@
  1626. +static inline struct pthread *__pthread_self()
  1627. +{
  1628. + register char *tp;
  1629. + __asm__ __volatile__ ("rur %0, threadptr" : "=r" (tp));
  1630. + return (pthread_t)(tp + 8 - sizeof(struct pthread));
  1631. +}
  1632. +
  1633. +#define TLS_ABOVE_TP
  1634. +#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) - 8)
  1635. +
  1636. +#define MC_PC sc_pc
  1637. diff --git a/arch/xtensa/reloc.h b/arch/xtensa/reloc.h
  1638. new file mode 100644
  1639. index 0000000..bae93a5
  1640. --- /dev/null
  1641. +++ b/arch/xtensa/reloc.h
  1642. @@ -0,0 +1,21 @@
  1643. +#include <endian.h>
  1644. +
  1645. +#if __BYTE_ORDER == __BIG_ENDIAN
  1646. +#define ENDIAN_SUFFIX "eb"
  1647. +#else
  1648. +#define ENDIAN_SUFFIX ""
  1649. +#endif
  1650. +
  1651. +#define LDSO_ARCH "xtensa" ENDIAN_SUFFIX
  1652. +
  1653. +#define TPOFF_K 8
  1654. +
  1655. +#define REL_PLT R_XTENSA_JMP_SLOT
  1656. +#define REL_RELATIVE R_XTENSA_RELATIVE
  1657. +#define REL_GOT R_XTENSA_GLOB_DAT
  1658. +#define REL_COPY R_XTENSA_32
  1659. +#define REL_TPOFF R_XTENSA_TLS_TPOFF
  1660. +//#define REL_TLSDESC R_XTENSA_TLSDESC_FN
  1661. +
  1662. +#define CRTJMP(pc,sp) __asm__ __volatile__( \
  1663. + "movsp a1, %1 ; jx %0" : : "a"(pc), "a"(sp) : "memory" )
  1664. diff --git a/arch/xtensa/syscall_arch.h b/arch/xtensa/syscall_arch.h
  1665. new file mode 100644
  1666. index 0000000..380ce17
  1667. --- /dev/null
  1668. +++ b/arch/xtensa/syscall_arch.h
  1669. @@ -0,0 +1,102 @@
  1670. +#define __SYSCALL_LL_E(x) \
  1671. +((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
  1672. +((union { long long ll; long l[2]; }){ .ll = x }).l[1]
  1673. +#define __SYSCALL_LL_O(x) 0, __SYSCALL_LL_E((x))
  1674. +
  1675. +static inline long __syscall0(long n)
  1676. +{
  1677. + register long a2 __asm__("a2") = n;
  1678. +
  1679. + __asm__ __volatile__ ("syscall"
  1680. + : "+&a"(a2)
  1681. + :
  1682. + : "memory");
  1683. + return a2;
  1684. +}
  1685. +
  1686. +static inline long __syscall1(long n, long a)
  1687. +{
  1688. + register long a2 __asm__("a2") = n;
  1689. + register long a6 __asm__("a6") = a;
  1690. +
  1691. + __asm__ __volatile__ ("syscall"
  1692. + : "+&a"(a2)
  1693. + : "a"(a6)
  1694. + : "memory");
  1695. + return a2;
  1696. +}
  1697. +
  1698. +static inline long __syscall2(long n, long a, long b)
  1699. +{
  1700. + register long a2 __asm__("a2") = n;
  1701. + register long a6 __asm__("a6") = a;
  1702. + register long a3 __asm__("a3") = b;
  1703. +
  1704. + __asm__ __volatile__ ("syscall"
  1705. + : "+&a"(a2)
  1706. + : "a"(a6), "a"(a3)
  1707. + : "memory");
  1708. + return a2;
  1709. +}
  1710. +
  1711. +static inline long __syscall3(long n, long a, long b, long c)
  1712. +{
  1713. + register long a2 __asm__("a2") = n;
  1714. + register long a6 __asm__("a6") = a;
  1715. + register long a3 __asm__("a3") = b;
  1716. + register long a4 __asm__("a4") = c;
  1717. +
  1718. + __asm__ __volatile__ ("syscall"
  1719. + : "+&a"(a2)
  1720. + : "a"(a6), "a"(a3), "a"(a4)
  1721. + : "memory");
  1722. + return a2;
  1723. +}
  1724. +
  1725. +static inline long __syscall4(long n, long a, long b, long c, long d)
  1726. +{
  1727. + register long a2 __asm__("a2") = n;
  1728. + register long a6 __asm__("a6") = a;
  1729. + register long a3 __asm__("a3") = b;
  1730. + register long a4 __asm__("a4") = c;
  1731. + register long a5 __asm__("a5") = d;
  1732. +
  1733. + __asm__ __volatile__ ("syscall"
  1734. + : "+&a"(a2)
  1735. + : "a"(a6), "a"(a3), "a"(a4), "a"(a5)
  1736. + : "memory");
  1737. + return a2;
  1738. +}
  1739. +
  1740. +static inline long __syscall5(long n, long a, long b, long c, long d, long e)
  1741. +{
  1742. + register long a2 __asm__("a2") = n;
  1743. + register long a6 __asm__("a6") = a;
  1744. + register long a3 __asm__("a3") = b;
  1745. + register long a4 __asm__("a4") = c;
  1746. + register long a5 __asm__("a5") = d;
  1747. + register long a8 __asm__("a8") = e;
  1748. +
  1749. + __asm__ __volatile__ ("syscall"
  1750. + : "+&a"(a2)
  1751. + : "a"(a6), "a"(a3), "a"(a4), "a"(a5), "a"(a8)
  1752. + : "memory");
  1753. + return a2;
  1754. +}
  1755. +
  1756. +static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
  1757. +{
  1758. + register long a2 __asm__("a2") = n;
  1759. + register long a6 __asm__("a6") = a;
  1760. + register long a3 __asm__("a3") = b;
  1761. + register long a4 __asm__("a4") = c;
  1762. + register long a5 __asm__("a5") = d;
  1763. + register long a8 __asm__("a8") = e;
  1764. + register long a9 __asm__("a9") = f;
  1765. +
  1766. + __asm__ __volatile__ ("syscall"
  1767. + : "+&a"(a2)
  1768. + : "a"(a6), "a"(a3), "a"(a4), "a"(a5), "a"(a8), "a"(a9)
  1769. + : "memory");
  1770. + return a2;
  1771. +}
  1772. diff --git a/configure b/configure
  1773. index 0955ce6..2c56cab 100755
  1774. --- a/configure
  1775. +++ b/configure
  1776. @@ -312,6 +312,7 @@ microblaze*) ARCH=microblaze ;;
  1777. or1k*) ARCH=or1k ;;
  1778. powerpc*) ARCH=powerpc ;;
  1779. sh[1-9bel-]*|sh|superh*) ARCH=sh ;;
  1780. +xtensa*) ARCH=xtensa ;;
  1781. unknown) fail "$0: unable to detect target arch; try $0 --target=..." ;;
  1782. *) fail "$0: unknown or unsupported target \"$target\"" ;;
  1783. esac
  1784. diff --git a/crt/xtensa/crti.s b/crt/xtensa/crti.s
  1785. new file mode 100644
  1786. index 0000000..6565656
  1787. --- /dev/null
  1788. +++ b/crt/xtensa/crti.s
  1789. @@ -0,0 +1,11 @@
  1790. +.section .init
  1791. +.global _init
  1792. +.type _init, @function
  1793. +_init:
  1794. + entry a1, 32
  1795. +
  1796. +.section .fini
  1797. +.global _fini
  1798. +.type _fini, @function
  1799. +_fini:
  1800. + entry a1, 32
  1801. diff --git a/crt/xtensa/crtn.s b/crt/xtensa/crtn.s
  1802. new file mode 100644
  1803. index 0000000..7e9a014
  1804. --- /dev/null
  1805. +++ b/crt/xtensa/crtn.s
  1806. @@ -0,0 +1,5 @@
  1807. +.section .init
  1808. + retw
  1809. +
  1810. +.section .fini
  1811. + retw
  1812. diff --git a/include/elf.h b/include/elf.h
  1813. index 8b3cd3e..8168cf1 100644
  1814. --- a/include/elf.h
  1815. +++ b/include/elf.h
  1816. @@ -2819,6 +2819,64 @@ typedef Elf32_Addr Elf32_Conflict;
  1817. #define R_OR1K_TLS_DTPOFF 33
  1818. #define R_OR1K_TLS_DTPMOD 34
  1819. +
  1820. +#define DT_XTENSA_GOT_LOC_OFF (DT_LOPROC + 0)
  1821. +#define DT_XTENSA_GOT_LOC_SZ (DT_LOPROC + 1)
  1822. +#define DT_XTENSA_NUM 2
  1823. +
  1824. +#define R_XTENSA_NONE 0
  1825. +#define R_XTENSA_32 1
  1826. +#define R_XTENSA_RTLD 2
  1827. +#define R_XTENSA_GLOB_DAT 3
  1828. +#define R_XTENSA_JMP_SLOT 4
  1829. +#define R_XTENSA_RELATIVE 5
  1830. +#define R_XTENSA_PLT 6
  1831. +#define R_XTENSA_OP0 8
  1832. +#define R_XTENSA_OP1 9
  1833. +#define R_XTENSA_OP2 10
  1834. +#define R_XTENSA_ASM_EXPAND 11
  1835. +#define R_XTENSA_ASM_SIMPLIFY 12
  1836. +#define R_XTENSA_GNU_VTINHERIT 15
  1837. +#define R_XTENSA_GNU_VTENTRY 16
  1838. +#define R_XTENSA_DIFF8 17
  1839. +#define R_XTENSA_DIFF16 18
  1840. +#define R_XTENSA_DIFF32 19
  1841. +#define R_XTENSA_SLOT0_OP 20
  1842. +#define R_XTENSA_SLOT1_OP 21
  1843. +#define R_XTENSA_SLOT2_OP 22
  1844. +#define R_XTENSA_SLOT3_OP 23
  1845. +#define R_XTENSA_SLOT4_OP 24
  1846. +#define R_XTENSA_SLOT5_OP 25
  1847. +#define R_XTENSA_SLOT6_OP 26
  1848. +#define R_XTENSA_SLOT7_OP 27
  1849. +#define R_XTENSA_SLOT8_OP 28
  1850. +#define R_XTENSA_SLOT9_OP 29
  1851. +#define R_XTENSA_SLOT10_OP 30
  1852. +#define R_XTENSA_SLOT11_OP 31
  1853. +#define R_XTENSA_SLOT12_OP 32
  1854. +#define R_XTENSA_SLOT13_OP 33
  1855. +#define R_XTENSA_SLOT14_OP 34
  1856. +#define R_XTENSA_SLOT0_ALT 35
  1857. +#define R_XTENSA_SLOT1_ALT 36
  1858. +#define R_XTENSA_SLOT2_ALT 37
  1859. +#define R_XTENSA_SLOT3_ALT 38
  1860. +#define R_XTENSA_SLOT4_ALT 39
  1861. +#define R_XTENSA_SLOT5_ALT 40
  1862. +#define R_XTENSA_SLOT6_ALT 41
  1863. +#define R_XTENSA_SLOT7_ALT 42
  1864. +#define R_XTENSA_SLOT8_ALT 43
  1865. +#define R_XTENSA_SLOT9_ALT 44
  1866. +#define R_XTENSA_SLOT10_ALT 45
  1867. +#define R_XTENSA_SLOT11_ALT 46
  1868. +#define R_XTENSA_SLOT12_ALT 47
  1869. +#define R_XTENSA_SLOT13_ALT 48
  1870. +#define R_XTENSA_SLOT14_ALT 49
  1871. +#define R_XTENSA_TLSDESC_FN 50
  1872. +#define R_XTENSA_TLSDESC_ARG 51
  1873. +#define R_XTENSA_TLS_TPOFF 53
  1874. +
  1875. +#define R_XTENSA_NUM 54
  1876. +
  1877. #ifdef __cplusplus
  1878. }
  1879. #endif
  1880. diff --git a/ldso/dlstart.c b/ldso/dlstart.c
  1881. index 4dbe178..0249937 100644
  1882. --- a/ldso/dlstart.c
  1883. +++ b/ldso/dlstart.c
  1884. @@ -22,6 +22,7 @@ void _dlstart_c(size_t *sp, size_t *dynv)
  1885. {
  1886. size_t i, aux[AUX_CNT], dyn[DYN_CNT];
  1887. size_t *rel, rel_size, base;
  1888. + unsigned long addr = 1;
  1889. int argc = *sp;
  1890. char **argv = (void *)(sp+1);
  1891. @@ -138,7 +139,17 @@ void _dlstart_c(size_t *sp, size_t *dynv)
  1892. for (; rel_size; rel+=3, rel_size-=3*sizeof(size_t)) {
  1893. if (!IS_RELATIVE(rel[1], 0)) continue;
  1894. size_t *rel_addr = (void *)(base + rel[0]);
  1895. - *rel_addr = base + rel[2];
  1896. + if (((unsigned long)rel_addr & -4096) != addr) {
  1897. + addr = (unsigned long)rel_addr & -4096;
  1898. + __asm__ __volatile__ ("movi a2, 82\n\t"
  1899. + "mov a6, %0\n\t"
  1900. + "mov a3, %1\n\t"
  1901. + "mov a4, %2\n\t"
  1902. + "syscall"
  1903. + :: "a"(addr), "a"(4096), "a"(7)
  1904. + : "a2", "a3", "a4", "a6", "memory");
  1905. + }
  1906. + *rel_addr += base + rel[2];
  1907. }
  1908. #endif
  1909. diff --git a/ldso/dynlink.c b/ldso/dynlink.c
  1910. index 87f3b7f..1927097 100644
  1911. --- a/ldso/dynlink.c
  1912. +++ b/ldso/dynlink.c
  1913. @@ -314,6 +314,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
  1914. size_t tls_val;
  1915. size_t addend;
  1916. int skip_relative = 0, reuse_addends = 0, save_slot = 0;
  1917. + unsigned long addr = 1;
  1918. if (dso == &ldso) {
  1919. /* Only ldso's REL table needs addend saving/reuse. */
  1920. @@ -328,6 +329,10 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
  1921. if (type == REL_NONE) continue;
  1922. sym_index = R_SYM(rel[1]);
  1923. reloc_addr = laddr(dso, rel[0]);
  1924. + if (((unsigned long)reloc_addr & -4096) != addr) {
  1925. + addr = (unsigned long)reloc_addr & -4096;
  1926. + mprotect((void *)addr, 4096, 7);
  1927. + }
  1928. if (sym_index) {
  1929. sym = syms + sym_index;
  1930. name = strings + sym->st_name;
  1931. @@ -377,7 +382,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
  1932. *reloc_addr = sym_val + addend;
  1933. break;
  1934. case REL_RELATIVE:
  1935. - *reloc_addr = (size_t)base + addend;
  1936. + *reloc_addr += (size_t)base + addend;
  1937. break;
  1938. case REL_SYM_OR_REL:
  1939. if (sym) *reloc_addr = sym_val + addend;
  1940. @@ -444,6 +449,40 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
  1941. #endif
  1942. }
  1943. break;
  1944. + case R_XTENSA_RTLD:
  1945. + break;
  1946. + case R_XTENSA_TLSDESC_FN:
  1947. + if (runtime && def.dso->tls_id >= static_tls_cnt) {
  1948. + reloc_addr[0] = (size_t)__tlsdesc_dynamic;
  1949. + } else {
  1950. + reloc_addr[0] = (size_t)__tlsdesc_static;
  1951. + }
  1952. + break;
  1953. + case R_XTENSA_TLSDESC_ARG:
  1954. + if (stride<3) addend = reloc_addr[1];
  1955. + if (runtime && def.dso->tls_id >= static_tls_cnt) {
  1956. + struct td_index *new = malloc(sizeof *new);
  1957. + if (!new) {
  1958. + error(
  1959. + "Error relocating %s: cannot allocate TLSDESC for %s",
  1960. + dso->name, sym ? name : "(local)" );
  1961. + longjmp(*rtld_fail, 1);
  1962. + }
  1963. + new->next = dso->td_index;
  1964. + dso->td_index = new;
  1965. + new->args[0] = def.dso->tls_id;
  1966. + new->args[1] = tls_val + addend;
  1967. + reloc_addr[0] = (size_t)new;
  1968. + } else {
  1969. +#ifdef TLS_ABOVE_TP
  1970. + reloc_addr[0] = tls_val + def.dso->tls.offset
  1971. + + TPOFF_K + addend;
  1972. +#else
  1973. + reloc_addr[0] = tls_val - def.dso->tls.offset
  1974. + + addend;
  1975. +#endif
  1976. + }
  1977. + break;
  1978. default:
  1979. error("Error relocating %s: unsupported relocation type %d",
  1980. dso->name, type);
  1981. diff --git a/src/internal/xtensa/syscall.s b/src/internal/xtensa/syscall.s
  1982. new file mode 100644
  1983. index 0000000..6dc584b
  1984. --- /dev/null
  1985. +++ b/src/internal/xtensa/syscall.s
  1986. @@ -0,0 +1,15 @@
  1987. +.global __syscall
  1988. +.hidden __syscall
  1989. +.type __syscall,@function
  1990. +.align 4
  1991. +__syscall:
  1992. + entry a1, 16
  1993. + mov a8, a3
  1994. + mov a3, a4
  1995. + mov a4, a5
  1996. + mov a5, a6
  1997. + mov a6, a8
  1998. + mov a8, a7
  1999. + l32i a9, a1, 16
  2000. + syscall
  2001. + retw
  2002. diff --git a/src/ldso/xtensa/tlsdesc.s b/src/ldso/xtensa/tlsdesc.s
  2003. new file mode 100644
  2004. index 0000000..5fa846d
  2005. --- /dev/null
  2006. +++ b/src/ldso/xtensa/tlsdesc.s
  2007. @@ -0,0 +1,22 @@
  2008. +.global __tlsdesc_static
  2009. +.hidden __tlsdesc_static
  2010. +.type __tlsdesc_static,@function
  2011. +.align 4
  2012. +__tlsdesc_static:
  2013. + entry a1, 16
  2014. + rur a3, threadptr
  2015. + add a2, a2, a3
  2016. + retw
  2017. +
  2018. +.hidden __tls_get_new
  2019. +
  2020. +.global __tlsdesc_dynamic
  2021. +.hidden __tlsdesc_dynamic
  2022. +.type __tlsdesc_dynamic,@function
  2023. +.align 4
  2024. +__tlsdesc_dynamic:
  2025. + entry a1, 16
  2026. + mov a6, a2
  2027. + call4 __tls_get_addr
  2028. + mov a2, a6
  2029. + retw
  2030. diff --git a/src/setjmp/xtensa/longjmp.s b/src/setjmp/xtensa/longjmp.s
  2031. new file mode 100644
  2032. index 0000000..0b49188
  2033. --- /dev/null
  2034. +++ b/src/setjmp/xtensa/longjmp.s
  2035. @@ -0,0 +1,73 @@
  2036. +.global _longjmp
  2037. +.global longjmp
  2038. +.type _longjmp,%function
  2039. +.type longjmp,%function
  2040. +.align 4
  2041. +_longjmp:
  2042. +longjmp:
  2043. + entry a1, 16
  2044. +
  2045. + /* Invalidate all but the current register window. */
  2046. + call4 __window_spill
  2047. +
  2048. + l32i a0, a2, 64
  2049. + addi a7, a1, -16
  2050. + l32i a4, a2, 0
  2051. + l32i a5, a2, 4
  2052. + s32i a4, a7, 0
  2053. + s32i a5, a7, 4
  2054. + l32i a4, a2, 8
  2055. + l32i a5, a2, 12
  2056. + s32i a4, a7, 8
  2057. + s32i a5, a7, 12
  2058. +
  2059. + /* Copy the remaining 0-8 saved registers. */
  2060. + extui a7, a0, 30, 2
  2061. + blti a7, 2, 2f
  2062. + l32i a8, a2, 52 /* a8: SP of 'caller-1' */
  2063. + slli a4, a7, 4
  2064. + sub a6, a8, a4
  2065. + addi a5, a2, 16
  2066. + addi a8, a8, -16 /* a8: end of overflow area */
  2067. +1:
  2068. + l32i a7, a5, 0
  2069. + l32i a4, a5, 4
  2070. + s32i a7, a6, 0
  2071. + s32i a4, a6, 4
  2072. + l32i a7, a5, 8
  2073. + l32i a4, a5, 12
  2074. + s32i a7, a6, 8
  2075. + s32i a4, a6, 12
  2076. + addi a5, a5, 16
  2077. + addi a6, a6, 16
  2078. + bltu a6, a8, 1b
  2079. +2:
  2080. + /* The 4 words saved from the register save area at the target's
  2081. + * sp are copied back to the target procedure's save area. The
  2082. + * only point of this is to prevent a catastrophic failure in
  2083. + * case the contents were moved by an alloca after calling
  2084. + * setjmp. This is a bit paranoid but it doesn't cost much.
  2085. + */
  2086. +
  2087. + l32i a7, a2, 4 /* load the target stack pointer */
  2088. + addi a7, a7, -16 /* find the destination save area */
  2089. + l32i a4, a2, 48
  2090. + l32i a5, a2, 52
  2091. + s32i a4, a7, 0
  2092. + s32i a5, a7, 4
  2093. + l32i a4, a2, 56
  2094. + l32i a5, a2, 60
  2095. + s32i a4, a7, 8
  2096. + s32i a5, a7, 12
  2097. +
  2098. + l32i a4, a2, 68
  2099. + beqz a4, 1f
  2100. +
  2101. + mov a6, a2
  2102. + movi a7, 1
  2103. +.hidden __sigsetjmp_tail
  2104. + call4 __sigsetjmp_tail
  2105. +1:
  2106. + movi a2, 1
  2107. + movnez a2, a3, a3
  2108. + retw
  2109. diff --git a/src/setjmp/xtensa/setjmp.s b/src/setjmp/xtensa/setjmp.s
  2110. new file mode 100644
  2111. index 0000000..1366af0
  2112. --- /dev/null
  2113. +++ b/src/setjmp/xtensa/setjmp.s
  2114. @@ -0,0 +1,13 @@
  2115. +.global __setjmp
  2116. +.global _setjmp
  2117. +.global setjmp
  2118. +.type __setjmp,@function
  2119. +.type _setjmp,@function
  2120. +.type setjmp,@function
  2121. +.align 4
  2122. +__setjmp:
  2123. +_setjmp:
  2124. +setjmp:
  2125. + entry a1, 16
  2126. + movi a3, 0
  2127. + j ___sigsetjmp
  2128. diff --git a/src/signal/xtensa/restore.s b/src/signal/xtensa/restore.s
  2129. new file mode 100644
  2130. index 0000000..a0c5229
  2131. --- /dev/null
  2132. +++ b/src/signal/xtensa/restore.s
  2133. @@ -0,0 +1,10 @@
  2134. +.global __restore
  2135. +.global __restore_rt
  2136. +.type __restore,%function
  2137. +.type __restore_rt,%function
  2138. +.space 1
  2139. +.align 4
  2140. +__restore:
  2141. +__restore_rt:
  2142. + movi a2, 225 # SYS_rt_sigreturn
  2143. + syscall
  2144. diff --git a/src/signal/xtensa/sigsetjmp.s b/src/signal/xtensa/sigsetjmp.s
  2145. new file mode 100644
  2146. index 0000000..825e182
  2147. --- /dev/null
  2148. +++ b/src/signal/xtensa/sigsetjmp.s
  2149. @@ -0,0 +1,69 @@
  2150. +.global sigsetjmp
  2151. +.global __sigsetjmp
  2152. +.global ___sigsetjmp
  2153. +.type sigsetjmp,%function
  2154. +.type __sigsetjmp,%function
  2155. +.type ___sigsetjmp,%function
  2156. +.align 4
  2157. +sigsetjmp:
  2158. +__sigsetjmp:
  2159. + entry a1, 16
  2160. +
  2161. +___sigsetjmp:
  2162. + call4 __window_spill
  2163. +
  2164. + /* Copy the caller registers a0 - a3 at (sp - 16) to jmpbuf. */
  2165. + addi a7, a1, -16
  2166. + l32i a4, a7, 0
  2167. + l32i a5, a7, 4
  2168. + s32i a4, a2, 0
  2169. + s32i a5, a2, 4
  2170. + l32i a4, a7, 8
  2171. + l32i a5, a7, 12
  2172. + s32i a4, a2, 8
  2173. + s32i a5, a2, 12
  2174. +
  2175. + /* Copy the caller registers a4-a8/a12 from the overflow area. */
  2176. + /* Entry moved the SP by 16 bytes, so SP of caller-1 is at (sp + 4). */
  2177. + extui a7, a0, 30, 2
  2178. + blti a7, 2, 2f
  2179. + l32i a8, a1, 4 /* a8: SP of 'caller-1' */
  2180. + slli a4, a7, 4
  2181. + sub a6, a8, a4
  2182. + addi a5, a2, 16
  2183. + addi a8, a8, -16 /* a8: end of overflow area */
  2184. +1:
  2185. + l32i a7, a6, 0
  2186. + l32i a4, a6, 4
  2187. + s32i a7, a5, 0
  2188. + s32i a4, a5, 4
  2189. + l32i a7, a6, 8
  2190. + l32i a4, a6, 12
  2191. + s32i a7, a5, 8
  2192. + s32i a4, a5, 12
  2193. + addi a5, a5, 16
  2194. + addi a6, a6, 16
  2195. + bltu a6, a8, 1b
  2196. +2:
  2197. + /* Copy caller-1 registers a0 - a3 (this is assuming entry a1, 16) */
  2198. + l32i a4, a1, 0
  2199. + l32i a5, a1, 4
  2200. + s32i a4, a2, 48
  2201. + s32i a5, a2, 52
  2202. + l32i a4, a1, 8
  2203. + l32i a5, a1, 12
  2204. + s32i a4, a2, 56
  2205. + s32i a5, a2, 60
  2206. +
  2207. + /* Save the return address, including the window size bits. */
  2208. + s32i a0, a2, 64
  2209. + s32i a3, a2, 68
  2210. + beqz a3, 1f
  2211. +
  2212. + mov a6, a2
  2213. + movi a7, 0
  2214. +.hidden __sigsetjmp_tail
  2215. + call4 __sigsetjmp_tail
  2216. +1:
  2217. + movi a2, 0
  2218. + retw
  2219. diff --git a/src/signal/xtensa/windowspill.s b/src/signal/xtensa/windowspill.s
  2220. new file mode 100644
  2221. index 0000000..7ab7f3d
  2222. --- /dev/null
  2223. +++ b/src/signal/xtensa/windowspill.s
  2224. @@ -0,0 +1,78 @@
  2225. +#include <bits/xtensa-config.h>
  2226. +
  2227. +#ifdef __XTENSA_WINDOWED_ABI__
  2228. +.global __window_spill
  2229. +.type __window_spill, @function
  2230. +.align 4
  2231. +__window_spill:
  2232. + entry a1, 48
  2233. + bbci.l a0, 31, .L4 /* branch if called with call4 */
  2234. + bbsi.l a0, 30, .L12 /* branch if called with call12 */
  2235. +
  2236. + /* Called with call8: touch register NUM_REGS-12 (4/20/52) */
  2237. +.L8:
  2238. +#if XCHAL_NUM_AREGS > 16
  2239. + call12 1f
  2240. + retw
  2241. +
  2242. + .align 4
  2243. +1: _entry a1, 48 /* touch NUM_REGS-24 (x/8/40) */
  2244. +
  2245. +#if XCHAL_NUM_AREGS == 32
  2246. + mov a8, a0
  2247. + retw
  2248. +#else
  2249. + mov a12, a0
  2250. + _entry a1, 48 /* touch NUM_REGS-36 (x/x/28) */
  2251. + mov a12, a0
  2252. + _entry a1, 48 /* touch NUM_REGS-48 (x/x/16) */
  2253. + mov a12, a0
  2254. + _entry a1, 16 /* touch NUM_REGS-60 (x/x/4) */
  2255. +#endif
  2256. +#endif
  2257. + mov a4, a0
  2258. + retw
  2259. +
  2260. + /* Called with call4: touch register NUM_REGS-8 (8/24/56) */
  2261. +.L4:
  2262. +#if XCHAL_NUM_AREGS == 16
  2263. + mov a8, a0
  2264. +#else
  2265. + call12 1f
  2266. + retw
  2267. +
  2268. + .align 4
  2269. +1: _entry a1, 48 /* touch NUM_REGS-20 (x/12/44) */
  2270. + mov a12, a0
  2271. +#if XCHAL_NUM_AREGS > 32
  2272. + _entry a1, 48 /* touch NUM_REGS-32 (x/x/32) */
  2273. + mov a12, a0
  2274. + _entry a1, 48 /* touch NUM_REGS-44 (x/x/20) */
  2275. + mov a12, a0
  2276. + _entry a1, 48 /* touch NUM_REGS-56 (x/x/8) */
  2277. + mov a8, a0
  2278. +#endif
  2279. +#endif
  2280. + retw
  2281. +
  2282. + /* Called with call12: touch register NUM_REGS-16 (x/16/48) */
  2283. +.L12:
  2284. +#if XCHAL_NUM_AREGS > 16
  2285. + call12 1f
  2286. + retw
  2287. +
  2288. + .align 4
  2289. +1: _entry a1, 48 /* touch NUM_REGS-28 (x/4/36) */
  2290. +#if XCHAL_NUM_AREGS == 32
  2291. + mov a4, a0
  2292. +#else
  2293. + mov a12, a0
  2294. + _entry a1, 48 /* touch NUM_REGS-40 (x/x/24) */
  2295. + mov a12, a0
  2296. + _entry a1, 48 /* touch NUM_REGS-52 (x/x/12) */
  2297. + mov a12, a0
  2298. +#endif
  2299. +#endif
  2300. + retw
  2301. +
  2302. +#endif
  2303. diff --git a/src/thread/xtensa/__set_thread_area.s b/src/thread/xtensa/__set_thread_area.s
  2304. new file mode 100644
  2305. index 0000000..4fe97ac
  2306. --- /dev/null
  2307. +++ b/src/thread/xtensa/__set_thread_area.s
  2308. @@ -0,0 +1,8 @@
  2309. +.global __set_thread_area
  2310. +.type __set_thread_area,@function
  2311. +.align 4
  2312. +__set_thread_area:
  2313. + entry a1, 16
  2314. + wur a2, threadptr
  2315. + movi a2, 0
  2316. + retw
  2317. diff --git a/src/thread/xtensa/__unmapself.s b/src/thread/xtensa/__unmapself.s
  2318. new file mode 100644
  2319. index 0000000..c5d8f54
  2320. --- /dev/null
  2321. +++ b/src/thread/xtensa/__unmapself.s
  2322. @@ -0,0 +1,10 @@
  2323. +.global __unmapself
  2324. +.type __unmapself,%function
  2325. +.align 4
  2326. +__unmapself:
  2327. + entry a1, 16
  2328. + mov a6, a2
  2329. + movi a2, 81 # SYS_munmap
  2330. + syscall
  2331. + movi a2, 118 # SYS_exit
  2332. + syscall
  2333. diff --git a/src/thread/xtensa/clone.s b/src/thread/xtensa/clone.s
  2334. new file mode 100644
  2335. index 0000000..c75db81
  2336. --- /dev/null
  2337. +++ b/src/thread/xtensa/clone.s
  2338. @@ -0,0 +1,39 @@
  2339. +// __clone(func, stack, flags, arg, ptid, tls, ctid)
  2340. +// a2, a3, a4, a5, a6, a7, [sp]
  2341. +
  2342. +// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
  2343. +// a2, a6, a3, a4, a5, a8
  2344. +
  2345. +.global __clone
  2346. +.type __clone,%function
  2347. +.align 4
  2348. +__clone:
  2349. + entry a1, 16
  2350. + // align stack and save func,arg
  2351. + srli a3, a3, 4
  2352. + slli a3, a3, 4
  2353. + addi a3, a3, -16
  2354. + s32i a2, a3, 0
  2355. + s32i a5, a3, 4
  2356. +
  2357. + // syscall
  2358. + mov a2, a4
  2359. + mov a4, a6
  2360. + mov a6, a2
  2361. + mov a5, a7
  2362. + l32i a8, a1, 16
  2363. + movi a2, 116 # SYS_clone
  2364. + syscall
  2365. +
  2366. + beqz a2, 1f
  2367. + // parent
  2368. + retw
  2369. +
  2370. + // child
  2371. +1:
  2372. + movi a0, 0
  2373. + l32i a4, a1, 0
  2374. + l32i a6, a1, 4
  2375. + callx4 a4
  2376. + movi a2, 118 # SYS_exit
  2377. + syscall
  2378. diff --git a/src/thread/xtensa/syscall_cp.s b/src/thread/xtensa/syscall_cp.s
  2379. new file mode 100644
  2380. index 0000000..f68df8d
  2381. --- /dev/null
  2382. +++ b/src/thread/xtensa/syscall_cp.s
  2383. @@ -0,0 +1,37 @@
  2384. +// __syscall_cp_asm(&self->cancel, nr, u, v, w, x, y, z)
  2385. +// a2 a3 a4 a5 a6 a7 [sp] [sp+4]
  2386. +
  2387. +// syscall(nr, u, v, w, x, y, z)
  2388. +// a2 a6 a3 a4 a5 a8 a9
  2389. +
  2390. +.global __cp_begin
  2391. +.hidden __cp_begin
  2392. +.global __cp_end
  2393. +.hidden __cp_end
  2394. +.global __cp_cancel
  2395. +.hidden __cp_cancel
  2396. +.hidden __cancel
  2397. +.global __syscall_cp_asm
  2398. +.hidden __syscall_cp_asm
  2399. +.type __syscall_cp_asm,%function
  2400. +.align 4
  2401. +__syscall_cp_asm:
  2402. + entry a1, 16
  2403. +__cp_begin:
  2404. + l32i a2, a2, 0
  2405. + bnez a2, __cp_cancel
  2406. + mov a2, a4
  2407. + mov a4, a6
  2408. + mov a6, a2
  2409. + mov a2, a3
  2410. + mov a3, a5
  2411. + mov a5, a7
  2412. + l32i a8, a1, 16
  2413. + l32i a9, a1, 20
  2414. + syscall
  2415. +__cp_end:
  2416. + retw
  2417. +__cp_cancel:
  2418. + call4 __cancel
  2419. + mov a2, a6
  2420. + retw
  2421. --
  2422. 2.1.4