手机版
你好,游客 登录 注册
背景:
阅读新闻

MTD 设备驱动 和 NAND Flash 驱动程序分析

[日期:2012-05-01] 来源:Linux社区  作者:acanoe [字体:大 中 小]

4、mtd_part 结构体分析     此结构定义在 ../drivers/mtd/mtdpart.c 中

  1. struct mtd_part {  
  2.     struct mtd_info mtd;      // 分区的信息(大部分由其 master 决定)   
  3.     struct mtd_info *master;  // 该分区的主分区   
  4.     uint64_t offset;          // 分区的偏移地址   
  5.     struct list_head list;    // 分区号   
  6. };  
mtd_part 结构体由于表示分区,它在mtd_info 结构体成员用于描述该分区, 它会被加入到 mtd_table (定义为 struct mtd_info *mtd_table[MAX_MTD_DEVICES])中,

其大部分成员有 mtd_part—> 决定,各种函数也指向主分区的相应函数。


5、mtd_partition 结构体分析    该结构体定义在 include/linux/mtd/partitions.h 中

  1. struct mtd_partition {  
  2.     char *name;         /* identifier string */     // 标识字符串   
  3.     uint64_t size;          /* partition size */        // 分区大小   
  4.     uint64_t offset;        /* offset within the master MTD space */                              // 主MTD空间内的偏移量                         
  5.     uint32_t mask_flags;        /* master MTD flags to mask out for this partition */                 // 掩码标志   
  6.     struct nand_ecclayout *ecclayout;   /* out of band layout for this partition (NAND only)*/  
  7. };  

mtd_partttion 会在MTD 原始设备层调用 add_mtd_partitons() 时传递分区信息,并通过下面两个函数进行注册和注销 分区:

  1. int add_mtd_partitions( struct mtd_info *master, struct mtd_partition *parts, int nbparts);  
  2. int del_mtd_partitions (struct mtd_info *master);  
add_mtd_partitions() 会对每一个新建立的分区建立一个新的 mtd_part 结构体,将其加入 mtd_partitions 中,并调用 add_mtd_device () 将此分区作为 MTD 设备加入 mtd_tabe。 linux
相关资讯       Linux驱动开发 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款