From f48f6ea34e9e92333db9ab81fa00094e1a2239f3 Mon Sep 17 00:00:00 2001 From: kuangyufei Date: Wed, 11 Aug 2021 18:30:10 +0800 Subject: [PATCH] =?UTF-8?q?=20=E6=B3=A8=E8=A7=A3=E6=A0=B9=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=B3=BB=E7=BB=9F=20=20=20=20=20=E7=99=BE=E4=B8=87?= =?UTF-8?q?=E6=B1=89=E5=AD=97=E6=B3=A8=E8=A7=A3=20+=20=E7=99=BE=E7=AF=87?= =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E5=88=86=E6=9E=90=20=3D>=20=E6=8C=96?= =?UTF-8?q?=E9=80=8F=E9=B8=BF=E8=92=99=E5=86=85=E6=A0=B8=E6=BA=90=E7=A0=81?= =?UTF-8?q?=20=20=20=20=20=E5=8D=9A=E5=AE=A2=E8=BE=93=E5=87=BA=E7=AB=99?= =?UTF-8?q?=E7=82=B9(=E5=9B=BD=E5=86=85):http://weharmonyos.com=20=20=20?= =?UTF-8?q?=20=20=E5=8D=9A=E5=AE=A2=E8=BE=93=E5=87=BA=E7=AB=99=E7=82=B9(?= =?UTF-8?q?=E5=9B=BD=E5=A4=96):https://openharmony.github.io=20=20=20=20?= =?UTF-8?q?=20=E6=B3=A8=E8=A7=A3=E6=96=87=E4=BB=B6=E7=B3=BB=E7=BB=9F:https?= =?UTF-8?q?://gitee.com/weharmony/third=5Fparty=5FNuttX=20=20=20=20=20?= =?UTF-8?q?=E6=B3=A8=E8=A7=A3=E5=8D=8F=E8=AE=AE=E6=A0=88:https://gitee.com?= =?UTF-8?q?/weharmony/third=5Fparty=5Flwip=20=20=20=20=20=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3=E7=BC=96=E8=AF=91=E5=AD=90=E7=B3=BB=E7=BB=9F:https://?= =?UTF-8?q?gitee.com/weharmony/build=5Flite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 142 +-------- drivers/mtd/multi_partition/include/mtd_dev.h | 90 +++--- .../multi_partition/include/mtd_partition.h | 276 +++++++++--------- fs/proc/os_adapt/proc_vfs.c | 2 +- fs/vfs/operation/fs_init.c | 2 +- fs/vfs/vnode.c | 4 +- kernel/common/rootfs/los_bootargs.c | 18 +- kernel/common/rootfs/los_bootargs.h | 2 +- kernel/common/rootfs/los_rootfs.c | 40 +-- kernel/common/rootfs/los_rootfs.h | 2 +- zzz/git/push.sh | 2 +- 11 files changed, 221 insertions(+), 359 deletions(-) diff --git a/README.md b/README.md index fbc3e1dd..12075bc2 100644 --- a/README.md +++ b/README.md @@ -116,147 +116,9 @@ # zzz 的想法源于微信中名称为AAA的那帮朋友,你的微信里应该也有他们熟悉的身影吧 :|P ``` -### **百篇博客.往期回顾** -在加注过程中,整理出以下文章。内容立足源码,常以生活场景打比方尽可能多的将内核知识点置入某种场景,具有画面感,容易理解记忆。说别人能听得懂的话很重要! 百篇博客绝不是百度教条式的在说一堆诘屈聱牙的概念,那没什么意思。更希望让内核变得栩栩如生,倍感亲切.确实有难度,自不量力,但已经出发,回头已是不可能的了。 :P +### **鸿蒙内核源码分析.总目录** -与代码有bug需不断debug一样,文章和注解内容会存在不少错漏之处,请多包涵,但会反复修正,持续更新,`.xx`代表修改的次数,精雕细琢,言简意赅,力求打造精品内容。 - -* [v63.xx 鸿蒙内核源码分析(文件系统篇) | 用图书管理说文件系统 ](https://my.oschina.net/weharmony/blog/5165752) **[ | 51](https://harmonyos.51cto.com/posts/7609)[ .c](https://blog.csdn.net/kuangyufei/article/details/119217155)[ .h](http://weharmonyos.com/blog/63_文件系统篇.html)[ .o](https://my.oschina.net/weharmony)** - - -* [v62.xx 鸿蒙内核源码分析(文件概念篇) | 为什么说一切皆是文件 ](https://my.oschina.net/weharmony/blog/5152858) **[ | 51](https://harmonyos.51cto.com/posts/7460)[ .c](https://blog.csdn.net/kuangyufei/article/details/119425132)[ .h](http://weharmonyos.com/blog/62_文件概念篇.html)[ .o](https://my.oschina.net/weharmony)** - -* [v61.xx 鸿蒙内核源码分析(忍者ninja篇) | 都忍者了能不快吗 ](https://my.oschina.net/weharmony/blog/5139034) **[ | 51](https://harmonyos.51cto.com/posts/7328)[ .c](https://blog.csdn.net/kuangyufei/article/details/118970589)[ .h](http://weharmonyos.com/blog/61_忍者ninja篇.html)[ .o](https://my.oschina.net/weharmony)** - -* [v60.xx 鸿蒙内核源码分析(gn应用篇) | gn语法及在鸿蒙的使用 ](https://my.oschina.net/weharmony/blog/5137565) **[ | 51](https://harmonyos.51cto.com/posts/7310)[ .c](https://blog.csdn.net/kuangyufei/article/details/118932416)[ .h](http://weharmonyos.com/blog/60_gn应用篇.html)[ .o](https://my.oschina.net/weharmony)** - -* [v59.xx 鸿蒙内核源码分析(构建工具篇) | 顺瓜摸藤调试鸿蒙构建过程 ](https://my.oschina.net/weharmony/blog/5135157) **[ | 51](https://harmonyos.51cto.com/posts/7287)[ .c](https://blog.csdn.net/kuangyufei/article/details/118878233)[ .h](http://weharmonyos.com/blog/59_构建工具篇.html)[ .o](https://my.oschina.net/weharmony)** - -* [v58.xx 鸿蒙内核源码分析(环境脚本篇) | 编译鸿蒙原来如此简单 ](https://my.oschina.net/weharmony/blog/5132725) **[ | 51](https://harmonyos.51cto.com/posts/7248)[ .c](https://blog.csdn.net/kuangyufei/article/details/118765692)[ .h](http://weharmonyos.com/blog/58_编译脚本篇.html)[ .o](https://my.oschina.net/weharmony)** - -* [v57.xx 鸿蒙内核源码分析(编译过程篇) | 简单案例窥视GCC编译全过程 ](https://my.oschina.net/weharmony/blog/5064209) **[ | 51](https://harmonyos.51cto.com/posts/5032)[ .c](https://blog.csdn.net/kuangyufei/article/details/117419679)[ .h](http://weharmonyos.com/blog/57_编译过程篇.html)[ .o](https://my.oschina.net/weharmony)** - -* [v56.xx 鸿蒙内核源码分析(进程映像篇) | ELF是如何被加载运行的? ](https://my.oschina.net/weharmony/blog/5060359) **[ | 51](https://harmonyos.51cto.com/posts/4815)[ .c](https://blog.csdn.net/kuangyufei/article/details/117325933)[ .h](http://weharmonyos.com/blog/56_进程映像篇.html)[ .o](https://my.oschina.net/weharmony)** - -* [v55.xx 鸿蒙内核源码分析(重定位篇) | 与国际接轨的对外部发言人 ](https://my.oschina.net/weharmony/blog/5055124) **[ | 51](https://harmonyos.51cto.com/posts/4519)[ .c](https://blog.csdn.net/kuangyufei/article/details/117110422)[ .h](http://weharmonyos.com/blog/55_重定位篇.html)[ .o](https://my.oschina.net/weharmony)** - -* [v54.xx 鸿蒙内核源码分析(静态链接篇) | 完整小项目看透静态链接过程 ](https://my.oschina.net/weharmony/blog/5049918) **[ | 51](https://harmonyos.51cto.com/posts/4430)[ .c](https://blog.csdn.net/kuangyufei/article/details/116835578)[ .h](http://weharmonyos.com/blog/54_静态链接篇.html)[ .o](https://my.oschina.net/weharmony)** - -* [v53.xx 鸿蒙内核源码分析(ELF解析篇) | 你要忘了她姐俩你就不是银 ](https://my.oschina.net/weharmony/blog/5048746) **[ | 51](https://harmonyos.51cto.com/posts/4413)[ .c](https://blog.csdn.net/kuangyufei/article/details/116781446)[ .h](http://weharmonyos.com/blog/53_ELF解析篇.html)[ .o](https://my.oschina.net/weharmony)** - -* [v52.xx 鸿蒙内核源码分析(静态站点篇) | 五一哪也没去就干了这事 ](https://my.oschina.net/weharmony/blog/5042657) **[ | 51](https://harmonyos.51cto.com/posts/4312)[ .c](https://blog.csdn.net/kuangyufei/article/details/116517461)[ .h](http://weharmonyos.com/blog/52_静态站点篇.html)[ .o](https://my.oschina.net/weharmony)** - -* [v51.xx 鸿蒙内核源码分析(ELF格式篇) | 应用程序入口并不是main ](https://my.oschina.net/weharmony/blog/5030288) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/116097977)[ .h](http://weharmonyos.com/blog/51_ELF格式篇.html)[ .o](https://my.oschina.net/weharmony)** - -* [v50.xx 鸿蒙内核源码分析(编译环境篇) | docker编译鸿蒙真的很香 ](https://my.oschina.net/weharmony/blog/5028613) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/116042551)[ .h](http://weharmonyos.com/blog/50_编译环境篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v49.xx 鸿蒙内核源码分析(信号消费篇) | 谁让CPU连续四次换栈运行 ](https://my.oschina.net/weharmony/blog/5027224) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/115958293)[ .h](http://weharmonyos.com/blog/49_信号消费篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v48.xx 鸿蒙内核源码分析(信号生产篇) | 年过半百,依然活力十足 ](https://my.oschina.net/weharmony/blog/5022149) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/115768099)[ .h](http://weharmonyos.com/blog/48_信号生产篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v47.xx 鸿蒙内核源码分析(进程回收篇) | 临终前如何向老祖宗托孤 ](https://my.oschina.net/weharmony/blog/5017716) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/115672752)[ .h](http://weharmonyos.com/blog/47_进程回收篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v46.xx 鸿蒙内核源码分析(特殊进程篇) | 龙生龙凤生凤老鼠生儿会打洞 ](https://my.oschina.net/weharmony/blog/5014444) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/115556505)[ .h](http://weharmonyos.com/blog/46_特殊进程篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v45.xx 鸿蒙内核源码分析(Fork篇) | 一次调用,两次返回 ](https://my.oschina.net/weharmony/blog/5010301) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/115467961)[ .h](http://weharmonyos.com/blog/45_Fork篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v44.xx 鸿蒙内核源码分析(中断管理篇) | 江湖从此不再怕中断 ](https://my.oschina.net/weharmony/blog/4995800) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/115130055)[ .h](http://weharmonyos.com/blog/44_中断管理篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v43.xx 鸿蒙内核源码分析(中断概念篇) | 海公公的日常工作 ](https://my.oschina.net/weharmony/blog/4992750) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/115014442)[ .h](http://weharmonyos.com/blog/43_中断概念篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v42.xx 鸿蒙内核源码分析(中断切换篇) | 系统因中断活力四射](https://my.oschina.net/weharmony/blog/4990948) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/114988891)[ .h](http://weharmonyos.com/blog/42_中断切换篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v41.xx 鸿蒙内核源码分析(任务切换篇) | 看汇编如何切换任务 ](https://my.oschina.net/weharmony/blog/4988628) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/114890180)[ .h](http://weharmonyos.com/blog/41_任务切换篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v40.xx 鸿蒙内核源码分析(汇编汇总篇) | 汇编可爱如邻家女孩 ](https://my.oschina.net/weharmony/blog/4977924) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/114597179)[ .h](http://weharmonyos.com/blog/40_汇编汇总篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v39.xx 鸿蒙内核源码分析(异常接管篇) | 社会很单纯,复杂的是人 ](https://my.oschina.net/weharmony/blog/4973016) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/114438285)[ .h](http://weharmonyos.com/blog/39_异常接管篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v38.xx 鸿蒙内核源码分析(寄存器篇) | 小强乃宇宙最忙存储器 ](https://my.oschina.net/weharmony/blog/4969487) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/114326994)[ .h](http://weharmonyos.com/blog/38_寄存器篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v37.xx 鸿蒙内核源码分析(系统调用篇) | 开发者永远的口头禅 ](https://my.oschina.net/weharmony/blog/4967613) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/114285166)[ .h](http://weharmonyos.com/blog/37_系统调用篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v36.xx 鸿蒙内核源码分析(工作模式篇) | CPU是韦小宝,七个老婆 ](https://my.oschina.net/weharmony/blog/4965052) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/114168567)[ .h](http://weharmonyos.com/blog/36_工作模式篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v35.xx 鸿蒙内核源码分析(时间管理篇) | 谁是内核基本时间单位 ](https://my.oschina.net/weharmony/blog/4956163) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/113867785)[ .h](http://weharmonyos.com/blog/35_时间管理篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v34.xx 鸿蒙内核源码分析(原子操作篇) | 谁在为原子操作保驾护航 ](https://my.oschina.net/weharmony/blog/4955290) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/113850603)[ .h](http://weharmonyos.com/blog/34_原子操作篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v33.xx 鸿蒙内核源码分析(消息队列篇) | 进程间如何异步传递大数据 ](https://my.oschina.net/weharmony/blog/4952961) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/113815355)[ .h](http://weharmonyos.com/blog/33_消息队列篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v32.xx 鸿蒙内核源码分析(CPU篇) | 整个内核就是一个死循环 ](https://my.oschina.net/weharmony/blog/4952034) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/113782749)[ .h](http://weharmonyos.com/blog/32_CPU篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v31.xx 鸿蒙内核源码分析(定时器篇) | 哪个任务的优先级最高 ](https://my.oschina.net/weharmony/blog/4951625) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/113774260)[ .h](http://weharmonyos.com/blog/31_定时器篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v30.xx 鸿蒙内核源码分析(事件控制篇) | 任务间多对多的同步方案 ](https://my.oschina.net/weharmony/blog/4950956) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/113759481)[ .h](http://weharmonyos.com/blog/30_事件控制篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v29.xx 鸿蒙内核源码分析(信号量篇) | 谁在负责解决任务的同步 ](https://my.oschina.net/weharmony/blog/4949720) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/113744267)[ .h](http://weharmonyos.com/blog/29_信号量篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v28.xx 鸿蒙内核源码分析(进程通讯篇) | 九种进程间通讯方式速揽 ](https://my.oschina.net/weharmony/blog/4947398) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/113700751)[ .h](http://weharmonyos.com/blog/28_进程通讯篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v27.xx 鸿蒙内核源码分析(互斥锁篇) | 比自旋锁丰满的互斥锁 ](https://my.oschina.net/weharmony/blog/4945465) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/113660357)[ .h](http://weharmonyos.com/blog/27_互斥锁篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v26.xx 鸿蒙内核源码分析(自旋锁篇) | 自旋锁当立贞节牌坊 ](https://my.oschina.net/weharmony/blog/4944129) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/113616250)[ .h](http://weharmonyos.com/blog/26_自旋锁篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v25.xx 鸿蒙内核源码分析(并发并行篇) | 听过无数遍的两个概念 ](https://my.oschina.net/u/3751245/blog/4940329) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/113516222)[ .h](http://weharmonyos.com/blog/25_并发并行篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v24.xx 鸿蒙内核源码分析(进程概念篇) | 进程在管理哪些资源 ](https://my.oschina.net/u/3751245/blog/4937521) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/113395872)[ .h](http://weharmonyos.com/blog/24_进程概念篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v23.xx 鸿蒙内核源码分析(汇编传参篇) | 如何传递复杂的参数 ](https://my.oschina.net/u/3751245/blog/4927892) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/113265990)[ .h](http://weharmonyos.com/blog/23_汇编传参篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v22.xx 鸿蒙内核源码分析(汇编基础篇) | CPU在哪里打卡上班 ](https://my.oschina.net/u/3751245/blog/4920361) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/112986628)[ .h](http://weharmonyos.com/blog/22_汇编基础篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v21.xx 鸿蒙内核源码分析(线程概念篇) | 是谁在不断的折腾CPU ](https://my.oschina.net/u/3751245/blog/4915543) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/112870193)[ .h](http://weharmonyos.com/blog/21_线程概念篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v20.xx 鸿蒙内核源码分析(用栈方式篇) | 程序运行场地由谁提供 ](https://my.oschina.net/u/3751245/blog/4893388) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/112534331)[ .h](http://weharmonyos.com/blog/20_用栈方式篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v19.xx 鸿蒙内核源码分析(位图管理篇) | 谁能一分钱分两半花 ](https://my.oschina.net/u/3751245/blog/4888467) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/112394982)[ .h](http://weharmonyos.com/blog/19_位图管理篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v18.xx 鸿蒙内核源码分析(源码结构篇) | 内核每个文件的含义 ](https://my.oschina.net/u/3751245/blog/4869137) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/111938348)[ .h](http://weharmonyos.com/blog/18_源码结构篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v17.xx 鸿蒙内核源码分析(物理内存篇) | 怎么管理物理内存 ](https://my.oschina.net/u/3751245/blog/4842408) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/111765600)[ .h](http://weharmonyos.com/blog/17_物理内存篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v16.xx 鸿蒙内核源码分析(内存规则篇) | 内存管理到底在管什么 ](https://my.oschina.net/u/3751245/blog/4698384) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/109437223)[ .h](http://weharmonyos.com/blog/16_内存规则篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v15.xx 鸿蒙内核源码分析(内存映射篇) | 虚拟内存虚在哪里 ](https://my.oschina.net/u/3751245/blog/4694841) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/109032636)[ .h](http://weharmonyos.com/blog/15_内存映射篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v14.xx 鸿蒙内核源码分析(内存汇编篇) | 谁是虚拟内存实现的基础 ](https://my.oschina.net/u/3751245/blog/4692156) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/108994081)[ .h](http://weharmonyos.com/blog/14_内存汇编篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v13.xx 鸿蒙内核源码分析(源码注释篇) | 鸿蒙必定成功,也必然成功 ](https://my.oschina.net/u/3751245/blog/4686747) **[ | 51](https://harmonyos.51cto.com/posts/4049)[ .c](https://blog.csdn.net/kuangyufei/article/details/109251754)[ .h](http://weharmonyos.com/blog/13_源码注释篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v12.xx 鸿蒙内核源码分析(内存管理篇) | 虚拟内存全景图是怎样的 ](https://my.oschina.net/u/3751245/blog/4652284) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/108821442)[ .h](http://weharmonyos.com/blog/12_内存管理篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v11.xx 鸿蒙内核源码分析(内存分配篇) | 内存有哪些分配方式 ](https://my.oschina.net/u/3751245/blog/4646802) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/108989906)[ .h](http://weharmonyos.com/blog/11_内存分配篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v10.xx 鸿蒙内核源码分析(内存主奴篇) | 皇上和奴才如何相处 ](https://my.oschina.net/u/3751245/blog/4646802) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/108723672)[ .h](http://weharmonyos.com/blog/10_内存主奴篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v09.xx 鸿蒙内核源码分析(调度故事篇) | 用故事说内核调度过程 ](https://my.oschina.net/u/3751245/blog/4634668) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/108745174)[ .h](http://weharmonyos.com/blog/09_调度故事篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v08.xx 鸿蒙内核源码分析(总目录) | 百万汉字注解 百篇博客分析 ](https://my.oschina.net/weharmony/blog/4626852) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/108727970)[ .h](http://weharmonyos.com/blog/08_总目录.html) [ .o](https://my.oschina.net/weharmony)** - -* [v07.xx 鸿蒙内核源码分析(调度机制篇) | 任务是如何被调度执行的 ](https://my.oschina.net/u/3751245/blog/4623040) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/108705968)[ .h](http://weharmonyos.com/blog/07_调度机制篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v06.xx 鸿蒙内核源码分析(调度队列篇) | 内核有多少个调度队列 ](https://my.oschina.net/u/3751245/blog/4606916) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/108626671)[ .h](http://weharmonyos.com/blog/06_调度队列篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v05.xx 鸿蒙内核源码分析(任务管理篇) | 任务池是如何管理的 ](https://my.oschina.net/u/3751245/blog/4603919) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/108661248)[ .h](http://weharmonyos.com/blog/05_任务管理篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v04.xx 鸿蒙内核源码分析(任务调度篇) | 任务是内核调度的单元 ](https://my.oschina.net/weharmony/blog/4595539) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/108621428)[ .h](http://weharmonyos.com/blog/04_任务调度篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v03.xx 鸿蒙内核源码分析(时钟任务篇) | 触发调度谁的贡献最大 ](https://my.oschina.net/u/3751245/blog/4574493) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/108603468)[ .h](http://weharmonyos.com/blog/03_时钟任务篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v02.xx 鸿蒙内核源码分析(进程管理篇) | 谁在管理内核资源 ](https://my.oschina.net/u/3751245/blog/4574429) **[ | 51](https://harmonyos.51cto.com/posts/3926)[ .c](https://blog.csdn.net/kuangyufei/article/details/108595941)[ .h](http://weharmonyos.com/blog/02_进程管理篇.html) [ .o](https://my.oschina.net/weharmony)** - -* [v01.xx 鸿蒙内核源码分析(双向链表篇) | 谁是内核最重要结构体 ](https://my.oschina.net/u/3751245/blog/4572304) **[ | 51](https://harmonyos.51cto.com/posts/3925)[ .c](https://blog.csdn.net/kuangyufei/article/details/108585659)[ .h](http://weharmonyos.com/blog/01_双向链表篇.html) [ .o](https://my.oschina.net/weharmony)** - -### 关于 51 .c .h .o -看系列篇文章会常看到 `51 .c .h .o`,希望这对大家阅读不会造成影响. -分别对应以下四个站点的首个字符,感谢这些站点一直以来对系列篇的支持和推荐,尤其是 **oschina gitee** ,很喜欢它的界面风格,简洁大方,让人感觉到开源的伟大! -* [51cto](https://harmonyos.51cto.com/column/34) -* [csdn](https://blog.csdn.net/kuangyufei) -* [harmony](http://weharmonyos.com/) -* [oschina](https://my.oschina.net/weharmony) - -而巧合的是`.c .h .o`是C语言的头/源/目标文件,这就很有意思了,冥冥之中似有天数,将这四个宝贝以这种方式融合在一起. `51 .c .h .o` , 我要CHO ,嗯嗯,hin 顺口 : ) +[v08.xx 鸿蒙内核源码分析(总目录) | 百万汉字注解 百篇博客分析 ](https://my.oschina.net/weharmony/blog/4626852) **[ | 51](https://harmonyos.51cto.com/column/34)[ .c](https://blog.csdn.net/kuangyufei/article/details/108727970)[ .h](http://weharmonyos.com/blog/08_总目录.html) [ .o](https://my.oschina.net/weharmony)** ### 百万汉字注解.百篇博客分析 [百万汉字注解 >> 精读鸿蒙源码,中文注解分析, 深挖地基工程,大脑永久记忆,四大码仓每日同步更新](https://gitee.com/weharmony/kernel_liteos_a_note)[< gitee ](https://gitee.com/weharmony/kernel_liteos_a_note)[| github ](https://github.com/kuangyufei/kernel_liteos_a_note)[| csdn ](https://codechina.csdn.net/kuangyufei/kernel_liteos_a_note)[| coding >](https://weharmony.coding.net/public/harmony/kernel_liteos_a_note/git/files) diff --git a/drivers/mtd/multi_partition/include/mtd_dev.h b/drivers/mtd/multi_partition/include/mtd_dev.h index f88a92ae..5a9c7c16 100644 --- a/drivers/mtd/multi_partition/include/mtd_dev.h +++ b/drivers/mtd/multi_partition/include/mtd_dev.h @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __MTD_DEV_H__ -#define __MTD_DEV_H__ - -#include "los_typedef.h" +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef __MTD_DEV_H__ +#define __MTD_DEV_H__ + +#include "los_typedef.h" /************************************************ MTD,Memory Technology Device即内存技术设备 Linux系统中采用MTD来管理不同类型的Flash芯片,包括NandFlash和NorFlash @@ -47,12 +47,12 @@ NAND型Flash具有较高的单元密度,容量可以做得比较大,加之 为1~16MB闪存市场的大部分,而NAND型Flash只是用在8~128MB的产品中,这也说明NOR主要用在代码存储介质中, NAND适合数据存储。 ************************************************/ - -#define MTD_NORFLASH 3 //存储空间一般比较小,但它可以不用初始化,可以在其内部运行程序,一般在其存储一些初始化内存的固件代码; -#define MTD_NANDFLASH 4 -#define MTD_DATAFLASH 6 -#define MTD_MLCNANDFLASH 8 - + +#define MTD_NORFLASH 3 //存储空间一般比较小,但它可以不用初始化,可以在其内部运行程序,一般在其存储一些初始化内存的固件代码; +#define MTD_NANDFLASH 4 +#define MTD_DATAFLASH 6 +#define MTD_MLCNANDFLASH 8 + /********************************************* 扇区是对硬盘而言,而块是对文件系统而言 文件系统不是一个扇区一个扇区的来读数据,一个扇区512个字节,太慢了,所以有了block(块)的概念, @@ -63,8 +63,8 @@ struct MtdNorDev {//一个block是4K,即:文件系统中1个块是由连续的 unsigned long blockStart; //开始块索引 unsigned long blockEnd; //结束块索引 }; - - + + struct MtdDev {//flash MTD 层 描述符 VOID *priv; UINT32 type; @@ -76,6 +76,6 @@ struct MtdDev {//flash MTD 层 描述符 int (*read)(struct MtdDev *mtd, UINT64 start, UINT64 len, const char *buf);//读操作 int (*write)(struct MtdDev *mtd, UINT64 start, UINT64 len, const char *buf);//写操作 }; - - -#endif /* __MTD_DEV_H__ */ + + +#endif /* __MTD_DEV_H__ */ diff --git a/drivers/mtd/multi_partition/include/mtd_partition.h b/drivers/mtd/multi_partition/include/mtd_partition.h index 85484abb..607efdb9 100644 --- a/drivers/mtd/multi_partition/include/mtd_partition.h +++ b/drivers/mtd/multi_partition/include/mtd_partition.h @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @defgroup filesystem FileSystem - * @defgroup mtd_partition Multi Partition - * @ingroup filesystem - */ -#ifndef _MTD_PARTITION_H -#define _MTD_PARTITION_H - -#include "sys/types.h" -#include "los_mux.h" -#include "mtd_list.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @defgroup filesystem FileSystem + * @defgroup mtd_partition Multi Partition + * @ingroup filesystem + */ +#ifndef _MTD_PARTITION_H +#define _MTD_PARTITION_H + +#include "sys/types.h" +#include "los_mux.h" +#include "mtd_list.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + /*************************************************************** * flash按照内部存储结构不同,分为两种:nor flash和nand flash * Nor FLASH使用方便,易于连接,可以在芯片上直接运行代码,稳定性出色,传输速率高, @@ -79,14 +79,14 @@ Nand Flash:芯片操作是以“块”为基本单位.NAND闪存的块比较 参考:https://blog.csdn.net/zhejfl/article/details/78544796 ***************************************************************/ - - + + #define SPIBLK_NAME "/dev/spinorblk" //nor spi flash 块设备 #define SPICHR_NAME "/dev/spinorchr" //nor spi flash 字符设备 #define NANDBLK_NAME "/dev/nandblk" //nand flash 块设备 #define NANDCHR_NAME "/dev/nandchr" //nand flash 字符设备 - + /*************************************************************** 存储器技术设备(英语:Memory Technology Device,缩写为 MTD),是Linux系统中设备文件系统的一个类别, 主要用于闪存的应用,是一种闪存转换层(Flash Translation Layer,FTL)。创造MTD子系统的主要目的是提供 @@ -122,7 +122,7 @@ MTD设备通常可分为四层 这四层从上到下依次是:设备节点、MTD设备层、MTD原始设备层和硬件驱动层。 参考: https://blog.csdn.net/lwj103862095/article/details/21545791 ***************************************************************/ - + typedef struct mtd_node {//通过mknod在/dev子目录下建立MTD块设备节点(主设备号为31)和MTD字符设备节点(主设备号为90) UINT32 start_block; //开始块索引 UINT32 end_block; //结束块索引 @@ -135,7 +135,7 @@ typedef struct mtd_node {//通过mknod在/dev子目录下建立MTD块设备节 LosMux lock; //每个分区都有自己的互斥锁 UINT32 user_num; //使用数量 } mtd_partition; - + typedef struct par_param {//分区参数描述符,一个分区既可支持按块访问也可以支持按字符访问,只要有驱动程序就阔以 mtd_partition *partition_head; //首个分区,其他分区都挂在.node_info节点上 struct MtdDev *flash_mtd; //flash设备描述符,属于硬件驱动层 @@ -145,87 +145,87 @@ typedef struct par_param {//分区参数描述符,一个分区既可支持按块 CHAR *charname; //字符设备名称 UINT32 block_size; //块单位(4K),对文件系统而言是按块读取数据,方便和内存页置换 } partition_param; - - -#define CONFIG_MTD_PATTITION_NUM 20 //分区数量的上限 - -#define ALIGN_ASSIGN(len, startAddr, startBlk, endBlk, blkSize) do { \ - (len) = (((len) + ((blkSize) - 1)) & ~((blkSize) - 1)); \ - (startAddr) = ((startAddr) & ~((blkSize) - 1)); \ - (startBlk) = (startAddr) / (blkSize); \ - (endBlk) = (len) / (blkSize) + ((startBlk) - 1); \ -} while (0) - -#define PAR_ASSIGNMENT(node, len, startAddr, num, mtd, blkSize) do { \ - (node)->start_block = (startAddr) / (blkSize); \ - (node)->end_block = (len) / (blkSize) + ((node)->start_block - 1); \ - (node)->patitionnum = (num); \ - (node)->mtd_info = (mtd); \ - (node)->mountpoint_name = NULL; \ -} while (0) - -partition_param *GetNandPartParam(VOID); -partition_param *GetSpinorPartParam(VOID); -mtd_partition *GetSpinorPartitionHead(VOID); - -/** - * @ingroup mtd_partition - * @brief Add a partition. - * - * @par Description: - * - * @attention - * - * - * @param type [IN] Storage medium type, support "nand" and "spinor" currently. - * @param startAddr [IN] Starting address of a partition. - * @param length [IN] Partition size. - * @param partitionNum [IN] Partition number, less than the value defined by CONFIG_MTD_PATTITION_NUM. - * - * @retval #-ENODEV The driver is not found. - * @retval #-EINVAL Invalid parameter. - * @retval #-ENOMEM Insufficient memory. - * @retval #ENOERR The partition is successfully created. - * - * @par Dependency: - * - * @see delete_mtd_partition - */ -extern INT32 add_mtd_partition(const CHAR *type, UINT32 startAddr, UINT32 length, UINT32 partitionNum); - -/** - * @ingroup mtd_partition - * @brief Delete a partition. - * - * @par Description: - * - * @attention - * - * - * @param partitionNum [IN] Partition number, less than the value defined by CONFIG_MTD_PATTITION_NUM. - * @param type [IN] Storage medium type, support "nand" and "spinor" currently. - * - * @retval #-EINVAL Invalid parameter. - * @retval #ENOERR The partition is successfully deleted. - * - * @par Dependency: - * - * @see add_mtd_partition - */ -extern INT32 delete_mtd_partition(UINT32 partitionNum, const CHAR *type); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _MTD_PARTITION_H */ + + +#define CONFIG_MTD_PATTITION_NUM 20 //分区数量的上限 + +#define ALIGN_ASSIGN(len, startAddr, startBlk, endBlk, blkSize) do { \ + (len) = (((len) + ((blkSize) - 1)) & ~((blkSize) - 1)); \ + (startAddr) = ((startAddr) & ~((blkSize) - 1)); \ + (startBlk) = (startAddr) / (blkSize); \ + (endBlk) = (len) / (blkSize) + ((startBlk) - 1); \ +} while (0) + +#define PAR_ASSIGNMENT(node, len, startAddr, num, mtd, blkSize) do { \ + (node)->start_block = (startAddr) / (blkSize); \ + (node)->end_block = (len) / (blkSize) + ((node)->start_block - 1); \ + (node)->patitionnum = (num); \ + (node)->mtd_info = (mtd); \ + (node)->mountpoint_name = NULL; \ +} while (0) + +partition_param *GetNandPartParam(VOID); +partition_param *GetSpinorPartParam(VOID); +mtd_partition *GetSpinorPartitionHead(VOID); + +/** + * @ingroup mtd_partition + * @brief Add a partition. + * + * @par Description: + * + * @attention + * + * + * @param type [IN] Storage medium type, support "nand" and "spinor" currently. + * @param startAddr [IN] Starting address of a partition. + * @param length [IN] Partition size. + * @param partitionNum [IN] Partition number, less than the value defined by CONFIG_MTD_PATTITION_NUM. + * + * @retval #-ENODEV The driver is not found. + * @retval #-EINVAL Invalid parameter. + * @retval #-ENOMEM Insufficient memory. + * @retval #ENOERR The partition is successfully created. + * + * @par Dependency: + * + * @see delete_mtd_partition + */ +extern INT32 add_mtd_partition(const CHAR *type, UINT32 startAddr, UINT32 length, UINT32 partitionNum); + +/** + * @ingroup mtd_partition + * @brief Delete a partition. + * + * @par Description: + * + * @attention + * + * + * @param partitionNum [IN] Partition number, less than the value defined by CONFIG_MTD_PATTITION_NUM. + * @param type [IN] Storage medium type, support "nand" and "spinor" currently. + * + * @retval #-EINVAL Invalid parameter. + * @retval #ENOERR The partition is successfully deleted. + * + * @par Dependency: + * + * @see add_mtd_partition + */ +extern INT32 delete_mtd_partition(UINT32 partitionNum, const CHAR *type); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif /* _MTD_PARTITION_H */ diff --git a/fs/proc/os_adapt/proc_vfs.c b/fs/proc/os_adapt/proc_vfs.c index 27fc1867..c545f466 100644 --- a/fs/proc/os_adapt/proc_vfs.c +++ b/fs/proc/os_adapt/proc_vfs.c @@ -191,7 +191,7 @@ int VfsProcfsLookup(struct Vnode *parent, const char *name, int len, struct Vnod (*vpp)->parent = parent; return LOS_OK; } -//装载实现,找个vnode节点挂上去 +//挂s载实现,找个vnode节点挂上去 int VfsProcfsMount(struct Mount *mnt, struct Vnode *device, const void *data) { struct Vnode *vp = NULL; diff --git a/fs/vfs/operation/fs_init.c b/fs/vfs/operation/fs_init.c index 8abd10cf..c85af9e5 100644 --- a/fs/vfs/operation/fs_init.c +++ b/fs/vfs/operation/fs_init.c @@ -71,7 +71,7 @@ void los_vfs_init(void)//只能调用一次,多次调用将会造成文件系 files_initialize(); files_initlist(&tg_filelist); - retval = VnodesInit();//虚拟节点初始化 + retval = VnodesInit();//索引节点初始化 if (retval != LOS_OK) { PRINT_ERR("los_vfs_init VnodeInit failed error %d\n", retval); return; diff --git a/fs/vfs/vnode.c b/fs/vfs/vnode.c index f5eaaeeb..98900bc1 100644 --- a/fs/vfs/vnode.c +++ b/fs/vfs/vnode.c @@ -41,7 +41,7 @@ static int g_totalVnodeSize = 0; /* total vnode size */ //已分配的总 static LosMux g_vnodeMux; //操作链表互斥量 static struct Vnode *g_rootVnode = NULL;//根节点 -static struct VnodeOps g_devfsOps;//设备文件系统节点操作 +static struct VnodeOps g_devfsOps;//设备文件节点操作 /********************************************************* linux下有专门的文件系统(devfs | sysfs)用来对设备进行管理,鸿蒙目前只支持 devfs方式 devfs和sysfs都是和proc一样,是一个虚拟的文件系统,提供了一种类似于文件的方法来管理位于/dev目录下的所有设备, @@ -218,7 +218,7 @@ int VnodeFree(struct Vnode *vnode) vnode->vop->Reclaim(vnode);//先回收资源 } - if (vnode->vop == &g_devfsOps) {//对于设备文件系统的回收 + if (vnode->vop == &g_devfsOps) {//对设备文件的回收 /* for dev vnode, just free it */ free(vnode->data);// free(vnode); diff --git a/kernel/common/rootfs/los_bootargs.c b/kernel/common/rootfs/los_bootargs.c index 3f54115c..b6c0b113 100644 --- a/kernel/common/rootfs/los_bootargs.c +++ b/kernel/common/rootfs/los_bootargs.c @@ -47,7 +47,7 @@ STATIC CHAR *g_cmdLine = NULL; STATIC UINT64 g_alignSize = 0; STATIC struct BootArgs g_bootArgs[MAX_ARGS_NUM] = {0}; - +//读取环境变量bootcmd 来启动内核 INT32 LOS_GetCmdLine() { int ret; @@ -59,40 +59,40 @@ INT32 LOS_GetCmdLine() } #ifdef LOSCFG_STORAGE_EMMC - los_disk *emmcDisk = los_get_mmcdisk_bytype(EMMC); + los_disk *emmcDisk = los_get_mmcdisk_bytype(EMMC); //获取硬盘信息 if (emmcDisk == NULL) { PRINT_ERR("Get EMMC disk failed!\n"); goto ERROUT; } g_alignSize = EMMC_SEC_SIZE; ret = los_disk_read(emmcDisk->disk_id, g_cmdLine, COMMAND_LINE_ADDR / EMMC_SEC_SIZE, - COMMAND_LINE_SIZE / EMMC_SEC_SIZE, TRUE); + COMMAND_LINE_SIZE / EMMC_SEC_SIZE, TRUE);//读取命令行内容 if (ret == 0) { return LOS_OK; } #endif #ifdef LOSCFG_STORAGE_SPINOR - struct MtdDev *mtd = GetMtd("spinor"); + struct MtdDev *mtd = GetMtd("spinor");//获取flash描述信息 if (mtd == NULL) { PRINT_ERR("Get spinor mtd failed!\n"); goto ERROUT; } g_alignSize = mtd->eraseSize; - ret = mtd->read(mtd, COMMAND_LINE_ADDR, COMMAND_LINE_SIZE, g_cmdLine); + ret = mtd->read(mtd, COMMAND_LINE_ADDR, COMMAND_LINE_SIZE, g_cmdLine);//读取spinor下的命令行内容 if (ret == COMMAND_LINE_SIZE) { return LOS_OK; } #endif #ifdef LOSCFG_STORAGE_SPINAND - struct MtdDev *mtd = GetMtd("nand"); + struct MtdDev *mtd = GetMtd("nand");//获取flash描述信息 if (mtd == NULL) { PRINT_ERR("Get nand mtd failed!\n"); goto ERROUT; } g_alignSize = mtd->eraseSize; - ret = mtd->read(mtd, COMMAND_LINE_ADDR, COMMAND_LINE_SIZE, g_cmdLine); + ret = mtd->read(mtd, COMMAND_LINE_ADDR, COMMAND_LINE_SIZE, g_cmdLine);//读取nand下的命令行内容 if (ret == COMMAND_LINE_SIZE) { return LOS_OK; } @@ -125,7 +125,7 @@ VOID LOS_FreeCmdLine() g_cmdLine = NULL; } } - +//获取boot参数 STATIC INT32 GetBootargs(CHAR **args) { #ifdef LOSCFG_BOOTENV_RAM @@ -154,7 +154,7 @@ STATIC INT32 GetBootargs(CHAR **args) return LOS_NOK; #endif } - +//解析boot参数 INT32 LOS_ParseBootargs() { INT32 idx = 0; diff --git a/kernel/common/rootfs/los_bootargs.h b/kernel/common/rootfs/los_bootargs.h index 3cb73d0c..b0d712f1 100644 --- a/kernel/common/rootfs/los_bootargs.h +++ b/kernel/common/rootfs/los_bootargs.h @@ -43,7 +43,7 @@ #define EMMC_SEC_SIZE 512 #endif -struct BootArgs { +struct BootArgs {//模式 | foo=bar CHAR *argName; CHAR *argValue; }; diff --git a/kernel/common/rootfs/los_rootfs.c b/kernel/common/rootfs/los_rootfs.c index 7530c5e0..81761ef7 100644 --- a/kernel/common/rootfs/los_rootfs.c +++ b/kernel/common/rootfs/los_rootfs.c @@ -114,7 +114,7 @@ STATIC INT32 AddEmmcParts(INT32 rootAddr, INT32 rootSize, INT32 userAddr, INT32 } #endif - +//增加一个分区 STATIC INT32 AddPartitions(CHAR *dev, UINT64 rootAddr, UINT64 rootSize, UINT64 userAddr, UINT64 userSize) { #ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 @@ -129,7 +129,7 @@ STATIC INT32 AddPartitions(CHAR *dev, UINT64 rootAddr, UINT64 rootSize, UINT64 u INT32 blk0 = 0; INT32 blk2 = 2; if (strcmp(dev, "flash") == 0 || strcmp(dev, FLASH_TYPE) == 0) { - ret = add_mtd_partition(FLASH_TYPE, rootAddr, rootSize, blk0); + ret = add_mtd_partition(FLASH_TYPE, rootAddr, rootSize, blk0);//增加一个MTD分区 if (ret != LOS_OK) { PRINT_ERR("Failed to add mtd root partition!\n"); return LOS_NOK; @@ -155,33 +155,33 @@ STATIC INT32 AddPartitions(CHAR *dev, UINT64 rootAddr, UINT64 rootSize, UINT64 u return LOS_NOK; } - +//获取根文件系统参数 STATIC INT32 ParseRootArgs(CHAR **dev, CHAR **fstype, UINT64 *rootAddr, UINT64 *rootSize, UINT32 *mountFlags) { INT32 ret; CHAR *rootAddrStr = NULL; CHAR *rootSizeStr = NULL; CHAR *rwTag = NULL; - - ret = LOS_GetArgValue("root", dev); + //获取文件系统放在哪种设备上 + ret = LOS_GetArgValue("root", dev);//root = flash | mmc | if (ret != LOS_OK) { PRINT_ERR("Cannot find root!"); return ret; } - + //获取文件系统类型 ret = LOS_GetArgValue("fstype", fstype); if (ret != LOS_OK) { PRINT_ERR("Cannot find fstype!"); return ret; } - + //获取内核地址空间开始位置 ret = LOS_GetArgValue("rootaddr", &rootAddrStr); if (ret != LOS_OK) { *rootAddr = ROOTFS_ADDR; } else { *rootAddr = LOS_SizeStrToNum(rootAddrStr); } - + //获取内核地址空间大小 ret = LOS_GetArgValue("rootsize", &rootSizeStr); if (ret != LOS_OK) { *rootSize = ROOTFS_SIZE; @@ -221,14 +221,14 @@ STATIC INT32 ParseUserArgs(UINT64 rootAddr, UINT64 rootSize, UINT64 *userAddr, U return LOS_OK; } - +//挂载分区,即挂载 "/","/storage" STATIC INT32 MountPartitions(CHAR *fsType, UINT32 mountFlags) { INT32 ret; INT32 err; /* Mount rootfs */ - ret = mount(ROOT_DEV_NAME, ROOT_DIR_NAME, fsType, mountFlags, NULL); + ret = mount(ROOT_DEV_NAME, ROOT_DIR_NAME, fsType, mountFlags, NULL);//挂载根文件系统 if (ret != LOS_OK) { err = get_errno(); PRINT_ERR("Failed to mount %s, rootDev %s, errno %d: %s\n", ROOT_DIR_NAME, ROOT_DEV_NAME, err, strerror(err)); @@ -236,13 +236,13 @@ STATIC INT32 MountPartitions(CHAR *fsType, UINT32 mountFlags) } /* Mount userfs */ - ret = mkdir(STORAGE_DIR_NAME, DEFAULT_MOUNT_DIR_MODE); + ret = mkdir(STORAGE_DIR_NAME, DEFAULT_MOUNT_DIR_MODE);//创建目录"/storage" if ((ret != LOS_OK) && ((err = get_errno()) != EEXIST)) { PRINT_ERR("Failed to mkdir %s, errno %d: %s\n", STORAGE_DIR_NAME, err, strerror(err)); return ret; } - ret = mount(USER_DEV_NAME, STORAGE_DIR_NAME, fsType, 0, DEFAULT_MOUNT_DATA); + ret = mount(USER_DEV_NAME, STORAGE_DIR_NAME, fsType, 0, DEFAULT_MOUNT_DATA);//挂载用户数据文件系统 if (ret != LOS_OK) { err = get_errno(); PRINT_ERR("Failed to mount %s, errno %d: %s\n", STORAGE_DIR_NAME, err, strerror(err)); @@ -251,13 +251,13 @@ STATIC INT32 MountPartitions(CHAR *fsType, UINT32 mountFlags) #ifdef LOSCFG_STORAGE_EMMC /* Mount userdata */ - ret = mkdir(USERDATA_DIR_NAME, DEFAULT_MOUNT_DIR_MODE); + ret = mkdir(USERDATA_DIR_NAME, DEFAULT_MOUNT_DIR_MODE);//创建目录"/userdata" if ((ret != LOS_OK) && ((err = get_errno()) != EEXIST)) { PRINT_ERR("Failed to mkdir %s, errno %d: %s\n", USERDATA_DIR_NAME, err, strerror(err)); return ret; } - ret = mount(USERDATA_DEV_NAME, USERDATA_DIR_NAME, fsType, 0, DEFAULT_MOUNT_DATA); + ret = mount(USERDATA_DEV_NAME, USERDATA_DIR_NAME, fsType, 0, DEFAULT_MOUNT_DATA);//挂载用户数据文件系统 if ((ret != LOS_OK) && ((err = get_errno()) == ENOTSUP)) { ret = format(USERDATA_DEV_NAME, 0, FM_FAT32); if (ret != LOS_OK) { @@ -294,7 +294,7 @@ STATIC INT32 CheckValidation(UINT64 rootAddr, UINT64 rootSize, UINT64 userAddr, return LOS_OK; } - +//挂载根文件系统 由 SystemInit 调用 INT32 OsMountRootfs() { INT32 ret; @@ -305,27 +305,27 @@ INT32 OsMountRootfs() UINT64 userAddr; UINT64 userSize; UINT32 mountFlags; - + //获取根文件系统s参数 ret = ParseRootArgs(&dev, &fstype, &rootAddr, &rootSize, &mountFlags); if (ret != LOS_OK) { return ret; } - + //获取用户文件参数 ret = ParseUserArgs(rootAddr, rootSize, &userAddr, &userSize); if (ret != LOS_OK) { return ret; } - + //检查内核和用户空间的有效性 ret = CheckValidation(rootAddr, rootSize, userAddr, userSize); if (ret != LOS_OK) { return ret; } - + //添加分区 ret = AddPartitions(dev, rootAddr, rootSize, userAddr, userSize); if (ret != LOS_OK) { return ret; } - + //挂载分区,即挂载 `/` ret = MountPartitions(fstype, mountFlags); if (ret != LOS_OK) { return ret; diff --git a/kernel/common/rootfs/los_rootfs.h b/kernel/common/rootfs/los_rootfs.h index 50c9c98b..aa296e0f 100644 --- a/kernel/common/rootfs/los_rootfs.h +++ b/kernel/common/rootfs/los_rootfs.h @@ -64,7 +64,7 @@ VFS是一种机制、是每一种文件系统都必须按照这个机制去实 #ifdef LOSCFG_STORAGE_SPINOR //外部开关定 使用哪种flash #define FLASH_TYPE "spinor" //flash类型 -#define ROOT_DEV_NAME "/dev/spinorblk0" //设备名称 +#define ROOT_DEV_NAME "/dev/spinorblk0" //根设备名称,将挂载到 `/` 目录下 #define USER_DEV_NAME "/dev/spinorblk2" #define ROOTFS_ADDR 0x600000 #define ROOTFS_SIZE 0x800000 diff --git a/zzz/git/push.sh b/zzz/git/push.sh index 2745b6c0..f62d3b43 100644 --- a/zzz/git/push.sh +++ b/zzz/git/push.sh @@ -1,5 +1,5 @@ git add -A -git commit -m ' 新增文件系统博客 | 同步官方源码 +git commit -m ' 注解根文件系统 百万汉字注解 + 百篇博客分析 => 挖透鸿蒙内核源码 博客输出站点(国内):http://weharmonyos.com 博客输出站点(国外):https://openharmony.github.io -- GitLab