Sony PlayStation2 Study
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1563 lines
24 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include <syscallnr.h>
  2. .text
  3. .p2align 3
  4. #define SYSCALL(name) \
  5. SYSCALL_SPECIAL(name, name)
  6. #ifdef USE_KMODE
  7. #define SYSCALL_SPECIAL(symbol, name) \
  8. .set push; \
  9. .set noreorder; \
  10. .text; \
  11. .align 4; \
  12. .globl symbol; \
  13. .type symbol,@function; \
  14. .ent symbol,0; \
  15. symbol: j __syscall; \
  16. li $3, __NR_##name;\
  17. nop; \
  18. .end symbol; \
  19. .size symbol,.-symbol; \
  20. .set pop;
  21. #else
  22. #define SYSCALL_SPECIAL(symbol, name) \
  23. .set push; \
  24. .set noreorder; \
  25. .text; \
  26. .align 4; \
  27. .globl symbol; \
  28. .type symbol,@function; \
  29. .ent symbol,0; \
  30. symbol: li $3, __NR_##name;\
  31. syscall; \
  32. jr $31; \
  33. nop; \
  34. .end symbol; \
  35. .size symbol,.-symbol; \
  36. .set pop;
  37. #endif
  38. #ifdef F___syscall
  39. .set push
  40. .set noreorder
  41. .text
  42. .align 4
  43. .globl __syscall
  44. .type __syscall,@function
  45. .ent __syscall,0
  46. __syscall:
  47. mfc0 $2, $12
  48. andi $2, $2, 0x18
  49. beqz $2, _kMode
  50. slt $2, $3, $0
  51. syscall
  52. jr $31
  53. nop
  54. _kMode:
  55. subu $26, $0, $3
  56. movn $3, $26, $2
  57. sll $3, $3, 2
  58. lui $26, 0x8000
  59. lhu $2, 0x02F0($26)
  60. sll $2, $2, 16
  61. lh $26, 0x02F8($26)
  62. add $2, $26
  63. addu $3, $2
  64. lw $26, 0x00($3)
  65. jr $26
  66. nop
  67. .end __syscall
  68. .size __syscall,.-__syscall
  69. .set pop
  70. #endif
  71. #ifdef F_ResetEE
  72. SYSCALL(ResetEE)
  73. #endif
  74. #ifdef F_SetGsCrt
  75. SYSCALL(SetGsCrt)
  76. #endif
  77. #ifdef KERNEL_NO_PATCHES
  78. #ifdef F_Exit
  79. SYSCALL_SPECIAL(Exit, _Exit)
  80. #endif
  81. #ifdef F_LoadExecPS2
  82. SYSCALL_SPECIAL(LoadExecPS2, _LoadExecPS2)
  83. #endif
  84. #ifdef F_ExecPS2
  85. SYSCALL_SPECIAL(ExecPS2, _ExecPS2)
  86. #endif
  87. #else /* KERNEL_NO_PATCHES */
  88. #ifdef F__Exit
  89. SYSCALL(_Exit)
  90. #endif
  91. #ifdef F__LoadExecPS2
  92. SYSCALL(_LoadExecPS2)
  93. #endif
  94. #ifdef F__ExecPS2
  95. SYSCALL(_ExecPS2)
  96. #endif
  97. #endif /* KERNEL_NO_PATCHES */
  98. #ifdef F_RFU009
  99. SYSCALL(RFU009)
  100. #endif
  101. #ifdef F_AddSbusIntcHandler
  102. SYSCALL(AddSbusIntcHandler)
  103. #endif
  104. #ifdef F_RemoveSbusIntcHandler
  105. SYSCALL(RemoveSbusIntcHandler)
  106. #endif
  107. #ifdef F_Interrupt2Iop
  108. SYSCALL(Interrupt2Iop)
  109. #endif
  110. #ifdef F_SetVTLBRefillHandler
  111. SYSCALL(SetVTLBRefillHandler)
  112. #endif
  113. #ifdef F_SetVCommonHandler
  114. SYSCALL(SetVCommonHandler)
  115. #endif
  116. #ifdef F_SetVInterruptHandler
  117. SYSCALL(SetVInterruptHandler)
  118. #endif
  119. #ifdef F_AddIntcHandler
  120. SYSCALL(AddIntcHandler)
  121. #endif
  122. #ifdef F_AddIntcHandler2
  123. SYSCALL(AddIntcHandler2)
  124. #endif
  125. #ifdef F_RemoveIntcHandler
  126. SYSCALL(RemoveIntcHandler)
  127. #endif
  128. #ifdef F_AddDmacHandler
  129. SYSCALL(AddDmacHandler)
  130. #endif
  131. #ifdef F_AddDmacHandler2
  132. SYSCALL(AddDmacHandler2)
  133. #endif
  134. #ifdef F_RemoveDmacHandler
  135. SYSCALL(RemoveDmacHandler)
  136. #endif
  137. #ifdef F__EnableIntc
  138. SYSCALL(_EnableIntc)
  139. #endif
  140. #ifdef F__DisableIntc
  141. SYSCALL(_DisableIntc)
  142. #endif
  143. #ifdef F__EnableDmac
  144. SYSCALL(_EnableDmac)
  145. #endif
  146. #ifdef F__DisableDmac
  147. SYSCALL(_DisableDmac)
  148. #endif
  149. #ifdef F__SetAlarm
  150. SYSCALL(_SetAlarm)
  151. #endif
  152. #ifdef F_SetAlarm
  153. #ifndef KERNEL_NO_PATCHES
  154. SYSCALL(SetAlarm)
  155. #endif
  156. #endif
  157. #ifdef F__ReleaseAlarm
  158. SYSCALL(_ReleaseAlarm)
  159. #endif
  160. #ifndef KERNEL_NO_PATCHES
  161. #ifdef F_ReleaseAlarm
  162. SYSCALL(ReleaseAlarm)
  163. #endif
  164. #endif
  165. #ifdef F__iEnableIntc
  166. SYSCALL(_iEnableIntc)
  167. #endif
  168. #ifdef F__iDisableIntc
  169. SYSCALL(_iDisableIntc)
  170. #endif
  171. #ifdef F__iEnableDmac
  172. SYSCALL(_iEnableDmac)
  173. #endif
  174. #ifdef F__iDisableDmac
  175. SYSCALL(_iDisableDmac)
  176. #endif
  177. #ifdef F__iSetAlarm
  178. SYSCALL(_iSetAlarm)
  179. #endif
  180. #ifndef KERNEL_NO_PATCHES
  181. #ifdef F_iSetAlarm
  182. SYSCALL(iSetAlarm)
  183. #endif
  184. #endif
  185. #ifdef F__iReleaseAlarm
  186. SYSCALL(_iReleaseAlarm)
  187. #endif
  188. #ifndef KERNEL_NO_PATCHES
  189. #ifdef F_iReleaseAlarm
  190. SYSCALL(iReleaseAlarm)
  191. #endif
  192. #endif
  193. #ifdef F_CreateThread
  194. SYSCALL(CreateThread)
  195. #endif
  196. #ifdef F_DeleteThread
  197. SYSCALL(DeleteThread)
  198. #endif
  199. #ifdef F_StartThread
  200. SYSCALL(StartThread)
  201. #endif
  202. #ifdef F_ExitThread
  203. SYSCALL(ExitThread)
  204. #endif
  205. #ifdef F_ExitDeleteThread
  206. SYSCALL(ExitDeleteThread)
  207. #endif
  208. #ifdef F_TerminateThread
  209. SYSCALL(TerminateThread)
  210. #endif
  211. #ifdef F_iTerminateThread
  212. SYSCALL(iTerminateThread)
  213. #endif
  214. #ifdef F_DisableDispatchThread
  215. SYSCALL(DisableDispatchThread)
  216. #endif
  217. #ifdef F_EnableDispatchThread
  218. SYSCALL(EnableDispatchThread)
  219. #endif
  220. #ifdef F_ChangeThreadPriority
  221. SYSCALL(ChangeThreadPriority)
  222. #endif
  223. #ifdef F_iChangeThreadPriority
  224. SYSCALL(iChangeThreadPriority)
  225. #endif
  226. #ifdef F_RotateThreadReadyQueue
  227. SYSCALL(RotateThreadReadyQueue)
  228. #endif
  229. #ifdef KERNEL_NO_PATCHES
  230. #ifdef F_iRotateThreadReadyQueue
  231. SYSCALL_SPECIAL(iRotateThreadReadyQueue, _iRotateThreadReadyQueue)
  232. #endif
  233. #else /* KERNEL_NO_PATCHES */
  234. #ifdef F__iRotateThreadReadyQueue
  235. SYSCALL(_iRotateThreadReadyQueue)
  236. #endif
  237. #endif /* KERNEL_NO_PATCHES */
  238. #ifdef F_ReleaseWaitThread
  239. SYSCALL(ReleaseWaitThread)
  240. #endif
  241. #ifdef F_iReleaseWaitThread
  242. SYSCALL(iReleaseWaitThread)
  243. #endif
  244. #ifdef F_GetThreadId
  245. SYSCALL(GetThreadId)
  246. #endif
  247. #ifdef F__iGetThreadId
  248. SYSCALL(_iGetThreadId)
  249. #endif
  250. #ifdef F_ReferThreadStatus
  251. SYSCALL(ReferThreadStatus)
  252. #endif
  253. #ifdef F_iReferThreadStatus
  254. SYSCALL(iReferThreadStatus)
  255. #endif
  256. #ifdef F_SleepThread
  257. SYSCALL(SleepThread)
  258. #endif
  259. #ifdef F_WakeupThread
  260. SYSCALL(WakeupThread)
  261. #endif
  262. #ifdef KERNEL_NO_PATCHES
  263. #ifdef F_iWakeupThread
  264. SYSCALL_SPECIAL(iWakeupThread, _iWakeupThread)
  265. #endif
  266. #else /* KERNEL_NO_PATCHES */
  267. #ifdef F__iWakeupThread
  268. SYSCALL(_iWakeupThread)
  269. #endif
  270. #endif /* KERNEL_NO_PATCHES */
  271. #ifdef F_CancelWakeupThread
  272. SYSCALL(CancelWakeupThread)
  273. #endif
  274. #ifdef F_iCancelWakeupThread
  275. SYSCALL(iCancelWakeupThread)
  276. #endif
  277. #ifdef F_SuspendThread
  278. SYSCALL(SuspendThread)
  279. #endif
  280. #ifdef KERNEL_NO_PATCHES
  281. #ifdef F_iSuspendThread
  282. SYSCALL_SPECIAL(iSuspendThread, _iSuspendThread)
  283. #endif
  284. #else /* KERNEL_NO_PATCHES */
  285. #ifdef F__iSuspendThread
  286. SYSCALL(_iSuspendThread)
  287. #endif
  288. #endif /* KERNEL_NO_PATCHES */
  289. #ifdef F_ResumeThread
  290. SYSCALL(ResumeThread)
  291. #endif
  292. #ifdef F_iResumeThread
  293. SYSCALL(iResumeThread)
  294. #endif
  295. #ifdef F_RFU059
  296. SYSCALL(RFU059)
  297. #endif
  298. #ifdef F_RFU060
  299. SYSCALL(RFU060)
  300. #endif
  301. #ifdef F_SetupThread
  302. SYSCALL(SetupThread)
  303. #endif
  304. #ifdef F_RFU061
  305. SYSCALL(RFU061)
  306. #endif
  307. #ifdef F_SetupHeap
  308. SYSCALL(SetupHeap)
  309. #endif
  310. #ifdef F_EndOfHeap
  311. SYSCALL(EndOfHeap)
  312. #endif
  313. #ifdef F_CreateSema
  314. SYSCALL(CreateSema)
  315. #endif
  316. #ifdef F_DeleteSema
  317. SYSCALL(DeleteSema)
  318. #endif
  319. #ifdef F_SignalSema
  320. SYSCALL(SignalSema)
  321. #endif
  322. #ifdef F_iSignalSema
  323. SYSCALL(iSignalSema)
  324. #endif
  325. #ifdef F_WaitSema
  326. SYSCALL(WaitSema)
  327. #endif
  328. #ifdef F_PollSema
  329. SYSCALL(PollSema)
  330. #endif
  331. #ifdef F_iPollSema
  332. SYSCALL(iPollSema)
  333. #endif
  334. #ifdef F_ReferSemaStatus
  335. SYSCALL(ReferSemaStatus)
  336. #endif
  337. #ifdef F_iReferSemaStatus
  338. SYSCALL(iReferSemaStatus)
  339. #endif
  340. #ifdef F_iDeleteSema
  341. SYSCALL(iDeleteSema)
  342. #endif
  343. #ifdef F_SetOsdConfigParam
  344. SYSCALL(SetOsdConfigParam)
  345. #endif
  346. #ifdef F_GetOsdConfigParam
  347. SYSCALL(GetOsdConfigParam)
  348. #endif
  349. #ifdef F_GetGsHParam
  350. SYSCALL(GetGsHParam)
  351. #endif
  352. #ifdef F_GetGsVParam
  353. SYSCALL(GetGsVParam)
  354. #endif
  355. #ifdef F_SetGsHParam
  356. SYSCALL(SetGsHParam)
  357. #endif
  358. #ifdef F_SetGsVParam
  359. SYSCALL(SetGsVParam)
  360. #endif
  361. #ifdef F_CreateEventFlag
  362. SYSCALL(CreateEventFlag)
  363. #endif
  364. #ifdef F_DeleteEventFlag
  365. SYSCALL(DeleteEventFlag)
  366. #endif
  367. #ifdef F_SetEventFlag
  368. SYSCALL(SetEventFlag)
  369. #endif
  370. #ifdef F_iSetEventFlag
  371. SYSCALL(iSetEventFlag)
  372. #endif
  373. #ifndef KERNEL_NO_PATCHES
  374. #ifdef F_PutTLBEntry
  375. SYSCALL(PutTLBEntry)
  376. #endif
  377. #ifdef F_iPutTLBEntry
  378. SYSCALL(iPutTLBEntry)
  379. #endif
  380. #ifdef F__SetTLBEntry
  381. SYSCALL(_SetTLBEntry)
  382. #endif
  383. #ifdef F_iSetTLBEntry
  384. SYSCALL(iSetTLBEntry)
  385. #endif
  386. #ifdef F_GetTLBEntry
  387. SYSCALL(GetTLBEntry)
  388. #endif
  389. #ifdef F_iGetTLBEntry
  390. SYSCALL(iGetTLBEntry)
  391. #endif
  392. #ifdef F_ProbeTLBEntry
  393. SYSCALL(ProbeTLBEntry)
  394. #endif
  395. #ifdef F_iProbeTLBEntry
  396. SYSCALL(iProbeTLBEntry)
  397. #endif
  398. #ifdef F_ExpandScratchPad
  399. SYSCALL(ExpandScratchPad)
  400. #endif
  401. #endif /* KERNEL_NO_PATCHES */
  402. #ifdef F_EnableIntcHandler
  403. SYSCALL(EnableIntcHandler)
  404. #endif
  405. #ifdef F_iEnableIntcHandler
  406. SYSCALL(iEnableIntcHandler)
  407. #endif
  408. #ifdef F_DisableIntcHandler
  409. SYSCALL(DisableIntcHandler)
  410. #endif
  411. #ifdef F_iDisableIntcHandler
  412. SYSCALL(iDisableIntcHandler)
  413. #endif
  414. #ifdef F_EnableDmacHandler
  415. SYSCALL(EnableDmacHandler)
  416. #endif
  417. #ifdef F_iEnableDmacHandler
  418. SYSCALL(iEnableDmacHandler)
  419. #endif
  420. #ifdef F_DisableDmacHandler
  421. SYSCALL(DisableDmacHandler)
  422. #endif
  423. #ifdef F_iDisableDmacHandler
  424. SYSCALL(iDisableDmacHandler)
  425. #endif
  426. #ifdef F_KSeg0
  427. SYSCALL(KSeg0)
  428. #endif
  429. #ifdef F_EnableCache
  430. SYSCALL(EnableCache)
  431. #endif
  432. #ifdef F_DisableCache
  433. SYSCALL(DisableCache)
  434. #endif
  435. #ifdef F_GetCop0
  436. SYSCALL(GetCop0)
  437. #endif
  438. #ifdef F_FlushCache
  439. SYSCALL(FlushCache)
  440. #endif
  441. #ifdef F_CpuConfig
  442. SYSCALL(CpuConfig)
  443. #endif
  444. #ifdef F_iGetCop0
  445. SYSCALL(iGetCop0)
  446. #endif
  447. #ifdef F_iFlushCache
  448. SYSCALL(iFlushCache)
  449. #endif
  450. #ifdef F_RFU105
  451. SYSCALL(RFU105)
  452. #endif
  453. #ifdef F_iCpuConfig
  454. SYSCALL(iCpuConfig)
  455. #endif
  456. #ifdef F_SifStopDma
  457. SYSCALL(SifStopDma)
  458. #endif
  459. #ifdef F_SetCPUTimerHandler
  460. SYSCALL(SetCPUTimerHandler)
  461. #endif
  462. #ifdef F_SetCPUTimer
  463. SYSCALL(SetCPUTimer)
  464. #endif
  465. #ifdef F_SetOsdConfigParam2
  466. SYSCALL(SetOsdConfigParam2)
  467. #endif
  468. #ifdef F_GetOsdConfigParam2
  469. SYSCALL(GetOsdConfigParam2)
  470. #endif
  471. #ifdef F_GsGetIMR
  472. SYSCALL(GsGetIMR)
  473. #endif
  474. #ifdef F_iGsGetIMR
  475. SYSCALL(iGsGetIMR)
  476. #endif
  477. #ifdef F_GsPutIMR
  478. SYSCALL(GsPutIMR)
  479. #endif
  480. #ifdef F_iGsPutIMR
  481. SYSCALL(iGsPutIMR)
  482. #endif
  483. #ifdef F_SetPgifHandler
  484. SYSCALL(SetPgifHandler)
  485. #endif
  486. #ifdef F_SetVSyncFlag
  487. SYSCALL(SetVSyncFlag)
  488. #endif
  489. #ifdef F_SetSyscall
  490. SYSCALL(SetSyscall)
  491. #endif
  492. //#ifdef F_print
  493. //SYSCALL(_print)
  494. //#endif
  495. #ifdef F_SifDmaStat
  496. SYSCALL(SifDmaStat)
  497. #endif
  498. #ifdef F_iSifDmaStat
  499. SYSCALL(iSifDmaStat)
  500. #endif
  501. #ifdef F_SifSetDma
  502. SYSCALL(SifSetDma)
  503. #endif
  504. #ifdef F_iSifSetDma
  505. SYSCALL(iSifSetDma)
  506. #endif
  507. #ifdef F_SifSetDChain
  508. SYSCALL(SifSetDChain)
  509. #endif
  510. #ifdef F_iSifSetDChain
  511. SYSCALL(iSifSetDChain)
  512. #endif
  513. #ifdef F_SifSetReg
  514. SYSCALL(SifSetReg)
  515. #endif
  516. #ifdef F_SifGetReg
  517. SYSCALL(SifGetReg)
  518. #endif
  519. #ifdef KERNEL_NO_PATCHES
  520. #ifdef F_ExecOSD
  521. SYSCALL_SPECIAL(ExecOSD, _ExecOSD)
  522. #endif
  523. #else /* KERNEL_NO_PATCHES */
  524. #ifdef F__ExecOSD
  525. SYSCALL(_ExecOSD)
  526. #endif
  527. #endif /* KERNEL_NO_PATCHES */
  528. #ifdef F_Deci2Call
  529. SYSCALL(Deci2Call)
  530. #endif
  531. #ifdef F_PSMode
  532. SYSCALL(PSMode)
  533. #endif
  534. #ifdef F_MachineType
  535. SYSCALL(MachineType)
  536. #endif
  537. #ifdef F_GetMemorySize
  538. SYSCALL(GetMemorySize)
  539. #endif
  540. #ifdef F__GetGsDxDyOffset
  541. SYSCALL(_GetGsDxDyOffset)
  542. #endif
  543. #ifdef F__InitTLB
  544. SYSCALL(_InitTLB)
  545. #endif
  546. #ifdef F_SetMemoryMode
  547. SYSCALL(SetMemoryMode)
  548. #endif
  549. #ifdef F_GPfuncs
  550. .text
  551. .align 2
  552. .globl ChangeGP
  553. .ent ChangeGP
  554. ChangeGP:
  555. move $v0, $gp
  556. jr $ra
  557. move $gp, $a0
  558. .end ChangeGP
  559. .globl SetGP
  560. .ent SetGP
  561. SetGP:
  562. jr $ra
  563. move $gp, $a0
  564. .end SetGP
  565. .globl GetGP
  566. .ent GetGP
  567. GetGP:
  568. jr $ra
  569. move $v0, $gp
  570. .end GetGP
  571. #endif
  572. #ifdef F_SifWriteBackDCache
  573. .globl SifWriteBackDCache
  574. .ent SifWriteBackDCache
  575. .set noreorder
  576. SifWriteBackDCache: /* DHWBIN: Data cache Hit WriteBack INvalidate. */
  577. lui $25, 0xffff
  578. ori $25, $25, 0xffc0
  579. blez $5, last
  580. addu $10, $4, $5
  581. and $8, $4, $25
  582. addiu $10, $10, -1
  583. and $9, $10, $25
  584. subu $10, $9, $8
  585. srl $11, $10, 0x6
  586. addiu $11, $11, 1
  587. andi $9, $11, 0x7
  588. beqz $9, eight
  589. srl $10, $11, 0x3
  590. loop1:
  591. sync
  592. cache 0x18, 0($8)
  593. sync
  594. addiu $9, $9, -1
  595. nop
  596. bgtz $9, loop1
  597. addiu $8, $8, 64
  598. eight:
  599. beqz $10, last
  600. loop8:
  601. addiu $10, $10, -1
  602. sync
  603. cache 0x18, 0($8)
  604. sync
  605. cache 0x18, 64($8)
  606. sync
  607. cache 0x18, 128($8)
  608. sync
  609. cache 0x18, 192($8)
  610. sync
  611. cache 0x18, 256($8)
  612. sync
  613. cache 0x18, 320($8)
  614. sync
  615. cache 0x18, 384($8)
  616. sync
  617. cache 0x18, 448($8)
  618. sync
  619. bgtz $10, loop8
  620. addiu $8, $8, 512
  621. last:
  622. jr $31
  623. nop
  624. .end SifWriteBackDCache
  625. #endif
  626. #define DXWBIN 0x14 /* Data cache: indeX WriteBack INvalidate. */
  627. #define DXIN 0x16 /* Data cache: indeX INvalidate. */
  628. #define opDCache(name, op) \
  629. .set push; \
  630. .set noreorder; \
  631. .set nomacro; \
  632. .text; \
  633. .p2align 3; \
  634. .globl name; \
  635. .type name,@function; \
  636. .ent name, 0; \
  637. name: lui $7, 0xffff; \
  638. daddu $6, $0, $0; \
  639. ori $7, 0xf000; \
  640. nop; \
  641. 1: sync; \
  642. cache 0x10, 0($6); \
  643. sync; \
  644. mfc0 $2, $28; \
  645. and $2, $7; \
  646. addu $2, $6; \
  647. sltu $3, $5, $2; \
  648. sltu $2, $4; \
  649. bnez $2, 2f; \
  650. nop; \
  651. bnez $3, 2f; \
  652. nop; \
  653. sync; \
  654. cache op, 0($6); \
  655. sync; \
  656. 2: sync; \
  657. cache 0x10, 1($6); \
  658. sync; \
  659. mfc0 $2, $28; \
  660. and $2, $7; \
  661. addu $2, $6; \
  662. sltu $3, $5, $2; \
  663. sltu $2, $4; \
  664. bnez $2, 3f; \
  665. nop; \
  666. bnez $3, 3f; \
  667. nop; \
  668. sync; \
  669. cache op, 1($6); \
  670. sync; \
  671. 3: sync; \
  672. addiu $6, 64; \
  673. slti $2, $6, 4096; \
  674. bnez $2, 1b; \
  675. nop; \
  676. jr $31; \
  677. nop; \
  678. .end name; \
  679. .size name,.-name; \
  680. .set pop;
  681. #ifdef F__SyncDCache
  682. opDCache(_SyncDCache, DXWBIN)
  683. #endif
  684. #ifdef F__InvalidDCache
  685. opDCache(_InvalidDCache, DXIN)
  686. #endif
  687. #ifdef F___errno
  688. /* This is needed in case we are linked against libm (the math library) but
  689. not libc. */
  690. .globl __errno
  691. .ent __errno
  692. .weak __errno
  693. __errno:
  694. la $2, errno
  695. jr $31
  696. nop
  697. .end __errno
  698. #endif
  699. #ifdef F_errno
  700. /* New applications compiled against ps2lib that use errno will resolve to
  701. this, while existing newlib applications will resolve to __errno. */
  702. .globl errno
  703. .weak errno
  704. .data
  705. errno:
  706. .space 4
  707. #endif
  708. #ifdef F_strlen
  709. /* Assembler version of strlen that uses quadword instructions.
  710. Jeff Johnston, Cygnus Solutions, Feb 10/1999.
  711. ============================================================
  712. Copyright (C) 1999 by Cygnus Solutions. All rights reserved.
  713. Permission to use, copy, modify, and distribute this
  714. software is freely granted, provided that this notice
  715. is preserved.
  716. ============================================================ */
  717. .text
  718. .align 2
  719. .globl strlen
  720. .text
  721. .ent strlen
  722. .weak strlen
  723. strlen:
  724. .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
  725. .mask 0x00000000,0
  726. .fmask 0x00000000,0
  727. #ifndef __OPTIMIZE_SIZE__
  728. /* check if src is quadword aligned, doubleword aligned, or neither in which case
  729. perform checking for null terminator one byte at a time. */
  730. andi $2,$4,0x7
  731. .set noreorder
  732. .set nomacro
  733. bne $2,$0,$L15
  734. move $7,$4
  735. .set macro
  736. .set reorder
  737. andi $3,$4,0xf
  738. dli $2,0x0101010101010101
  739. .set noreorder
  740. .set nomacro
  741. bne $3,$0,$L12
  742. move $5,$4
  743. .set macro
  744. .set reorder
  745. /* src is quadword aligned. Load a quadword at a time and check for null terminator.
  746. If null terminator is found, go and find exact position by looking at each byte
  747. of the last quadword. Otherwise, continue to next quadword and keep searching. */
  748. lq $3,0($5)
  749. pcpyld $8,$2,$2
  750. dli $4,0x8080808080808080
  751. psubb $2,$3,$8
  752. pnor $3,$0,$3
  753. pcpyld $9,$4,$4
  754. pand $2,$2,$3
  755. pand $2,$2,$9
  756. pcpyud $3,$2,$8
  757. or $6,$3,$2
  758. .set noreorder
  759. .set nomacro
  760. bnel $6,$0,$L15
  761. move $4,$5
  762. .set macro
  763. .set reorder
  764. addu $5,$5,16
  765. $L14:
  766. lq $2,0($5)
  767. #nop
  768. pnor $3,$0,$2
  769. psubb $2,$2,$8
  770. pand $2,$2,$3
  771. pand $4,$2,$9
  772. pcpyud $3,$4,$6
  773. or $3,$3,$4
  774. .set noreorder
  775. .set nomacro
  776. beql $3,$0,$L14
  777. addu $5,$5,16
  778. .set macro
  779. .set reorder
  780. .set noreorder
  781. .set nomacro
  782. b $L15
  783. move $4,$5
  784. .set macro
  785. .set reorder
  786. /* src is doubleword aligned. Load a doubleword at a time and check for null terminator.
  787. If null terminator is found, go and find exact position by looking at each byte
  788. of the last doubleword. Otherwise, continue to next doubleword and keep searching. */
  789. $L12:
  790. ld $3,0($5)
  791. dli $4,0x8080808080808080
  792. dsubu $2,$3,$2
  793. nor $3,$0,$3
  794. and $2,$2,$3
  795. and $2,$2,$4
  796. .set noreorder
  797. .set nomacro
  798. bnel $2,$0,$L15
  799. move $4,$5
  800. .set macro
  801. .set reorder
  802. dli $6,0x0101010101010101
  803. addu $5,$5,8
  804. $L16:
  805. ld $2,0($5)
  806. #nop
  807. nor $3,$0,$2
  808. dsubu $2,$2,$6
  809. and $2,$2,$3
  810. and $2,$2,$4
  811. .set noreorder
  812. .set nomacro
  813. beql $2,$0,$L16
  814. addu $5,$5,8
  815. .set macro
  816. .set reorder
  817. move $4,$5
  818. #else /* __OPTIMIZE_SIZE__ */
  819. move $7,$4
  820. #endif /* __OPTIMIZE_SIZE__ */
  821. /* search a byte at a time for null terminator and then calculate length by subtracting
  822. original string address from null terminator address. */
  823. $L9:
  824. $L15:
  825. .set noreorder
  826. .set nomacro
  827. lb $2,0($4)
  828. #nop
  829. beq $2,$0,1f
  830. addu $4,$4,1
  831. lb $2,0($4)
  832. #nop
  833. bne $2,$0,$L9
  834. addu $4,$4,1
  835. 1:
  836. subu $4,$4,1
  837. .set macro
  838. .set reorder
  839. .set noreorder
  840. .set nomacro
  841. j $31
  842. subu $2,$4,$7
  843. .set macro
  844. .set reorder
  845. .end strlen
  846. #endif
  847. #ifdef F_strncpy
  848. /* Assembler version of strncpy using quadword instructions
  849. Jeff Johnston, Cygnus Solutions, Feb 10/1999.
  850. ============================================================
  851. Copyright (C) 1999 by Cygnus Solutions. All rights reserved.
  852. Permission to use, copy, modify, and distribute this
  853. software is freely granted, provided that this notice
  854. is preserved.
  855. ============================================================ */
  856. .text
  857. .p2align 3
  858. .globl strncpy
  859. .text
  860. .ent strncpy
  861. .weak strncpy
  862. strncpy:
  863. .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
  864. .mask 0x00000000,0
  865. .fmask 0x00000000,0
  866. move $8,$4
  867. #ifndef __OPTIMIZE_SIZE__
  868. /* check if src and dest are doubleword aligned, quadword aligned, or neither in which
  869. case copy byte by byte */
  870. or $7,$5,$4
  871. li $10,0x10
  872. andi $2,$7,0x7
  873. li $9,0x8
  874. .set noreorder
  875. .set nomacro
  876. bne $2,$0,$L9
  877. andi $2,$7,0xf
  878. .set macro
  879. .set reorder
  880. movz $9,$10,$2
  881. .set noreorder
  882. .set nomacro
  883. bne $2,$0,$L17
  884. sltu $2,$6,$9
  885. .set macro
  886. .set reorder
  887. /* src and dest are quadword aligned. Check a quadword at a time looking for a
  888. null terminator or until the nth byte is reached. Otherwise, copy the
  889. quadword to dest and continue looping checking quadwords. Once a null
  890. terminator is found or n is < 16 go copy a byte at a time. */
  891. $L31:
  892. bne $2,$0,$L9
  893. dli $7,0x0101010101010101
  894. lq $3,0($5)
  895. pcpyld $9,$7,$7
  896. pnor $3,$0,$3
  897. dli $7,0x8080808080808080
  898. psubb $2,$3,$9
  899. pcpyld $10,$7,$7
  900. pand $2,$2,$3
  901. pand $2,$2,$10
  902. pcpyud $3,$2,$4
  903. or $3,$2,$3
  904. .set noreorder
  905. .set nomacro
  906. bne $3,$0,$L5
  907. move $7,$8
  908. .set macro
  909. .set reorder
  910. lq $3,0($5)
  911. .p2align 3
  912. $L39:
  913. addu $6,$6,-16
  914. addu $5,$5,16
  915. sltu $2,$6,16
  916. sq $3,0($7)
  917. .set noreorder
  918. .set nomacro
  919. bne $2,$0,$L5
  920. addu $7,$7,16
  921. .set macro
  922. .set reorder
  923. lq $2,0($5)
  924. #nop
  925. pnor $3,$0,$2
  926. psubb $2,$2,$9
  927. pand $2,$2,$3
  928. pand $2,$2,$10
  929. pcpyud $3,$2,$4
  930. or $2,$2,$3
  931. .set noreorder
  932. .set nomacro
  933. beql $2,$0,$L19
  934. lq $3,0($5)
  935. b $L9
  936. move $4,$7
  937. .set macro
  938. .set reorder
  939. /* src and dest are quadword aligned. Check a quadword at a time looking for a
  940. null terminator or until the nth byte is reached. Otherwise, copy the
  941. quadword to dest and continue looping checking quadwords. Once a null
  942. terminator is found or n is < 16 go copy a byte at a time. */
  943. $L17:
  944. bne $2,$0,$L9
  945. ld $3,0($5)
  946. dli $9,0x0101010101010101
  947. dli $10,0x8080808080808080
  948. dsubu $2,$3,$9
  949. nor $3,$0,$3
  950. and $2,$2,$3
  951. and $2,$2,$10
  952. .set noreorder
  953. .set nomacro
  954. bne $2,$0,$L5
  955. move $7,$8
  956. .set macro
  957. .set reorder
  958. ld $3,0($5)
  959. .p2align 3
  960. $L19:
  961. addu $6,$6,-8
  962. addu $5,$5,8
  963. sltu $2,$6,8
  964. sd $3,0($7)
  965. .set noreorder
  966. .set nomacro
  967. bne $2,$0,$L5
  968. addu $7,$7,8
  969. .set macro
  970. .set reorder
  971. ld $2,0($5)
  972. #nop
  973. nor $3,$0,$2
  974. dsubu $2,$2,$9
  975. and $2,$2,$3
  976. and $2,$2,$10
  977. .set noreorder
  978. .set nomacro
  979. beql $2,$0,$L19
  980. ld $3,0($5)
  981. .set macro
  982. .set reorder
  983. $L5:
  984. move $4,$7
  985. #endif /* !__OPTIMIZE_SIZE__ */
  986. /* check a byte at a time looking for either the null terminator or until n bytes are
  987. copied. If the null terminator is found and n is not reached yet, copy null
  988. bytes until n is reached. */
  989. .p2align 3
  990. $L9:
  991. .set noreorder
  992. .set nomacro
  993. beq $6,$0,$L18
  994. move $2,$6
  995. .set macro
  996. .set reorder
  997. lbu $2,0($5)
  998. addu $6,$6,-1
  999. addu $5,$5,1
  1000. sb $2,0($4)
  1001. sll $2,$2,24
  1002. .set noreorder
  1003. .set nomacro
  1004. bne $2,$0,$L9
  1005. addu $4,$4,1
  1006. .set macro
  1007. .set reorder
  1008. move $2,$6
  1009. $L20:
  1010. .set noreorder
  1011. .set nomacro
  1012. beq $2,$0,$L18
  1013. addu $6,$6,-1
  1014. .set macro
  1015. .set reorder
  1016. .p2align 3
  1017. $L16:
  1018. sb $0,0($4)
  1019. move $2,$6
  1020. addu $4,$4,1
  1021. .set noreorder
  1022. .set nomacro
  1023. nop
  1024. nop
  1025. bne $2,$0,$L16
  1026. addu $6,$6,-1
  1027. .set macro
  1028. .set reorder
  1029. $L18:
  1030. .set noreorder
  1031. .set nomacro
  1032. j $31
  1033. move $2,$8
  1034. .set macro
  1035. .set reorder
  1036. .end strncpy
  1037. #endif
  1038. #ifdef F_memcpy
  1039. /* Assembler version of memcpy using quadword instructions.
  1040. Jeff Johnston, Cygnus Solutions, Feb 10/1999.
  1041. ============================================================
  1042. Copyright (C) 1999 by Cygnus Solutions. All rights reserved.
  1043. Permission to use, copy, modify, and distribute this
  1044. software is freely granted, provided that this notice
  1045. is preserved.
  1046. ============================================================ */
  1047. .text
  1048. .align 2
  1049. .globl memcpy
  1050. .text
  1051. .ent memcpy
  1052. .weak memcpy
  1053. memcpy:
  1054. .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
  1055. .mask 0x00000000,0
  1056. .fmask 0x00000000,0
  1057. move $8,$4
  1058. #ifndef __OPTIMIZE_SIZE__
  1059. /* if bytes to move are < 32 or src or dest are not quadword aligned, jump to
  1060. code that moves one byte at a time */
  1061. sltu $2,$6,32
  1062. .set noreorder
  1063. .set nomacro
  1064. bne $2,$0,$L2
  1065. move $3,$8
  1066. .set macro
  1067. .set reorder
  1068. or $2,$5,$8
  1069. andi $2,$2,0xF
  1070. .set noreorder
  1071. .set nomacro
  1072. bnel $2,$0,$L20
  1073. addu $6,$6,-1
  1074. .set macro
  1075. .set reorder
  1076. move $7,$8
  1077. /* while remainder to move is >= 32 bytes, use LQ/SQ quadword instructions
  1078. to move data */
  1079. $L5:
  1080. lq $3,0($5)
  1081. addu $6,$6,-32
  1082. addu $5,$5,16
  1083. sltu $4,$6,32
  1084. sq $3,0($7)
  1085. addu $7,$7,16
  1086. lq $2,0($5)
  1087. addu $5,$5,16
  1088. sq $2,0($7)
  1089. .set noreorder
  1090. .set nomacro
  1091. beq $4,$0,$L5
  1092. addu $7,$7,16
  1093. .set macro
  1094. .set reorder
  1095. sltu $2,$6,8
  1096. .set noreorder
  1097. .set nomacro
  1098. bne $2,$0,$L2
  1099. move $3,$7
  1100. .set macro
  1101. .set reorder
  1102. /* while remainder to move is >= 8 bytes, use LD/SD doubleword instructions
  1103. to move data */
  1104. $L9:
  1105. ld $3,0($5)
  1106. addu $6,$6,-8
  1107. addu $5,$5,8
  1108. sltu $2,$6,8
  1109. sd $3,0($7)
  1110. .set noreorder
  1111. .set nomacro
  1112. beq $2,$0,$L9
  1113. addu $7,$7,8
  1114. .set macro
  1115. .set reorder
  1116. move $3,$7
  1117. #else /* __OPTIMIZE_SIZE__ */
  1118. move $3,$8
  1119. #endif /* !__OPTIMIZE_SIZE__ */
  1120. /* Move any remaining bytes one at a time */
  1121. $L2:
  1122. addu $6,$6,-1
  1123. $L20:
  1124. li $2,-1 # 0xffffffffffffffff
  1125. .set noreorder
  1126. .set nomacro
  1127. beq $6,$2,$L12
  1128. move $4,$2
  1129. .set macro
  1130. .set reorder
  1131. $L13:
  1132. lbu $2,0($5)
  1133. addu $6,$6,-1
  1134. addu $5,$5,1
  1135. sb $2,0($3)
  1136. .set noreorder
  1137. .set nomacro
  1138. nop
  1139. bne $6,$4,$L13
  1140. addu $3,$3,1
  1141. .set macro
  1142. .set reorder
  1143. $L12:
  1144. .set noreorder
  1145. .set nomacro
  1146. j $31
  1147. move $2,$8
  1148. .set macro
  1149. .set reorder
  1150. .end memcpy
  1151. #endif
  1152. #ifdef F_memset
  1153. /* Assembler version of memset using quadword instructions.
  1154. Jeff Johnston, Cygnus Solutions, Feb 10/1999.
  1155. ============================================================
  1156. Copyright (C) 1999 by Cygnus Solutions. All rights reserved.
  1157. Permission to use, copy, modify, and distribute this
  1158. software is freely granted, provided that this notice
  1159. is preserved.
  1160. ============================================================ */
  1161. .text
  1162. .align 2
  1163. .globl memset
  1164. .text
  1165. .ent memset
  1166. .weak memset
  1167. memset:
  1168. .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
  1169. .mask 0x00000000,0
  1170. .fmask 0x00000000,0
  1171. #ifndef __OPTIMIZE_SIZE__
  1172. /* if not setting a double word or more, go and set one byte at a time */
  1173. sltu $2,$6,8
  1174. .set noreorder
  1175. .set nomacro
  1176. bne $2,$0,$L2
  1177. move $3,$4
  1178. .set macro
  1179. .set reorder
  1180. /* if not aligned on a quadword boundary, set one byte at a time */
  1181. andi $2,$4,0xf
  1182. .set noreorder
  1183. .set nomacro
  1184. bne $2,$0,$L2
  1185. move $7,$4
  1186. .set macro
  1187. .set reorder
  1188. /* otherwise, build a double word containing the bytes to set */
  1189. andi $9,$5,0xff
  1190. sltu $10,$6,32
  1191. move $8,$9
  1192. dsll $3,$8,8
  1193. or $8,$3,$9
  1194. pcpyh $3,$8
  1195. .set noreorder
  1196. .set nomacro
  1197. /* check if setting 32 bytes or more, otherwise set 8 bytes at a time */
  1198. bne $10,$0,$L31
  1199. sltu $2,$6,8
  1200. .set macro
  1201. .set reorder
  1202. /* take double word built from the byte to set and make a quadword */
  1203. pcpyld $8,$3,$3
  1204. /* loop while bytes to set >=32 and use quadword stores */
  1205. $L12:
  1206. sq $8,0($7)
  1207. addu $6,$6,-32
  1208. addu $7,$7,16
  1209. sltu $2,$6,32
  1210. sq $8,0($7)
  1211. .set noreorder
  1212. .set nomacro
  1213. beq $2,$0,$L12
  1214. addu $7,$7,16
  1215. .set macro
  1216. .set reorder
  1217. .set noreorder
  1218. .set nomacro
  1219. b $L31
  1220. sltu $2,$6,8
  1221. .set macro
  1222. .set reorder
  1223. $L16:
  1224. addu $6,$6,-8
  1225. addu $7,$7,8
  1226. sltu $2,$6,8
  1227. $L31:
  1228. .set noreorder
  1229. .set nomacro
  1230. nop
  1231. nop
  1232. beql $2,$0,$L16
  1233. sd $3,0($7)
  1234. .set macro
  1235. .set reorder
  1236. move $3,$7
  1237. #else /* __OPTIMIZE_SIZE__ */
  1238. move $3,$4
  1239. #endif /* __OPTIMIZE_SIZE__ */
  1240. /* loop while bytes left to set and set one byte at a time */
  1241. $L2:
  1242. li $2,4294901760 # 0xffff0000
  1243. addu $6,$6,-1
  1244. ori $2,$2,0xffff
  1245. beq $6,$2,$L19
  1246. li $2,4294901760 # 0xffff0000
  1247. ori $2,$2,0xffff
  1248. $L20:
  1249. sb $5,0($3)
  1250. addu $6,$6,-1
  1251. .set noreorder
  1252. .set nomacro
  1253. nop
  1254. nop
  1255. nop
  1256. bne $6,$2,$L20
  1257. addu $3,$3,1
  1258. .set macro
  1259. .set reorder
  1260. $L19:
  1261. .set noreorder
  1262. .set nomacro
  1263. j $31
  1264. move $2,$4
  1265. .set macro
  1266. .set reorder
  1267. .end memset
  1268. #endif