Linux Platform Device and Driver
从Linux 2.6起引入了一套新的驱动管理和注册机制:Platform_device和Platform_driver。
Linux中大部分的设备驱动,都可以使用这套机制, 设备用Platform_device表示,驱动用Platform_driver进行注册。
Linux platform driver机制和传统的device driver 机制(通过driver_register函数进行注册)相比,一个十分明显的优势在于platform机制将设备本身的资源注册进内核,由内核统一管理,在驱动程序中使用这些资源时通过platform device提供的标准接口进行申请并使用。这样提高了驱动和资源管理的独立性,并且拥有较好的可移植性和安全性(这些标准接口是安全的)。
Platform机制的本身使用并不复杂,由两部分组成:platform_device和platfrom_driver。
通过Platform机制开发发底层驱动的大致流程为: 定义 platform_device à 注册 platform_device à 定义 platform_driver à注册 platform_driver。
首先要确认的就是设备的资源信息,例如设备的地址,中断号等。
在2.6内核中platform设备用结构体platform_device来描述,该结构体定义在kernel\include\linux\platform_device.h中,
struct platform_device {
const char * name;
u32 id;
struct device dev;
u32 num_resources;
struct resource * resource;
};
该结构一个重要的元素是resource,该元素存入了最为重要的设备资源信息,定义在kernel\include\linux\ioport.h中,
struct resource {
const char *name;
unsigned long start, end;
unsigned long flags;
struct resource *parent, *sibling, *child;
};
下面举s3c2410平台的i2c驱动作为例子来说明:
/* arch/arm/mach-s3c2410/devs.c */
/* I2C */
static struct resource s3c_i2c_resource[] = {
[0] = {
.start = S3C24XX_PA_IIC,
.end = S3C24XX_PA_IIC + S3C24XX_SZ_IIC - 1,
相关文档:
软实时和硬实时,软实时是说违反了程序执行的deadline也不会有致命的错误,而硬实时的deadline是写死的。
很多linux有硬实时的补丁,如MontaVista。
有源晶振和无源晶振,有源的叫osllicator,无源的叫crystal。
uclinux是静态编译的,没有mmu机制。
x86的要选xterm...
serveu假设服务器 + linux用sftp(通过ssh ......
在windows上尝试centos后我直接给格式化掉centos,启动系统出现grub的启动画面,有2个解决方案
1:在dos环境下用fdisk /mbr 级可以修复mbr即可
2:如果没dos盘则用下面命令:
1)rootnoverify (hd0,0) //回车,记得rootnoverify后面有个空格
2)chainloader (hd0,0)+1 // 记得还是有空格
3 ......
/*
socket select模型,服务端
绝大多数注释自己写的,参考man
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/un.h>
#include &l ......
如果你既没做系统启动软盘,同时多系统的引导LILO 和GRUB 又被删除,那么只能使用Linux 系统安装盘来恢复root的密码,步骤如下。 一. lilo引导在出现 lilo: 提示时键入 linux single Boot: linux single 回车可直接进入linux单用户模式 vi /etc/passwd 删除root项中的密码 (这里也可以直接使用passwd命令重新设置root的密码 ......