Browse Source

Merge branch 'master' into patch-add-file-mapping

MemoryShore 11 months ago
parent
commit
535b702a18
100 changed files with 762 additions and 275 deletions
  1. 12 9
      .github/workflows/cache-toolchain.yml
  2. 20 56
      README.md
  3. 21 59
      README_EN.md
  4. 1 0
      build-scripts/.gitignore
  5. 2 0
      build-scripts/Makefile
  6. 0 2
      build-scripts/kernel_build/src/lib.rs
  7. 11 4
      docs/conf.py
  8. 5 0
      kernel/.cargo/config.toml
  9. 6 4
      kernel/Cargo.toml
  10. 3 3
      kernel/Makefile
  11. 1 0
      kernel/crates/bitmap/src/lib.rs
  12. 9 0
      kernel/crates/bitmap/src/static_bitmap.rs
  13. 0 5
      kernel/crates/bitmap/src/traits.rs
  14. 0 0
      kernel/crates/intertrait/.gitignore
  15. 1 1
      kernel/crates/intertrait/Cargo.toml
  16. 0 0
      kernel/crates/intertrait/LICENSE-MIT
  17. 1 1
      kernel/crates/intertrait/README.md
  18. 1 1
      kernel/crates/intertrait/macros/Cargo.toml
  19. 0 0
      kernel/crates/intertrait/macros/LICENSE-APACHE
  20. 0 0
      kernel/crates/intertrait/macros/LICENSE-MIT
  21. 0 0
      kernel/crates/intertrait/macros/src/args.rs
  22. 0 0
      kernel/crates/intertrait/macros/src/gen_caster.rs
  23. 0 0
      kernel/crates/intertrait/macros/src/item_impl.rs
  24. 0 0
      kernel/crates/intertrait/macros/src/item_type.rs
  25. 0 0
      kernel/crates/intertrait/macros/src/lib.rs
  26. 0 0
      kernel/crates/intertrait/src/cast.rs
  27. 0 0
      kernel/crates/intertrait/src/cast/cast_arc.rs
  28. 0 0
      kernel/crates/intertrait/src/cast/cast_box.rs
  29. 0 0
      kernel/crates/intertrait/src/cast/cast_mut.rs
  30. 0 0
      kernel/crates/intertrait/src/cast/cast_rc.rs
  31. 0 0
      kernel/crates/intertrait/src/cast/cast_ref.rs
  32. 0 0
      kernel/crates/intertrait/src/hasher.rs
  33. 0 0
      kernel/crates/intertrait/src/lib.rs
  34. 0 0
      kernel/crates/intertrait/tests/castable_to.rs
  35. 0 0
      kernel/crates/intertrait/tests/on-enum.rs
  36. 0 0
      kernel/crates/intertrait/tests/on-struct.rs
  37. 0 0
      kernel/crates/intertrait/tests/on-trait-impl-assoc-type1.rs
  38. 0 0
      kernel/crates/intertrait/tests/on-trait-impl-assoc-type2.rs
  39. 0 0
      kernel/crates/intertrait/tests/on-trait-impl-assoc-type3.rs
  40. 0 0
      kernel/crates/intertrait/tests/on-trait-impl.rs
  41. 0 0
      kernel/crates/intertrait/tests/on-type-multi-traits.rs
  42. 0 0
      kernel/crates/intertrait/tests/run.rs
  43. 0 0
      kernel/crates/intertrait/tests/ui/duplicate-flags.rs
  44. 0 0
      kernel/crates/intertrait/tests/ui/duplicate-flags.stderr
  45. 0 0
      kernel/crates/intertrait/tests/ui/on-generic-type.rs
  46. 0 0
      kernel/crates/intertrait/tests/ui/on-generic-type.stderr
  47. 0 0
      kernel/crates/intertrait/tests/ui/on-type-impl.rs
  48. 0 0
      kernel/crates/intertrait/tests/ui/on-type-impl.stderr
  49. 0 0
      kernel/crates/intertrait/tests/ui/unknown-flag.rs
  50. 0 0
      kernel/crates/intertrait/tests/ui/unknown-flag.stderr
  51. 6 0
      kernel/crates/klog_types/src/lib.rs
  52. 5 3
      kernel/crates/rust-slabmalloc/src/pages.rs
  53. 1 1
      kernel/crates/unified-init/Cargo.toml
  54. 1 1
      kernel/crates/unified-init/macros/Cargo.toml
  55. 1 1
      kernel/rust-toolchain.toml
  56. 2 2
      kernel/src/Makefile
  57. 1 0
      kernel/src/arch/io.rs
  58. 3 2
      kernel/src/arch/x86_64/driver/apic/apic_timer.rs
  59. 1 0
      kernel/src/arch/x86_64/driver/apic/lapic_vector.rs
  60. 1 7
      kernel/src/arch/x86_64/driver/hpet.rs
  61. 2 0
      kernel/src/arch/x86_64/init/mod.rs
  62. 1 0
      kernel/src/arch/x86_64/interrupt/entry.rs
  63. 1 0
      kernel/src/arch/x86_64/interrupt/msi.rs
  64. 1 0
      kernel/src/arch/x86_64/ipc/signal.rs
  65. 8 11
      kernel/src/arch/x86_64/kvm/vmx/vcpu.rs
  66. 2 2
      kernel/src/arch/x86_64/kvm/vmx/vmx_asm_wrapper.rs
  67. 1 0
      kernel/src/arch/x86_64/mod.rs
  68. 1 2
      kernel/src/arch/x86_64/process/kthread.rs
  69. 1 0
      kernel/src/arch/x86_64/process/table.rs
  70. 1 0
      kernel/src/arch/x86_64/smp/mod.rs
  71. 1 1
      kernel/src/arch/x86_64/x86_64-unknown-none.json
  72. 2 0
      kernel/src/driver/acpi/bus.rs
  73. 1 2
      kernel/src/driver/base/device/bus.rs
  74. 3 4
      kernel/src/driver/base/device/dd.rs
  75. 4 4
      kernel/src/driver/base/device/driver.rs
  76. 4 8
      kernel/src/driver/base/device/mod.rs
  77. 1 0
      kernel/src/driver/base/platform/platform_device.rs
  78. 1 0
      kernel/src/driver/base/platform/platform_driver.rs
  79. 2 0
      kernel/src/driver/block/cache/cached_block_device.rs
  80. 12 6
      kernel/src/driver/clocksource/acpi_pm.rs
  81. 3 37
      kernel/src/driver/clocksource/timer_riscv.rs
  82. 35 15
      kernel/src/driver/disk/ahci/ahcidisk.rs
  83. 32 5
      kernel/src/driver/disk/ahci/hba.rs
  84. 19 6
      kernel/src/driver/disk/ahci/mod.rs
  85. 1 2
      kernel/src/driver/firmware/efi/init.rs
  86. 1 0
      kernel/src/driver/input/ps2_dev/ps2_device.rs
  87. 1 0
      kernel/src/driver/input/ps2_mouse/ps_mouse_device.rs
  88. 6 4
      kernel/src/driver/input/serio/i8042/mod.rs
  89. 1 0
      kernel/src/driver/input/serio/serio_device.rs
  90. 1 0
      kernel/src/driver/input/serio/serio_driver.rs
  91. 2 1
      kernel/src/driver/net/e1000e/e1000e.rs
  92. 483 0
      kernel/src/driver/net/loopback.rs
  93. 2 1
      kernel/src/driver/net/mod.rs
  94. 1 2
      kernel/src/driver/open_firmware/fdt.rs
  95. 1 0
      kernel/src/driver/pci/driver.rs
  96. 1 0
      kernel/src/driver/rtc/mod.rs
  97. 2 0
      kernel/src/driver/serial/mod.rs
  98. 1 0
      kernel/src/driver/serial/serial8250/mod.rs
  99. 2 0
      kernel/src/driver/serial/serial8250/serial8250_pio.rs
  100. 1 0
      kernel/src/driver/tty/console.rs

+ 12 - 9
.github/workflows/cache-toolchain.yml

@@ -51,17 +51,17 @@ jobs:
 
 
             cargo install cargo-binutils
             cargo install cargo-binutils
             rustup toolchain install nightly-x86_64-unknown-linux-gnu
             rustup toolchain install nightly-x86_64-unknown-linux-gnu
-            rustup toolchain install nightly-2023-01-21-x86_64-unknown-linux-gnu
+            rustup toolchain install nightly-2024-07-23-x86_64-unknown-linux-gnu
             rustup toolchain install nightly-2023-08-15-x86_64-unknown-linux-gnu
             rustup toolchain install nightly-2023-08-15-x86_64-unknown-linux-gnu
-            rustup component add rust-src --toolchain nightly-2023-01-21-x86_64-unknown-linux-gnu
+            rustup component add rust-src --toolchain nightly-2024-07-23-x86_64-unknown-linux-gnu
             rustup component add rust-src --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
             rustup component add rust-src --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
-            rustup target add x86_64-unknown-none --toolchain nightly-2023-01-21-x86_64-unknown-linux-gnu
+            rustup target add x86_64-unknown-none --toolchain nightly-2024-07-23-x86_64-unknown-linux-gnu
             rustup target add x86_64-unknown-none --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
             rustup target add x86_64-unknown-none --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
 
 
-            rustup toolchain install nightly-2023-01-21-riscv64gc-unknown-linux-gnu --force-non-host
+            rustup toolchain install nightly-2024-07-23-riscv64gc-unknown-linux-gnu --force-non-host
             rustup toolchain install nightly-2023-08-15-riscv64gc-unknown-linux-gnu --force-non-host
             rustup toolchain install nightly-2023-08-15-riscv64gc-unknown-linux-gnu --force-non-host
-            rustup target add riscv64gc-unknown-none-elf --toolchain nightly-2023-01-21-riscv64gc-unknown-linux-gnu
-            rustup target add riscv64imac-unknown-none-elf --toolchain nightly-2023-01-21-riscv64gc-unknown-linux-gnu
+            rustup target add riscv64gc-unknown-none-elf --toolchain nightly-2024-07-23-riscv64gc-unknown-linux-gnu
+            rustup target add riscv64imac-unknown-none-elf --toolchain nightly-2024-07-23-riscv64gc-unknown-linux-gnu
             rustup target add riscv64gc-unknown-none-elf --toolchain nightly-2023-08-15-riscv64gc-unknown-linux-gnu
             rustup target add riscv64gc-unknown-none-elf --toolchain nightly-2023-08-15-riscv64gc-unknown-linux-gnu
             rustup target add riscv64imac-unknown-none-elf --toolchain nightly-2023-08-15-riscv64gc-unknown-linux-gnu
             rustup target add riscv64imac-unknown-none-elf --toolchain nightly-2023-08-15-riscv64gc-unknown-linux-gnu
                 
                 
@@ -71,12 +71,12 @@ jobs:
 
 
             rustup component add rustfmt
             rustup component add rustfmt
             rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu
             rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu
-            rustup component add rustfmt --toolchain nightly-2023-01-21-x86_64-unknown-linux-gnu
+            rustup component add rustfmt --toolchain nightly-2024-07-23-x86_64-unknown-linux-gnu
             rustup component add rustfmt --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
             rustup component add rustfmt --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
-            rustup component add rustfmt --toolchain nightly-2023-01-21-riscv64gc-unknown-linux-gnu
+            rustup component add rustfmt --toolchain nightly-2024-07-23-riscv64gc-unknown-linux-gnu
             rustup component add rustfmt --toolchain nightly-2023-08-15-riscv64gc-unknown-linux-gnu
             rustup component add rustfmt --toolchain nightly-2023-08-15-riscv64gc-unknown-linux-gnu
 
 
-            rustup default nightly
+            rustup default nightly-2024-07-23
 
 
             cargo install dadk --version 0.1.11
             cargo install dadk --version 0.1.11
           
           
@@ -86,6 +86,9 @@ jobs:
             rustup toolchain install ${userapp_musl_toolchain}
             rustup toolchain install ${userapp_musl_toolchain}
             rustup component add --toolchain ${userapp_musl_toolchain} rust-src
             rustup component add --toolchain ${userapp_musl_toolchain} rust-src
             rustup target add --toolchain ${userapp_musl_toolchain} x86_64-unknown-linux-musl
             rustup target add --toolchain ${userapp_musl_toolchain} x86_64-unknown-linux-musl
+
+            rustup target add x86_64-unknown-linux-musl --toolchain nightly-2024-07-23-x86_64-unknown-linux-gnu
+            rustup component add rust-src --toolchain nightly-2024-07-23-x86_64-unknown-linux-gnu
            
            
 
 
 
 

+ 20 - 56
README.md

@@ -26,25 +26,25 @@
   DragonOS目前在社区驱动下正在快速发展中,目前DragonOS已经实现了约1/4的Linux接口,在未来我们将提供对Linux的100%兼容性,并且提供新特性。
   DragonOS目前在社区驱动下正在快速发展中,目前DragonOS已经实现了约1/4的Linux接口,在未来我们将提供对Linux的100%兼容性,并且提供新特性。
 
 
 
 
-[关于DragonOS,你想了解的都在这儿 - DragonOS](https://dragonos.org/?p=46)
+## 参与开发?
 
 
-## 网站
+仔细阅读 [DragonOS社区介绍文档] ,能够帮助你了解社区的运作方式,以及如何参与贡献!
 
 
-- 项目官网  **[DragonOS.org](https://dragonos.org)**
+- **了解开发动态、开发任务,请访问DragonOS社区论坛**: [https://bbs.dragonos.org.cn](https://bbs.dragonos.org.cn)
+- 您也可以从项目的issue里面了解相关的开发内容。
 
 
-- 项目文档  **[docs.DragonOS.org](https://docs.dragonos.org)**
 
 
-- **了解开发动态、开发任务,请访问DragonOS社区论坛**: [https://bbs.dragonos.org.cn](https://bbs.dragonos.org.cn)
+  如果你愿意加入我们,你可以查看issue,并在issue下发表讨论、想法,或者访问DragonOS的论坛,了解开发动态、开发任务: [https://bbs.dragonos.org.cn](https://bbs.dragonos.org.cn)
 
 
-- 软件镜像站 **[mirrors.DragonOS.org](https://mirrors.DragonOS.org)**
-- Git镜像站 **[git.mirrors.DragonOS.org](https://git.mirrors.DragonOS.org)**
-- 国内镜像站 **[mirrors.DragonOS.org.cn](https://mirrors.DragonOS.org.cn)**
+  你也可以带着你的创意与想法,和社区的小伙伴一起讨论,为DragonOS创造一些新的功能。
 
 
-- 开发交流QQ群 **115763565**
+## 网站
+
+
+- 项目官网  **[DragonOS.org](https://dragonos.org)**
+- 文档:**[docs.dragonos.org](https://docs.dragonos.org)**
+- 社区介绍文档: **[community.dragonos.org](https://community.dragonos.org)**
 
 
-- 代码搜索引擎 [code.DragonOS.org](http://code.dragonos.org)
-  
-   
 
 
 ## 如何运行?
 ## 如何运行?
 
 
@@ -52,34 +52,20 @@
 
 
 - [构建DragonOS — DragonOS dev 文档](https://docs.dragonos.org/zh_CN/latest/introduction/build_system.html)
 - [构建DragonOS — DragonOS dev 文档](https://docs.dragonos.org/zh_CN/latest/introduction/build_system.html)
 
 
-## 系统特性
-
-  请参见文档:[系统特性](https://docs.dragonos.org/zh_CN/latest/introduction/features.html)
-
-## 如何加入?
 
 
-  如果你愿意加入我们,你可以查看issue,并在issue下发表讨论、想法,或者访问DragonOS的论坛,了解开发动态、开发任务: [https://bbs.dragonos.org.cn](https://bbs.dragonos.org.cn)
-
-  你也可以带着你的创意与想法,和社区的小伙伴一起讨论,为DragonOS创造一些新的功能。
 
 
 ## 如何与社区建立联系?
 ## 如何与社区建立联系?
 
 
-  你可以发邮件给Maintainer: longjin,邮件地址是 [longjin@DragonOS.org](mailto:longjin@DragonOS.org) 。
-
-  或者是加入我们的开发交流QQ群:**115763565**
-
-  对于正式问题的讨论,请在 **[https://bbs.dragonos.org.cn](https://bbs.dragonos.org.cn)** 上的对应板块,使用正式的语言发帖讨论。亦或者是在本仓库的issue下提出问题。
+请阅读[贡献者指南](https://community.dragonos.org/contributors/#%E7%A4%BE%E5%8C%BA)~
 
 
+- 您可以通过[社区管理团队]信息,与各委员会的成员们建立联系~
+- 同时,您可以通过[SIGs]和[WGs]页面,找到对应的社区团体负责人的联系方式~
 
 
 ## 贡献者名单
 ## 贡献者名单
 
 
 [Contributors to DragonOS-Community/DragonOS · GitHub](https://github.com/DragonOS-Community/DragonOS/graphs/contributors)
 [Contributors to DragonOS-Community/DragonOS · GitHub](https://github.com/DragonOS-Community/DragonOS/graphs/contributors)
 
 
-## 联系我们
 
 
-社区对外联系邮箱:contact@DragonOS.org
-
-社区负责人邮箱:longjin@DragonOS.org
 
 
 ## 赞助
 ## 赞助
 
 
@@ -134,32 +120,10 @@
 
 
 **我们谴责**:任何不遵守开源协议的行为。包括但不限于:剽窃该项目的代码作为你的毕业设计等学术不端行为以及商业闭源使用而不付费。
 **我们谴责**:任何不遵守开源协议的行为。包括但不限于:剽窃该项目的代码作为你的毕业设计等学术不端行为以及商业闭源使用而不付费。
 
 
-若您发现了任何违背开源协议的使用行为,我们欢迎您发邮件反馈!让我们共同建设诚信的开源社区。
-
-## 参考资料
-
-  本项目参考了以下资料,我对这些项目、书籍、文档的作者表示感谢!
-
-- 《一个64位操作系统的实现》田宇(人民邮电出版社)
-
-- 《现代操作系统 原理与实现》陈海波、夏虞斌(机械工业出版社)
-
-- [SimpleKernel](https://github.com/Simple-XX/SimpleKernel)
-
-- [osdev.org](https://wiki.osdev.org/Main_Page)
-
-- ACPI_6_3_final_Jan30
-
-- the GNU GRUB manual
-
-- Intel® 64 and IA-32 Architectures Software Developer’s Manual
-
-- IA-PC HPET (High Precision Event Timers) Specification
-
-- [skiftOS]([GitHub - skiftOS/skift: 🥑 A hobby operating system built from scratch in modern C++. Featuring a reactive UI library and a strong emphasis on user experience.](https://github.com/skiftOS/skift))
-
-- [GuideOS](https://github.com/Codetector1374/GuideOS)
+若您发现了任何违背开源协议的使用行为,我们欢迎您发邮件到 pmc@dragonos.org 反馈!让我们共同建设诚信的开源社区。
 
 
-- [redox-os](https://gitlab.redox-os.org/redox-os/redox)
 
 
-- [rcore](https://github.com/rcore-os/rCore)
+[DragonOS社区介绍文档]: https://community.dragonos.org/
+[社区管理团队]: https://community.dragonos.org/governance/staff-info.html
+[SIGs]: https://community.dragonos.org/sigs/
+[WGs]: https://community.dragonos.org/wgs/

+ 21 - 59
README_EN.md

@@ -25,52 +25,37 @@
 
 
   Driven by the community, DragonOS is currently evolving rapidly. DragonOS has already implemented about 1/4 of Linux interfaces, and in the future, we will strive to provide 100% compatibility with Linux, along with new features.
   Driven by the community, DragonOS is currently evolving rapidly. DragonOS has already implemented about 1/4 of Linux interfaces, and in the future, we will strive to provide 100% compatibility with Linux, along with new features.
 
 
-[All you want to know about DragonOS is here - DragonOS](https://dragonos.org/?p=46)
 
 
-## Websites
+## Get Involved in Development?
 
 
-- Home Page  **[DragonOS.org](https://dragonos.org)**
-- Documentation  **[docs.DragonOS.org](https://docs.dragonos.org)**
-- **To learn about development dynamics and development tasks, please visit DragonOS's BBS:** [https://bbs.dragonos.org.cn](https://bbs.dragonos.org.cn)
-- Software mirror website **[mirrors.DragonOS.org](https://mirrors.DragonOS.org)**
-- Git mirror website **[git.mirrors.DragonOS.org](https://git.mirrors.DragonOS.org)**
-- QQ group **115763565**
-- Code search engine [code.DragonOS.org](http://code.dragonos.org) 
+Carefully read the [DragonOS Community Introduction Document] to understand how the community operates and how you can contribute!
 
 
-## How to run?
+- **To stay updated on development news and tasks, visit the DragonOS Community Forum**: [https://bbs.dragonos.org.cn](https://bbs.dragonos.org.cn)
+- You can also learn about the development progress by checking the project's issues.
 
 
-  The steps to run DragonOS are very simple. You can refer to the following information to run DragonOS within 15 minutes at the fastest!
+  If you're interested in joining us, you can check out the issues and post your discussions or ideas under them, or visit the DragonOS forum to learn about development updates and tasks: [https://bbs.dragonos.org.cn](https://bbs.dragonos.org.cn)
 
 
-- [Building DragonOS - DragonOS dev document](https://docs.dragonos.org/zh_CN/latest/introduction/build_system.html)
+  You're also welcome to bring your creative ideas and discuss them with the community members, working together to create new features for DragonOS.
 
 
-## DragonOS' Features
 
 
-  See documentation:[Features](https://docs.dragonos.org/zh_CN/latest/introduction/features.html)
+## Website
 
 
-## How to join DragonOS ?
+- **Project's Website**: [DragonOS.org](https://dragonos.org)
+- Documentation: [docs.dragonos.org](https://docs.dragonos.org)
+- Community Introduction Document: [community.dragonos.org](https://community.dragonos.org)
 
 
-  If you are willing to join us, you can visit DragonOS's BBS , learn about development dynamics and development tasks: [https://bbs.dragonos.org.cn](https://bbs.dragonos.org.cn)
+## How to Run?
 
 
-  Or, you can also bring your ideas, discuss with community members, and create some new functions for DragonOS.
+  Running DragonOS is quite straightforward. You can refer to the following resources and get DragonOS up and running in as little as 15 minutes!
 
 
-## How to contact the community?
+- [Building DragonOS — DragonOS Development Documentation](https://docs.dragonos.org/zh_CN/latest/introduction/build_system.html)
 
 
-  You can send an email to the project's maintainer: longjin. His email address is [longjin@DragonOS.org](mailto: longjin@DragonOS.org) .
+## How to Connect with the Community?
 
 
-  Or join our development exchange QQ group: **115763565**
+Please read the [Contributor Guide](https://community.dragonos.org/contributors/#%E7%A4%BE%E5%8C%BA)~
 
 
-  For the discussion of formal issues, we recommend that you use the official language to post on the corresponding section of **[https://bbs.dragonos.org.cn](https://bbs.dragonos.org.cn)**. Or you can post questions under the issue of this repository.
-
-
-## List of contributors
-
-[Contributors to DragonOS-Community/DragonOS · GitHub](https://github.com/DragonOS-Community/DragonOS/graphs/contributors)
-
-## Get contact with us
-
-Community Contact Email: contact@DragonOS.org
-
-Maintainer longjin's Email:longjin@DragonOS.org
+- You can establish contact with the members of various committees through the [Community Management Team] information.
+- Additionally, you can find the contact information of the respective community group leaders via the [SIGs] and [WGs] pages.
 
 
 
 
 ## Reward
 ## Reward
@@ -128,30 +113,7 @@ We guarantee that all sponsorship funds and items will be used for:
 
 
 If you find any violation of the open source license, we welcome you to send email feedback! Let's build an honest open source community together!
 If you find any violation of the open source license, we welcome you to send email feedback! Let's build an honest open source community together!
 
 
-## References
-
-  This project refers to the following materials. I sincerely give my thanks to the authors of these projects, books and documents!
-
-- Implementation of a 64 bit operating system, Tian Yu (POSTS&TELECOM  PRESS)
-
-- Principle and implementation of modern operating system, Chen Haibo, Xia Yubin (China Machine Press)
-
-- [SimpleKernel](https://github.com/Simple-XX/SimpleKernel)
-
-- [osdev.org](https://wiki.osdev.org/Main_Page)
-
-- ACPI_6_3_final_Jan30
-
-- the GNU GRUB manual
-
-- Intel® 64 and IA-32 Architectures Software Developer’s Manual
-
-- IA-PC HPET (High Precision Event Timers) Specification
-
-- [skiftOS]([GitHub - skiftOS/skift: 🥑 A hobby operating system built from scratch in modern C++. Featuring a reactive UI library and a strong emphasis on user experience.](https://github.com/skiftOS/skift))
-
-- [GuideOS](https://github.com/Codetector1374/GuideOS)
-
-- [redox-os](https://gitlab.redox-os.org/redox-os/redox)
-
-- [rcore](https://github.com/rcore-os/rCore)
+[DragonOS Community Introduction Document]: https://community.dragonos.org/
+[Community Management Team]: https://community.dragonos.org/governance/staff-info.html
+[SIGs]: https://community.dragonos.org/sigs/
+[WGs]: https://community.dragonos.org/wgs/

+ 1 - 0
build-scripts/.gitignore

@@ -0,0 +1 @@
+/target/

+ 2 - 0
build-scripts/Makefile

@@ -4,3 +4,5 @@ fmt:
 
 
 clean:
 clean:
 	@cargo clean
 	@cargo clean
+check:
+	@cargo +nightly-2024-07-23 check --workspace $(CARGO_ZBUILD) --message-format=json

+ 0 - 2
build-scripts/kernel_build/src/lib.rs

@@ -1,5 +1,3 @@
-#![feature(cfg_target_abi)]
-
 #[macro_use]
 #[macro_use]
 extern crate lazy_static;
 extern crate lazy_static;
 extern crate cc;
 extern crate cc;

+ 11 - 4
docs/conf.py

@@ -10,15 +10,14 @@
 # add these directories to sys.path here. If the directory is relative to the
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 #
 #
-# import os
+import os
 # import sys
 # import sys
 # sys.path.insert(0, os.path.abspath('.'))
 # sys.path.insert(0, os.path.abspath('.'))
 
 
-
 # -- Project information -----------------------------------------------------
 # -- Project information -----------------------------------------------------
 
 
 project = 'DragonOS'
 project = 'DragonOS'
-copyright = '2022-2023, DragonOS Community'
+copyright = '2022-2024, DragonOS Community'
 author = 'longjin'
 author = 'longjin'
 
 
 # The full version, including alpha/beta/rc tags
 # The full version, including alpha/beta/rc tags
@@ -73,4 +72,12 @@ myst_enable_extensions = [
     "strikethrough",
     "strikethrough",
     "substitution",
     "substitution",
     "tasklist",
     "tasklist",
-]
+]
+
+
+# Define the canonical URL if you are using a custom domain on Read the Docs
+html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
+
+# Tell Jinja2 templates the build is running on Read the Docs
+if os.environ.get("READTHEDOCS", "") == "True":
+    html_context["READTHEDOCS"] = True

+ 5 - 0
kernel/.cargo/config.toml

@@ -5,4 +5,9 @@
 [target.'cfg(target_os = "none")']
 [target.'cfg(target_os = "none")']
 runner = "bootimage runner"
 runner = "bootimage runner"
 
 
+[build]
+# '-Zlinker-features=-lld' 禁用rustlld(20240723),因为它与linkme0.3版本冲突
+rustflags = ["-Zlinker-features=-lld"]
+rustdocflags = ["-Zlinker-features=-lld"]
+
 [env]
 [env]

+ 6 - 4
kernel/Cargo.toml

@@ -12,16 +12,18 @@ crate-type = ["staticlib"]
 [workspace]
 [workspace]
 members = [ 
 members = [ 
     "crates/*",
     "crates/*",
-    "src/libs/intertrait"
 ]
 ]
 
 
 [features]
 [features]
-default = ["backtrace", "kvm"]
+default = ["backtrace", "kvm", "fatfs", "fatfs-secure"]
 # 内核栈回溯
 # 内核栈回溯
 backtrace = []
 backtrace = []
 # kvm
 # kvm
 kvm = []
 kvm = []
 
 
+fatfs = []
+fatfs-secure = ["fatfs"]
+
 
 
 # 运行时依赖项
 # 运行时依赖项
 [dependencies]
 [dependencies]
@@ -37,10 +39,10 @@ driver_base_macros = { "path" = "crates/driver_base_macros" }
 elf = { version = "=0.7.2", default-features = false }
 elf = { version = "=0.7.2", default-features = false }
 hashbrown = "=0.13.2"
 hashbrown = "=0.13.2"
 ida = { path = "src/libs/ida" }
 ida = { path = "src/libs/ida" }
-intertrait = { path = "src/libs/intertrait" }
+intertrait = { path = "crates/intertrait" }
 kdepends = { path = "crates/kdepends" }
 kdepends = { path = "crates/kdepends" }
 klog_types = { path = "crates/klog_types" }
 klog_types = { path = "crates/klog_types" }
-linkme = "=0.2"
+linkme = "=0.3.27"
 num = { version = "=0.4.0", default-features = false }
 num = { version = "=0.4.0", default-features = false }
 num-derive = "=0.3"
 num-derive = "=0.3"
 num-traits = { git = "https://git.mirrors.dragonos.org.cn/DragonOS-Community/num-traits.git", rev="1597c1c", default-features = false }
 num-traits = { git = "https://git.mirrors.dragonos.org.cn/DragonOS-Community/num-traits.git", rev="1597c1c", default-features = false }

+ 3 - 3
kernel/Makefile

@@ -36,12 +36,12 @@ check: ECHO
 # @echo "Checking kernel... ARCH=$(ARCH)"
 # @echo "Checking kernel... ARCH=$(ARCH)"
 # @exit 1
 # @exit 1
 ifeq ($(ARCH), x86_64)
 ifeq ($(ARCH), x86_64)
-	@cargo +nightly-2023-08-15 check --workspace $(CARGO_ZBUILD) --message-format=json --target ./src/$(TARGET_JSON)
+	@cargo +nightly-2024-07-23 check --workspace $(CARGO_ZBUILD) --message-format=json --target ./src/$(TARGET_JSON)
 else ifeq ($(ARCH), riscv64)
 else ifeq ($(ARCH), riscv64)
-	@cargo +nightly-2023-08-15 check --workspace $(CARGO_ZBUILD) --message-format=json --target $(TARGET_JSON)
+	@cargo +nightly-2024-07-23 check --workspace $(CARGO_ZBUILD) --message-format=json --target $(TARGET_JSON)
 endif
 endif
 
 
 test:
 test:
 # 测试内核库
 # 测试内核库
-	@cargo +nightly-2023-08-15 test --workspace --exclude dragonos_kernel
+	@cargo +nightly-2024-07-23 test --workspace --exclude dragonos_kernel
 
 

+ 1 - 0
kernel/crates/bitmap/src/lib.rs

@@ -2,6 +2,7 @@
 #![feature(core_intrinsics)]
 #![feature(core_intrinsics)]
 #![allow(incomplete_features)] // for const generics
 #![allow(incomplete_features)] // for const generics
 #![feature(generic_const_exprs)]
 #![feature(generic_const_exprs)]
+#![allow(internal_features)]
 #![allow(clippy::needless_return)]
 #![allow(clippy::needless_return)]
 
 
 #[macro_use]
 #[macro_use]

+ 9 - 0
kernel/crates/bitmap/src/static_bitmap.rs

@@ -14,6 +14,15 @@ where
     core: BitMapCore<usize>,
     core: BitMapCore<usize>,
 }
 }
 
 
+impl<const N: usize> Default for StaticBitmap<N>
+where
+    [(); (N + usize::BITS as usize - 1) / (usize::BITS as usize)]:,
+{
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
 impl<const N: usize> StaticBitmap<N>
 impl<const N: usize> StaticBitmap<N>
 where
 where
     [(); (N + usize::BITS as usize - 1) / (usize::BITS as usize)]:,
     [(); (N + usize::BITS as usize - 1) / (usize::BITS as usize)]:,

+ 0 - 5
kernel/crates/bitmap/src/traits.rs

@@ -182,11 +182,6 @@ macro_rules! bitops_for {
                 }
                 }
             }
             }
 
 
-            #[cfg(feature = "std")]
-            fn to_hex(bits: &Self) -> String {
-                format!("{:x}", bits)
-            }
-
             #[inline]
             #[inline]
             fn bit_size() -> usize {
             fn bit_size() -> usize {
                 <$target>::BITS as usize
                 <$target>::BITS as usize

+ 0 - 0
kernel/src/libs/intertrait/.gitignore → kernel/crates/intertrait/.gitignore


+ 1 - 1
kernel/src/libs/intertrait/Cargo.toml → kernel/crates/intertrait/Cargo.toml

@@ -14,7 +14,7 @@ include = ["src/**/*", "Cargo.toml", "LICENSE-*", "README.md"]
 
 
 
 
 [dependencies]
 [dependencies]
-linkme = "0.2"
+linkme = "=0.3.27"
 hashbrown = "0.13.2"
 hashbrown = "0.13.2"
 intertrait-macros = { version = "=0.2.2", path = "macros" }
 intertrait-macros = { version = "=0.2.2", path = "macros" }
 
 

+ 0 - 0
kernel/src/libs/intertrait/LICENSE-MIT → kernel/crates/intertrait/LICENSE-MIT


+ 1 - 1
kernel/src/libs/intertrait/README.md → kernel/crates/intertrait/README.md

@@ -23,7 +23,7 @@ Add the following two dependencies to your `Cargo.toml`:
 ```toml
 ```toml
 [dependencies]
 [dependencies]
 intertrait = "0.2"
 intertrait = "0.2"
-linkme = "0.2"
+linkme = "=0.3.27"
 ```
 ```
 
 
 The `linkme` dependency is required due to the use of `linkme` macro in the output of `intertrait` macros.
 The `linkme` dependency is required due to the use of `linkme` macro in the output of `intertrait` macros.

+ 1 - 1
kernel/src/libs/intertrait/macros/Cargo.toml → kernel/crates/intertrait/macros/Cargo.toml

@@ -20,4 +20,4 @@ uuid = { version = "0.8", features = ["v4"] }
 
 
 [dev-dependencies]
 [dev-dependencies]
 intertrait = { version = "=0.2.2", path = ".." }
 intertrait = { version = "=0.2.2", path = ".." }
-linkme = "0.2"
+linkme = "=0.3.27"

+ 0 - 0
kernel/src/libs/intertrait/macros/LICENSE-APACHE → kernel/crates/intertrait/macros/LICENSE-APACHE


+ 0 - 0
kernel/src/libs/intertrait/macros/LICENSE-MIT → kernel/crates/intertrait/macros/LICENSE-MIT


+ 0 - 0
kernel/src/libs/intertrait/macros/src/args.rs → kernel/crates/intertrait/macros/src/args.rs


+ 0 - 0
kernel/src/libs/intertrait/macros/src/gen_caster.rs → kernel/crates/intertrait/macros/src/gen_caster.rs


+ 0 - 0
kernel/src/libs/intertrait/macros/src/item_impl.rs → kernel/crates/intertrait/macros/src/item_impl.rs


+ 0 - 0
kernel/src/libs/intertrait/macros/src/item_type.rs → kernel/crates/intertrait/macros/src/item_type.rs


+ 0 - 0
kernel/src/libs/intertrait/macros/src/lib.rs → kernel/crates/intertrait/macros/src/lib.rs


+ 0 - 0
kernel/src/libs/intertrait/src/cast.rs → kernel/crates/intertrait/src/cast.rs


+ 0 - 0
kernel/src/libs/intertrait/src/cast/cast_arc.rs → kernel/crates/intertrait/src/cast/cast_arc.rs


+ 0 - 0
kernel/src/libs/intertrait/src/cast/cast_box.rs → kernel/crates/intertrait/src/cast/cast_box.rs


+ 0 - 0
kernel/src/libs/intertrait/src/cast/cast_mut.rs → kernel/crates/intertrait/src/cast/cast_mut.rs


+ 0 - 0
kernel/src/libs/intertrait/src/cast/cast_rc.rs → kernel/crates/intertrait/src/cast/cast_rc.rs


+ 0 - 0
kernel/src/libs/intertrait/src/cast/cast_ref.rs → kernel/crates/intertrait/src/cast/cast_ref.rs


+ 0 - 0
kernel/src/libs/intertrait/src/hasher.rs → kernel/crates/intertrait/src/hasher.rs


+ 0 - 0
kernel/src/libs/intertrait/src/lib.rs → kernel/crates/intertrait/src/lib.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/castable_to.rs → kernel/crates/intertrait/tests/castable_to.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/on-enum.rs → kernel/crates/intertrait/tests/on-enum.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/on-struct.rs → kernel/crates/intertrait/tests/on-struct.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/on-trait-impl-assoc-type1.rs → kernel/crates/intertrait/tests/on-trait-impl-assoc-type1.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/on-trait-impl-assoc-type2.rs → kernel/crates/intertrait/tests/on-trait-impl-assoc-type2.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/on-trait-impl-assoc-type3.rs → kernel/crates/intertrait/tests/on-trait-impl-assoc-type3.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/on-trait-impl.rs → kernel/crates/intertrait/tests/on-trait-impl.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/on-type-multi-traits.rs → kernel/crates/intertrait/tests/on-type-multi-traits.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/run.rs → kernel/crates/intertrait/tests/run.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/ui/duplicate-flags.rs → kernel/crates/intertrait/tests/ui/duplicate-flags.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/ui/duplicate-flags.stderr → kernel/crates/intertrait/tests/ui/duplicate-flags.stderr


+ 0 - 0
kernel/src/libs/intertrait/tests/ui/on-generic-type.rs → kernel/crates/intertrait/tests/ui/on-generic-type.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/ui/on-generic-type.stderr → kernel/crates/intertrait/tests/ui/on-generic-type.stderr


+ 0 - 0
kernel/src/libs/intertrait/tests/ui/on-type-impl.rs → kernel/crates/intertrait/tests/ui/on-type-impl.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/ui/on-type-impl.stderr → kernel/crates/intertrait/tests/ui/on-type-impl.stderr


+ 0 - 0
kernel/src/libs/intertrait/tests/ui/unknown-flag.rs → kernel/crates/intertrait/tests/ui/unknown-flag.rs


+ 0 - 0
kernel/src/libs/intertrait/tests/ui/unknown-flag.stderr → kernel/crates/intertrait/tests/ui/unknown-flag.stderr


+ 6 - 0
kernel/crates/klog_types/src/lib.rs

@@ -175,6 +175,12 @@ impl MMLogCycle {
     }
     }
 }
 }
 
 
+impl Default for MMLogCycle {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
 impl kdepends::thingbuf::Recycle<AllocatorLog> for MMLogCycle {
 impl kdepends::thingbuf::Recycle<AllocatorLog> for MMLogCycle {
     fn new_element(&self) -> AllocatorLog {
     fn new_element(&self) -> AllocatorLog {
         AllocatorLog::zeroed()
         AllocatorLog::zeroed()

+ 5 - 3
kernel/crates/rust-slabmalloc/src/pages.rs

@@ -38,7 +38,7 @@ impl Bitfield for [AtomicU64] {
     fn initialize(&mut self, for_size: usize, capacity: usize) {
     fn initialize(&mut self, for_size: usize, capacity: usize) {
         // Set everything to allocated
         // Set everything to allocated
         for bitmap in self.iter_mut() {
         for bitmap in self.iter_mut() {
-            *bitmap = AtomicU64::new(u64::max_value());
+            *bitmap = AtomicU64::new(u64::MAX);
         }
         }
 
 
         // Mark actual slots as free
         // Mark actual slots as free
@@ -64,7 +64,7 @@ impl Bitfield for [AtomicU64] {
 
 
         for (base_idx, b) in self.iter().enumerate() {
         for (base_idx, b) in self.iter().enumerate() {
             let bitval = b.load(Ordering::Relaxed);
             let bitval = b.load(Ordering::Relaxed);
-            if bitval == u64::max_value() {
+            if bitval == u64::MAX {
                 continue;
                 continue;
             } else {
             } else {
                 let negated = !bitval;
                 let negated = !bitval;
@@ -125,7 +125,7 @@ impl Bitfield for [AtomicU64] {
     #[inline(always)]
     #[inline(always)]
     fn is_full(&self) -> bool {
     fn is_full(&self) -> bool {
         self.iter()
         self.iter()
-            .filter(|&x| x.load(Ordering::Relaxed) != u64::max_value())
+            .filter(|&x| x.load(Ordering::Relaxed) != u64::MAX)
             .count()
             .count()
             == 0
             == 0
     }
     }
@@ -410,6 +410,7 @@ impl<'a, T: AllocablePage> PageList<'a, T> {
     }
     }
 
 
     /// Removes `slab_page` from the list.
     /// Removes `slab_page` from the list.
+    #[allow(clippy::manual_inspect)]
     pub(crate) fn pop<'b>(&'b mut self) -> Option<&'a mut T> {
     pub(crate) fn pop<'b>(&'b mut self) -> Option<&'a mut T> {
         match self.head {
         match self.head {
             None => None,
             None => None,
@@ -453,6 +454,7 @@ impl<'a, P: AllocablePage + 'a> Iterator for ObjectPageIterMut<'a, P> {
     type Item = &'a mut P;
     type Item = &'a mut P;
 
 
     #[inline]
     #[inline]
+    #[allow(clippy::manual_inspect)]
     fn next(&mut self) -> Option<&'a mut P> {
     fn next(&mut self) -> Option<&'a mut P> {
         unsafe {
         unsafe {
             self.head.resolve_mut().map(|next| {
             self.head.resolve_mut().map(|next| {

+ 1 - 1
kernel/crates/unified-init/Cargo.toml

@@ -10,5 +10,5 @@ path = "src/main.rs"
 
 
 [dependencies]
 [dependencies]
 unified-init-macros = { path = "macros" }
 unified-init-macros = { path = "macros" }
-linkme = "0.2"
+linkme = "=0.3.27"
 system_error = { path = "../system_error" }
 system_error = { path = "../system_error" }

+ 1 - 1
kernel/crates/unified-init/macros/Cargo.toml

@@ -16,5 +16,5 @@ uuid = { version = "0.8", features = ["v4"] }
 
 
 [dev-dependencies]
 [dev-dependencies]
 unified-init = { path = ".." }
 unified-init = { path = ".." }
-linkme = "0.2"
+linkme = "=0.3.27"
 system_error = { path = "../../system_error" }
 system_error = { path = "../../system_error" }

+ 1 - 1
kernel/rust-toolchain.toml

@@ -1,3 +1,3 @@
 [toolchain]
 [toolchain]
-channel = "nightly-2023-08-15"
+channel = "nightly-2024-07-23"
 components = ["rust-src", "clippy"]
 components = ["rust-src", "clippy"]

+ 2 - 2
kernel/src/Makefile

@@ -21,7 +21,7 @@ ifeq ($(ARCH), x86_64)
 endif
 endif
 endif
 endif
 
 
-RUSTFLAGS = $(RUSTFLAGS_UNWIND)
+RUSTFLAGS += $(RUSTFLAGS_UNWIND)
 
 
 CFLAGS = $(GLOBAL_CFLAGS) -fno-pie $(CFLAGS_UNWIND) -I $(shell pwd) -I $(shell pwd)/include
 CFLAGS = $(GLOBAL_CFLAGS) -fno-pie $(CFLAGS_UNWIND) -I $(shell pwd) -I $(shell pwd)/include
 
 
@@ -40,7 +40,7 @@ kernel_subdirs := common driver debug syscall libs
 
 
 
 
 kernel_rust:
 kernel_rust:
-	RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2023-08-15 $(CARGO_ZBUILD) build --release --target $(TARGET_JSON)
+	RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-07-23 $(CARGO_ZBUILD) build --release --target $(TARGET_JSON)
 
 
 
 
 all: kernel
 all: kernel

+ 1 - 0
kernel/src/arch/io.rs

@@ -1,4 +1,5 @@
 /// 每个架构都需要实现的IO接口
 /// 每个架构都需要实现的IO接口
+#[allow(unused)]
 pub trait PortIOArch {
 pub trait PortIOArch {
     unsafe fn in8(port: u16) -> u8;
     unsafe fn in8(port: u16) -> u8;
     unsafe fn in16(port: u16) -> u16;
     unsafe fn in16(port: u16) -> u16;

+ 3 - 2
kernel/src/arch/x86_64/driver/apic/apic_timer.rs

@@ -12,10 +12,10 @@ use crate::exception::manage::irq_manager;
 use crate::exception::IrqNumber;
 use crate::exception::IrqNumber;
 
 
 use crate::mm::percpu::PerCpu;
 use crate::mm::percpu::PerCpu;
-use crate::process::ProcessManager;
 use crate::smp::core::smp_get_processor_id;
 use crate::smp::core::smp_get_processor_id;
 use crate::smp::cpu::ProcessorId;
 use crate::smp::cpu::ProcessorId;
 use crate::time::clocksource::HZ;
 use crate::time::clocksource::HZ;
+use crate::time::tick_common::tick_handle_periodic;
 use alloc::string::ToString;
 use alloc::string::ToString;
 use alloc::sync::Arc;
 use alloc::sync::Arc;
 pub use drop;
 pub use drop;
@@ -156,6 +156,7 @@ impl LocalApicTimerIntrController {
         local_apic_timer.start_current();
         local_apic_timer.start_current();
     }
     }
 
 
+    #[allow(dead_code)]
     pub(super) fn disable(&self) {
     pub(super) fn disable(&self) {
         let cpu_id = smp_get_processor_id();
         let cpu_id = smp_get_processor_id();
         let local_apic_timer = local_apic_timer_instance_mut(cpu_id);
         let local_apic_timer = local_apic_timer_instance_mut(cpu_id);
@@ -277,7 +278,7 @@ impl LocalApicTimer {
 
 
     pub(super) fn handle_irq(trap_frame: &TrapFrame) -> Result<IrqReturn, SystemError> {
     pub(super) fn handle_irq(trap_frame: &TrapFrame) -> Result<IrqReturn, SystemError> {
         // sched_update_jiffies();
         // sched_update_jiffies();
-        ProcessManager::update_process_times(trap_frame.is_from_user());
+        tick_handle_periodic(trap_frame);
         return Ok(IrqReturn::Handled);
         return Ok(IrqReturn::Handled);
     }
     }
 }
 }

+ 1 - 0
kernel/src/arch/x86_64/driver/apic/lapic_vector.rs

@@ -179,6 +179,7 @@ bitflags! {
     }
     }
 }
 }
 
 
+#[allow(dead_code)]
 pub(super) fn irq_msi_compose_msg(cfg: &HardwareIrqConfig, msg: &mut MsiMsg, dmar: bool) {
 pub(super) fn irq_msi_compose_msg(cfg: &HardwareIrqConfig, msg: &mut MsiMsg, dmar: bool) {
     *msg = MsiMsg::new_zeroed();
     *msg = MsiMsg::new_zeroed();
 
 

+ 1 - 7
kernel/src/arch/x86_64/driver/hpet.rs

@@ -30,10 +30,7 @@ use crate::{
         mmio_buddy::{mmio_pool, MMIOSpaceGuard},
         mmio_buddy::{mmio_pool, MMIOSpaceGuard},
         PhysAddr,
         PhysAddr,
     },
     },
-    time::{
-        jiffies::NSEC_PER_JIFFY,
-        timer::{try_raise_timer_softirq, update_timer_jiffies},
-    },
+    time::jiffies::NSEC_PER_JIFFY,
 };
 };
 
 
 static mut HPET_INSTANCE: Option<Hpet> = None;
 static mut HPET_INSTANCE: Option<Hpet> = None;
@@ -249,9 +246,6 @@ impl Hpet {
     pub(super) fn handle_irq(&self, timer_num: u32) {
     pub(super) fn handle_irq(&self, timer_num: u32) {
         if timer_num == 0 {
         if timer_num == 0 {
             assert!(!CurrentIrqArch::is_irq_enabled());
             assert!(!CurrentIrqArch::is_irq_enabled());
-            update_timer_jiffies(1, Self::HPET0_INTERVAL_USEC as i64);
-
-            try_raise_timer_softirq();
         }
         }
     }
     }
 }
 }

+ 2 - 0
kernel/src/arch/x86_64/init/mod.rs

@@ -35,6 +35,7 @@ extern "C" {
 }
 }
 
 
 #[no_mangle]
 #[no_mangle]
+#[allow(static_mut_refs)]
 unsafe extern "C" fn kernel_main(
 unsafe extern "C" fn kernel_main(
     mb2_info: u64,
     mb2_info: u64,
     mb2_magic: u64,
     mb2_magic: u64,
@@ -66,6 +67,7 @@ unsafe extern "C" fn kernel_main(
 
 
 /// 在内存管理初始化之前的架构相关的早期初始化
 /// 在内存管理初始化之前的架构相关的早期初始化
 #[inline(never)]
 #[inline(never)]
+#[allow(static_mut_refs)]
 pub fn early_setup_arch() -> Result<(), SystemError> {
 pub fn early_setup_arch() -> Result<(), SystemError> {
     let stack_start = unsafe { *(head_stack_start as *const u64) } as usize;
     let stack_start = unsafe { *(head_stack_start as *const u64) } as usize;
     debug!("head_stack_start={:#x}\n", stack_start);
     debug!("head_stack_start={:#x}\n", stack_start);

+ 1 - 0
kernel/src/arch/x86_64/interrupt/entry.rs

@@ -564,6 +564,7 @@ pub unsafe fn set_system_trap_gate(irq: u32, ist: u8, vaddr: VirtAddr) {
     set_gate(idt_entry, 0xEF, ist, vaddr);
     set_gate(idt_entry, 0xEF, ist, vaddr);
 }
 }
 
 
+#[allow(static_mut_refs)]
 unsafe fn get_idt_entry(irq: u32) -> &'static mut [u64] {
 unsafe fn get_idt_entry(irq: u32) -> &'static mut [u64] {
     assert!(irq < 256);
     assert!(irq < 256);
     let mut idt_vaddr =
     let mut idt_vaddr =

+ 1 - 0
kernel/src/arch/x86_64/interrupt/msi.rs

@@ -26,6 +26,7 @@ pub struct X86MsiDataNormal {
 }
 }
 
 
 #[derive(Debug)]
 #[derive(Debug)]
+#[allow(dead_code)]
 pub struct X86MsiDataDmar {
 pub struct X86MsiDataDmar {
     pub dmar_subhandle: u32,
     pub dmar_subhandle: u32,
 }
 }

+ 1 - 0
kernel/src/arch/x86_64/ipc/signal.rs

@@ -396,6 +396,7 @@ impl SigContext {
     }
     }
 }
 }
 /// @brief 信号处理备用栈的信息
 /// @brief 信号处理备用栈的信息
+#[allow(dead_code)]
 #[derive(Debug, Clone, Copy)]
 #[derive(Debug, Clone, Copy)]
 pub struct SigStack {
 pub struct SigStack {
     pub sp: *mut c_void,
     pub sp: *mut c_void,

+ 8 - 11
kernel/src/arch/x86_64/kvm/vmx/vcpu.rs

@@ -10,8 +10,8 @@ use crate::arch::mm::{LockedFrameAllocator, PageMapper};
 use crate::arch::x86_64::mm::X86_64MMArch;
 use crate::arch::x86_64::mm::X86_64MMArch;
 use crate::arch::MMArch;
 use crate::arch::MMArch;
 
 
-use crate::mm::{phys_2_virt, VirtAddr};
 use crate::mm::{MemoryManagementArch, PageTableKind};
 use crate::mm::{MemoryManagementArch, PageTableKind};
+use crate::mm::{PhysAddr, VirtAddr};
 use crate::virt::kvm::vcpu::Vcpu;
 use crate::virt::kvm::vcpu::Vcpu;
 use crate::virt::kvm::vm::Vm;
 use crate::virt::kvm::vm::Vm;
 use alloc::alloc::Global;
 use alloc::alloc::Global;
@@ -42,6 +42,7 @@ pub struct MSRBitmap {
     pub data: [u8; PAGE_SIZE],
     pub data: [u8; PAGE_SIZE],
 }
 }
 
 
+#[allow(dead_code)]
 #[derive(Debug)]
 #[derive(Debug)]
 pub struct VcpuData {
 pub struct VcpuData {
     /// The virtual and physical address of the Vmxon naturally aligned 4-KByte region of memory
     /// The virtual and physical address of the Vmxon naturally aligned 4-KByte region of memory
@@ -73,6 +74,7 @@ pub enum VcpuState {
     Act = 2,
     Act = 2,
 }
 }
 
 
+#[allow(dead_code)]
 #[derive(Debug)]
 #[derive(Debug)]
 pub struct VmxVcpu {
 pub struct VmxVcpu {
     pub vcpu_id: u32,
     pub vcpu_id: u32,
@@ -318,13 +320,13 @@ impl VmxVcpu {
         )?;
         )?;
         vmx_vmwrite(
         vmx_vmwrite(
             VmcsFields::HOST_GDTR_BASE as u32,
             VmcsFields::HOST_GDTR_BASE as u32,
-            pseudo_descriptpr.base.to_bits() as u64,
+            pseudo_descriptpr.base as usize as u64,
         )?;
         )?;
         vmx_vmwrite(VmcsFields::HOST_IDTR_BASE as u32, unsafe {
         vmx_vmwrite(VmcsFields::HOST_IDTR_BASE as u32, unsafe {
             let mut pseudo_descriptpr: x86::dtables::DescriptorTablePointer<u64> =
             let mut pseudo_descriptpr: x86::dtables::DescriptorTablePointer<u64> =
                 Default::default();
                 Default::default();
             x86::dtables::sidt(&mut pseudo_descriptpr);
             x86::dtables::sidt(&mut pseudo_descriptpr);
-            pseudo_descriptpr.base.to_bits() as u64
+            pseudo_descriptpr.base as usize as u64
         })?;
         })?;
 
 
         // fast entry into the kernel
         // fast entry into the kernel
@@ -474,14 +476,9 @@ pub fn get_segment_base(gdt_base: *const u64, gdt_size: u16, segment_selector: u
     let base_mid = (descriptor & 0x0000_00FF_0000_0000) >> 16;
     let base_mid = (descriptor & 0x0000_00FF_0000_0000) >> 16;
     let base_low = (descriptor & 0x0000_0000_FFFF_0000) >> 16;
     let base_low = (descriptor & 0x0000_0000_FFFF_0000) >> 16;
     let segment_base = (base_high | base_mid | base_low) & 0xFFFFFFFF;
     let segment_base = (base_high | base_mid | base_low) & 0xFFFFFFFF;
-    let virtaddr = phys_2_virt(segment_base.try_into().unwrap())
-        .try_into()
-        .unwrap();
-    debug!(
-        "segment_base={:x}",
-        phys_2_virt(segment_base.try_into().unwrap())
-    );
-    return virtaddr;
+    let virtaddr = unsafe { MMArch::phys_2_virt(PhysAddr::new(segment_base as usize)).unwrap() };
+
+    return virtaddr.data() as u64;
 }
 }
 
 
 // FIXME: may have bug
 // FIXME: may have bug

+ 2 - 2
kernel/src/arch/x86_64/kvm/vmx/vmx_asm_wrapper.rs

@@ -64,10 +64,10 @@ pub fn vmx_vmlaunch() -> Result<(), SystemError> {
             "push    rsi",
             "push    rsi",
             "push    rdi",
             "push    rdi",
             "vmwrite {0:r}, rsp",
             "vmwrite {0:r}, rsp",
-            "lea rax, 1f[rip]",
+            "lea rax, 2f[rip]",
             "vmwrite {1:r}, rax",
             "vmwrite {1:r}, rax",
             "vmlaunch",
             "vmlaunch",
-            "1:",
+            "2:",
             "pop    rdi",
             "pop    rdi",
             "pop    rsi",
             "pop    rsi",
             "pop    rdx",
             "pop    rdx",

+ 1 - 0
kernel/src/arch/x86_64/mod.rs

@@ -30,6 +30,7 @@ pub use interrupt::X86_64InterruptArch as CurrentIrqArch;
 pub use crate::arch::asm::pio::X86_64PortIOArch as CurrentPortIOArch;
 pub use crate::arch::asm::pio::X86_64PortIOArch as CurrentPortIOArch;
 pub use kvm::X86_64KVMArch as KVMArch;
 pub use kvm::X86_64KVMArch as KVMArch;
 
 
+#[allow(unused_imports)]
 pub use crate::arch::ipc::signal::X86_64SignalArch as CurrentSignalArch;
 pub use crate::arch::ipc::signal::X86_64SignalArch as CurrentSignalArch;
 pub use crate::arch::time::X86_64TimeArch as CurrentTimeArch;
 pub use crate::arch::time::X86_64TimeArch as CurrentTimeArch;
 
 

+ 1 - 2
kernel/src/arch/x86_64/process/kthread.rs

@@ -42,9 +42,8 @@ impl KernelThreadMechanism {
         frame.rip = kernel_thread_bootstrap_stage1 as usize as u64;
         frame.rip = kernel_thread_bootstrap_stage1 as usize as u64;
 
 
         // fork失败的话,子线程不会执行。否则将导致内存安全问题。
         // fork失败的话,子线程不会执行。否则将导致内存安全问题。
-        let pid = ProcessManager::fork(&frame, clone_flags).map_err(|e| {
+        let pid = ProcessManager::fork(&frame, clone_flags).inspect_err(|_e| {
             unsafe { KernelThreadCreateInfo::parse_unsafe_arc_ptr(create_info) };
             unsafe { KernelThreadCreateInfo::parse_unsafe_arc_ptr(create_info) };
-            e
         })?;
         })?;
 
 
         ProcessManager::find(pid)
         ProcessManager::find(pid)

+ 1 - 0
kernel/src/arch/x86_64/process/table.rs

@@ -59,6 +59,7 @@ impl TSSManager {
         x86::task::load_tr(selector);
         x86::task::load_tr(selector);
     }
     }
 
 
+    #[allow(static_mut_refs)]
     unsafe fn set_tss_descriptor(index: u16, vaddr: VirtAddr) {
     unsafe fn set_tss_descriptor(index: u16, vaddr: VirtAddr) {
         const LIMIT: u64 = 103;
         const LIMIT: u64 = 103;
         let gdt_vaddr = VirtAddr::new(&GDT_Table as *const _ as usize);
         let gdt_vaddr = VirtAddr::new(&GDT_Table as *const _ as usize);

+ 1 - 0
kernel/src/arch/x86_64/smp/mod.rs

@@ -259,6 +259,7 @@ impl X86_64SMPArch {
 }
 }
 
 
 impl SmpCpuManager {
 impl SmpCpuManager {
+    #[allow(static_mut_refs)]
     pub fn arch_init(_boot_cpu: ProcessorId) {
     pub fn arch_init(_boot_cpu: ProcessorId) {
         assert!(smp_get_processor_id().data() == 0);
         assert!(smp_get_processor_id().data() == 0);
         // 写入APU_START_CR3,这个值会在AP处理器启动时设置到CR3寄存器
         // 写入APU_START_CR3,这个值会在AP处理器启动时设置到CR3寄存器

+ 1 - 1
kernel/src/arch/x86_64/x86_64-unknown-none.json

@@ -1,6 +1,6 @@
 {
 {
   "llvm-target": "x86_64-unknown-none",
   "llvm-target": "x86_64-unknown-none",
-  "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
+  "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
   "arch": "x86_64",
   "arch": "x86_64",
   "target-endian": "little",
   "target-endian": "little",
   "target-pointer-width": "64",
   "target-pointer-width": "64",

+ 2 - 0
kernel/src/driver/acpi/bus.rs

@@ -111,6 +111,7 @@ impl Bus for AcpiBus {
 ///
 ///
 ///
 ///
 /// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/acpi/acpi_bus.h#364
 /// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/acpi/acpi_bus.h#364
+#[allow(unused)]
 pub trait AcpiDevice: Device {}
 pub trait AcpiDevice: Device {}
 
 
 /// Acpi驱动应当实现的trait
 /// Acpi驱动应当实现的trait
@@ -120,4 +121,5 @@ pub trait AcpiDevice: Device {}
 /// todo: 仿照linux的acpi_driver去设计这个trait
 /// todo: 仿照linux的acpi_driver去设计这个trait
 ///
 ///
 /// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/acpi/acpi_bus.h#163
 /// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/acpi/acpi_bus.h#163
+#[allow(unused)]
 pub trait AcpiDriver: Driver {}
 pub trait AcpiDriver: Driver {}

+ 1 - 2
kernel/src/driver/base/device/bus.rs

@@ -478,9 +478,8 @@ impl BusManager {
 
 
         driver_manager()
         driver_manager()
             .create_attr_file(driver, &DriverAttrBind)
             .create_attr_file(driver, &DriverAttrBind)
-            .map_err(|e| {
+            .inspect_err(|_e| {
                 driver_manager().remove_attr_file(driver, &DriverAttrUnbind);
                 driver_manager().remove_attr_file(driver, &DriverAttrUnbind);
-                e
             })?;
             })?;
 
 
         return Ok(());
         return Ok(());

+ 3 - 4
kernel/src/driver/base/device/dd.rs

@@ -142,6 +142,7 @@ impl DeviceManager {
     /// - Ok(true): 匹配成功
     /// - Ok(true): 匹配成功
     /// - Ok(false): 没有匹配成功
     /// - Ok(false): 没有匹配成功
     /// - Err(SystemError): 匹配过程中出现意外错误,没有匹配成功
     /// - Err(SystemError): 匹配过程中出现意外错误,没有匹配成功
+    ///
     /// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c#899
     /// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/base/dd.c#899
     fn do_device_attach_driver(
     fn do_device_attach_driver(
         &self,
         &self,
@@ -484,17 +485,15 @@ impl DriverManager {
 
 
         sysfs_instance()
         sysfs_instance()
             .create_link(Some(&device_kobj), &driver_kobj, "driver".to_string())
             .create_link(Some(&device_kobj), &driver_kobj, "driver".to_string())
-            .map_err(|e| {
+            .inspect_err(|_e| {
                 fail_rm_dev_link();
                 fail_rm_dev_link();
-                e
             })?;
             })?;
 
 
         device_manager()
         device_manager()
             .create_file(device, &DeviceAttrCoredump)
             .create_file(device, &DeviceAttrCoredump)
-            .map_err(|e| {
+            .inspect_err(|_e| {
                 sysfs_instance().remove_link(&device_kobj, "driver".to_string());
                 sysfs_instance().remove_link(&device_kobj, "driver".to_string());
                 fail_rm_dev_link();
                 fail_rm_dev_link();
-                e
             })?;
             })?;
 
 
         return Ok(());
         return Ok(());

+ 4 - 4
kernel/src/driver/base/device/driver.rs

@@ -213,10 +213,10 @@ impl DriverManager {
 
 
         bus_manager().add_driver(&driver)?;
         bus_manager().add_driver(&driver)?;
 
 
-        self.add_groups(&driver, driver.groups()).map_err(|e| {
-            bus_manager().remove_driver(&driver);
-            e
-        })?;
+        self.add_groups(&driver, driver.groups())
+            .inspect_err(|_e| {
+                bus_manager().remove_driver(&driver);
+            })?;
 
 
         // todo: 发送uevent
         // todo: 发送uevent
 
 

+ 4 - 8
kernel/src/driver/base/device/mod.rs

@@ -646,18 +646,16 @@ impl DeviceManager {
             let parent_kobj = parent.clone() as Arc<dyn KObject>;
             let parent_kobj = parent.clone() as Arc<dyn KObject>;
             sysfs_instance()
             sysfs_instance()
                 .create_link(Some(&dev_kobj), &parent_kobj, "device".to_string())
                 .create_link(Some(&dev_kobj), &parent_kobj, "device".to_string())
-                .map_err(|e| {
+                .inspect_err(|_e| {
                     err_remove_subsystem(&dev_kobj);
                     err_remove_subsystem(&dev_kobj);
-                    e
                 })?;
                 })?;
         }
         }
 
 
         sysfs_instance()
         sysfs_instance()
             .create_link(Some(&subsys_kobj), &dev_kobj, dev.name())
             .create_link(Some(&subsys_kobj), &dev_kobj, dev.name())
-            .map_err(|e| {
+            .inspect_err(|_e| {
                 err_remove_device(&dev_kobj);
                 err_remove_device(&dev_kobj);
                 err_remove_subsystem(&dev_kobj);
                 err_remove_subsystem(&dev_kobj);
-                e
             })?;
             })?;
 
 
         return Ok(());
         return Ok(());
@@ -695,18 +693,16 @@ impl DeviceManager {
         // 添加kobj_type的属性文件
         // 添加kobj_type的属性文件
         if let Some(kobj_type) = dev.kobj_type() {
         if let Some(kobj_type) = dev.kobj_type() {
             self.add_groups(dev, kobj_type.attribute_groups().unwrap_or(&[]))
             self.add_groups(dev, kobj_type.attribute_groups().unwrap_or(&[]))
-                .map_err(|e| {
+                .inspect_err(|_e| {
                     err_remove_class_groups(dev);
                     err_remove_class_groups(dev);
-                    e
                 })?;
                 })?;
         }
         }
 
 
         // 添加设备本身的属性文件
         // 添加设备本身的属性文件
         self.add_groups(dev, dev.attribute_groups().unwrap_or(&[]))
         self.add_groups(dev, dev.attribute_groups().unwrap_or(&[]))
-            .map_err(|e| {
+            .inspect_err(|_e| {
                 err_remove_kobj_type_groups(dev);
                 err_remove_kobj_type_groups(dev);
                 err_remove_class_groups(dev);
                 err_remove_class_groups(dev);
-                e
             })?;
             })?;
 
 
         return Ok(());
         return Ok(());

+ 1 - 0
kernel/src/driver/base/platform/platform_device.rs

@@ -64,6 +64,7 @@ pub trait PlatformDevice: Device {
     /// @brief: 判断设备是否初始化
     /// @brief: 判断设备是否初始化
     /// @parameter: None
     /// @parameter: None
     /// @return: 如果已经初始化,返回true,否则,返回false
     /// @return: 如果已经初始化,返回true,否则,返回false
+    #[allow(dead_code)]
     fn is_initialized(&self) -> bool;
     fn is_initialized(&self) -> bool;
 
 
     /// @brief: 设置设备状态
     /// @brief: 设置设备状态

+ 1 - 0
kernel/src/driver/base/platform/platform_driver.rs

@@ -16,6 +16,7 @@ use super::{platform_bus, platform_device::PlatformDevice};
 ///
 ///
 /// 应当在所有实现这个trait的结构体上方,添加 `#[cast_to([sync] PlatformDriver)]`,
 /// 应当在所有实现这个trait的结构体上方,添加 `#[cast_to([sync] PlatformDriver)]`,
 /// 否则运行时将报错“该对象不是PlatformDriver”
 /// 否则运行时将报错“该对象不是PlatformDriver”
+#[allow(dead_code)]
 pub trait PlatformDriver: Driver {
 pub trait PlatformDriver: Driver {
     /// 检测设备是否能绑定到这个驱动
     /// 检测设备是否能绑定到这个驱动
     ///
     ///

+ 2 - 0
kernel/src/driver/block/cache/cached_block_device.rs

@@ -16,6 +16,7 @@ static mut CMAPPER: Option<LockedCacheMapper> = None;
 /// 该结构体向外提供BlockCache服务
 /// 该结构体向外提供BlockCache服务
 pub struct BlockCache;
 pub struct BlockCache;
 
 
+#[allow(static_mut_refs)]
 unsafe fn mapper() -> Result<&'static mut LockedCacheMapper, BlockCacheError> {
 unsafe fn mapper() -> Result<&'static mut LockedCacheMapper, BlockCacheError> {
     unsafe {
     unsafe {
         match &mut CMAPPER {
         match &mut CMAPPER {
@@ -25,6 +26,7 @@ unsafe fn mapper() -> Result<&'static mut LockedCacheMapper, BlockCacheError> {
     };
     };
 }
 }
 
 
+#[allow(static_mut_refs)]
 unsafe fn space() -> Result<&'static mut LockedCacheSpace, BlockCacheError> {
 unsafe fn space() -> Result<&'static mut LockedCacheSpace, BlockCacheError> {
     unsafe {
     unsafe {
         match &mut CSPACE {
         match &mut CSPACE {

+ 12 - 6
kernel/src/driver/clocksource/acpi_pm.rs

@@ -88,8 +88,10 @@ impl Acpipm {
             max_idle_ns: Default::default(),
             max_idle_ns: Default::default(),
             flags: ClocksourceFlags::CLOCK_SOURCE_IS_CONTINUOUS,
             flags: ClocksourceFlags::CLOCK_SOURCE_IS_CONTINUOUS,
             watchdog_last: CycleNum::new(0),
             watchdog_last: CycleNum::new(0),
+            cs_last: CycleNum::new(0),
             uncertainty_margin: 0,
             uncertainty_margin: 0,
             maxadj: 0,
             maxadj: 0,
+            cycle_last: CycleNum::new(0),
         };
         };
         let acpi_pm = Arc::new(Acpipm(SpinLock::new(InnerAcpipm {
         let acpi_pm = Arc::new(Acpipm(SpinLock::new(InnerAcpipm {
             data,
             data,
@@ -117,14 +119,18 @@ impl Clocksource for Acpipm {
 
 
     fn update_clocksource_data(&self, data: ClocksourceData) -> Result<(), SystemError> {
     fn update_clocksource_data(&self, data: ClocksourceData) -> Result<(), SystemError> {
         let d = &mut self.0.lock_irqsave().data;
         let d = &mut self.0.lock_irqsave().data;
-        d.set_flags(data.flags);
-        d.set_mask(data.mask);
-        d.set_max_idle_ns(data.max_idle_ns);
-        d.set_mult(data.mult);
         d.set_name(data.name);
         d.set_name(data.name);
         d.set_rating(data.rating);
         d.set_rating(data.rating);
+        d.set_mask(data.mask);
+        d.set_mult(data.mult);
         d.set_shift(data.shift);
         d.set_shift(data.shift);
+        d.set_max_idle_ns(data.max_idle_ns);
+        d.set_flags(data.flags);
         d.watchdog_last = data.watchdog_last;
         d.watchdog_last = data.watchdog_last;
+        d.cs_last = data.cs_last;
+        d.set_uncertainty_margin(data.uncertainty_margin);
+        d.set_maxadj(data.maxadj);
+        d.cycle_last = data.cycle_last;
         return Ok(());
         return Ok(());
     }
     }
 }
 }
@@ -281,7 +287,7 @@ pub fn init_acpi_pm_clocksource() -> Result<(), SystemError> {
     }
     }
 
 
     // 检查TSC时钟源的监视器是否被禁用,如果被禁用则将时钟源的标志设置为CLOCK_SOURCE_MUST_VERIFY
     // 检查TSC时钟源的监视器是否被禁用,如果被禁用则将时钟源的标志设置为CLOCK_SOURCE_MUST_VERIFY
-    // 没有实现clocksource_selecet_watchdog函数,所以这里设置为false
+    // 是因为jiffies精度小于acpi pm,所以不需要被jiffies监视
     let tsc_clocksource_watchdog_disabled = false;
     let tsc_clocksource_watchdog_disabled = false;
     if tsc_clocksource_watchdog_disabled {
     if tsc_clocksource_watchdog_disabled {
         clocksource_acpi_pm().0.lock_irqsave().data.flags |=
         clocksource_acpi_pm().0.lock_irqsave().data.flags |=
@@ -290,7 +296,7 @@ pub fn init_acpi_pm_clocksource() -> Result<(), SystemError> {
 
 
     // 注册ACPI PM Timer
     // 注册ACPI PM Timer
     let acpi_pmtmr = clocksource_acpi_pm() as Arc<dyn Clocksource>;
     let acpi_pmtmr = clocksource_acpi_pm() as Arc<dyn Clocksource>;
-    match acpi_pmtmr.register(100, PMTMR_TICKS_PER_SEC as u32) {
+    match acpi_pmtmr.register(1, PMTMR_TICKS_PER_SEC as u32) {
         Ok(_) => {
         Ok(_) => {
             info!("ACPI PM Timer registered as clocksource sccessfully");
             info!("ACPI PM Timer registered as clocksource sccessfully");
             return Ok(());
             return Ok(());

+ 3 - 37
kernel/src/driver/clocksource/timer_riscv.rs

@@ -20,12 +20,9 @@ use crate::{
     },
     },
     libs::spinlock::SpinLock,
     libs::spinlock::SpinLock,
     mm::percpu::PerCpu,
     mm::percpu::PerCpu,
-    process::ProcessManager,
     smp::core::smp_get_processor_id,
     smp::core::smp_get_processor_id,
     time::{
     time::{
-        clocksource::HZ,
-        jiffies::NSEC_PER_JIFFY,
-        timer::{try_raise_timer_softirq, update_timer_jiffies},
+        clocksource::HZ, tick_common::tick_handle_periodic, timer::try_raise_timer_softirq,
         TimeArch,
         TimeArch,
     },
     },
 };
 };
@@ -37,13 +34,6 @@ static SBI_TIMER_INIT_BMP: SpinLock<StaticBitmap<{ PerCpu::MAX_CPU_NUM as usize
 
 
 static mut INTERVAL_CNT: usize = 0;
 static mut INTERVAL_CNT: usize = 0;
 
 
-/// 已经过去的纳秒数
-///
-/// 0号核心用这个值来更新墙上时钟,他只能被0号核心访问
-static mut HART0_NSEC_PASSED: usize = 0;
-/// hart0上一次更新墙上时钟的时间
-static mut HART0_LAST_UPDATED: u64 = 0;
-
 impl RiscVSbiTimer {
 impl RiscVSbiTimer {
     pub const TIMER_IRQ: HardwareIrqNumber = HardwareIrqNumber::new(5);
     pub const TIMER_IRQ: HardwareIrqNumber = HardwareIrqNumber::new(5);
 
 
@@ -54,8 +44,8 @@ impl RiscVSbiTimer {
         //     smp_get_processor_id().data(),
         //     smp_get_processor_id().data(),
         //     CurrentTimeArch::get_cycles() as u64
         //     CurrentTimeArch::get_cycles() as u64
         // );
         // );
-        ProcessManager::update_process_times(trap_frame.is_from_user());
-        Self::update_nsec_passed_and_walltime();
+        tick_handle_periodic(trap_frame);
+        compiler_fence(Ordering::SeqCst);
         sbi_rt::set_timer(CurrentTimeArch::get_cycles() as u64 + unsafe { INTERVAL_CNT } as u64);
         sbi_rt::set_timer(CurrentTimeArch::get_cycles() as u64 + unsafe { INTERVAL_CNT } as u64);
         Ok(())
         Ok(())
     }
     }
@@ -68,30 +58,6 @@ impl RiscVSbiTimer {
     fn disable() {
     fn disable() {
         unsafe { riscv::register::sie::clear_stimer() };
         unsafe { riscv::register::sie::clear_stimer() };
     }
     }
-
-    fn update_nsec_passed_and_walltime() {
-        if smp_get_processor_id().data() != 0 {
-            return;
-        }
-
-        let cycles = CurrentTimeArch::get_cycles() as u64;
-        let nsec_passed =
-            CurrentTimeArch::cycles2ns((cycles - unsafe { HART0_LAST_UPDATED }) as usize);
-        unsafe {
-            HART0_LAST_UPDATED = cycles;
-            HART0_NSEC_PASSED += nsec_passed;
-        }
-
-        let jiffies = unsafe { HART0_NSEC_PASSED } / NSEC_PER_JIFFY as usize;
-        unsafe { HART0_NSEC_PASSED %= NSEC_PER_JIFFY as usize };
-
-        update_timer_jiffies(
-            jiffies as u64,
-            (jiffies * NSEC_PER_JIFFY as usize / 1000) as i64,
-        );
-        try_raise_timer_softirq();
-        compiler_fence(Ordering::SeqCst);
-    }
 }
 }
 
 
 /// riscv 初始化本地调度时钟源
 /// riscv 初始化本地调度时钟源

+ 35 - 15
kernel/src/driver/disk/ahci/ahcidisk.rs

@@ -1,4 +1,5 @@
-use super::{_port, hba::HbaCmdTable, virt_2_phys};
+use super::{_port, hba::HbaCmdTable};
+use crate::arch::MMArch;
 use crate::driver::base::block::block_device::{BlockDevice, BlockId};
 use crate::driver::base::block::block_device::{BlockDevice, BlockId};
 use crate::driver::base::block::disk_info::Partition;
 use crate::driver::base::block::disk_info::Partition;
 use crate::driver::base::class::Class;
 use crate::driver::base::class::Class;
@@ -19,7 +20,7 @@ use crate::driver::disk::ahci::hba::{
 };
 };
 use crate::libs::rwlock::{RwLockReadGuard, RwLockWriteGuard};
 use crate::libs::rwlock::{RwLockReadGuard, RwLockWriteGuard};
 use crate::libs::spinlock::SpinLock;
 use crate::libs::spinlock::SpinLock;
-use crate::mm::{phys_2_virt, verify_area, VirtAddr};
+use crate::mm::{verify_area, MemoryManagementArch, PhysAddr, VirtAddr};
 use log::error;
 use log::error;
 use system_error::SystemError;
 use system_error::SystemError;
 
 
@@ -86,9 +87,11 @@ impl AhciDisk {
 
 
         #[allow(unused_unsafe)]
         #[allow(unused_unsafe)]
         let cmdheader: &mut HbaCmdHeader = unsafe {
         let cmdheader: &mut HbaCmdHeader = unsafe {
-            (phys_2_virt(
+            (MMArch::phys_2_virt(PhysAddr::new(
                 volatile_read!(port.clb) as usize + slot as usize * size_of::<HbaCmdHeader>(),
                 volatile_read!(port.clb) as usize + slot as usize * size_of::<HbaCmdHeader>(),
-            ) as *mut HbaCmdHeader)
+            ))
+            .unwrap()
+            .data() as *mut HbaCmdHeader)
                 .as_mut()
                 .as_mut()
                 .unwrap()
                 .unwrap()
         };
         };
@@ -118,7 +121,9 @@ impl AhciDisk {
 
 
         #[allow(unused_unsafe)]
         #[allow(unused_unsafe)]
         let cmdtbl = unsafe {
         let cmdtbl = unsafe {
-            (phys_2_virt(volatile_read!(cmdheader.ctba) as usize) as *mut HbaCmdTable)
+            (MMArch::phys_2_virt(PhysAddr::new(volatile_read!(cmdheader.ctba) as usize))
+                .unwrap()
+                .data() as *mut HbaCmdTable)
                 .as_mut()
                 .as_mut()
                 .unwrap() // 必须使用 as_mut ,得到的才是原来的变量
                 .unwrap() // 必须使用 as_mut ,得到的才是原来的变量
         };
         };
@@ -132,7 +137,10 @@ impl AhciDisk {
 
 
         // 8K bytes (16 sectors) per PRDT
         // 8K bytes (16 sectors) per PRDT
         for i in 0..((volatile_read!(cmdheader.prdtl) - 1) as usize) {
         for i in 0..((volatile_read!(cmdheader.prdtl) - 1) as usize) {
-            volatile_write!(cmdtbl.prdt_entry[i].dba, virt_2_phys(buf_ptr) as u64);
+            volatile_write!(
+                cmdtbl.prdt_entry[i].dba,
+                MMArch::virt_2_phys(VirtAddr::new(buf_ptr)).unwrap().data() as u64
+            );
             cmdtbl.prdt_entry[i].dbc = 8 * 1024 - 1;
             cmdtbl.prdt_entry[i].dbc = 8 * 1024 - 1;
             volatile_set_bit!(cmdtbl.prdt_entry[i].dbc, 1 << 31, true); // 允许中断 prdt_entry.i
             volatile_set_bit!(cmdtbl.prdt_entry[i].dbc, 1 << 31, true); // 允许中断 prdt_entry.i
             buf_ptr += 8 * 1024;
             buf_ptr += 8 * 1024;
@@ -141,7 +149,10 @@ impl AhciDisk {
 
 
         // Last entry
         // Last entry
         let las = (volatile_read!(cmdheader.prdtl) - 1) as usize;
         let las = (volatile_read!(cmdheader.prdtl) - 1) as usize;
-        volatile_write!(cmdtbl.prdt_entry[las].dba, virt_2_phys(buf_ptr) as u64);
+        volatile_write!(
+            cmdtbl.prdt_entry[las].dba,
+            MMArch::virt_2_phys(VirtAddr::new(buf_ptr)).unwrap().data() as u64
+        );
         cmdtbl.prdt_entry[las].dbc = ((tmp_count << 9) - 1) as u32; // 数据长度
         cmdtbl.prdt_entry[las].dbc = ((tmp_count << 9) - 1) as u32; // 数据长度
 
 
         volatile_set_bit!(cmdtbl.prdt_entry[las].dbc, 1 << 31, true); // 允许中断
         volatile_set_bit!(cmdtbl.prdt_entry[las].dbc, 1 << 31, true); // 允许中断
@@ -195,9 +206,8 @@ impl AhciDisk {
                 return Err(SystemError::EIO);
                 return Err(SystemError::EIO);
             }
             }
         }
         }
-
-        if kbuf.is_some() {
-            buf.copy_from_slice(kbuf.as_ref().unwrap());
+        if let Some(kbuf) = &kbuf {
+            buf.copy_from_slice(kbuf);
         }
         }
 
 
         compiler_fence(Ordering::SeqCst);
         compiler_fence(Ordering::SeqCst);
@@ -234,9 +244,11 @@ impl AhciDisk {
         compiler_fence(Ordering::SeqCst);
         compiler_fence(Ordering::SeqCst);
         #[allow(unused_unsafe)]
         #[allow(unused_unsafe)]
         let cmdheader: &mut HbaCmdHeader = unsafe {
         let cmdheader: &mut HbaCmdHeader = unsafe {
-            (phys_2_virt(
+            (MMArch::phys_2_virt(PhysAddr::new(
                 volatile_read!(port.clb) as usize + slot as usize * size_of::<HbaCmdHeader>(),
                 volatile_read!(port.clb) as usize + slot as usize * size_of::<HbaCmdHeader>(),
-            ) as *mut HbaCmdHeader)
+            ))
+            .unwrap()
+            .data() as *mut HbaCmdHeader)
                 .as_mut()
                 .as_mut()
                 .unwrap()
                 .unwrap()
         };
         };
@@ -273,7 +285,9 @@ impl AhciDisk {
 
 
         #[allow(unused_unsafe)]
         #[allow(unused_unsafe)]
         let cmdtbl = unsafe {
         let cmdtbl = unsafe {
-            (phys_2_virt(volatile_read!(cmdheader.ctba) as usize) as *mut HbaCmdTable)
+            (MMArch::phys_2_virt(PhysAddr::new(volatile_read!(cmdheader.ctba) as usize))
+                .unwrap()
+                .data() as *mut HbaCmdTable)
                 .as_mut()
                 .as_mut()
                 .unwrap()
                 .unwrap()
         };
         };
@@ -287,7 +301,10 @@ impl AhciDisk {
 
 
         // 8K bytes (16 sectors) per PRDT
         // 8K bytes (16 sectors) per PRDT
         for i in 0..((volatile_read!(cmdheader.prdtl) - 1) as usize) {
         for i in 0..((volatile_read!(cmdheader.prdtl) - 1) as usize) {
-            volatile_write!(cmdtbl.prdt_entry[i].dba, virt_2_phys(buf_ptr) as u64);
+            volatile_write!(
+                cmdtbl.prdt_entry[i].dba,
+                MMArch::virt_2_phys(VirtAddr::new(buf_ptr)).unwrap().data() as u64
+            );
             volatile_write_bit!(cmdtbl.prdt_entry[i].dbc, (1 << 22) - 1, 8 * 1024 - 1); // 数据长度
             volatile_write_bit!(cmdtbl.prdt_entry[i].dbc, (1 << 22) - 1, 8 * 1024 - 1); // 数据长度
             volatile_set_bit!(cmdtbl.prdt_entry[i].dbc, 1 << 31, true); // 允许中断
             volatile_set_bit!(cmdtbl.prdt_entry[i].dbc, 1 << 31, true); // 允许中断
             buf_ptr += 8 * 1024;
             buf_ptr += 8 * 1024;
@@ -296,7 +313,10 @@ impl AhciDisk {
 
 
         // Last entry
         // Last entry
         let las = (volatile_read!(cmdheader.prdtl) - 1) as usize;
         let las = (volatile_read!(cmdheader.prdtl) - 1) as usize;
-        volatile_write!(cmdtbl.prdt_entry[las].dba, virt_2_phys(buf_ptr) as u64);
+        volatile_write!(
+            cmdtbl.prdt_entry[las].dba,
+            MMArch::virt_2_phys(VirtAddr::new(buf_ptr)).unwrap().data() as u64
+        );
         volatile_set_bit!(cmdtbl.prdt_entry[las].dbc, 1 << 31, true); // 允许中断
         volatile_set_bit!(cmdtbl.prdt_entry[las].dbc, 1 << 31, true); // 允许中断
         volatile_write_bit!(
         volatile_write_bit!(
             cmdtbl.prdt_entry[las].dbc,
             cmdtbl.prdt_entry[las].dbc,

+ 32 - 5
kernel/src/driver/disk/ahci/hba.rs

@@ -2,7 +2,8 @@ use core::{intrinsics::size_of, ptr};
 
 
 use core::sync::atomic::compiler_fence;
 use core::sync::atomic::compiler_fence;
 
 
-use crate::mm::phys_2_virt;
+use crate::arch::MMArch;
+use crate::mm::{MemoryManagementArch, PhysAddr};
 
 
 /// 文件说明: 实现了 AHCI 中的控制器 HBA 的相关行为
 /// 文件说明: 实现了 AHCI 中的控制器 HBA 的相关行为
 
 
@@ -43,6 +44,7 @@ pub enum HbaPortType {
 
 
 /// 声明了 HBA 的所有属性
 /// 声明了 HBA 的所有属性
 #[repr(packed)]
 #[repr(packed)]
+#[allow(dead_code)]
 pub struct HbaPort {
 pub struct HbaPort {
     pub clb: u64,         // 0x00, command list base address, 1K-byte aligned
     pub clb: u64,         // 0x00, command list base address, 1K-byte aligned
     pub fb: u64,          // 0x08, FIS base address, 256-byte aligned
     pub fb: u64,          // 0x08, FIS base address, 256-byte aligned
@@ -65,6 +67,7 @@ pub struct HbaPort {
 
 
 /// 全称 HBA Memory Register,是HBA的寄存器在内存中的映射
 /// 全称 HBA Memory Register,是HBA的寄存器在内存中的映射
 #[repr(packed)]
 #[repr(packed)]
+#[allow(dead_code)]
 pub struct HbaMem {
 pub struct HbaMem {
     pub cap: u32,             // 0x00, Host capability
     pub cap: u32,             // 0x00, Host capability
     pub ghc: u32,             // 0x04, Global host control
     pub ghc: u32,             // 0x04, Global host control
@@ -94,6 +97,7 @@ pub struct HbaPrdtEntry {
 /// HAB Command Table
 /// HAB Command Table
 /// 每个 Port 一个 Table,主机和设备的交互都靠这个数据结构
 /// 每个 Port 一个 Table,主机和设备的交互都靠这个数据结构
 #[repr(packed)]
 #[repr(packed)]
+#[allow(dead_code)]
 pub struct HbaCmdTable {
 pub struct HbaCmdTable {
     // 0x00
     // 0x00
     pub cfis: [u8; 64], // Command FIS
     pub cfis: [u8; 64], // Command FIS
@@ -195,7 +199,13 @@ impl HbaPort {
 
 
         unsafe {
         unsafe {
             compiler_fence(core::sync::atomic::Ordering::SeqCst);
             compiler_fence(core::sync::atomic::Ordering::SeqCst);
-            ptr::write_bytes(phys_2_virt(clb as usize) as *mut u64, 0, 1024);
+            ptr::write_bytes(
+                MMArch::phys_2_virt(PhysAddr::new(clb as usize))
+                    .unwrap()
+                    .data() as *mut u64,
+                0,
+                1024,
+            );
         }
         }
 
 
         // 赋值 fis base address
         // 赋值 fis base address
@@ -204,20 +214,36 @@ impl HbaPort {
         volatile_write!(self.fb, fb);
         volatile_write!(self.fb, fb);
         unsafe {
         unsafe {
             compiler_fence(core::sync::atomic::Ordering::SeqCst);
             compiler_fence(core::sync::atomic::Ordering::SeqCst);
-            ptr::write_bytes(phys_2_virt(fb as usize) as *mut u64, 0, 256);
+            ptr::write_bytes(
+                MMArch::phys_2_virt(PhysAddr::new(fb as usize))
+                    .unwrap()
+                    .data() as *mut u64,
+                0,
+                256,
+            );
         }
         }
 
 
         // 赋值 command table base address
         // 赋值 command table base address
         // Command table offset: 40K + 8K*portno
         // Command table offset: 40K + 8K*portno
         // Command table size = 256*32 = 8K per port
         // Command table size = 256*32 = 8K per port
-        let mut cmdheaders = phys_2_virt(clb as usize) as *mut u64 as *mut HbaCmdHeader;
+        let mut cmdheaders = unsafe {
+            MMArch::phys_2_virt(PhysAddr::new(clb as usize))
+                .unwrap()
+                .data()
+        } as *mut u64 as *mut HbaCmdHeader;
         for ctbas_value in ctbas.iter().take(32) {
         for ctbas_value in ctbas.iter().take(32) {
             volatile_write!((*cmdheaders).prdtl, 0); // 一开始没有询问,prdtl = 0(预留了8个PRDT项的空间)
             volatile_write!((*cmdheaders).prdtl, 0); // 一开始没有询问,prdtl = 0(预留了8个PRDT项的空间)
             volatile_write!((*cmdheaders).ctba, *ctbas_value);
             volatile_write!((*cmdheaders).ctba, *ctbas_value);
             // 这里限制了 prdtl <= 8, 所以一共用了256bytes,如果需要修改,可以修改这里
             // 这里限制了 prdtl <= 8, 所以一共用了256bytes,如果需要修改,可以修改这里
             compiler_fence(core::sync::atomic::Ordering::SeqCst);
             compiler_fence(core::sync::atomic::Ordering::SeqCst);
             unsafe {
             unsafe {
-                ptr::write_bytes(phys_2_virt(*ctbas_value as usize) as *mut u64, 0, 256);
+                ptr::write_bytes(
+                    MMArch::phys_2_virt(PhysAddr::new(*ctbas_value as usize))
+                        .unwrap()
+                        .data() as *mut u64,
+                    0,
+                    256,
+                );
             }
             }
             cmdheaders = (cmdheaders as usize + size_of::<HbaCmdHeader>()) as *mut HbaCmdHeader;
             cmdheaders = (cmdheaders as usize + size_of::<HbaCmdHeader>()) as *mut HbaCmdHeader;
         }
         }
@@ -262,6 +288,7 @@ pub enum FisType {
 }
 }
 
 
 #[repr(packed)]
 #[repr(packed)]
+#[allow(dead_code)]
 pub struct FisRegH2D {
 pub struct FisRegH2D {
     // DWORD 0
     // DWORD 0
     pub fis_type: u8, // FIS_TYPE_REG_H2D
     pub fis_type: u8, // FIS_TYPE_REG_H2D

+ 19 - 6
kernel/src/driver/disk/ahci/mod.rs

@@ -3,6 +3,7 @@ pub mod ahci_inode;
 pub mod ahcidisk;
 pub mod ahcidisk;
 pub mod hba;
 pub mod hba;
 
 
+use crate::arch::MMArch;
 use crate::driver::base::block::disk_info::BLK_GF_AHCI;
 use crate::driver::base::block::disk_info::BLK_GF_AHCI;
 use crate::driver::block::cache::cached_block_device::BlockCache;
 use crate::driver::block::cache::cached_block_device::BlockCache;
 // 依赖的rust工具包
 // 依赖的rust工具包
@@ -18,7 +19,7 @@ use crate::driver::disk::ahci::{
 };
 };
 use crate::libs::rwlock::RwLockWriteGuard;
 use crate::libs::rwlock::RwLockWriteGuard;
 use crate::libs::spinlock::{SpinLock, SpinLockGuard};
 use crate::libs::spinlock::{SpinLock, SpinLockGuard};
-use crate::mm::virt_2_phys;
+use crate::mm::{MemoryManagementArch, VirtAddr};
 use ahci_inode::LockedAhciInode;
 use ahci_inode::LockedAhciInode;
 use alloc::{boxed::Box, collections::LinkedList, format, string::String, sync::Arc, vec::Vec};
 use alloc::{boxed::Box, collections::LinkedList, format, string::String, sync::Arc, vec::Vec};
 use core::sync::atomic::compiler_fence;
 use core::sync::atomic::compiler_fence;
@@ -97,13 +98,25 @@ pub fn ahci_init() -> Result<(), SystemError> {
                         debug!("<ahci_rust_init> Find a {:?} type Disk.", tp);
                         debug!("<ahci_rust_init> Find a {:?} type Disk.", tp);
 
 
                         // 计算地址
                         // 计算地址
-                        let fb = virt_2_phys(ahci_port_base_vaddr + (32 << 10) + (j << 8));
-                        let clb = virt_2_phys(ahci_port_base_vaddr + (j << 10));
+                        let fb = unsafe {
+                            MMArch::virt_2_phys(VirtAddr::new(
+                                ahci_port_base_vaddr + (32 << 10) + (j << 8),
+                            ))
+                        }
+                        .unwrap()
+                        .data();
+                        let clb = unsafe {
+                            MMArch::virt_2_phys(VirtAddr::new(ahci_port_base_vaddr + (j << 10)))
+                                .unwrap()
+                                .data()
+                        };
                         let ctbas = (0..32)
                         let ctbas = (0..32)
-                            .map(|x| {
-                                virt_2_phys(
+                            .map(|x| unsafe {
+                                MMArch::virt_2_phys(VirtAddr::new(
                                     ahci_port_base_vaddr + (40 << 10) + (j << 13) + (x << 8),
                                     ahci_port_base_vaddr + (40 << 10) + (j << 13) + (x << 8),
-                                ) as u64
+                                ))
+                                .unwrap()
+                                .data() as u64
                             })
                             })
                             .collect::<Vec<_>>();
                             .collect::<Vec<_>>();
 
 

+ 1 - 2
kernel/src/driver/firmware/efi/init.rs

@@ -168,9 +168,8 @@ fn uefi_init(system_table: PhysAddr) -> Result<(), SystemError> {
     let st_ptr = st_vaddr.data() as *const uefi_raw::table::system::SystemTable;
     let st_ptr = st_vaddr.data() as *const uefi_raw::table::system::SystemTable;
     efi_manager()
     efi_manager()
         .check_system_table_header(unsafe { &st_ptr.as_ref().unwrap().header }, 2)
         .check_system_table_header(unsafe { &st_ptr.as_ref().unwrap().header }, 2)
-        .map_err(|e| {
+        .inspect_err(|_| {
             err_unmap_systable(st_vaddr);
             err_unmap_systable(st_vaddr);
-            e
         })?;
         })?;
 
 
     let st_ref = unsafe { st_ptr.as_ref().unwrap() };
     let st_ref = unsafe { st_ptr.as_ref().unwrap() };

+ 1 - 0
kernel/src/driver/input/ps2_dev/ps2_device.rs

@@ -1,4 +1,5 @@
 use crate::driver::{base::device::Device, input::serio::serio_device::SerioDevice};
 use crate::driver::{base::device::Device, input::serio::serio_device::SerioDevice};
 
 
 // todo: https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/libps2.h#33
 // todo: https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/libps2.h#33
+#[allow(unused)]
 pub trait Ps2Device: Device + SerioDevice {}
 pub trait Ps2Device: Device + SerioDevice {}

+ 1 - 0
kernel/src/driver/input/ps2_mouse/ps_mouse_device.rs

@@ -387,6 +387,7 @@ impl Ps2MouseDevice {
         Ok(())
         Ok(())
     }
     }
 
 
+    #[allow(dead_code)]
     fn wait_for_read(&self) -> Result<(), SystemError> {
     fn wait_for_read(&self) -> Result<(), SystemError> {
         let timeout = 100_000;
         let timeout = 100_000;
         for _ in 0..timeout {
         for _ in 0..timeout {

+ 6 - 4
kernel/src/driver/input/serio/i8042/mod.rs

@@ -47,14 +47,16 @@ pub fn i8042_init() -> Result<(), SystemError> {
     Ok(())
     Ok(())
 }
 }
 
 
-// TODO: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/input/serio/i8042.c#441
+/// TODO: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/input/serio/i8042.c#441
+#[allow(dead_code)]
 pub fn i8042_start(_serio: &Arc<dyn SerioDevice>) -> Result<(), SystemError> {
 pub fn i8042_start(_serio: &Arc<dyn SerioDevice>) -> Result<(), SystemError> {
-    todo!()
+    todo!("i8042_start")
 }
 }
 
 
-// TODO: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/input/serio/i8042.c#471
+/// TODO: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/input/serio/i8042.c#471
+#[allow(dead_code)]
 pub fn i8042_stop(_serio: &Arc<dyn SerioDevice>) -> Result<(), SystemError> {
 pub fn i8042_stop(_serio: &Arc<dyn SerioDevice>) -> Result<(), SystemError> {
-    todo!()
+    todo!("i8042_stop")
 }
 }
 
 
 /// # 函数的功能
 /// # 函数的功能

+ 1 - 0
kernel/src/driver/input/serio/serio_device.rs

@@ -8,6 +8,7 @@ use super::serio_bus;
 /// 串行设备,实现该trait的设备实例挂载在serio总线上,同时应该实现Device trait
 /// 串行设备,实现该trait的设备实例挂载在serio总线上,同时应该实现Device trait
 ///
 ///
 /// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/serio.h#20
 /// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/serio.h#20
+#[allow(dead_code)]
 pub trait SerioDevice: Device {
 pub trait SerioDevice: Device {
     /// # 函数功能
     /// # 函数功能
     ///
     ///

+ 1 - 0
kernel/src/driver/input/serio/serio_driver.rs

@@ -11,6 +11,7 @@ use super::{serio_bus, serio_device::SerioDevice};
 /// 实现该trait的设备驱动实例应挂载在serio总线上,同时应该实现Driver trait
 /// 实现该trait的设备驱动实例应挂载在serio总线上,同时应该实现Driver trait
 ///
 ///
 /// 参考:  https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/serio.h#67
 /// 参考:  https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/serio.h#67
+#[allow(dead_code)]
 pub trait SerioDriver: Driver {
 pub trait SerioDriver: Driver {
     // 写入时唤醒设备
     // 写入时唤醒设备
     fn write_wakeup(&self, device: &Arc<dyn SerioDevice>) -> Result<(), SystemError>;
     fn write_wakeup(&self, device: &Arc<dyn SerioDevice>) -> Result<(), SystemError>;

+ 2 - 1
kernel/src/driver/net/e1000e/e1000e.rs

@@ -780,7 +780,8 @@ const E1000E_TXD_CMD_EOP: u8 = 1 << 0;
 const E1000E_TXD_CMD_IFCS: u8 = 1 << 1;
 const E1000E_TXD_CMD_IFCS: u8 = 1 << 1;
 const E1000E_TXD_CMD_RS: u8 = 1 << 3;
 const E1000E_TXD_CMD_RS: u8 = 1 << 3;
 
 
-// E1000E驱动初始化过程中可能的错误
+/// E1000E驱动初始化过程中可能的错误
+#[allow(dead_code)]
 pub enum E1000EPciError {
 pub enum E1000EPciError {
     // 获取到错误类型的BAR(IO BAR)
     // 获取到错误类型的BAR(IO BAR)
     // An IO BAR was provided rather than a memory BAR.
     // An IO BAR was provided rather than a memory BAR.

+ 483 - 0
kernel/src/driver/net/loopback.rs

@@ -0,0 +1,483 @@
+use crate::arch::rand::rand;
+use crate::driver::base::class::Class;
+use crate::driver::base::device::bus::Bus;
+use crate::driver::base::device::driver::Driver;
+use crate::driver::base::device::{Device, DeviceType, IdTable};
+use crate::driver::base::kobject::{KObjType, KObject, KObjectState};
+use crate::init::initcall::INITCALL_DEVICE;
+use crate::libs::spinlock::SpinLock;
+use crate::net::{generate_iface_id, NET_DEVICES};
+use crate::time::Instant;
+use alloc::collections::VecDeque;
+use alloc::fmt::Debug;
+use alloc::string::{String, ToString};
+use alloc::sync::{Arc, Weak};
+use alloc::vec::Vec;
+use core::cell::UnsafeCell;
+use core::ops::{Deref, DerefMut};
+use smoltcp::wire::HardwareAddress;
+use smoltcp::{
+    phy::{self},
+    wire::{IpAddress, IpCidr},
+};
+use system_error::SystemError;
+use unified_init::macros::unified_init;
+
+use super::NetDevice;
+
+const DEVICE_NAME: &str = "loopback";
+
+/// ## 环回接收令牌
+/// 用于储存lo网卡接收到的数据
+pub struct LoopbackRxToken {
+    buffer: Vec<u8>,
+}
+
+impl phy::RxToken for LoopbackRxToken {
+    /// ## 实现Rxtoken的consume函数
+    /// 接受一个函数 `f`,并在 `self.buffer` 上调用它。
+    ///
+    /// ## 参数
+    /// - mut self :一个可变的 `LoopbackRxToken` 实例。
+    /// - f :接受一个可变的 u8 切片,并返回类型 `R` 的结果。
+    ///
+    /// ## 返回值
+    /// 返回函数 `f` 在 `self.buffer` 上的调用结果。
+    fn consume<R, F>(mut self, f: F) -> R
+    where
+        F: FnOnce(&mut [u8]) -> R,
+    {
+        f(self.buffer.as_mut_slice())
+    }
+}
+
+/// ## 环回发送令牌
+/// 返回驱动用于操作lo设备
+pub struct LoopbackTxToken {
+    driver: LoopbackDriver,
+}
+
+impl phy::TxToken for LoopbackTxToken {
+    /// ## 实现TxToken的consume函数
+    /// 向lo的队列推入待发送的数据报,实现环回
+    ///
+    /// ## 参数
+    /// - self
+    /// - len:数据包的长度
+    /// - f:接受一个可变的 u8 切片,并返回类型 `R` 的结果。
+    ///
+    /// ## 返回值
+    /// 返回f对数据包操纵的结果
+    fn consume<R, F>(self, len: usize, f: F) -> R
+    where
+        F: FnOnce(&mut [u8]) -> R,
+    {
+        let mut buffer = vec![0; len];
+        let result = f(buffer.as_mut_slice());
+        let mut device = self.driver.inner.lock();
+        device.loopback_transmit(buffer);
+        result
+    }
+}
+
+/// ## Loopback设备
+/// 成员是一个队列,用来存放接受到的数据包。
+/// 当使用lo发送数据包时,不会把数据包传到link层,而是直接发送到该队列,实现环回。
+pub struct Loopback {
+    //回环设备的缓冲区,接受的数据包会存放在这里,发送的数据包也会发送到这里,实现环回
+    queue: VecDeque<Vec<u8>>,
+}
+
+impl Loopback {
+    /// ## Loopback创建函数
+    /// 创建lo设备
+    pub fn new() -> Self {
+        let queue = VecDeque::new();
+        Loopback { queue }
+    }
+    /// ## Loopback处理接受到的数据包函数
+    /// Loopback接受到数据后会调用这个函数来弹出接收的数据,返回给协议栈
+    ///
+    /// ## 参数
+    /// - &mut self :自身可变引用
+    ///
+    /// ## 返回值
+    /// - queue的头部数据包
+    pub fn loopback_receive(&mut self) -> Vec<u8> {
+        let buffer = self.queue.pop_front();
+        match buffer {
+            Some(buffer) => {
+                //debug!("lo receive:{:?}", buffer);
+                return buffer;
+            }
+            None => {
+                return Vec::new();
+            }
+        }
+    }
+    /// ## Loopback发送数据包的函数
+    /// Loopback发送数据包给自己的接收队列,实现环回
+    ///
+    /// ## 参数
+    /// - &mut self:自身可变引用
+    /// - buffer:需要发送的数据包
+    pub fn loopback_transmit(&mut self, buffer: Vec<u8>) {
+        //debug!("lo transmit!");
+        self.queue.push_back(buffer)
+    }
+}
+
+/// ## driver的包裹器
+/// 为实现获得不可变引用的Interface的内部可变性,故为Driver提供UnsafeCell包裹器
+///
+/// 参考virtio_net.rs
+struct LoopbackDriverWapper(UnsafeCell<LoopbackDriver>);
+unsafe impl Send for LoopbackDriverWapper {}
+unsafe impl Sync for LoopbackDriverWapper {}
+
+/// ## deref 方法返回一个指向 `LoopbackDriver` 的引用。
+impl Deref for LoopbackDriverWapper {
+    type Target = LoopbackDriver;
+    fn deref(&self) -> &Self::Target {
+        unsafe { &*self.0.get() }
+    }
+}
+/// ## `deref_mut` 方法返回一个指向可变 `LoopbackDriver` 的引用。
+impl DerefMut for LoopbackDriverWapper {
+    fn deref_mut(&mut self) -> &mut Self::Target {
+        unsafe { &mut *self.0.get() }
+    }
+}
+
+impl LoopbackDriverWapper {
+    /// ## force_get_mut返回一个指向可变 `LoopbackDriver` 的引用。
+    #[allow(clippy::mut_from_ref)]
+    #[allow(clippy::mut_from_ref)]
+    fn force_get_mut(&self) -> &mut LoopbackDriver {
+        unsafe { &mut *self.0.get() }
+    }
+}
+
+/// ## Loopback驱动
+/// 负责操作Loopback设备实现基本的网卡功能
+pub struct LoopbackDriver {
+    pub inner: Arc<SpinLock<Loopback>>,
+}
+
+impl LoopbackDriver {
+    /// ## LoopbackDriver创建函数
+    pub fn new() -> Self {
+        let inner = Arc::new(SpinLock::new(Loopback::new()));
+        LoopbackDriver { inner }
+    }
+}
+
+impl Clone for LoopbackDriver {
+    fn clone(&self) -> Self {
+        LoopbackDriver {
+            inner: self.inner.clone(),
+        }
+    }
+}
+
+impl phy::Device for LoopbackDriver {
+    type RxToken<'a> = LoopbackRxToken where Self: 'a;
+    type TxToken<'a> = LoopbackTxToken where Self: 'a;
+    /// ## 返回设备的物理层特性。
+    /// lo设备的最大传输单元为65535,最大突发大小为1,传输介质默认为Ethernet
+    fn capabilities(&self) -> phy::DeviceCapabilities {
+        let mut result = phy::DeviceCapabilities::default();
+        result.max_transmission_unit = 65535;
+        result.max_burst_size = Some(1);
+        result.medium = smoltcp::phy::Medium::Ethernet;
+        return result;
+    }
+    /// ## Loopback驱动处理接受数据事件
+    /// 驱动调用Loopback的receive函数,处理buffer封装成(rx,tx)返回给上层
+    ///
+    /// ## 参数
+    /// - `&mut self` :自身可变引用
+    /// - `_timestamp`
+    ///
+    /// ## 返回值
+    /// - None: 如果接收队列为空,返回 `None`,以通知上层没有可以接收的包
+    /// - Option::Some((rx, tx)):如果接收队列不为空,返回 `Some`,其中包含一个接收令牌 `rx` 和一个发送令牌 `tx`
+    fn receive(
+        &mut self,
+        _timestamp: smoltcp::time::Instant,
+    ) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> {
+        let buffer = self.inner.lock().loopback_receive();
+        //receive队列为为空,返回NONE值以通知上层没有可以receive的包
+        if buffer.is_empty() {
+            return Option::None;
+        }
+        let rx = LoopbackRxToken { buffer };
+        let tx = LoopbackTxToken {
+            driver: self.clone(),
+        };
+        return Option::Some((rx, tx));
+    }
+    /// ## Loopback驱动处理发送数据包事件
+    /// Loopback驱动在需要发送数据时会调用这个函数来获取一个发送令牌。
+    ///
+    /// ## 参数
+    /// - `&mut self` :自身可变引用
+    /// - `_timestamp`
+    ///
+    /// ## 返回值
+    /// - 返回一个 `Some`,其中包含一个发送令牌,该令牌包含一个对自身的克隆引用
+    fn transmit(&mut self, _timestamp: smoltcp::time::Instant) -> Option<Self::TxToken<'_>> {
+        Some(LoopbackTxToken {
+            driver: self.clone(),
+        })
+    }
+}
+
+/// ## LoopbackInterface结构
+/// 封装驱动包裹器和iface,设置接口名称
+pub struct LoopbackInterface {
+    driver: LoopbackDriverWapper,
+    iface_id: usize,
+    iface: SpinLock<smoltcp::iface::Interface>,
+    name: String,
+}
+
+impl LoopbackInterface {
+    /// ## `new` 是一个公共函数,用于创建一个新的 `LoopbackInterface` 实例。
+    /// 生成一个新的接口 ID。创建一个新的接口配置,设置其硬件地址和随机种子,使用接口配置和驱动器创建一个新的 `smoltcp::iface::Interface` 实例。
+    /// 设置接口的 IP 地址为 127.0.0.1。
+    /// 创建一个新的 `LoopbackDriverWapper` 实例,包装驱动器。
+    /// 创建一个新的 `LoopbackInterface` 实例,包含驱动器、接口 ID、接口和名称,并将其封装在一个 `Arc` 中。
+    /// ## 参数
+    /// - `driver`:一个 `LoopbackDriver` 实例,用于驱动网络环回操作。
+    ///
+    /// ## 返回值
+    /// 返回一个 `Arc<Self>`,即一个指向新创建的 `LoopbackInterface` 实例的智能指针。
+    pub fn new(mut driver: LoopbackDriver) -> Arc<Self> {
+        let iface_id = generate_iface_id();
+        let mut iface_config = smoltcp::iface::Config::new(HardwareAddress::Ethernet(
+            smoltcp::wire::EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x01]),
+        ));
+        iface_config.random_seed = rand() as u64;
+
+        let mut iface =
+            smoltcp::iface::Interface::new(iface_config, &mut driver, Instant::now().into());
+        //设置网卡地址为127.0.0.1
+        iface.update_ip_addrs(|ip_addrs| {
+            ip_addrs
+                .push(IpCidr::new(IpAddress::v4(127, 0, 0, 1), 8))
+                .unwrap();
+        });
+        let driver = LoopbackDriverWapper(UnsafeCell::new(driver));
+        Arc::new(LoopbackInterface {
+            driver,
+            iface_id,
+            iface: SpinLock::new(iface),
+            name: "lo".to_string(),
+        })
+    }
+}
+
+impl Debug for LoopbackInterface {
+    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+        f.debug_struct("LoopbackInterface")
+            .field("iface_id", &self.iface_id)
+            .field("iface", &"smtoltcp::iface::Interface")
+            .field("name", &self.name)
+            .finish()
+    }
+}
+//TODO: 向sysfs注册lo设备
+impl KObject for LoopbackInterface {
+    fn as_any_ref(&self) -> &dyn core::any::Any {
+        self
+    }
+
+    fn set_inode(&self, _inode: Option<Arc<crate::filesystem::kernfs::KernFSInode>>) {
+        todo!()
+    }
+
+    fn inode(&self) -> Option<Arc<crate::filesystem::kernfs::KernFSInode>> {
+        todo!()
+    }
+
+    fn parent(&self) -> Option<alloc::sync::Weak<dyn KObject>> {
+        todo!()
+    }
+
+    fn set_parent(&self, _parent: Option<alloc::sync::Weak<dyn KObject>>) {
+        todo!()
+    }
+
+    fn kset(&self) -> Option<Arc<crate::driver::base::kset::KSet>> {
+        todo!()
+    }
+
+    fn set_kset(&self, _kset: Option<Arc<crate::driver::base::kset::KSet>>) {
+        todo!()
+    }
+
+    fn kobj_type(&self) -> Option<&'static dyn crate::driver::base::kobject::KObjType> {
+        todo!()
+    }
+
+    fn name(&self) -> String {
+        self.name.clone()
+    }
+
+    fn set_name(&self, _name: String) {
+        todo!()
+    }
+
+    fn kobj_state(
+        &self,
+    ) -> crate::libs::rwlock::RwLockReadGuard<crate::driver::base::kobject::KObjectState> {
+        todo!()
+    }
+
+    fn kobj_state_mut(
+        &self,
+    ) -> crate::libs::rwlock::RwLockWriteGuard<crate::driver::base::kobject::KObjectState> {
+        todo!()
+    }
+
+    fn set_kobj_state(&self, _state: KObjectState) {
+        todo!()
+    }
+
+    fn set_kobj_type(&self, _ktype: Option<&'static dyn KObjType>) {
+        todo!()
+    }
+}
+
+impl Device for LoopbackInterface {
+    fn dev_type(&self) -> DeviceType {
+        DeviceType::Net
+    }
+
+    fn id_table(&self) -> IdTable {
+        IdTable::new(DEVICE_NAME.to_string(), None)
+    }
+
+    fn set_bus(&self, _bus: Option<Weak<dyn Bus>>) {
+        todo!()
+    }
+
+    fn set_class(&self, _class: Option<Weak<dyn Class>>) {
+        todo!()
+    }
+
+    fn driver(&self) -> Option<Arc<dyn Driver>> {
+        todo!()
+    }
+
+    fn set_driver(&self, _driver: Option<Weak<dyn Driver>>) {
+        todo!()
+    }
+
+    fn is_dead(&self) -> bool {
+        todo!()
+    }
+
+    fn can_match(&self) -> bool {
+        todo!()
+    }
+
+    fn set_can_match(&self, _can_match: bool) {
+        todo!()
+    }
+
+    fn state_synced(&self) -> bool {
+        true
+    }
+}
+
+impl NetDevice for LoopbackInterface {
+    /// 由于lo网卡设备不是实际的物理设备,其mac地址需要手动设置为一个默认值,这里默认为0200000001
+    fn mac(&self) -> smoltcp::wire::EthernetAddress {
+        let mac = [0x02, 0x00, 0x00, 0x00, 0x00, 0x01];
+        smoltcp::wire::EthernetAddress(mac)
+    }
+
+    #[inline]
+    fn nic_id(&self) -> usize {
+        self.iface_id
+    }
+
+    #[inline]
+    fn name(&self) -> String {
+        self.name.clone()
+    }
+    /// ## `update_ip_addrs` 用于更新接口的 IP 地址。
+    ///
+    /// ## 参数
+    /// - `&self` :自身引用
+    /// - `ip_addrs` :一个包含 `smoltcp::wire::IpCidr` 的切片,表示要设置的 IP 地址和子网掩码
+    ///
+    /// ## 返回值
+    /// - 如果 `ip_addrs` 的长度不为 1,返回 `Err(SystemError::EINVAL)`,表示输入参数无效
+    /// - 如果更新成功,返回 `Ok(())`
+    fn update_ip_addrs(
+        &self,
+        ip_addrs: &[smoltcp::wire::IpCidr],
+    ) -> Result<(), system_error::SystemError> {
+        if ip_addrs.len() != 1 {
+            return Err(SystemError::EINVAL);
+        }
+
+        self.iface.lock().update_ip_addrs(|addrs| {
+            let dest = addrs.iter_mut().next();
+
+            if let Some(dest) = dest {
+                *dest = ip_addrs[0];
+            } else {
+                addrs.push(ip_addrs[0]).expect("Push ipCidr failed: full");
+            }
+        });
+        return Ok(());
+    }
+    /// ## `poll` 用于轮询接口的状态。
+    ///
+    /// ## 参数
+    /// - `&self` :自身引用
+    /// - `sockets` :一个可变引用到 `smoltcp::iface::SocketSet`,表示要轮询的套接字集
+    ///
+    /// ## 返回值
+    /// - 如果轮询成功,返回 `Ok(())`
+    /// - 如果轮询失败,返回 `Err(SystemError::EAGAIN_OR_EWOULDBLOCK)`,表示需要再次尝试或者操作会阻塞
+    fn poll(&self, sockets: &mut smoltcp::iface::SocketSet) -> Result<(), SystemError> {
+        let timestamp: smoltcp::time::Instant = Instant::now().into();
+        let mut guard = self.iface.lock();
+        let poll_res = guard.poll(timestamp, self.driver.force_get_mut(), sockets);
+        if poll_res {
+            return Ok(());
+        }
+        return Err(SystemError::EAGAIN_OR_EWOULDBLOCK);
+    }
+
+    #[inline(always)]
+    fn inner_iface(&self) -> &SpinLock<smoltcp::iface::Interface> {
+        return &self.iface;
+    }
+}
+
+pub fn loopback_probe() {
+    loopback_driver_init();
+}
+/// ## lo网卡设备初始化函数
+/// 创建驱动和iface,初始化一个lo网卡,添加到全局NET_DEVICES中
+pub fn loopback_driver_init() {
+    let driver = LoopbackDriver::new();
+    let iface = LoopbackInterface::new(driver);
+
+    NET_DEVICES
+        .write_irqsave()
+        .insert(iface.iface_id, iface.clone());
+}
+
+/// ## lo网卡设备的注册函数
+#[unified_init(INITCALL_DEVICE)]
+pub fn loopback_init() -> Result<(), SystemError> {
+    loopback_probe();
+    return Ok(());
+}

+ 2 - 1
kernel/src/driver/net/mod.rs

@@ -11,8 +11,9 @@ use system_error::SystemError;
 mod dma;
 mod dma;
 pub mod e1000e;
 pub mod e1000e;
 pub mod irq_handle;
 pub mod irq_handle;
+pub mod loopback;
 pub mod virtio_net;
 pub mod virtio_net;
-
+#[allow(dead_code)]
 pub trait NetDevice: Device {
 pub trait NetDevice: Device {
     /// @brief 获取网卡的MAC地址
     /// @brief 获取网卡的MAC地址
     fn mac(&self) -> EthernetAddress;
     fn mac(&self) -> EthernetAddress;

+ 1 - 2
kernel/src/driver/open_firmware/fdt.rs

@@ -468,8 +468,7 @@ fn read_cell(reg_value: &[u8], base_index: usize, cells: usize) -> (u64, usize)
         1 => {
         1 => {
             return (
             return (
                 u32::from_be_bytes(reg_value[base_index..base_index + 4].try_into().unwrap())
                 u32::from_be_bytes(reg_value[base_index..base_index + 4].try_into().unwrap())
-                    .try_into()
-                    .unwrap(),
+                    .into(),
                 next_base_index,
                 next_base_index,
             );
             );
         }
         }

+ 1 - 0
kernel/src/driver/pci/driver.rs

@@ -12,6 +12,7 @@ use super::{dev_id::PciDeviceID, device::PciDevice, subsys::pci_bus};
 /// Pci驱动应该实现的trait
 /// Pci驱动应该实现的trait
 ///
 ///
 /// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/pci.h#907
 /// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/pci.h#907
+#[allow(dead_code)]
 pub trait PciDriver: Driver {
 pub trait PciDriver: Driver {
     /// # 函数的功能
     /// # 函数的功能
     /// 对设备进行probe操作
     /// 对设备进行probe操作

+ 1 - 0
kernel/src/driver/rtc/mod.rs

@@ -47,6 +47,7 @@ pub trait RtcDevice: Device {
     fn class_ops(&self) -> &'static dyn RtcClassOps;
     fn class_ops(&self) -> &'static dyn RtcClassOps;
 }
 }
 
 
+#[allow(dead_code)]
 pub trait RtcClassOps: Send + Sync + Debug {
 pub trait RtcClassOps: Send + Sync + Debug {
     fn read_time(&self, dev: &Arc<dyn RtcDevice>) -> Result<RtcTime, SystemError>;
     fn read_time(&self, dev: &Arc<dyn RtcDevice>) -> Result<RtcTime, SystemError>;
     fn set_time(&self, dev: &Arc<dyn RtcDevice>, time: &RtcTime) -> Result<(), SystemError>;
     fn set_time(&self, dev: &Arc<dyn RtcDevice>, time: &RtcTime) -> Result<(), SystemError>;

+ 2 - 0
kernel/src/driver/serial/mod.rs

@@ -9,6 +9,7 @@ use self::serial8250::serial8250_manager;
 
 
 pub mod serial8250;
 pub mod serial8250;
 
 
+#[allow(dead_code)]
 pub trait UartDriver: Debug + Send + Sync {
 pub trait UartDriver: Debug + Send + Sync {
     fn device_number(&self) -> DeviceNumber;
     fn device_number(&self) -> DeviceNumber;
 
 
@@ -21,6 +22,7 @@ pub trait UartDriver: Debug + Send + Sync {
 /// 串口端口应当实现的trait
 /// 串口端口应当实现的trait
 ///
 ///
 /// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/serial_core.h#428
 /// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/linux/serial_core.h#428
+#[allow(dead_code)]
 pub trait UartPort {
 pub trait UartPort {
     fn iobase(&self) -> Option<usize> {
     fn iobase(&self) -> Option<usize> {
         None
         None

+ 1 - 0
kernel/src/driver/serial/serial8250/mod.rs

@@ -141,6 +141,7 @@ impl Serial8250Manager {
 }
 }
 
 
 /// 所有的8250串口设备都应该实现的trait
 /// 所有的8250串口设备都应该实现的trait
+#[allow(dead_code)]
 trait Serial8250Port: UartPort {
 trait Serial8250Port: UartPort {
     fn device(&self) -> Option<Arc<Serial8250ISADevices>> {
     fn device(&self) -> Option<Arc<Serial8250ISADevices>> {
         None
         None

+ 2 - 0
kernel/src/driver/serial/serial8250/serial8250_pio.rs

@@ -20,6 +20,7 @@ static mut PIO_PORTS: [Option<Serial8250PIOPort>; 8] =
     [None, None, None, None, None, None, None, None];
     [None, None, None, None, None, None, None, None];
 
 
 impl Serial8250Manager {
 impl Serial8250Manager {
+    #[allow(static_mut_refs)]
     pub(super) fn bind_pio_ports(
     pub(super) fn bind_pio_ports(
         &self,
         &self,
         uart_driver: &Arc<Serial8250ISADriver>,
         uart_driver: &Arc<Serial8250ISADriver>,
@@ -251,6 +252,7 @@ impl Serial8250PIOPortInner {
         Self { device: None }
         Self { device: None }
     }
     }
 
 
+    #[allow(dead_code)]
     pub fn device(&self) -> Option<Arc<Serial8250ISADevices>> {
     pub fn device(&self) -> Option<Arc<Serial8250ISADevices>> {
         if let Some(device) = self.device.as_ref() {
         if let Some(device) = self.device.as_ref() {
             return device.upgrade();
             return device.upgrade();

+ 1 - 0
kernel/src/driver/tty/console.rs

@@ -10,6 +10,7 @@ pub trait ConsoleSwitch: Sync + Send {
     fn con_init(&self, vc_data: &mut VirtualConsoleData, init: bool) -> Result<(), SystemError>;
     fn con_init(&self, vc_data: &mut VirtualConsoleData, init: bool) -> Result<(), SystemError>;
 
 
     /// 进行释放等系列操作,目前未使用
     /// 进行释放等系列操作,目前未使用
+    #[allow(dead_code)]
     fn con_deinit(&self) -> Result<(), SystemError>;
     fn con_deinit(&self) -> Result<(), SystemError>;
 
 
     /// ## 清空console的一片区域
     /// ## 清空console的一片区域

Some files were not shown because too many files changed in this diff