Linux/Device Driver

read() 함수의 구현

aucd29 2013. 9. 26. 16:38
ssize_t xxx_read(struct file *filp, const char *buf, size_t count, loff_t *f_pos)
{
    if(!(준비된 데이터가 존재하나?))
    {
        if(!(filp->f_flags & O_NONBLOCK))
        {
            // 블록 모드가 열렸다면 프로세스를 재운다.
        }
    }

    // 하드웨어에서 데이터를 읽고
    // inb(), outb(), readb(), writeb()를 이용
    // 또는 버퍼를 읽는다.

    // 사용자 공간에 데이터를 전달
    // copy_to_user, put_user

    return 처리된 데이터 갯수;
}