_syscall.s 802 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #
  2. ! $Source: /cvsroot/tack/Ack/plat/linux386/libsys/_syscall.s,v $
  3. ! $State: Exp $
  4. ! $Revision: 1.1 $
  5. ! Declare segments (the order is important).
  6. .sect .text
  7. .sect .rom
  8. .sect .data
  9. .sect .bss
  10. .sect .text
  11. EINVAL = 22
  12. #define IFFALSE 4
  13. #define IFTRUE 12
  14. #define ALWAYS 20
  15. #define LT 0
  16. #define GT 1
  17. #define EQ 2
  18. #define OV 3
  19. ! Perform a Linux system call.
  20. .define __syscall
  21. __syscall:
  22. lwz r0, 0(sp)
  23. lwz r3, 4(sp)
  24. lwz r4, 8(sp)
  25. lwz r5, 12(sp)
  26. sc 0
  27. bclr IFFALSE, OV, 0
  28. ! On error, r3 contains the errno.
  29. ! It just so happens that errnos 1-34 are the same in Linux as in ACK.
  30. cmpi cr0, 0, r3, 1
  31. bc IFTRUE, LT, 2f
  32. cmpi cr0, 0, r3, 34
  33. bc IFTRUE, GT, 2f
  34. 3:
  35. addis r4, r0, <_errno
  36. ori r4, r4, >_errno
  37. stw r3, 0(r4)
  38. addi r3, r0, -1
  39. bclr ALWAYS, 0, 0
  40. 2:
  41. addi r3, r0, EINVAL
  42. b 3b