Module

    [LKM] Character Device Driver

    Kernel version: 5.14.17 What is a device driver? device driver는 하나의 컴퓨터 프로그램이다. 컴퓨터나 오토마톤에 접목되어 특정 타입의 device를 동작시키거나 조종한다. device는 우리가 생각하는 여러 주변 하드웨어 기기들을 일컫는 말이다. 키보드, 마우스, 모니터, USB,... 등등 많은 종류의 하드웨어가 컴퓨터와 통신하는데 주로 sequential bytes의 형태로 이루어진다. 이 말은 즉 linux에서는 모든 devices가 file이라고 본다. ([Kernel of Linux] 강의 정리 내용을 참고하자.) 결국 우리가 만들게 될 device driver는 device라는 하나의 파일을 컨트롤하기 위한 프로그램을 만드는 것이다. devic..

    [Kernel of Linux] 14. Memory Management

    지난 강의 요약 - File System (3) Linux는 Unix와는 달리 많은 종류의 FS을 커버할 수 있도록 만들어졌다. 그래서 실제 physical FS layer 위에 유저를 위한 standard를 제공하기 위한 VFS(Virtual FS) layer를 얹어놨다. VFS는 standard objects 4가지를 통해 어떤 FS든지 정의할 수 있도록 했다. superblock object / inode object / file object / dentry object. dentry를 제외한 나머지 object들은 이전에도 많이 했으니 넘어가고 dentry에 대해 알아보자. dentry는 directory entry로 단순히 말해 path(name) components의 inode를 저장하는 것을..

    [LKM] Module Programming Basic

    Environment: Linux Kernel v2.6.14.6 LKM (Loadable Kernel Module). Module programming을 하기 위해 필요한 기본 지식과 만드는 법. 1. callee, caller 모듈 작성 callee.c #include #include #include // module init int __init init_callee(void) { return 0; } // module exit void __exit exit_callee(void) { } int add(int a, int b) { printk(KERN_ALERT "[callee Module] add called...\n"); return a + b; } int sub(int a, int b) { pri..