Implement your own system calls in the Linux kernel

Source: Internet
Author: User

To implement a simple print: PRINTK

1.

Vim PRINTK.C
void Sys_pk ()
{
PRINTK ("This was a new sys call");
}

CD Arch/arm/kernel

2.vim calls. S
At the back, add
Call (SYS_PK)

3.CD Arch/arm/include

Add the following lines to the file Unistd.h in the appropriate location:

Vim Unistd.h

At the very back add:
#define __NR_PK (__nr_syscall_base+363)

4. Recompile the kernel

Make clean

Make Uimage arch=arm cross_compile=arm-linux-

CP Uimage/rootfs

TFTP 0xc0008000 Uimage

Bootm 0xc0008000

5. Using the newly added system call

Vim SYSCALL.C

void PK ()

{

__ASM__ (
"Ldr r7,=363 (more than 8 bits cannot use MOV instructions) \ n"
"Swi\n"
:
:
: "Memory")
};
}
void Main ()
{
PK ();

}

}

6. Compiling the link C file

Arm-linux-gcc-static Syscall.c-o Syscall

CP Syscall/rootfs

Implement your own system calls in the Linux kernel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.