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

wordpress慢数据库南宁seo标准

wordpress慢数据库,南宁seo标准,手工业网站怎么做,营销型网站建设sempkARM驱动学习之8 动态申请字符类设备号 KernelCode: • 字符设备函数在文件“include/linux/fs.h”中 • alloc_chrdev_region() 是动态分配主次设备号。 • 宏定义MAJOR提取dev_t数据中的主设备号源码: /*** alloc_chrdev_region() - register a range of char dev…

                            ARM驱动学习之8 动态申请字符类设备号

KernelCode:
• 字符设备函数在文件“include/linux/fs.h”中
• alloc_chrdev_region() 是动态分配主次设备号。
• 宏定义MAJOR提取dev_t数据中的主设备号源码:
/*** alloc_chrdev_region() - register a range of char device numbers* @dev: output parameter for first assigned number* @baseminor: first of the requested range of minor numbers * @count: the number of minor numbers required* @name: the name of the associated device or driver** Allocates a range of char device numbers.  The major number will be* chosen dynamically, and returned (along with the first minor number)* in @dev.  Returns zero or a negative error code.*/int alloc_chrdev_region(dev_t *dev,unsigned baseminor, unsigned count,const char *name)
{struct char_device_struct *cd;cd = __register_chrdev_region(0, baseminor, count, name);if (IS_ERR(cd))return PTR_ERR(cd);*dev = MKDEV(cd->major, cd->baseminor);return 0;
}/*** unregister_chrdev_region() - return a range of device numbers* @from: the first in the range of numbers to unregister* @count: the number of device numbers to unregister** This function will unregister a range of @count device numbers,* starting with @from.  The caller should normally be the one who* allocated those numbers in the first place...*/
void unregister_chrdev_region(dev_t from, unsigned count)
{dev_t to = from + count;dev_t n, next;for (n = from; n < to; n = next) {next = MKDEV(MAJOR(n)+1, 0);if (next > to)next = to;kfree(__unregister_chrdev_region(MAJOR(n), MINOR(n), next - n));}
}1.在scdev_init如下:
DEVICE_NAME改为“ascdev”
ret = alloc_chrdev_region(&num_dev,numdev_minor,DEVICE_MINOR_NUM,DEVICE_NAME);
numdev_magor = MAJOR(num_dev);
printk(KERN_EMERGE "numdev_magor is %d \n",numdev_magor);• 加载运行
– 使用命令“cat /proc/devices”查看
– 动态加载模块之后再查看设备号

源码:

#include <linux/init.h>
/*包含初始化宏定义的头文件,代码中的module_init和module_exit在此文件中*/
#include <linux/module.h>
/*包含初始化加载模块的头文件,代码中的MODULE_LICENSE在此头文件中*//*定义module_param module_param_array的头文件*/
#include <linux/moduleparam.h>
/*定义module_param module_param_array中perm的头文件*/
#include <linux/stat.h>/*字符设备函数*/
#include <linux/fs.h>
/*MDKDEV转换设备号数据类型宏定义*/
#include <linux/kdev_t.h>
/*定义字符设备的结构体*/
#include <linux/cdev.h>#define DEVICE_NAME "Ascdev"
#define DEVICE_MINOR_NUM 2
#define DEV_MAJOR 0
#define DEV_MINOR 0MODULE_LICENSE("Dual BSD/GPL");
/*声明是开源的,没有内核版本限制*/
MODULE_AUTHOR("iTOPEET_dz");
/*声明作者*/static int numdev_major = DEV_MAJOR ;//主设备号
static int numdev_minor = DEV_MINOR ;//次设备号module_param(numdev_major,int,S_IRUSR);
module_param(numdev_minor,int,S_IRUSR);static int Ascdev_init(void)
{int ret = 0;dev_t num_dev;if(numdev_major){num_dev = MKDEV(numdev_major,numdev_minor);//宏命令,用于处理各种设备号相关的数据//设备注册ret = register_chrdev_region(num_dev,DEVICE_MINOR_NUM,DEVICE_NAME);if(ret < 0){printk(KERN_EMERG "register_chrdev_region req is %d is failed \n",num_dev );return -1;}printk(KERN_EMERG "register_chrdev_region %d is success \n",numdev_major);	}else{ret = alloc_chrdev_region(&num_dev,numdev_minor,DEVICE_MINOR_NUM,DEVICE_NAME);if(ret < 0){printk(KERN_EMERG "alloc_chrdev_region req is %d is failed \n",num_dev );return -1;}numdev_major = MAJOR(num_dev);printk(KERN_EMERG "numdev_major is %d \n",numdev_major);}printk(KERN_EMERG "Ascdev enter!\n");/*打印信息,KERN_EMERG表示紧急信息*/return 0;
}static void Ascdev_exit(void)
{	unregister_chrdev_region(MKDEV(numdev_major,numdev_minor),DEVICE_MINOR_NUM);printk(KERN_EMERG "Ascdev exit!\n");
}module_init(Ascdev_init);
/*初始化函数*/
module_exit(Ascdev_exit);
/*卸载函数*/

Makefile:

#!/bin/bash
#通知编译器我们要编译模块的哪些源码
#这里是编译itop4412_hello.c这个文件编译成中间文件itop4412_hello.o
#obj-m += mini_linux_module.o 
obj-m += request_cdev_num.o 
#源码目录变量,这里用户需要根据实际情况选择路径
#作者是将Linux的源码拷贝到目录/home/topeet/android4.0下并解压的
KDIR := /home/topeet/Android4.0/iTop4412_Kernel_3.0
#当前目录变量
PWD ?= $(shell pwd)#make命名默认寻找第一个目标
#make -C就是指调用执行的路径
#$(KDIR)Linux源码目录,作者这里指的是/home/topeet/android4.0/iTop4412_Kernel_3.0
#$(PWD)当前目录变量
#modules要执行的操作
all:make -C $(KDIR) M=$(PWD) modules#make clean执行的操作是删除后缀为o的文件
clean:rm -rf *.mod.c *.o *.order *.ko *.mod.o *.symvers

http://www.tj-hxxt.cn/news/37902.html

相关文章:

  • 山东平台网站建设多少钱seo入门课程
  • 用dw做的网站怎么上线免费网站推广网站短视频
  • 建设久久建筑网站网站设计规划
  • 政府门户网站建设和管理论文黄页引流推广网站入口
  • 做企业网站价格seo诊断方法步骤
  • 文化传媒公司网站建设网上销售
  • 网站建设宣传单页seo与sem的区别和联系
  • 江苏永坤建设有限公司网站seo管家
  • wordpress 帮助南京seo排名
  • 网站被封了怎么办线上营销手段有哪些
  • 做网站尺寸一般都多大苏州关键词排名提升
  • 企业网站开发工资站长之家是什么网站
  • 成都专业建设网站百度深圳总部
  • 灵台门户网站建设网络推广渠道公司
  • 做钢材什么网站好武汉seo招聘信息
  • 厦门 网站建设企业网站推广方案设计毕业设计
  • 网站开发与设计结课大作业公司运营策划方案
  • 深圳好看的网站建设哪家公司好seo搜索引擎优化业务
  • 十大计算机培训机构排名优化营商环境的措施建议
  • wordpress 搭建宁海关键词优化怎么优化
  • 淘宝客网站做seo友链网
  • windows版本的wordpressseo收录查询工具
  • 网站运营需要什么行业技术懂得网站推广
  • 杂志网站建设推广网站有哪些
  • 做网站分层技术廊坊seo优化
  • 福州网站建设网站设计网站推广百度搜索引擎算法
  • 锋云科技做网站靠谱吗seo的基本内容
  • 网站制作费用及后期运营淘宝seo是指什么
  • 一个公司做两个网站可以吗seo搜索引擎优化论文
  • 深圳电子商城网站建设百度指数查询官网入口