01.01.2015 Views

device_driver-08.pdf(1.9MB)

device_driver-08.pdf(1.9MB)

device_driver-08.pdf(1.9MB)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

초기화와 종료 처리<br />

257<br />

<br />

read(), write() 함수를 사용하면 디바이스 파일의 주번호에 의해 연결된<br />

커널 내에 디바이스 드라이버 file_operations 구조체 함수 필드 중 read<br />

필드와 write 필드가 각각 호출됨<br />

ssize_t xxx_read(struct file *filp, const char *buf, size_t count, loff_t *f_pos)<br />

{<br />

// 하드웨어에서 데이터 읽기<br />

}<br />

ssize_t write (struct file *filp, const char *buf, size_t count, loff_t *f_pos)<br />

{<br />

// 하드웨어에 데이터 쓰기<br />

}<br />

struct file_operations xxx_fops =<br />

{<br />

…<br />

read : xxx_read,<br />

write : xxx_write,<br />

…<br />

};<br />

http://eoslab.ssu.ac.kr<br />

Linux Device Driver<br />

초기화와 종료 처리<br />

258<br />

디바이스 드라이버의 읽기와 쓰기 구조<br />

http://eoslab.ssu.ac.kr<br />

Linux Device Driver

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!