How to call a self-designed system call
Author: xie_minix
/ * This program is more simple. Just understand that the C language and read "Getting Started (2)" can quickly understand * /
#include
#include
#include
#include
#include
#include
#include
INT main (int Argc, char ** argv)
{
Int Err;
U_SHORT DNUM = 1;
Struct IFNet Myifnet;
Do {
Err = syscall (286, dnum, & myifnet); / * Parameter 286 is the system call number, DNUM is a device number, here is 1, that is to say only to the network device 1 in the example. MYIFNET is called back The data is placed in this structure. * /
IF (Err == 0)
{
Printf ("Device% D =>% S", DNUM, myifnet.if_xname;
Printf ("Type:% D Maximum Transmission Unit (MTU):% D Break:% D Send Package:% D Receive Pack Error number:% D Send Pack error number:% d / n", Myifnet.if_type, myifnet.if_mtu, myifnet.if_baudrate, myifnet.if_ipackets, myifnet.if_opackets, myifnet.if_ierrors, myifnet.if_oerrors;
/ * The information in the IFNET structure is rich, what you want to do. If you don't. You can design some global variables in the core development (2). To count or control what you want to do. "* /
}
Sleep (1); / * Output per second * /
} while (err == 0);
}
/ * The entire calling process is very simple, but it is necessary to note that the following application method is not adopted when applying myIFNET:
Struct IFNet * myifnet;
Because this is not allocated to the IFNET structure, but gives a pointer, but the pointer is no initial value, when the system is called, Syscall (286, DNUM, myifnet) MYIFNet
Due to no initial value, the call failed.
The same procedure is completed in "Getting Started (2)" and compiles the core and restarts, it can run this file.