Linux 通用数据结构说明
- device_driver include/linux/device.h struct device_driver {
const char * name; /* 驱动名称 */
struct bus_type * bus; /* 总线类型 */
struct completion unloaded; /* 卸载事件通知机制 */ struct kobject kobj; /* sys 中的对象 */
struct klist klist_devices; /* 设备列表 */ struct klist_node knode_bus; /* 总线结点列表 */
struct module * owner;/* 所有者 */
/* 设备驱动通用方法 */
int (*probe) (struct device * dev); /* 探测设备 */ int (*remove) (struct device * dev); /* 移除设备 */ void (*shutdown) (struct device * dev); /* 关闭设备 */
/* 挂起设备 */
int (*suspend) (struct device * dev, pm_message_t state, u32 level); int (*resume) (struct device * dev, u32 level); /* 恢复 */
};
- platform_device include/linux/device.h struct platform_device {
const char * name; /* 名称 */
u32 id; /* 设备编号, -1 表示不支持同类多个设备 */ struct device dev; /* 设备 */
u32 num_resources; /* 资源数 */ struct resource * resource; /* 资源列表 */
};
3. resource struct resource {
const char name; /*
资源名称 */
unsigned
long start, end; /* 开始位置和结束位置 */ unsigned long flags; /* 资源类型 */
/* 资源在资源树中的父亲,兄弟和孩子
*/ struct resource *parent, *sibling, *child;
};
4. device include/linux/device.h
struct device {
struct klist klist_children;
/* 在设备列表中的孩子列表 */ struct klist_node knode_parent; /* 兄弟结点 */
struct
klist_node knode_driver; /* 驱动结点 */ struct klist_node knode_bus; /* 总线结点 */ struct device parent; /* 父亲 */
struct kobject kobj; /* sys结点 */ char
bus_id[BUS_ID_SIZE];
struct semaphore
sem; /* 同步驱动的信号量 */
struct bus_type * bus; /* 总线类型 */
struct device_driver *driver; /* 设备驱动 */ void *driver_data;
/* 驱动的私有数据 */
void *platform_data; /* 平台指定的数据,为 device
核心驱动保留 */ void *firmware_data; /* 固件指定的数据,为 device
核心驱动保留 */ struct dev_pm_info
power; /* 设备电源管理信息 */
u64 *dma_mask; /* DMA掩码 */
u64 coherent_dma_mask;
struct
list_head dma_pools; /* DMA缓冲池 */
struct dma_coherent_mem *dma_mem; /* 连续 DMA 内存的起始位置
*/
void (*release)(struct device * dev); /*
释放设置方法 */
};
- nand_hw_control
include/linux/mtd/nand.h struct nand_hw_control {
spinlock_t lock; /* 自旋锁,用于硬件控制 */ struct nand_chip *active; /* 正在处理 MTD 设备
*/ wait_queue_head_t wq; /* 等待队列 */
};
- nand_chip
include/linux/mtd/nand.h struct nand_chip {
void iomem *IO_ADDR_R; /* 读地址 */ void iomem *IO_ADDR_W; /* 写地址 */
/* 字节操作 */
u_char (*read_byte)(struct mtd_info *mtd); /*
读一个字节 */
void (*write_byte)(struct mtd_info *mtd, u_char byte); /* 写一个字节 */
/*
双字节操作 */
u16 (*read_word)(struct mtd_info mtd); /* 读一个字 */
void (*write_word)(struct mtd_info *mtd, u16 word); /* 写一个字 */
/*
buffer 操作 */
void (*write_buf)(struct mtd_info *mtd, const u_char *buf, int len); void (*read_buf)(struct mtd_info
*mtd, u_char *buf, int len);
int (*verify_buf)(struct
mtd_info *mtd, const u_char
*buf, int len);
/*
选择一个操作芯片 */
void (*select_chip)(struct
mtd_info *mtd, int chip);
/*
坏块检查操作 */
int (*block_bad)(struct
mtd_info *mtd, loff_t ofs, int getchip);
/*
坏块标记操作 */
int (*block_markbad)(struct
mtd_info *mtd, loff_t ofs);
/*
硬件控制操作 */
void (*hwcontrol)(struct
mtd_info *mtd, int cmd);
/*
设备准备操作 */
int (*dev_ready)(struct
mtd_info *mtd);
/*
命令发送操作 */
void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int
page_addr);
/*
等待命令完成 */
int (*waitfunc)(struct mtd_info
*mtd, struct nand_chip
*this, int state);
/*
计算 ECC 码操作 */
int (*calculate_ecc)(struct
mtd_info *mtd, const u_char *dat,
u_char
*ecc_code);
/*
数据纠错操作 */
int (*correct_data)(struct mtd_info *mtd, u_char *dat, u_char *read_ecc,
u_char *calc_ecc);
/*
开启硬件 ECC */
void (*enable_hwecc)(struct
mtd_info *mtd, int mode);
/* 擦除操作 */
void (*erase_cmd)(struct
mtd_info *mtd, int page);
/* 检查坏块表 */
int (*scan_bbt)(struct
mtd_info *mtd);
int eccmode; /* ECC 模式 */
int eccsize; /* ECC 计算时使用的字节数 */
int eccbytes; /*
ECC 码的字节数 */
int eccsteps; /*
ECC 码计算的步骤数 */
int chip_delay;
/* 芯片的延迟时间 */ spinlock_t chip_lock; /*
芯片访问的自旋锁 */ wait_queue_head_t wq; /* 芯片访问的等待队列 */ nand_state_t state; /*
Nand Flash 状态 */
int page_shift; /* 页右移的位数,即 column
地址位数 */
int phys_erase_shift; /* 块右移的位数, 即 column 和页一共的地址位数 */ int bbt_erase_shift; /* 坏块页表的位数 */
int chip_shift; /* 该芯片总共的地址位数 */
u_char *data_buf; /*
数据缓冲区 */
u_char *oob_buf; /*
oob 缓冲区 */
int oobdirty; /*
oob 缓冲区是否需要重新初始化 */
u_char *data_poi; /* 数据缓冲区指针 */ unsigned int options; /*
芯片专有选项 */
int badblockpos;/* 坏块标示字节在 OOB 中的位置 */
int numchips; /* 芯片的个数 */
|
unsigned |
long |
chipsize; |
/* |
|
int |
pagemask; |
/* 每个芯片页数的屏蔽字, 通过它取出每个芯片包含多少个页 */ |
|
|
int |
pagebuf; |
/* |
struct nand_oobinfo *autooob; /* oob 信息 */ uint8_t *bbt; /* 坏块页表 */
struct nand_bbt_descr *bbt_td;
/* 坏块表描述 */
struct nand_bbt_descr *bbt_md; /*
坏块表镜像描述 */
struct nand_bbt_descr *badblock_pattern; /* 坏块检测模板 */
struct nand_hw_control *controller; /* 硬件控制 */
void *priv;
/* 私有数据结构 */
/*
进行附加错误检查 */
int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page);
};
- mtd_info include/linux/mtd/mtd.h struct mtd_info {
u_char type; /* 设备类型 */ u_int32_t flags; /* 设备标志位组 */ u_int32_t
size; /* 总共设备的大小 */ u_int32_t
erasesize; /* 擦除块的大小 */
u_int32_t
oobblock; /* OOB 块的大小,如:512 个字节有一个 OOB */ u_int32_t oobsize; /* OOB数据的大小,如:一个 OOB 块有 16 个字节
*/ u_int32_t ecctype; /* ECC 校验的类型 */
u_int32_t eccsize; /* ECC 码的大小 */
char
*name; /* 设备名称 */
int
index; /* 设备编号 */
/* oobinfo
信息,它可以通过 MEMSETOOBINFO ioctl 命令来设置 */ struct nand_oobinfo oobinfo;
u_int32_t
oobavail; /* OOB区的有效字节数,为文件系统提供 */
/* 数据擦除边界信息 */
int numeraseregions;
struct mtd_erase_region_info *eraseregions;
u_int32_t
bank_size; /* 保留 */
/*
擦除操作 */
int (*erase) (struct mtd_info *mtd,
struct erase_info *instr);
/* 指向某个执行代码位置 */
int (*point) (struct mtd_info *mtd,
loff_t from,
size_t len, size_t *retlen, u_char **mtdbuf);
/*
取消指向 */
void (*unpoint)
(struct mtd_info *mtd, u_char *
addr, loff_t from, size_t len);
/*
读/写操作 */
int (*read) (struct
mtd_info *mtd, loff_t
from, size_t len, size_t *retlen, u_char *buf); int (*write) (struct mtd_info
*mtd, loff_t to, size_t
len,
size_t *retlen, const u_char *buf);
/* 带 ECC 码的读/写操作 */
int
(*read_ecc) (struct mtd_info
*mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf,
u_char *eccbuf, struct nand_oobinfo *oobsel);
int (*write_ecc) (struct mtd_info
*mtd, loff_t to, size_t len, size_t *retlen,
const u_char *buf, u_char *eccbuf, struct
nand_oobinfo *oobsel);
/* 带 OOB 码的读/写操作 */
int
(*read_oob) (struct mtd_info
*mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf);
int
(*write_oob) (struct mtd_info
*mtd, loff_t to, size_t
len, size_t *retlen, const u_char *buf);
/* 提供访问保护寄存器区的方法 */
int (*get_fact_prot_info) (struct
mtd_info *mtd, struct
otp_info *buf, size_t
len); int (*read_fact_prot_reg) (struct
mtd_info *mtd, loff_t
from, size_t len,
size_t *retlen, u_char *buf);
int (*get_user_prot_info) (struct
mtd_info *mtd, struct
otp_info *buf, size_t
len); int (*read_user_prot_reg) (struct
mtd_info *mtd, loff_t
from, size_t len,
size_t *retlen, u_char *buf);
int (*write_user_prot_reg) (struct
mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf);
int (*lock_user_prot_reg) (struct
mtd_info *mtd, loff_t from, size_t len);
/* 提供 readv
和 writev 方法 */
int
(*readv) (struct mtd_info
*mtd, struct kvec *vecs, unsigned long count, loff_t from, size_t *retlen);
int
(*readv_ecc) (struct mtd_info
*mtd, struct kvec *vecs, unsigned long count, loff_t from, size_t *retlen, u_char *eccbuf,
struct nand_oobinfo *oobsel);
int (*writev) (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen);
int (*writev_ecc) (struct mtd_info
*mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen, u_char *eccbuf, struct
nand_oobinfo *oobsel);
/*
同步操作 */
void (*sync) (struct mtd_info *mtd);
/* 芯片级支持的加/解锁操作 */
int (*lock) (struct mtd_info *mtd, loff_t ofs, size_t len);
int (*unlock) (struct mtd_info *mtd, loff_t ofs, size_t len);
/* 电源管理操作 */
int (*suspend) (struct mtd_info *mtd); void (*resume) (struct mtd_info *mtd);
/* 坏块管理操作 */
int (*block_isbad) (struct mtd_info *mtd, loff_t ofs); int (*block_markbad) (struct mtd_info *mtd, loff_t ofs);
/* 重启前的通知事件 */
struct
notifier_block reboot_notifier; void *priv; /* 私有数据结构 */
struct module
*owner; /* 模块所有者 */ int usecount; /* 使用次数 */
};
Linux 通用数据结构说明的更多相关文章
- 探索Linux通用SCSI驱动器
通过 SCSI 命令管理计算机上的数据,并将数据传输到 SCSI 设备.在本文中,作者介绍了一些 SCSI 命令,以及在 Linux® 中使用 SCSI API 时执行 SCSI 命令的方法.他介绍了 ...
- C语言实现通用数据结构的高效设计
近期在阅读一个开源的C++代码.里面用到了大量的STL里面的东西.或许是自己一直用C而非常少用C++来实现算法的原因.STL里面大量的模板令人心烦.一直对STL的效率表示怀疑,但在网上搜到这样一个帖子 ...
- linux内核数据结构之链表
linux内核数据结构之链表 1.前言 最近写代码需用到链表结构,正好公共库有关于链表的.第一眼看时,觉得有点新鲜,和我之前见到的链表结构不一样,只有前驱和后继指针,而没有数据域.后来看代码注释发现该 ...
- GDSL 1.7 发布,C语言通用数据结构库
GDSL 1.7 修复了 interval-heap 模块的一个小 bug. GDSL (通用数据结构库) 包含一组程序用于操作各种数据结构.这是一个可移植的库,完全由 ANSI C 编写.为 C 开 ...
- Linux通用小技能
Linux通用小技能 前言 无论你用ubuntu还是centos,通通没问题,运维这东西,踩坑写文档就是了. 小技能 新磁盘挂载 不管是阿里云还是腾讯云,还是自己的机器,请记住这条命令. mkfs.e ...
- Linux 内核数据结构:Linux 双向链表
Linux 内核提供一套双向链表的实现,你可以在 include/linux/list.h 中找到.我们以双向链表着手开始介绍 Linux 内核中的数据结构 ,因为这个是在 Linux 内核中使用最为 ...
- Linux 内核数据结构:双向链表
Linux 内核提供一套双向链表的实现,你可以在 include/linux/list.h 中找到.我们以双向链表着手开始介绍 Linux 内核中的数据结构 ,因为这个是在 Linux 内核中使用最为 ...
- linux内核数据结构学习总结
目录 . 进程相关数据结构 ) struct task_struct ) struct cred ) struct pid_link ) struct pid ) struct signal_stru ...
- Linux VFS数据结构
先说明一下,linux内核中各种数据结构也不停的在变,所以不同版本的内核各个数据结构的定义可能会差别很大,这一组关于linux 文件系统的文章中的代码都摘自linux-2.6.34.1. VFS依赖于 ...
随机推荐
- 同构图+思维构造——牛客多校第六场E
考的其实是同构图的性质: 1.同构图的顶点数,边数相等 2.同构图通过点的映射后邻接矩阵相同 这篇博客讲的很好https://www.jianshu.com/p/c33b5d1b4cd9 本题还需要一 ...
- flume的安装和使用
1.下载 [linyouyi@hadoop01 software]$ wget https://mirrors.aliyun.com/apache/flume/1.9.0/apache-flume-1 ...
- USACO 06JAN 牛的舞会 洛谷2863
题目描述 The N (2 <= N <= 10,000) cows are so excited: it's prom night! They are dressed in their ...
- NX二次开发-UFUN获取球的参数UF_MODL_ask_sphere_parms
NX11+VS2013 #include <uf.h> #include <uf_modl.h> #include <uf_ui.h> UF_initialize( ...
- 暴力”注入Explorer
暴力"注入Explorer pjf(jfpan20000@sina.com) 向一个运行中的进程注入自己的代码,最自然莫过于使用Cr ...
- LeetCode 1037. Valid Boomerang (有效的回旋镖)
题目标签:Math 题目给了我们三个点,让我们判断这三个点是否在一条直线上. 利用斜率 k = (y1 - y0) / (x1 - x0) 来判断,如果 三个点 abc, ab 的斜率 = bc 的斜 ...
- python数据结构之图的实现方法
python数据结构之图的实现方法 本文实例讲述了python数据结构之图的实现方法.分享给大家供大家参考.具体如下: 下面简要的介绍下: 比如有这么一张图: A -> B A ...
- 解决ios10及以上Safari双击和双指缩放无法禁止的问题
移动端web缩放有两种: 1.双击缩放: 2.双指手势缩放. 在iOS 10以前,iOS和Android都可以通过一行meta标签来禁止页面缩放 <meta content="widt ...
- POJ 4718 /// 树链剖分+线段树区间合并 求树上两点间的LCIS长度
题目大意: 给定n个点 每个点都有权值 接下来给定树的n条边 第 i 个数 a[i] 表示 i+1到a[i]之间 有一条边 给定q q个询问 每次询问给出 x y 求x到y的最长上升子序列的长度 题解 ...
- JS对象 四舍五入round() round() 方法可把一个数字四舍五入为最接近的整数。 语法: Math.round(x)
四舍五入round() round() 方法可把一个数字四舍五入为最接近的整数. 语法: Math.round(x) 参数说明: 注意: 1. 返回与 x 最接近的整数. 2. 对于 0.5,该方法将 ...