Adding new system calls under ARM Linux

Publisher:中原读书客Latest update time:2016-04-18 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
   A recent project requires  adding new system calls to the ARM Linux kernel to meet the needs of the project. So I searched on Google and Baidu, but the results were not satisfactory. I had to solve it myself! The steps to add are as follows (Note: I use the kernel 2.6.14.7, other versions are for readers to modify):
    1. Open arch/arm/kernel/calls.S, find "#define NR_syscalls 328" and modify it. It should be noted that the number of system calls here must be increased by multiples of 4, otherwise the compilation will be wrong, for example: "#define NR_syscalls 332". Next, add the pointer of the system call function prototype, for example: .long sys_set_senda
    
    2. Open include/asm-arm/unistd.h and add the macro of the system call number (I personally feel that this step can be omitted), for example:
    #define __NR_plan_set_senda             (__NR_SYSCALL_BASE+323)
The numbers here must be added in order. Otherwise, it will cause core operation errors.
    
    3. Instantiate the system call, that is, write the implementation of the newly added system call. This is your job, for example:
    asmlinkage long sys_set_senda(int iset)
    {
      if(iset)
         UART_PUT_CR(&at91_port[2],AT91C_US_SENDA);
      else
         UART_PUT_CR(&at91_port[2],AT91C_US_RSTSTA);
      return 0;
    }
    
    4. Open include/linux/syscalls.h and add function declaration
    asmlinkage long sys_set_senda(int iset);
    
    5. Calling the system call in the application
   int set_senda(int isset)
   {
      register long __r0 __asm__("r0") = (long)isset;
       register long __res __asm__("r0");
       __asm__ __volatile__ ( "swit" "0x900143" "nt" : "=r" ( __res) : "r" (__r0) : "lr");
       do { if ((unsigned long)(__res) >= (unsigned long)(-125))
               { errno = -(__res); __res = -1; }
               return (int) (__res);
       } while (0);
   }
    6. End (Note: Readers are requested to study the case of multiple parameters on their own)

Keywords:ARM Reference address:Adding new system calls under ARM Linux

Previous article:STM32 Getting Started Tutorial System Clock SysTick
Next article:The difference between ldr and mov in arm

Recommended ReadingLatest update time:2024-11-16 15:49

ARM development board embedded Linux system and host PC transfer files through serial port
Embedded Linux system and host transfer files through serial port If you want to download something from a PC to the embedded Linux system of a development board, many people will first think of using network tools such as tftp or sftp to download from the network port. But what if the network is unavailable and you
[Microcontroller]
GNU ARM Assembly--(XIX) u-boot-nand-spl startup process analysis
        After understanding the bootloader and spending some time relearning the makefile and related scripts of the open source software, my u-boot porting work was completed relatively smoothly:         Transplantation environment:         ubuntu 12.04         U-Boot 2012.07 (Nov 28 2012 - 20:05:48)         arm
[Microcontroller]
GPIO operation of s3c6410 under Linux (4)
1. In the previous few articles, one of them called such a function, as follows: static __init void s3c64xx_gpiolib_add_4bit(struct s3c_gpio_chip *chip) { chip- chip.direction_input = s3c64xx_gpiolib_4bit_input; chip- chip.direction_output = s3c64xx_gpiolib_4bit_output; } This function is defined in arch/arm/plat-
[Microcontroller]
Synopsys Helps The Linux Foundation Identify the World's Most Widely Used Open Source Application Repository
Synopsys Helps The Linux Foundation Identify the World's Most Widely Used Open Source Application Repository Latest open source census report released Synopsys' 2021 Open Source Security and Risk Analysis (OSSRA) report shows that the number of vulnerable, outdated, and abandoned open s
[Embedded]
Synopsys Helps The Linux Foundation Identify the World's Most Widely Used Open Source Application Repository
VIA releases first ARM-based industrial system
VIA today released a new fanless mini system "ARMOS-800", which is its first industrial system based on ARM architecture. Before this, VIA AMOS series used its own processors, but this time when the platform was changed, an "R" was added to the series name, which more prominently represents the ARM chip.   The overa
[Analog Electronics]
VIA releases first ARM-based industrial system
How to Make Your Own ARM Board
Introduction: First, you need to consider what kind of board you are going to make, whether it is to complete a project or just a learning board. After clarifying the purpose, start designing the schematic. . . . . . When I was surfing the Internet, I saw many people asking how to make an ARM board by themselves, an
[Microcontroller]
Design of digital system for call control protocol without center based on ARM7 and MX618 chip
introduction The centerless mobile communication system is an important part of my country's professional mobile communication system. It works in a simplex intercom mode with an operating frequency between 915.0125 and 916.0875 MHz. The system has many technical features such as centerless networking, digital selecti
[Microcontroller]
Design of digital system for call control protocol without center based on ARM7 and MX618 chip
uC/GUI transplantation example on ARM core S3C44B0X
uC/GUI is a graphical user interface (GUI) software package for embedded systems launched by Micrigm. Since uC/GUI is written entirely in ANSI-C, it is independent of the processor and can be easily ported to different operating systems and embedded microprocessors, and can support graphic LCDs of different sizes.
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号