kernel configuration kernel MTD file system mount system
- Slides: 33
kernel configuration • 기본 kernel 부팅을 위한 설정들 • MTD file system을 mount하기 위한 설정들
system type
Serial drivers • Device drivers -> Character devices -> Serial drivers
Boot options
MTD • Device drivers -> Memory Technology Devices (MTD) ->
MTD • Device drivers -> Memory Technology Devices (MTD) -> Ram/Rom/Flash chip drivers
MTD • Device drivers -> Memory Technology Devices (MTD) -> Mapping drivers for chip access
File systems • File systems -> Miscellaneous filesystems ->
실습 : 커널 모듈 작성 • Hello World 프로그램 /* hello. c */ – 모듈이 로딩될 때 #include <linux/module. h> /* 모든 모듈에 필요 */ #include <linux/kernel. h> /* printk() 등에 필요 */ • Hello world 출력 – 모듈이 제거될 때 int hello_init(void) { // 모듈이 로딩될 때 호출 printk (“Hello worldn”); return 0; } • Goodbye world 출력 void hello_exit(void) { // 제거 될 때 호출 printk (“Goodbye world”); } module_init(hello_init); module_exit(hello_exit); MODULE_LICENSE(“GPL”); 문자 디바이스 드라이버 11
리눅스 디바이스 드라이버의 종류(2) Application area Application System Call Interface VFS Kernel area Character D/D Buffer Cache Network Subsystem Block D/D Network D/D Device Interface Hardware 문자 디바이스 드라이버 Hardware 16
문자 디바이스 드라이버 기본 골격 #include <linux/kernel. h> #include <linux/module. h> #include <linux/init. h> 헤더 파일 int device_open( … ) { … } int device_release( … ) { … } ssize_t device_write( … ) { … } ssize_t device_read( … ) { … } 파일 연산 함수 정의 static struct file_operations device_fops = { … ssize_t (*read) (…); ssize_t (*write) (…); … int (*open) (…); int (*release) (…); … }; 파일 연산 구조체 int init_module(void) { … } void cleanup_module(void) { … } module_init(hello_init); module_exit(hello_exit); 문자 디바이스 드라이버 19
실습 : Dummy 디바이스 드라이버 작성 • 헤더 파일 및 매크로 정의 #include <linux/module. h> #include <linux/kernel. h> #include <linux/fs. h> #include <linux/errno. h> #include <linux/types. h> #include <linux/fcntl. h> #define DUMMY_NAME “dummy” #define DUMMY_MAJOR_NUMBER 240 문자 디바이스 드라이버 24
실습 : Dummy 디바이스 드라이버 작성(2) • 드라이버 등록 static int dummy_init(void) { int ret; printk(“dummy initn”); ret = register_chrdev(DUMMY_MAJOR_NUMBER, DUMMY_NAME, &dummy_fops); if (res < 0) return ret; return 0; } module_init(dummy_init); 문자 디바이스 드라이버 25
실습 : Dummy 디바이스 드라이버 작성(3) • 드라이버 제거 static void dummy_exit(void) { printk(“dummy exitn”); unregister_chrdev( DUMMY_MAJOR_NUMBER, DUMMY_NAME); } module_exit(dummy_exit); MODULE_LICENSE(“GPL”); 문자 디바이스 드라이버 26
실습 : Dummy 디바이스 드라이버 작성(4) • 파일 연산 구조체 정의 struct file_operations dummy_fops = { . owner = THIS_MODULE, . open = dummy_open, . read = dummy_read, . write = dummy_write, . ioctl = dummy_ioctl, . release = dummy_release, }; 문자 디바이스 드라이버 27
실습 : Dummy 디바이스 드라이버 작성(5) • open & release int dummy_open(struct inode *inode, struct file *filep) { int num = MINOR(inode->i_rdev); printk(“dummy dev open -> minor %dn”, num); return 0; } int dummy_release(struct inode *inode, struct file *filep) { printk(“dummy dev closen”); return 0; } 문자 디바이스 드라이버 28
실습 : Dummy 디바이스 드라이버 작성(6) • read & write size_t dummy_read(struct file *filep, char *buf, size_t count, loff_t *f_pos) { printk(“dummy dev read -> buf 0 x%08 x, count 0 x%08 xn”, buf, count); return 0 x 33; } size_t dummy_write(struct file *filep, const char *buf, size_t count, loff_t *f_pos) { printk(“dummy dev write -> buf 0 x%08 x, count 0 x%08 xn”, buf, count); return 0 x 43; } 문자 디바이스 드라이버 29
실습 : Dummy 디바이스 드라이버 작성(7) • ioctl int dummy_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg) { printk(“dummy dev ioctl -> cmd 0 x%08 x, arg 0 x%08 xn”, cmd, arg); return 0 x 53; } 문자 디바이스 드라이버 30
실습 : Dummy 드라이버를 제어하기 위한 어플리케이션 작성 • app. c #include <stdio. h> #include <sys/types. h> #include <sys/stat. h> #include <sys/ioctl. h> #include <fcntl. h> #include <unistd. h> printf(“ 2> read functionn”); #define DEV_NAME “/dev/dummy_device” ret = write(dev, 0 x 40, 0 x 41); printf(“ret = 0 x%x 08 xn”, ret); ret = read(dev, 0 x 30, 0 x 31); printf(“ret = 0 x%x 08 xn”, ret); printf(“ 3> write functionn”); int main() { int dev; char buf[128]; int ret; printf(“ 4> ioctl functionn”); ret = ioctl(dev, 0 x 51, 0 x 52); printf(“ret = 0 x%x 08 xn”, printf(“ 1> device openn”); printf(“ 5> device closen”); dev = open(DEV_NAME, O_RDWR|O_NDELAY); ret = close(dev); printf(“ret = 0 x%x 08 xn”, ret); } printf(“dev %dn”, dev); if (dev >= 0) { 문자 디바이스 드라이버 return 0; } 31
- Securecrt 다운로드
- File-file yang dibuat oleh user pada jenis file di linux
- Hmrc agent services
- Moving target indicator
- Plalloy mtd b.v.
- Mtd plan
- Relative configuration vs absolute configuration
- Number of chiral centres in morphine
- Electron configuration vs noble gas configuration
- Absolute vs relative configuration
- Distributed file system
- In a file-oriented information system, a transaction file
- Difference between logical file and physical file
- File sharing management system
- An html file is a text file containing small markup tags.
- Linux kernel block diagram
- What does the program do windows ntos kernel system
- Tebwin
- Introduction to windows operating system
- File system modules in distributed system
- Architecture of distributed file system
- File system in operating system
- File system in operating system
- File system in operating system
- Plena voice alarm system configuration software
- Configuration management system pmp
- System configuration dialog
- System.net.mail
- Mount litera zee school ahmednagar
- Mount st helens plates involved
- Blessings listed by jesus in the sermon on the mount senai
- Umbrella term
- Direct wet mount
- Enamel rods in gingival third of primary teeth