ARM-Linux驱动--MTD驱动分析(一)
时间:11-20
来源:互联网
点击:
- sanddelaytoensurethewrite
- succeeds(butnotsleep).*/
- int(*panic_write)(structmtd_info*mtd,loff_tto,size_tlen,size_t*retlen,constu_char*buf);
- //用于MTD设备的OBB数据读写
- int(*read_oob)(structmtd_info*mtd,loff_tfrom,
- structmtd_oob_ops*ops);
- int(*write_oob)(structmtd_info*mtd,loff_tto,
- structmtd_oob_ops*ops);
- /*
- *Methodstoaccesstheprotectionregisterarea,presentinsome
- *flashdevices.Theuserdataisonetimeprogrammablebutthe
- *factorydataisreadonly.
- */
- int(*get_fact_prot_info)(structmtd_info*mtd,structotp_info*buf,size_tlen);
- int(*read_fact_prot_reg)(structmtd_info*mtd,loff_tfrom,size_tlen,size_t*retlen,u_char*buf);
- int(*get_user_prot_info)(structmtd_info*mtd,structotp_info*buf,size_tlen);
- int(*read_user_prot_reg)(structmtd_info*mtd,loff_tfrom,size_tlen,size_t*retlen,u_char*buf);
- int(*write_user_prot_reg)(structmtd_info*mtd,loff_tfrom,size_tlen,size_t*retlen,u_char*buf);
- int(*lock_user_prot_reg)(structmtd_info*mtd,loff_tfrom,size_tlen);
- /*kvec-basedread/writemethods.
- NB:Thecountparameteristhenumberof_vectors_,eachof
- whichcontainsan(ofs,len)tuple.
- */
- int(*writev)(structmtd_info*mtd,conststructkvec*vecs,unsignedlongcount,loff_tto,size_t*retlen);
- /*Sync*/
- //MTD设备的同步函数
- void(*sync)(structmtd_info*mtd);
- /*Chip-supporteddevicelocking*/
- //芯片的加锁和解锁
- int(*lock)(structmtd_info*mtd,loff_tofs,uint64_tlen);
- int(*unlock)(structmtd_info*mtd,loff_tofs,uint64_tlen);
- /*PowerManagementfunctions*/
- //支持电源管理函数
- int(*suspend)(structmtd_info*mtd);
- void(*resume)(structmtd_info*mtd);
- /*Badblockmanagementfunctions*/
- //坏块管理函数
- int(*block_isbad)(structmtd_info*mtd,loff_tofs);
- int(*block_markbad)(structmtd_info*mtd,loff_tofs);
- structnotifier_blockreboot_notifier;/*defaultmodebeforereboot*/
- /*ECCstatusinformation*/
- structmtd_ecc_statsecc_stats;//ECC状态信息
- /*Subpageshift(NAND)*/
- intsubpage_sft;
- void*priv;//私有数据指针
- structmodule*owner;
- structdevicedev;
- intusecount;//记录用户的个数
- /*Ifthedriverissomethingsmart,likeUBI,itmayneedtomaintain
- *itsownreferencecounting.Thebelowfunctionsareonlyfordriver.
- *Thedrivermayregisteritscallbacks.Thesecallbacksarenot
- *supposedtobecalledbyMTDusers*/
- //驱动回调函数
- int(*get_device)(structmtd_info*mtd);
- void(*put_device)(structmtd_info*mtd);
- };
2、mtd_part结构体信息
- /*Ourpartitionlinkedlist*/
- staticLIST_HEAD(mtd_partitions);//分区链表
- /*Ourpartitionnodestructure*/
- //分区结构信息
- structmtd_part{
- structmtd_infomtd;//mtd_info数据结构,会被加入mtd_table中
- structmtd_info*master;//该分区的主分区
- uint64_toffset;//该分区的偏移地址
- structlist_headlist;//分区链表
- };
3、mtd_partition描述mtd具体分区结构
- /*
- *Partitiondefinitionstructure:
- *
- *AnarrayofstructpartitionispassedalongwithaMTDobjectto
- *add_mtd_partitions()tocreatethem.
- *
- *Foreachpartition,thesefieldsareavailable:
- *name:stringthatwillbeusedtolabelthepartitionsMTDdevice.
- *size:thepartitionsize;ifdefinedasMTDPART_SIZ_FULL,thepartition
- *willextendtotheendofthemasterMTDdevice.
- *offset:absolutestartingpositionwithinthemasterMTDdevice;if
- *definedasMTDPART_OFS_APPEND,thepartitionwillstartwherethe
- *previousoneended;ifMTDPART_OFS_NXTBLK,atthenexteraseblock.
- *mask_flags:containsflagsthathavetobemasked(removed)fromthe
- *masterMTDflagsetforthecorrespondingMTDpartition.
- *Forexample,toforcearead-onlypartition,simplyadding
- *MTD_WRITEABLEtothemask_flagswilldothetrick.
- *
- *Note:writeablepartitionsrequiretheirsizeandoffsetbe
- *erasesizealigned(e.g.useMTDPART_OFS_NEXTBLK).
- */
- structmtd_partition{
- char*name;/*identifierstring分区名*/
- uint64_tsize;/*partitionsize分区大小*/
- uint64_toffset;/*offsetwithinthemasterMTDspace偏移地址*/
- uint32_tmask_flags;/*masterMTDflagstomaskoutforthispartition*/
- structnand_ecclayout*ecclayout;/*outofbandlayoutforthispartition(NANDonly)*/
- };
ARM-Linux驱动MTD驱动分 相关文章:
- ARM-Linux驱动--MTD驱动分析(二)(11-20)
- ARM-Linux驱动--MTD驱动分析(三)(11-20)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)