資源簡介
這是linux下的字符設(shè)備驅(qū)動程序,對于初學(xué)驅(qū)動程序的人有很不錯的參考價值。
代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#include?
#define?DEFAULT_MSG?“This?is?my?device!\n“ /*默認(rèn)字符設(shè)備數(shù)據(jù)*/
#define?DEVICE_NAME?“mydev“ /*設(shè)備名*/
#define?MAXBUF?20 /*設(shè)備數(shù)據(jù)緩沖區(qū)大小*/
static?unsigned?char?mydev_buf[MAXBUF]; /*設(shè)備內(nèi)存數(shù)據(jù)緩沖區(qū)*/
static?int?mydev_open?(struct?inode?*inode?struct?file?*file);
static?int?mydev_release?(struct?inode?*inode?struct?file?*file);
static?ssize_t?mydev_read?(struct?file?*file?char?__user?*bufsize_t?count?loff_t?*pos);
static?ssize_t?mydev_write?(struct?file?*file?const?char?__user?*bufsize_t?count?loff_t?*pos);
static?int?mydev_open?(struct?inode?*inode?struct?file?*file)
{
????return?0;
}
static?int?mydev_release?(struct?inode?*inode?s
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3501??2010-03-07?10:57??work2\mydev.c
?????文件????????616??2010-03-07?10:57??work2\Makefile
?????文件????????441??2010-03-07?10:57??work2\test.c
?????目錄??????????0??2010-03-24?18:44??work2
-----------?---------??----------?-----??----
?????????????????4558????????????????????4
評論
共有 條評論