06 jhkim 3624etri re kr 2015 10 11
- Slides: 18
06. 디바이스의 등록과 해제 김진홍 jhkim 3624@etri. re. kr 2015. 10. 11.
저수준 입출력 함수와 file_operations 필드 • open(): xxx_open() • fd = open(const char *pathname, int flags); 1. 디바이스 드라이버 제어 방식 • int xxx_open(struct inode *inode, struct file *filp) { return ret; } 2. struct file_operations 3. 문자 디바이스 드라이버의 등록과 해제 및 구성 4. 문자 디바이스 드라이버 작성 예제 9/29
저수준 입출력 함수와 file_operations 필드 • close(): xxx_release() • fd = close(int fd); 1. 디바이스 드라이버 제어 방식 • int xxx_release(struct inode *inode, struct file *filp) { return ret; } 2. struct file_operations 3. 문자 디바이스 드라이버의 등록과 해제 및 구성 4. 문자 디바이스 드라이버 작성 예제 10/29
저수준 입출력 함수와 file_operations 필드 • read(): xxx_read() • ret = read(int fd, void *buf, size_t count); 1. 디바이스 드라이버 제어 방식 • ssize_t xxx_read(struct file *filp, char *buf, size_t count, loff_t *f_pos) { return ret; } 2. struct file_operations 3. 문자 디바이스 드라이버의 등록과 해제 및 구성 4. 문자 디바이스 드라이버 작성 예제 11/29
저수준 입출력 함수와 file_operations 필드 • write(): xxx_write() • ret = write(int fd, void *buf, size_t count); 1. 디바이스 드라이버 제어 방식 • ssize_t xxx_write(struct file *filp, char *buf, size_t count, loff_t *f_pos) { return ret; } 2. struct file_operations 3. 문자 디바이스 드라이버의 등록과 해제 및 구성 4. 문자 디바이스 드라이버 작성 예제 12/29
저수준 입출력 함수와 file_operations 필드 • lseek(): xxx_llseek() • ret = write(int fd, off_t offset, int whence); 1. 디바이스 드라이버 제어 방식 • ssize_t xxx_llseek(struct file *filp, loff_t off, int whence) { return ret; } 2. struct file_operations 3. 문자 디바이스 드라이버의 등록과 해제 및 구성 4. 문자 디바이스 드라이버 작성 예제 13/29
개요 • 등록과 제거 • 등록 • register_chrdev 1. 디바이스 드라이버 제어 방식 (unsigned int major, const char *name, struct file_operations *fops) 2. struct file_operations • 제거 • unregister_chrdev(unsigned int major, const char *name) 3. 문자 디바이스 드라이버의 등록과 해제 및 구성 4. 문자 디바이스 드라이버 작성 예제 14/29
struct file_operations 변수 • Struct file_operations xxx_fops = {. owner = THIS_MODULE, . llseek = xxx_llseek, . read = xxx_read, . write = xxx_write, . ioctl = xxx_ioctl, 1. 디바이스 드라이버 제어 방식 2. struct file_operations 3. 문자 디바이스 드라이버의 등록과 해제 및 구성 4. 문자 디바이스 드라이버 작성 예제 . open = xxx_open, . release = xxx_release, }; 15/29
문자 디바이스 드라이버의 등록과 해제 • 문자 드라이버의 동작 순서 사용자 공간 커널 공간 insmod 장치파일 디바이스 드라이버 (1) (3) (4) /dev/calldev 응용 프로그램 chrdevs[MAX_PROBE_HASH] open(…) struct file_operations *fops; read(…) write(…) ioctl(…) close(…) rmmod module_init(xxx_init) xxx_init(…) { register_chdrv( ) } (2) struct file_operations xxx_fop = { open : xxx_open, read : xxx_read, write : xxx_write, ioctl : xxx_ioctl, release : xxx_release }; (5) 1. 디바이스 드라이버 제어 방식 2. struct file_operations 3. 문자 디바이스 드라이버의 등록과 해제 및 구성 4. 문자 디바이스 드라이버 작성 예제 module_exit(xxx_exit); (6) (7) xxx_exit(…) { unregister_chdrv(…) } 16/29
Qna 17/29
- 21 september 2015
- Astro quiz round 2
- Acronym whmis
- Värskeõhuklapi paigaldus
- 2015 pearson education inc
- Checklist audit iso 37001
- Vista higher learning french
- 2025-2015
- Sentencia t762 de 2015
- Developmental milestones chart iap
- Dementia 2015
- Lanbidez familias profesionales
- Pearson education inc publishing
- Workplace hazardous materials information system symbols
- Iso 9000 vs 9001
- 2015 brain wrinkles answer key
- Visual studio 2015 rc
- Iatf 16949 process interaction map
- Insight 2015 conference