201 lines
2.7 KiB
HTML
201 lines
2.7 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>_syscallN macro</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
|
|
REL="HOME"
|
|
TITLE="Implementing a System Call on Linux 2.6 for i386"
|
|
HREF="index.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="testmycall.c (new user space source file to be created)"
|
|
HREF="x156.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Testing our new system call"
|
|
HREF="x204.html"></HEAD
|
|
><BODY
|
|
CLASS="sect1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
SUMMARY="Header navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>Implementing a System Call on Linux 2.6 for i386</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x156.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
></TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x204.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="AEN173"
|
|
></A
|
|
>16. _syscallN macro</H1
|
|
><P
|
|
></P
|
|
><OL
|
|
TYPE="1"
|
|
><LI
|
|
><P
|
|
>_syscall0(int,mycall) indicates that:</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>The name of the system call is mycall.</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>It takes zero arguments.</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>It returns an int.</P
|
|
></LI
|
|
></OL
|
|
><P
|
|
></P
|
|
><P
|
|
></P
|
|
><OL
|
|
TYPE="1"
|
|
><LI
|
|
><P
|
|
>_syscall1(int,mycall,int,number) indicates that:</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>The name of the system call is mycall.</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>It takes one argument.</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>The argument is an int named number.</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>It returns an int.</P
|
|
></LI
|
|
></OL
|
|
><P
|
|
></P
|
|
><P
|
|
>When you expand _syscall1(long,mycall,int,i), you get the following code:</P
|
|
><P
|
|
>long mycall(int i)</P
|
|
><P
|
|
>{</P
|
|
><P
|
|
>return syscall(__NR_mycall, i);</P
|
|
><P
|
|
>}</P
|
|
><P
|
|
></P
|
|
><P
|
|
>But the definition of _syscallN macros are different in the kernel. You can look at /usr/src/linux/include/asm-i386/unistd.h for the definition.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
SUMMARY="Footer navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x156.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
ACCESSKEY="H"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x204.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>testmycall.c (new user space source file to be created)</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Testing our new system call</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |