91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-13
  • 語言: 其他
  • 標簽: LINUX??QT??

資源簡介

LINUX的驅動例子,能啟動字符設備,很有試驗價值, 詳細的代碼以及完整的MAKEFILE是學習試驗的絕好資料

資源截圖

代碼片段和文件信息

/**
??*?A?demo?driver?for?simple?Character?device.“
??*
??*?simple_chrdev.c?
??*
??*?Author?Tianze?Sun
??*?
??*?E-mail?stz@cic.tsinghua.edu.cn
??*
??*?Fri?Jun?2th?20:32:43?GMT?2006
??*
??*?Current?version:?1.1.0
??*
??*?All?rights?reserved.?Licensed?under?dual?BSD/GPL?license.
??*/

#include??
#include??
#include??
#include??
#include??
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
?
#include?
#include?
#include?

#define?SIMPLE_PHYS_ADDR 0x1FFFFF7C //Address
#define?SIZE_OF_SIMPLE 2 ????????? //2?Bytes
#define?SIMPLE_TIMER_DELAY? 1 //?1?ms

#define?SIMPLE_IOCTL_MAGIC??????????‘K‘ //Magic
#define?CMD1 _IOW(SIMPLE_IOCTL_MAGIC3unsigned?long)
#define?CMD2 _IOW(SIMPLE_IOCTL_MAGIC4unsigned?long)
#define?CMDn _IOW(SIMPLE_IOCTL_MAGIC5unsigned?long)
#define?SIMPLE_NAME?“Simple“?

int?SIMPLE_MAJOR?=?0;
int?SIMPLE_MINOR?=?0;?
int?SIMPLE_NUMBER?=?1;
void?__iomem?*simple_addr_virt?=?NULL;
struct?cdev?*simple_cdev;?
dev_t??simple_dev;?

int?simple_open(struct?inode?*inode?struct?file?*filp);?
int?simple_release(struct?inode?*inode?struct?file?*filp);?
int?simple_ioctl?(struct?inode?*inode?struct?file?*file?unsigned?int?cmd?unsigned?long?arg);?
static?ssize_t?simple_read(struct?file?*?file?char?__user?*buf?size_t?count?loff_t?*ppos);
static?ssize_t?simple_write(struct?file?*file?const?char?__user?*buf?size_t?len?loff_t?*ppos);
loff_t?simple_llseek(struct?file?*fileloff_t?offset?int?origin);

static?struct?timer_list?simple_timer;
static?void?simple_timer_handler(unsigned?long?data);

extern?struct?file_operations?simple_fops;?
struct?file_operations?simple_fops?=?
{?
.owner ?=?THIS_MODULE?
.llseek ?=?simple_llseek?
.open? ?=?simple_open?
.read ?=?simple_read
.write ?=?simple_write
.ioctl ?=?simple_ioctl
.release?=?simple_release?
};?

/*?Open?*/?
int?simple_open(struct?inode?*inode?struct?file?*filp)?
{?
printk(“Simple?Device?is?opened\n“);?
try_module_get(THIS_MODULE)?;?
return?0?;?
}?

/*?Release?*/?
int?simple_release(struct?inode?*inode?struct?file?*filp)?
{?
printk(“Simple?Device?is?released!\n“);
module_put(THIS_MODULE)?;?
return?0?;?
}?

static?ssize_t?simple_read(struct?file?*filechar?__user?*bufsize_t?countloff_t?*ppos)
{
int?rv =?0; /*?Return?Value?*/
if?(count?<=?0)
return?count;
printk(“Reading?Data?now...\n“);
if?(file->f_flags?&?O_NONBLOCK)?{?
rv?=?-EAGAIN;
return?rv;
}
//Get?data?from?Kernel?space.
return?rv;
}

/*?Write?*/
static?ssize_t?simple_write(struct?file?*fileconst?char?__user?*bufsize_t?lenloff_t?*ppos)
{
int?rv?=?0;
printk(“Writing?Data?now...\n“);
//Get?data?from?User?space.
return?rv;
}

/*?Llseek?*/
loff_t?simple_llseek(struct?file?*file?loff_t?offset?int?origin)
{
long?long?retval?=?

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????????764??2006-08-27?22:19??Chapter07\Makefile

?????文件????????660??2006-08-27?22:19??Chapter07\Makefile.x86

?????文件???????5899??2006-08-27?22:22??Chapter07\simple_chrdev.final.c

?????目錄??????????0??2009-03-07?14:28??Chapter07

-----------?---------??----------?-----??----

?????????????????7323????????????????????4


評論

共有 條評論