syscall-i386-linux-2.0.S
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:8k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* ==== syscall.S ============================================================
  2.  * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
  3.  * All rights reserved.
  4.  *
  5.  * Description : Machine dependent syscalls for i386/i486/i586
  6.  *
  7.  *  1.00 93/08/26 proven
  8.  *      -Started coding this file.
  9.  *
  10.  * 1.01 93/11/13 proven
  11.  * -The functions readv() and writev() added.
  12.  *
  13.  * 1.16 94/01/30 proven
  14.  * -This file now requires gas version 2.0 or greater.
  15.  */
  16. #ifndef lint
  17. .text
  18. .asciz "$Id$";
  19. #endif
  20. #include <sys/syscall.h>
  21. #include <config.h>
  22. #ifdef __ELF__
  23. #define NAME(X)  machdep_sys_##X
  24. #define END(X) 1: ; .type NAME(X),@function ; .size NAME(X),1b - NAME(X)
  25. #else
  26. #define NAME(X) _machdep_sys_##X
  27. #define END(X)
  28. #endif
  29. #define SYSCALL0(x)
  30. .globl NAME(x) ;
  31. NAME(x):
  32. push %ebx;
  33. lea SYS_##x, %eax;
  34. int $0x80;
  35. pop %ebx;
  36. ret;
  37. END(x)
  38. #define SYSCALL1(x)
  39. .globl NAME(x) ;
  40. NAME(x):
  41. push %ebx;
  42. mov 8(%esp), %ebx;
  43. lea SYS_##x, %eax;
  44. int $0x80;
  45. pop %ebx;
  46. ret;
  47.     END(x)
  48. #define SYSCALL2(x)
  49. .globl NAME(x) ;
  50. NAME(x):
  51. push %ebx;
  52. mov 8(%esp), %ebx;
  53. mov 12(%esp), %ecx;
  54. lea SYS_##x, %eax;
  55. int $0x80;
  56. pop %ebx;
  57. ret;
  58.     END(x)
  59. #define SYSCALL3(x)
  60. .globl NAME(x) ;
  61. NAME(x):
  62. push %ebx;
  63. mov 8(%esp), %ebx;
  64. mov 12(%esp), %ecx;
  65. mov 16(%esp), %edx;
  66. lea SYS_##x, %eax;
  67. int $0x80;
  68. pop %ebx;
  69. ret; 
  70. END(x)
  71. #define SYSCALL4(x)
  72. .globl NAME(x) ;
  73. NAME(x):
  74. push %ebx;
  75. push %esi;
  76. mov 12(%esp), %ebx;
  77. mov 16(%esp), %ecx;
  78. mov 20(%esp), %edx;
  79. mov 24(%esp), %esi;
  80. lea SYS_##x, %eax;
  81. int $0x80;
  82. pop %esi;
  83. pop %ebx;
  84. ret; 
  85. END(x)
  86. #define SYSCALL5(x)
  87. .globl NAME(x) ;
  88. NAME(x):
  89. push %ebx;
  90. push %esi;
  91. push %edi;
  92. mov 16(%esp), %ebx;
  93. mov 20(%esp), %ecx;
  94. mov 24(%esp), %edx;
  95. mov 28(%esp), %esi;
  96. mov 32(%esp), %edi;
  97. lea SYS_##x, %eax;
  98. int $0x80;
  99. pop %edi;
  100. pop %esi;
  101. pop %ebx;
  102. ret; 
  103. END(x)
  104. /* =========================================================================
  105.  * exit  1 select  82
  106.  * fork  2 fstatfs 100
  107.  * read  3 socketcall 102
  108.  * write  4 flock 143
  109.  * open  5 readv 145
  110.  * creat  8 writev 146
  111.  * link  9
  112.  * unlink 10
  113.  * execve 11
  114.  * chdir 12
  115.  * chmod 15
  116.  * chown 16
  117.  * lseek 19
  118.  * rename 38
  119.  * dup 41
  120.  * pipe 42
  121.  * ioctl 54
  122.  * fcntl 55
  123.  * dup2 63
  124.  * readdir 89
  125.  * ftruncate 93
  126.  * fchmod 94
  127.  * fchown 95
  128.  */
  129. /*
  130.  * Initial asm stuff for all functions.
  131.  */
  132. .text
  133. .align 2
  134. /* ==========================================================================
  135.  * machdep_sys_read()
  136.  */
  137. SYSCALL3(read)
  138. /* ==========================================================================
  139.  * machdep_sys_write()
  140.  */
  141. SYSCALL3(write)
  142. /* ==========================================================================
  143.  * machdep_sys_open()
  144.  */
  145. SYSCALL3(open)
  146. /* ==========================================================================
  147.  * machdep_sys_close()
  148.  */
  149. SYSCALL1(close)
  150. /* ==========================================================================
  151.  * machdep_sys_creat()
  152.  */
  153. SYSCALL2(creat)
  154. /* ==========================================================================
  155.  * machdep_sys_dup2()
  156.  */
  157. SYSCALL2(dup2)
  158. /* ==========================================================================
  159.  * machdep_sys_fcntl()
  160.  */
  161. SYSCALL3(fcntl)
  162. /* ==========================================================================
  163.  * machdep_sys_fchown()
  164.  */
  165. SYSCALL3(fchown)
  166. /* ==========================================================================
  167.  * machdep_sys_fchmod()
  168.  */
  169. SYSCALL2(fchmod)
  170. /* ==========================================================================
  171.  * machdep_sys_ioctl()
  172.  */
  173. SYSCALL3(ioctl)
  174. /* ==========================================================================
  175.  * machdep_sys_chown()
  176.  */
  177. SYSCALL3(chown)
  178. /* ==========================================================================
  179.  * machdep_sys_chmod()
  180.  */
  181. SYSCALL2(chmod)
  182. /* ==========================================================================
  183.  * machdep_sys_chdir()
  184.  */
  185. SYSCALL1(chdir)
  186. /* ==========================================================================
  187.  * machdep_sys_unlink()
  188.  */
  189. SYSCALL1(unlink)
  190. /* ==========================================================================
  191.  * machdep_sys_link()
  192.  */
  193. SYSCALL2(link)
  194. /* ==========================================================================
  195.  * machdep_sys_rename()
  196.  */
  197. SYSCALL2(rename)
  198. /* ==========================================================================
  199.  * machdep_sys_lseek()
  200.  */
  201. SYSCALL3(lseek)
  202. /* ==========================================================================
  203.  * machdep_sys_pipe()
  204.  */
  205. SYSCALL1(pipe)
  206. /* ==========================================================================
  207.  * machdep_sys_dup()
  208.  */
  209. SYSCALL1(dup)
  210. /* ==========================================================================
  211.  * machdep_sys_fork()
  212.  */
  213. SYSCALL0(fork)
  214. /* ==========================================================================
  215.  * machdep_sys_execve()
  216.  */
  217. SYSCALL3(execve)
  218. /* ==========================================================================
  219.  * machdep_sys_stat()
  220.  */
  221. SYSCALL2(stat)
  222. /* ==========================================================================
  223.  * machdep_sys_fstat()
  224.  */
  225. SYSCALL2(fstat)
  226. /* ==========================================================================
  227.  * machdep_sys_lstat()
  228.  */
  229. SYSCALL2(lstat)
  230. /* ==========================================================================
  231.  * machdep_sys_fstatfs()
  232.  */
  233. SYSCALL2(fstatfs)
  234. /* ==========================================================================
  235.  * machdep_sys_ftruncate()
  236.  */
  237. SYSCALL2(ftruncate)
  238. /* ==========================================================================
  239.  * machdep_sys_chroot()
  240.  */
  241. SYSCALL1(chroot)
  242. /* ==========================================================================
  243.  * machdep_sys_uname()
  244.  */
  245. SYSCALL1(uname)
  246. /* ==========================================================================
  247.  * Nonstandard calls used to make the system work
  248.  *
  249.  * ==========================================================================
  250.  * machdep_sys_select()
  251.  */
  252. .globl NAME(select)
  253. NAME(select):
  254. push %ebx
  255. lea 8(%esp), %ebx
  256. lea SYS_select, %eax
  257. int $0x80
  258. pop %ebx
  259. ret
  260. END(select)
  261. /* ==========================================================================
  262.  * machdep_sys_wait4()
  263.  */
  264. SYSCALL4(wait4)
  265. /* ==========================================================================
  266.  * machdep_sys_readdir()
  267.  */
  268. SYSCALL3(readdir)
  269. /* ==========================================================================
  270.  * machdep_sys_socketcall()
  271.  */
  272. SYSCALL2(socketcall)
  273. SYSCALL1(exit)
  274. SYSCALL3(sigprocmask)
  275. /* ==========================================================================
  276.  * machdep_sys_sigsuspend()
  277.  */
  278. .globl NAME(sigsuspend)
  279. NAME(sigsuspend):
  280.     push %ebp
  281. mov %esp,%ebp
  282. push %edi
  283. push %esi
  284. push %ebx
  285. mov 8(%ebp), %edx
  286. mov (%edx), %edx
  287. lea SYS_sigsuspend, %eax
  288. int $0x80
  289. pop %ebx
  290. pop %esi
  291. pop %edi
  292. mov %ebp,%esp
  293.     pop %ebp
  294. ret
  295. END(sigsuspend)
  296. /* ==========================================================================
  297.  * machdep_sys_readv()
  298.  */
  299. #ifdef HAVE_SYSCALL_READV
  300. SYSCALL3(readv)
  301. #endif
  302. /* ==========================================================================
  303.  * machdep_sys_writev()
  304.  */
  305. #ifdef HAVE_SYSCALL_WRITEV 
  306. SYSCALL3(writev)
  307. #endif
  308. /* ==========================================================================
  309.  * machdep_sys_flock()
  310.  */
  311. #ifdef HAVE_SYSCALL_FLOCK
  312. SYSCALL2(flock)
  313. #endif