usys_old.S 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. #include "syscall.h"
  2. #include "traps.h"
  3. /* This is clumsy, but don't know how to make it smart */
  4. .globl fork
  5. fork:
  6. push {lr}
  7. push {r12}
  8. push {r11}
  9. push {r10}
  10. push {r9}
  11. push {r8}
  12. push {r7}
  13. push {r6}
  14. push {r5}
  15. push {r4}
  16. push {r3}
  17. push {r2}
  18. push {r1}
  19. push {r0}
  20. mov r0, #SYS_fork
  21. swi #T_SYSCALL
  22. pop {r1} /* to avoid overwrite of r0 */
  23. pop {r1}
  24. pop {r2}
  25. pop {r3}
  26. pop {r4}
  27. pop {r5}
  28. pop {r6}
  29. pop {r7}
  30. pop {r8}
  31. pop {r9}
  32. pop {r10}
  33. pop {r11}
  34. pop {r12}
  35. pop {lr}
  36. bx lr
  37. .globl exit
  38. exit:
  39. push {lr}
  40. push {r12}
  41. push {r11}
  42. push {r10}
  43. push {r9}
  44. push {r8}
  45. push {r7}
  46. push {r6}
  47. push {r5}
  48. push {r4}
  49. push {r3}
  50. push {r2}
  51. push {r1}
  52. push {r0}
  53. mov r0, #SYS_exit
  54. swi #T_SYSCALL
  55. pop {r1} /* to avoid overwrite of r0 */
  56. pop {r1}
  57. pop {r2}
  58. pop {r3}
  59. pop {r4}
  60. pop {r5}
  61. pop {r6}
  62. pop {r7}
  63. pop {r8}
  64. pop {r9}
  65. pop {r10}
  66. pop {r11}
  67. pop {r12}
  68. pop {lr}
  69. bx lr
  70. .globl wait
  71. wait:
  72. push {lr}
  73. push {r12}
  74. push {r11}
  75. push {r10}
  76. push {r9}
  77. push {r8}
  78. push {r7}
  79. push {r6}
  80. push {r5}
  81. push {r4}
  82. push {r3}
  83. push {r2}
  84. push {r1}
  85. push {r0}
  86. mov r0, #SYS_wait
  87. swi #T_SYSCALL
  88. pop {r1} /* to avoid overwrite of r0 */
  89. pop {r1}
  90. pop {r2}
  91. pop {r3}
  92. pop {r4}
  93. pop {r5}
  94. pop {r6}
  95. pop {r7}
  96. pop {r8}
  97. pop {r9}
  98. pop {r10}
  99. pop {r11}
  100. pop {r12}
  101. pop {lr}
  102. bx lr
  103. .globl pipe
  104. pipe:
  105. push {lr}
  106. push {r12}
  107. push {r11}
  108. push {r10}
  109. push {r9}
  110. push {r8}
  111. push {r7}
  112. push {r6}
  113. push {r5}
  114. push {r4}
  115. push {r3}
  116. push {r2}
  117. push {r1}
  118. push {r0}
  119. mov r0, #SYS_pipe
  120. swi #T_SYSCALL
  121. pop {r1} /* to avoid overwrite of r0 */
  122. pop {r1}
  123. pop {r2}
  124. pop {r3}
  125. pop {r4}
  126. pop {r5}
  127. pop {r6}
  128. pop {r7}
  129. pop {r8}
  130. pop {r9}
  131. pop {r10}
  132. pop {r11}
  133. pop {r12}
  134. pop {lr}
  135. bx lr
  136. .globl read
  137. read:
  138. push {lr}
  139. push {r12}
  140. push {r11}
  141. push {r10}
  142. push {r9}
  143. push {r8}
  144. push {r7}
  145. push {r6}
  146. push {r5}
  147. push {r4}
  148. push {r3}
  149. push {r2}
  150. push {r1}
  151. push {r0}
  152. mov r0, #SYS_read
  153. swi #T_SYSCALL
  154. pop {r1} /* to avoid overwrite of r0 */
  155. pop {r1}
  156. pop {r2}
  157. pop {r3}
  158. pop {r4}
  159. pop {r5}
  160. pop {r6}
  161. pop {r7}
  162. pop {r8}
  163. pop {r9}
  164. pop {r10}
  165. pop {r11}
  166. pop {r12}
  167. pop {lr}
  168. bx lr
  169. .globl write
  170. write:
  171. push {lr}
  172. push {r12}
  173. push {r11}
  174. push {r10}
  175. push {r9}
  176. push {r8}
  177. push {r7}
  178. push {r6}
  179. push {r5}
  180. push {r4}
  181. push {r3}
  182. push {r2}
  183. push {r1}
  184. push {r0}
  185. mov r0, #SYS_write
  186. swi #T_SYSCALL
  187. pop {r1} /* to avoid overwrite of r0 */
  188. pop {r1}
  189. pop {r2}
  190. pop {r3}
  191. pop {r4}
  192. pop {r5}
  193. pop {r6}
  194. pop {r7}
  195. pop {r8}
  196. pop {r9}
  197. pop {r10}
  198. pop {r11}
  199. pop {r12}
  200. pop {lr}
  201. bx lr
  202. .globl close
  203. close:
  204. push {lr}
  205. push {r12}
  206. push {r11}
  207. push {r10}
  208. push {r9}
  209. push {r8}
  210. push {r7}
  211. push {r6}
  212. push {r5}
  213. push {r4}
  214. push {r3}
  215. push {r2}
  216. push {r1}
  217. push {r0}
  218. mov r0, #SYS_close
  219. swi #T_SYSCALL
  220. pop {r1} /* to avoid overwrite of r0 */
  221. pop {r1}
  222. pop {r2}
  223. pop {r3}
  224. pop {r4}
  225. pop {r5}
  226. pop {r6}
  227. pop {r7}
  228. pop {r8}
  229. pop {r9}
  230. pop {r10}
  231. pop {r11}
  232. pop {r12}
  233. pop {lr}
  234. bx lr
  235. .globl kill
  236. kill:
  237. push {lr}
  238. push {r12}
  239. push {r11}
  240. push {r10}
  241. push {r9}
  242. push {r8}
  243. push {r7}
  244. push {r6}
  245. push {r5}
  246. push {r4}
  247. push {r3}
  248. push {r2}
  249. push {r1}
  250. push {r0}
  251. mov r0, #SYS_kill
  252. swi #T_SYSCALL
  253. pop {r1} /* to avoid overwrite of r0 */
  254. pop {r1}
  255. pop {r2}
  256. pop {r3}
  257. pop {r4}
  258. pop {r5}
  259. pop {r6}
  260. pop {r7}
  261. pop {r8}
  262. pop {r9}
  263. pop {r10}
  264. pop {r11}
  265. pop {r12}
  266. pop {lr}
  267. bx lr
  268. .globl exec
  269. exec:
  270. push {lr}
  271. push {r12}
  272. push {r11}
  273. push {r10}
  274. push {r9}
  275. push {r8}
  276. push {r7}
  277. push {r6}
  278. push {r5}
  279. push {r4}
  280. push {r3}
  281. push {r2}
  282. push {r1}
  283. push {r0}
  284. mov r0, #SYS_exec
  285. swi #T_SYSCALL
  286. pop {r1} /* to avoid overwrite of r0 */
  287. pop {r1}
  288. pop {r2}
  289. pop {r3}
  290. pop {r4}
  291. pop {r5}
  292. pop {r6}
  293. pop {r7}
  294. pop {r8}
  295. pop {r9}
  296. pop {r10}
  297. pop {r11}
  298. pop {r12}
  299. pop {lr}
  300. bx lr
  301. .globl open
  302. open:
  303. push {lr}
  304. push {r12}
  305. push {r11}
  306. push {r10}
  307. push {r9}
  308. push {r8}
  309. push {r7}
  310. push {r6}
  311. push {r5}
  312. push {r4}
  313. push {r3}
  314. push {r2}
  315. push {r1}
  316. push {r0}
  317. mov r0, #SYS_open
  318. swi #T_SYSCALL
  319. pop {r1} /* to avoid overwrite of r0 */
  320. pop {r1}
  321. pop {r2}
  322. pop {r3}
  323. pop {r4}
  324. pop {r5}
  325. pop {r6}
  326. pop {r7}
  327. pop {r8}
  328. pop {r9}
  329. pop {r10}
  330. pop {r11}
  331. pop {r12}
  332. pop {lr}
  333. bx lr
  334. .globl mknod
  335. mknod:
  336. push {lr}
  337. push {r12}
  338. push {r11}
  339. push {r10}
  340. push {r9}
  341. push {r8}
  342. push {r7}
  343. push {r6}
  344. push {r5}
  345. push {r4}
  346. push {r3}
  347. push {r2}
  348. push {r1}
  349. push {r0}
  350. mov r0, #SYS_mknod
  351. swi #T_SYSCALL
  352. pop {r1} /* to avoid overwrite of r0 */
  353. pop {r1}
  354. pop {r2}
  355. pop {r3}
  356. pop {r4}
  357. pop {r5}
  358. pop {r6}
  359. pop {r7}
  360. pop {r8}
  361. pop {r9}
  362. pop {r10}
  363. pop {r11}
  364. pop {r12}
  365. pop {lr}
  366. bx lr
  367. .globl unlink
  368. unlink:
  369. push {lr}
  370. push {r12}
  371. push {r11}
  372. push {r10}
  373. push {r9}
  374. push {r8}
  375. push {r7}
  376. push {r6}
  377. push {r5}
  378. push {r4}
  379. push {r3}
  380. push {r2}
  381. push {r1}
  382. push {r0}
  383. mov r0, #SYS_unlink
  384. swi #T_SYSCALL
  385. pop {r1} /* to avoid overwrite of r0 */
  386. pop {r1}
  387. pop {r2}
  388. pop {r3}
  389. pop {r4}
  390. pop {r5}
  391. pop {r6}
  392. pop {r7}
  393. pop {r8}
  394. pop {r9}
  395. pop {r10}
  396. pop {r11}
  397. pop {r12}
  398. pop {lr}
  399. bx lr
  400. .globl fstat
  401. fstat:
  402. push {lr}
  403. push {r12}
  404. push {r11}
  405. push {r10}
  406. push {r9}
  407. push {r8}
  408. push {r7}
  409. push {r6}
  410. push {r5}
  411. push {r4}
  412. push {r3}
  413. push {r2}
  414. push {r1}
  415. push {r0}
  416. mov r0, #SYS_fstat
  417. swi #T_SYSCALL
  418. pop {r1} /* to avoid overwrite of r0 */
  419. pop {r1}
  420. pop {r2}
  421. pop {r3}
  422. pop {r4}
  423. pop {r5}
  424. pop {r6}
  425. pop {r7}
  426. pop {r8}
  427. pop {r9}
  428. pop {r10}
  429. pop {r11}
  430. pop {r12}
  431. pop {lr}
  432. bx lr
  433. .globl link
  434. link:
  435. push {lr}
  436. push {r12}
  437. push {r11}
  438. push {r10}
  439. push {r9}
  440. push {r8}
  441. push {r7}
  442. push {r6}
  443. push {r5}
  444. push {r4}
  445. push {r3}
  446. push {r2}
  447. push {r1}
  448. push {r0}
  449. mov r0, #SYS_link
  450. swi #T_SYSCALL
  451. pop {r1} /* to avoid overwrite of r0 */
  452. pop {r1}
  453. pop {r2}
  454. pop {r3}
  455. pop {r4}
  456. pop {r5}
  457. pop {r6}
  458. pop {r7}
  459. pop {r8}
  460. pop {r9}
  461. pop {r10}
  462. pop {r11}
  463. pop {r12}
  464. pop {lr}
  465. bx lr
  466. .globl mkdir
  467. mkdir:
  468. push {lr}
  469. push {r12}
  470. push {r11}
  471. push {r10}
  472. push {r9}
  473. push {r8}
  474. push {r7}
  475. push {r6}
  476. push {r5}
  477. push {r4}
  478. push {r3}
  479. push {r2}
  480. push {r1}
  481. push {r0}
  482. mov r0, #SYS_mkdir
  483. swi #T_SYSCALL
  484. pop {r1} /* to avoid overwrite of r0 */
  485. pop {r1}
  486. pop {r2}
  487. pop {r3}
  488. pop {r4}
  489. pop {r5}
  490. pop {r6}
  491. pop {r7}
  492. pop {r8}
  493. pop {r9}
  494. pop {r10}
  495. pop {r11}
  496. pop {r12}
  497. pop {lr}
  498. bx lr
  499. .globl chdir
  500. chdir:
  501. push {lr}
  502. push {r12}
  503. push {r11}
  504. push {r10}
  505. push {r9}
  506. push {r8}
  507. push {r7}
  508. push {r6}
  509. push {r5}
  510. push {r4}
  511. push {r3}
  512. push {r2}
  513. push {r1}
  514. push {r0}
  515. mov r0, #SYS_chdir
  516. swi #T_SYSCALL
  517. pop {r1} /* to avoid overwrite of r0 */
  518. pop {r1}
  519. pop {r2}
  520. pop {r3}
  521. pop {r4}
  522. pop {r5}
  523. pop {r6}
  524. pop {r7}
  525. pop {r8}
  526. pop {r9}
  527. pop {r10}
  528. pop {r11}
  529. pop {r12}
  530. pop {lr}
  531. bx lr
  532. .globl dup
  533. dup:
  534. push {lr}
  535. push {r12}
  536. push {r11}
  537. push {r10}
  538. push {r9}
  539. push {r8}
  540. push {r7}
  541. push {r6}
  542. push {r5}
  543. push {r4}
  544. push {r3}
  545. push {r2}
  546. push {r1}
  547. push {r0}
  548. mov r0, #SYS_dup
  549. swi #T_SYSCALL
  550. pop {r1} /* to avoid overwrite of r0 */
  551. pop {r1}
  552. pop {r2}
  553. pop {r3}
  554. pop {r4}
  555. pop {r5}
  556. pop {r6}
  557. pop {r7}
  558. pop {r8}
  559. pop {r9}
  560. pop {r10}
  561. pop {r11}
  562. pop {r12}
  563. pop {lr}
  564. bx lr
  565. .globl getpid
  566. getpid:
  567. push {lr}
  568. push {r12}
  569. push {r11}
  570. push {r10}
  571. push {r9}
  572. push {r8}
  573. push {r7}
  574. push {r6}
  575. push {r5}
  576. push {r4}
  577. push {r3}
  578. push {r2}
  579. push {r1}
  580. push {r0}
  581. mov r0, #SYS_getpid
  582. swi #T_SYSCALL
  583. pop {r1} /* to avoid overwrite of r0 */
  584. pop {r1}
  585. pop {r2}
  586. pop {r3}
  587. pop {r4}
  588. pop {r5}
  589. pop {r6}
  590. pop {r7}
  591. pop {r8}
  592. pop {r9}
  593. pop {r10}
  594. pop {r11}
  595. pop {r12}
  596. pop {lr}
  597. bx lr
  598. .globl sbrk
  599. sbrk:
  600. push {lr}
  601. push {r12}
  602. push {r11}
  603. push {r10}
  604. push {r9}
  605. push {r8}
  606. push {r7}
  607. push {r6}
  608. push {r5}
  609. push {r4}
  610. push {r3}
  611. push {r2}
  612. push {r1}
  613. push {r0}
  614. mov r0, #SYS_sbrk
  615. swi #T_SYSCALL
  616. pop {r1} /* to avoid overwrite of r0 */
  617. pop {r1}
  618. pop {r2}
  619. pop {r3}
  620. pop {r4}
  621. pop {r5}
  622. pop {r6}
  623. pop {r7}
  624. pop {r8}
  625. pop {r9}
  626. pop {r10}
  627. pop {r11}
  628. pop {r12}
  629. pop {lr}
  630. bx lr
  631. .globl sleep
  632. sleep:
  633. push {lr}
  634. push {r12}
  635. push {r11}
  636. push {r10}
  637. push {r9}
  638. push {r8}
  639. push {r7}
  640. push {r6}
  641. push {r5}
  642. push {r4}
  643. push {r3}
  644. push {r2}
  645. push {r1}
  646. push {r0}
  647. mov r0, #SYS_sleep
  648. swi #T_SYSCALL
  649. pop {r1} /* to avoid overwrite of r0 */
  650. pop {r1}
  651. pop {r2}
  652. pop {r3}
  653. pop {r4}
  654. pop {r5}
  655. pop {r6}
  656. pop {r7}
  657. pop {r8}
  658. pop {r9}
  659. pop {r10}
  660. pop {r11}
  661. pop {r12}
  662. pop {lr}
  663. bx lr
  664. .globl uptime
  665. uptime:
  666. push {lr}
  667. push {r12}
  668. push {r11}
  669. push {r10}
  670. push {r9}
  671. push {r8}
  672. push {r7}
  673. push {r6}
  674. push {r5}
  675. push {r4}
  676. push {r3}
  677. push {r2}
  678. push {r1}
  679. push {r0}
  680. mov r0, #SYS_uptime
  681. swi #T_SYSCALL
  682. pop {r1} /* to avoid overwrite of r0 */
  683. pop {r1}
  684. pop {r2}
  685. pop {r3}
  686. pop {r4}
  687. pop {r5}
  688. pop {r6}
  689. pop {r7}
  690. pop {r8}
  691. pop {r9}
  692. pop {r10}
  693. pop {r11}
  694. pop {r12}
  695. pop {lr}
  696. bx lr
  697. /*
  698. SYSCALL(fork)
  699. SYSCALL(exit)
  700. SYSCALL(wait)
  701. SYSCALL(pipe)
  702. SYSCALL(read)
  703. SYSCALL(write)
  704. SYSCALL(close)
  705. SYSCALL(kill)
  706. SYSCALL(exec)
  707. SYSCALL(open)
  708. SYSCALL(mknod)
  709. SYSCALL(unlink)
  710. SYSCALL(fstat)
  711. SYSCALL(link)
  712. SYSCALL(mkdir)
  713. SYSCALL(chdir)
  714. SYSCALL(dup)
  715. SYSCALL(getpid)
  716. SYSCALL(sbrk)
  717. SYSCALL(sleep)
  718. SYSCALL(uptime)
  719. */