프로그래밍
Linux system_call Test
Dilrong
2015. 4. 1. 22:00
[kernel] = linux-2.6.11-h270-tku 경로
/*
NR_추가할 시스템 콜 함수이름
+281 고유 할당 번호
[kernel]/include/asm-arm/unistd.h 할당번호 추가
*/
#define __NR_hybuscall (__NR_SYSCALL_BASE+281)
/*
시스템 콜 처리함수 등록
unistd.h에 정의한 번호와 일치해야함]
[kernel]/arch/arm/kernel/calls.S
*/
.long sys_hybuscall
/*
처리함수 구현
asmlinkage = 어셈블리 언어로 구현된 함수에서 호출될 때 사용하는 키워드
함수이름은 calls.S에 등로된 이름과 같아야함
[kernel]/kernel/test_syscall.c
*/
#include<linux/kernel.h> asmlikage int sys_hybuscall() { printk("Welcome to the embedded World!!\n"); return (0); }
Makefile 수정
[kernel]/kernel/Makefile
*/
에서 obj-y = ...test_syscall.o
/*
시스템 콜을 호출하는 유저 어플리케이션 작성
[kernel]에서 하지말고 밖에다가 해야함
*/
#include<linux/unistd.h> #include<errno.h> _syscall0(int, hybuscall); int main() { hybus(); return 0; }
//Makefile
KDIR := [kernel]/include
CFLAGS:=-I$(KDIR
syscall_test: syscall_test.c
arm-linux-gcc $(CFLAGS) -o syscall_test syscall_test.c
반응형