:doc: multiboot2支持模块

This commit is contained in:
fslongjin 2022-07-12 17:57:11 +08:00
parent da4867d662
commit a5ce84c26e
8 changed files with 80 additions and 11 deletions

View File

@ -2,5 +2,7 @@
====================================
开发者: fslongjin
工作邮箱: longjin@RinGoTek.cn
[内容待完善]

View File

@ -17,7 +17,7 @@
:maxdepth: 1
:caption: 内核层
kernel/bootloader/index
kernel/boot/index
kernel/process_management/index
kernel/filesystem/index

View File

@ -0,0 +1,19 @@
# 引导加载程序
## 原理
  目前DragonOS仅支持Legacy BIOS进行启动引导。
  `head.S`的头部包含了Multiboot2引导头里面标志了一些Multiboot2相关的特定信息以及一些配置命令。
  在DragonOS的启动初期会存储由GRUB2传来的magic number以及multiboot2_boot_info_addr。当系统进入`Start_Kernel`函数之后将会把这两个信息保存到multiboot2驱动程序之中。信息的具体含义请参照Multiboot2 Specification进行理解该部分难度不大相信读者经过思考能理解其中的原理。
## 未来发展方向
- 增加对UEFI启动的支持
## 参考资料
- [Multiboot2 Specification](http://git.savannah.gnu.org/cgit/grub.git/tree/doc/multiboot.texi?h=multiboot2)
- [GNU GRUB Manual 2.06](https://www.gnu.org/software/grub/manual/grub/grub.html)

View File

@ -0,0 +1,11 @@
引导加载
====================================
DragonOS采用GRUB2作为其引导加载程序支持Multiboot2协议引导。目前仅支持GRUB2.06版本。
.. toctree::
:maxdepth: 1
:caption: 目录
bootloader
multiboot2

View File

@ -0,0 +1,46 @@
# Multiboot2支持模块
  Multiboot2支持模块提供对Multiboot2协议的支持。位于`kernel/driver/multiboot2`文件夹中。
  根据Multiboot2协议操作系统能够从BootLoader处获得一些信息比如基本的硬件信息以及ACPI表的起始地址等。
---
## 数据结构
  `kernel/driver/multiboot2/multiboot2.h`中按照Multiboot2协议的规定定义了大部分的数据结构具体细节可查看该文件: [DragonOS/multiboot2.h at master · fslongjin/DragonOS · GitHub](https://github.com/fslongjin/DragonOS/blob/master/kernel/driver/multiboot2/multiboot2.h)
---
## 迭代器
  由于Multiboot2的信息存储在自`multiboot2_boot_info_addr`开始的一段连续的内存空间之中且不同类型的header的长度不同因此设计了一迭代器`multiboot2_iter`
### 函数原型
```c
void multiboot2_iter(bool (*_fun)(const struct iter_data_t *, void *, unsigned int *),
void *data, unsigned int *count)
```
**_fun**
  指定的handler。当某个header的tag与该handler所处理的tag相同时handler将处理该header并返回true。
  其第一个参数为tag类型第二个参数为返回的数据的指针第三个值为计数某些没有用到该值的地方该值可以为空
**data**
  传递给`_fun`的第二个参数,`_fun`函数将填充该指针所指向的内存区域,从而返回数据。
**count**
  当返回的**data**为一个列表时,通过该值来指示列表中有多少项。
---
## 迭代工作函数
  在模块中按照我们需要获取不同类型的tag的需要定义了一些迭代器工作函数。

View File

@ -1,8 +0,0 @@
引导加载程序
====================================
.. toctree::
:maxdepth: 2
:caption: 目录
intro

View File

@ -1 +0,0 @@
# 简介

2
run.sh
View File

@ -29,7 +29,7 @@ OS=`uname -s`
if [ "${OS}" == "Linux" ]; then
GRUB_PATH="$(dirname $(which grub-file))"
elif [ "${OS}" == "Darwin" ]; then
GRUB_PATH="$(pwd)/tools/grub-2.04/build/grub/bin"
GRUB_PATH="$(pwd)/tools/grub-2.06/build/grub/bin"
fi
export PATH="${GRUB_PATH}:$PATH"