当前位置: 首页 > news >正文

专门做当归的网站网站seo哪里做的好

专门做当归的网站,网站seo哪里做的好,网站建设含意,赣州市官网PCIe驱动开发(2)— 第一个简单驱动编写和测试 一、前言 教程参考:02_实战部分_PCIE设备测试 教程参考:03_PCIe设备驱动源码解析 二、驱动编写 新建hello_pcie.c文件 touch hello_pcie.c然后编写内容如下所示: #i…

PCIe驱动开发(2)— 第一个简单驱动编写和测试

一、前言

教程参考:02_实战部分_PCIE设备测试
教程参考:03_PCIe设备驱动源码解析

二、驱动编写

新建hello_pcie.c文件

touch hello_pcie.c

然后编写内容如下所示:

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>#define HELLO_PCI_DEVICE_ID	    0x11e8
#define HELLO_PCI_VENDOR_ID	    0x1234
#define HELLO_PCI_REVISION_ID	0x10static struct pci_device_id ids[] = {{ PCI_DEVICE(HELLO_PCI_VENDOR_ID, HELLO_PCI_DEVICE_ID), },{ 0 , }
};static struct hello_pci_info_t {struct pci_dev *dev;void __iomem *address_bar0;
} hello_pci_info;MODULE_DEVICE_TABLE(pci, ids);static irqreturn_t hello_pci_irq_handler(int irq, void *dev_info)
{struct hello_pci_info_t *_pci_info = dev_info;uint32_t irq_status;// get irq_stutasirq_status = *((uint32_t *)(_pci_info->address_bar0 + 0x24));printk("hello_pcie: get irq status: 0x%0x\n", irq_status);// clean irq*((uint32_t *)(_pci_info->address_bar0 + 0x64)) = irq_status;// get irq_stutasirq_status = *((uint32_t *)(_pci_info->address_bar0 + 0x24));if(irq_status == 0x00){printk("hello_pcie: receive irq and clean success. \n");return IRQ_HANDLED;}else{printk("hello_pcie: receive irq but clean failed !!! \n");return IRQ_NONE;}
}static int hello_pcie_probe(struct pci_dev *dev, const struct pci_device_id *id)
{int bar = 0;int ret;resource_size_t len;ret = pci_enable_device(dev);if(ret) {return ret;}len = pci_resource_len(dev, bar);hello_pci_info.address_bar0 = pci_iomap(dev, bar, len);hello_pci_info.dev = dev;// register interruptret = request_irq(dev->irq, hello_pci_irq_handler, IRQF_SHARED, "hello_pci", &hello_pci_info);if(ret) {printk("request IRQ failed.\n");return ret;}// enable irq for finishing factorial computation*((uint32_t *)(hello_pci_info.address_bar0 + 0x20)) = 0x80;return 0;
}static void hello_pcie_remove(struct pci_dev *dev)
{// disable irq for finishing factorial computation*((uint32_t *)(hello_pci_info.address_bar0 + 0x20)) = 0x01;free_irq(dev->irq, &hello_pci_info);pci_iounmap(dev, hello_pci_info.address_bar0);pci_disable_device(dev);
}static struct pci_driver hello_pci_driver = {.name		= "hello_pcie",.id_table	= ids,.probe		= hello_pcie_probe,.remove		= hello_pcie_remove,
};static int __init hello_pci_init(void)
{return pci_register_driver(&hello_pci_driver);
}static void __exit hello_pci_exit(void)
{pci_unregister_driver(&hello_pci_driver);
}MODULE_LICENSE("GPL");
module_init(hello_pci_init);
module_exit(hello_pci_exit);

三、驱动编译

新建Makefile文件编写内容如下:


ifeq ($(KERNELRELEASE),)KERNELDIR ?= /lib/modules/$(shell uname -r)/build  
PWD := $(shell pwd)all:$(MAKE) -C $(KERNELDIR) M=$(PWD) modules clean:rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions Module* modules*.PHONY: all cleanelseobj-m := hello_pcie.o
endif

然后执行 make命令进行编译
在这里插入图片描述
编译完成后可以得到驱动对应的 .ko文件
在这里插入图片描述

四、驱动加载及测试

驱动编译完成后使用如下命令加载即可:

sudo insmod hello_pcie.ko

然后使用lspci查看该pcie设备,可以看到驱动加载成功:
在这里插入图片描述
同时我们也可以看到其BAR0基地址为0xfea00000,我们使用devmem向其0x08编译地址写入数据进行阶乘运算:
在这里插入图片描述

使用详细说明可以查看查看qemu源码的docs/specs/edu.txt文件
在这里插入图片描述
然后我们使用dmesg命令可以查看驱动的相关打印:
在这里插入图片描述

http://www.dt0577.cn/news/3664.html

相关文章:

  • 做网站需要自己上传产品吗谷歌ads广告投放
  • 甘肃省引洮工程建设管理局官方网站搜索引擎优化与关键词的关系
  • web前段和网站开发百度seo推广是什么
  • 博彩网站怎么做产品网络推广的方法有哪些
  • 开发公司网站公司seo是哪个英文的缩写
  • wordpress默认后台登陆地址seo推广培训
  • 数据库查询网站建设推广文案怎么写
  • 自己做发小说网站泉州百度搜索推广
  • 做网站台式还是笔记本北京seo公司哪家好
  • 门户网站举例北京seo网络优化师
  • 怎么做网站demo网店代运营收费
  • 网站链接数怎么做aso优化
  • phpcms手机网站爱站网长尾词挖掘工具
  • 做网站不打广告怎么赚钱怎么推广引流客户
  • 一般网站海报做一张多久西安百度百科
  • 网站建设怎么收费爱站关键词搜索
  • 从什么网站可以做兼职软件推广接单平台
  • 做网站frontpage 2003建立网站需要什么条件
  • 表格模板网站网站建设的整体流程有哪些
  • 网站怎样做外链阿里巴巴怎么优化关键词排名
  • 台州网站建设团队域名停靠浏览器
  • 怎样建设团学组织微信网站打开百度首页
  • 怎么破解别人做的付费网站网站优化公司收费
  • 无人视频在线观看免费播放影院seo运营学校
  • 杭州网站推广找哪家广州 竞价托管
  • 做网站客户改来改去网络营销软件下载
  • 怎么弄 一个空间放两个网站 用不同的域名郴州seo
  • 做互联网的网站郑州网站运营
  • 佛山高端网站制作公司哪家好网络营销岗位招聘信息
  • 企点是干嘛用的网站排名优化价格