[PATCH v3 0/4] docs/zh_CN:add riscv translation
STALE1982d
Revision v3 of 3 in this series.
8 messages,
3 authors,
2021-03-01 · open the first message on its own page
This series of patches translates all documents in the Doc/riscv directory.
v1->v2:
Modify the cover letter: remove some content from the tail;
v2->v3
remove features.rst
todos ----> 待办事项
Yanteng Si(4):
docs/zh_CN:add riscv boot-image-header.rst translation
docs/zh_CN: add riscv patch-acceptance.rst translation
docs/zh_CN: add riscv pmu.rst translation
docs/zh_CN: add riscv index.rst translation
Signed-off-by: Yanteng Si <redacted>
---
dcumentation/translations/zh_CN/riscv/boot-image-header.rst | 67
++++++++++++++++++++++++++++++++++++++++
Documentation/translations/zh_CN/riscv/index.rst | 29
++++++++++++++++++
Documentation/translations/zh_CN/riscv/patch-acceptance.rst | 32
++++++++++++++++++++
Documentation/translations/zh_CN/riscv/pmu.rst | 233
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 361 insertions(+)
This patch translates Documentation/riscv/boot-image-header.rst intoChinese.
Signed-off-by: Yanteng Si <redacted>
Reviewed-by: Alex Shi <redacted>
---
.../zh_CN/riscv/boot-image-header.rst | 67 +++++++++++++++++++
1 file changed, 67 insertions(+)
create mode 100644 Documentation/translations/zh_CN/riscv/boot-image-header.rst
diff --git a/Documentation/translations/zh_CN/riscv/boot-image-header.rst b/Documentation/translations/zh_CN/riscv/boot-image-header.rst
new file mode 100644
index 000000000000..fadfe08d03d5
--- /dev/null
+++ b/Documentation/translations/zh_CN/riscv/boot-image-header.rst @@ -0,0 +1,67 @@
+ .. include :: ../disclaimer-zh_CN.rst
+
+ :Original: :doc: `../../../riscv/boot-image-header`
+ :Translator: Yanteng Si <siyanteng@loongson.cn>
+
+ .. _cn_boot-image-header.rst:
+
+
+ ==========================
+ RISC-V Linux启动镜像文件头
+ ==========================
+
+ :Author: Atish Patra <atish.patra@wdc.com>
+ :Date: 20 May 2019
+
+ 此文档仅描述RISC-V Linux 启动文件头的详情。
+
+ TODO:
+ 写一个完整的启动指南。
+
+ 在解压后的Linux内核镜像中存在以下64字节的文件头::
+
+ u32 code0; /* Executable code * /
+ u32 code1; /* Executable code * /
+ u64 text_offset; /* Image load offset, little endian * /
+ u64 image_size; /* Effective Image size, little endian * /
+ u64 flags; /* kernel flags, little endian * /
+ u32 version; /* Version of this header * /
+ u32 res1 = 0; /* Reserved * /
+ u64 res2 = 0; /* Reserved * /
+ u64 magic = 0x5643534952; /* Magic number, little endian, "RISCV" * /
+ u32 magic2 = 0x05435352; /* Magic number 2, little endian, "RSC\x05" * /
+ u32 res3; /* Reserved for PE COFF offset * /
+
+ 这种头格式与PE/COFF文件头兼容,并在很大程度上受到ARM64文件头的启发。因此,ARM64
+ 和RISC-V文件头可以在未来合并为一个共同的头。
+
+ 注意
+ ====
+
+ - 将来也可以复用这个文件头,用来对RISC-V的EFI桩提供支持。为了使内核镜像如同一个
+ EFI应用程序一样加载,EFI规范中规定在内核镜像的开始需要PE/COFF镜像文件头。为了
+ 支持EFI桩,应该用“MZ”魔术字符替换掉code0,并且res3(偏移量未0x3c)应指向PE/COFF
+ 文件头的其余部分.
+
+ - 表示文件头的版本号的bit位域
+
+ ========== ==========
+ Bits 0:15 次要 版本
+ Bits 16:31 主要 版本
+ ========== ==========
+
+ 这保持了新旧版本之间的兼容性。
+ 当前版本被定义为0.2。
+
+ - 从版本0.2开始,结构体成员“magic”就已经被弃用,在之后的版本中,可能会移除掉它。
+ 最初,该成员应该与ARM64头的“magic”成员匹配,但遗憾的是并没有。
+ “magic2”成员代替“magic”成员与ARM64头相匹配。
+
+ - 在当前的文件头,标志位域只剩下了一个。
+
+ ===== ==============================
+ Bit 0 内核字节序。1 if BE, 0 if LE.
+ ===== ==============================
+
+ - 对于引导加载程序加载内核映像来说,image_size成员是强制性要写进文件头的,否则将引
+ 导失败。--
2.25.1
This patch translates Documentation/riscv/index.rst into Chinese.
Signed-off-by: Yanteng Si <redacted>
Reviewed-by: Alex Shi <redacted>
---
.../translations/zh_CN/riscv/index.rst | 28 +++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 Documentation/translations/zh_CN/riscv/index.rst
diff --git a/Documentation/translations/zh_CN/riscv/index.rst b/Documentation/translations/zh_CN/riscv/index.rst
new file mode 100644
index 000000000000..db13b1101490
--- /dev/null
+++ b/Documentation/translations/zh_CN/riscv/index.rst @@ -0,0 +1,28 @@
+ .. SPDX-License-Identifier: GPL-2.0
+
+ .. include :: ../disclaimer-zh_CN.rst
+
+ :Original: :doc: `../../../riscv/index`
+ :Translator: Yanteng Si <siyanteng@loongson.cn>
+
+ .. _cn_riscv_index:
+
+
+ ===============
+ RISC-V 体系结构
+ ===============
+
+ .. toctree ::
+ :maxdepth: 1
+
+ boot-image-header
+ pmu
+ patch-acceptance
+
+
+ .. only :: subproject and html
+
+ 目录
+ ====
+
+ * :ref: `genindex` --
2.25.1
This patch translates Documentation/riscv/patch-acceptance.rst into Chineae.
Signed-off-by: Yanteng Si <redacted>
Reviewed-by: Alex Shi <redacted>
---
.../zh_CN/riscv/patch-acceptance.rst | 32 +++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 Documentation/translations/zh_CN/riscv/patch-acceptance.rst
diff --git a/Documentation/translations/zh_CN/riscv/patch-acceptance.rst b/Documentation/translations/zh_CN/riscv/patch-acceptance.rst
new file mode 100644
index 000000000000..75446871559f
--- /dev/null
+++ b/Documentation/translations/zh_CN/riscv/patch-acceptance.rst @@ -0,0 +1,32 @@
+ .. SPDX-License-Identifier: GPL-2.0
+
+ .. include :: ../disclaimer-zh_CN.rst
+
+ :Original: :doc: `../../../riscv/patch-acceptance`
+ :Translator: Yanteng Si <siyanteng@loongson.cn>
+
+ .. _cn_riscv_patch-acceptance:
+
+
+ arch/riscv 开发者维护指南
+ =========================
+
+ 概述
+ ----
+ RISC-V指令集体系结构是公开开发的:
+ 正在进行的草案可供所有人查看和测试实现。新模块或者扩展草案可能会在开发过程中发
+ 生更改---有时以不兼容的方式对以前的草案进行更改。这种灵活性可能会给RISC-V Linux
+ 维护者带来挑战。Linux开发过程更喜欢经过良好检查和测试的代码,而不是试验代码。我
+ 们希望推广同样的规则到即将被内核合并的RISC-V相关代码。
+
+ 提交补遗清单
+ -------------------------
+ 如果RISC-V基金会将这些模块或扩展的规范列为“冻结”或“已批准”,则我们仅接受新模块
+ 或扩展的补丁。 (爱好者当然可以维护自己的Linux内核树,其中包含所需代码扩展草案
+ 的代码。)
+
+ 此外,RISC-V规范允许爱好者创建自己的自定义扩展。这些自定义拓展不需要通过RISC-V
+ 基金会的任何审核或批准。为了避免将爱好者一些特别的RISC-V拓展添加进内核代码带来
+ 的维护复杂性和对性能的潜在影响,我们将只接受RISC-V基金会正式冻结或批准的的扩展
+ 补丁。(爱好者当然可以维护自己的Linux内核树,其中包含他们想要的任何自定义扩展
+ 的代码。)--
2.25.1
This patch translates Documentation/riscv/pmu.rst into Chinese.
Signed-off-by: Yanteng Si <redacted>
Reviewed-by: Alex Shi <redacted>
---
.../translations/zh_CN/riscv/pmu.rst | 233 ++++++++++++++++++
1 file changed, 233 insertions(+)
create mode 100644 Documentation/translations/zh_CN/riscv/pmu.rst
diff --git a/Documentation/translations/zh_CN/riscv/pmu.rst b/Documentation/translations/zh_CN/riscv/pmu.rst
new file mode 100644
index 000000000000..c22cf82dcc61
--- /dev/null
+++ b/Documentation/translations/zh_CN/riscv/pmu.rst @@ -0,0 +1,233 @@
+ .. include :: ../disclaimer-zh_CN.rst
+
+ :Original: :doc: `../../../riscv/pmu`
+ :Translator: Yanteng Si <siyanteng@loongson.cn>
+
+ .. _cn_riscv_pmu:
+
+
+ ========================
+ RISC-V平台上对PMUs的支持
+ ========================
+
+ Alan Kao <alankao@andestech.com>, Mar 2018
+
+ 简介
+ ------------
+
+ 截止本文撰写时,在The RISC-V ISA Privileged Version 1.10中提到的 perf_event
+ 相关特性如下:
+ (详情请查阅手册)
+
+ * [m|s]counteren
+ * mcycle[h], cycle[h]
+ * minstret[h], instret[h]
+ * mhpeventx, mhpcounterx[h]
+
+ 仅有以上这些功能,移植perf需要做很多工作,究其原因是缺少以下通用架构的性能
+ 监测特性:
+
+ * 启用/停用计数器
+ 在我们这里,计数器一直在自由运行。
+ * 计数器溢出引起的中断
+ 规范中没有这种功能。
+ * 中断指示器
+ 不可能所有的计数器都有很多的中断端口,所以需要一个中断指示器让软件来判断
+ 哪个计数器刚好溢出。
+ * 写入计数器
+ 由于内核不能修改计数器,所以会有一个SBI来支持这个功能[1]。 另外,一些厂商
+ 考虑实现M-S-U型号机器的硬件扩展来直接写入计数器。
+
+ 这篇文档旨在为开发者提供一个在内核中支持PMU的简要指南。下面的章节简要解释了
+ perf' 机制和待办事项。
+
+ 你可以在这里查看以前的讨论[1][2]。 另外,查看附录中的相关内核结构体可能会有
+ 帮助。
+
+
+ 1. 初始化
+ ---------
+
+ *riscv_pmu* 是一个类型为 *struct riscv_pmu* 的全局指针,它包含了根据perf内部
+ 约定的各种方法和PMU-specific参数。人们应该声明这样的实例来代表PMU。 默认情况
+ 下, *riscv_pmu* 指向一个常量结构体 *riscv_base_pmu* ,它对基准QEMU模型有非常
+ 基础的支持。
+
+
+ 然后他/她可以将实例的指针分配给 *riscv_pmu* ,这样就可以利用已经实现的最小逻
+ 辑,或者创建他/她自己的 *riscv_init_platform_pmu* 实现。
+
+ 换句话说,现有的 *riscv_base_pmu* 源只是提供了一个参考实现。 开发者可以灵活地
+ 决定多少部分可用,在最极端的情况下,他们可以根据自己的需要定制每一个函数。
+
+
+ 2. Event Initialization
+ -----------------------
+
+ 当用户启动perf命令来监控一些事件时,首先会被用户空间的perf工具解释为多个
+ *perf_event_open* 系统调用,然后进一步调用上一步分配的 *event_init* 成员函数
+ 的主体。 在 *riscv_base_pmu* 的情况下,就是 *riscv_event_init* 。
+
+ 该功能的主要目的是将用户提供的事件翻译成映射图,从而可以直接对HW-related的控
+ 制寄存器或计数器进行操作。该翻译基于 *riscv_pmu* 中提供的映射和方法。
+
+ 注意,有些功能也可以在这个阶段完成:
+
+ (1) 中断设置,这个在下一节说;
+ (2) 特限级设置(仅用户空间、仅内核空间、两者都有);
+ (3) 析构函数设置。 通常应用 *riscv_destroy_event* 即可;
+ (4) 对非采样事件的调整,这将被函数应用,如 *perf_adjust_period* ,通常如下::
+
+ if (!is_sampling_event(event)) {
+ hwc->sample_period = x86_pmu.max_period;
+ hwc->last_period = hwc->sample_period;
+ local64_set(&hwc->period_left, hwc->sample_period);
+ }
+
+
+ 在 *riscv_base_pmu* 的情况下,目前只提供了(3)。
+
+
+ 3. 中断
+ -------
+
+ 3.1. 中断初始化
+
+ 这种情况经常出现在 *event_init* 方案的开头。通常情况下,这应该是一个代码段,如::
+
+ int x86_reserve_hardware(void)
+ {
+ int err = 0;
+
+ if (!atomic_inc_not_zero(&pmc_refcount)) {
+ mutex_lock(&pmc_reserve_mutex);
+ if (atomic_read(&pmc_refcount) == 0) {
+ if (!reserve_pmc_hardware())
+ err = -EBUSY;
+ else
+ reserve_ds_buffers();
+ }
+ if (!err)
+ atomic_inc(&pmc_refcount);
+ mutex_unlock(&pmc_reserve_mutex);
+ }
+
+ return err;
+ }
+
+ 而神奇的是 *reserve_pmc_hardware* ,它通常做原子操作,使实现的IRQ可以从某个全局函
+ 数指针访问。 而 *release_pmc_hardware* 的作用正好相反,它用在上一节提到的事件分配
+ 器中。
+
+ (注:从所有架构的实现来看,*reserve/release* 对总是IRQ设置,所以 *pmc_hardware*
+ 似乎有些误导。 它并不处理事件和物理计数器之间的绑定,这一点将在下一节介绍。)
+
+ 3.2. IRQ结构体
+
+ 基本上,一个IRQ运行以下伪代码::
+
+ for each hardware counter that triggered this overflow
+
+ get the event of this counter
+
+ // following two steps are defined as *read()* ,
+ // check the section Reading/Writing Counters for details.
+ count the delta value since previous interrupt
+ update the event->count (# event occurs) by adding delta, and
+ event->hw.period_left by subtracting delta
+
+ if the event overflows
+ sample data
+ set the counter appropriately for the next overflow
+
+ if the event overflows again
+ too frequently, throttle this event
+ fi
+ fi
+
+ end for
+
+ 然而截至目前,没有一个RISC-V的实现为perf设计了中断,所以具体的实现要在未来完成。
+
+ 4. Reading/Writing 计数
+ -----------------------
+
+ 它们看似差不多,但perf对待它们的态度却截然不同。 对于读,在 *struct pmu* 中有一个
+ *read* 接口,但它的作用不仅仅是读。 根据上下文,*read* 函数不仅要读取计数器的内容
+ (event->count),还要更新左周期到下一个中断(event->hw.period_left)。
+
+ 但 perf 的核心不需要直接写计数器。 写计数器隐藏在以下两点的抽象化之后,
+ 1) *pmu->start* ,从字面上看就是开始计数,所以必须把计数器设置成一个合适的值,以
+ 便下一次中断;
+ 2)在IRQ里面,应该把计数器设置成同样的合理值。
+
+ 在RISC-V中,读操作不是问题,但写操作就需要费些力气了,因为S模式不允许写计数器。
+
+
+ 5. add()/del()/start()/stop()
+ -----------------------------
+
+ 基本思想: add()/del() 向PMU添加/删除事件,start()/stop() 启动/停止PMU中某个事件
+ 的计数器。 所有这些函数都使用相同的参数: *struct perf_event * event* 和 * int flag* 。
+
+ 把 perf 看作一个状态机,那么你会发现这些函数作为这些状态之间的状态转换过程。
+ 定义了三种状态(event->hw.state):
+
+ * PERF_HES_STOPPED: 计数停止
+ * PERF_HES_UPTODATE: event->count是最新的
+ * PERF_HES_ARCH: 依赖于体系结构的用法,。。。我们现在并不需要它。
+
+ 这些状态转换的正常流程如下:
+
+ * 用户启动一个 perf 事件,导致调用 *event_init* 。
+ * 当被上下文切换进来的时候,*add* 会被 perf core 调用,并带有一个标志 PERF_EF_START,
+ 也就是说事件被添加后应该被启动。 在这个阶段,如果有的话,一般事件会被绑定到一个物
+ 理计数器上。当状态变为PERF_HES_STOPPED和PERF_HES_UPTODATE,因为现在已经停止了,
+ (软件)事件计数不需要更新。
+
+ - 然后调用 *start* ,并启用计数器。
+ 通过PERF_EF_RELOAD标志,它向计数器写入一个适当的值(详细情况请参考上一节)。
+ 如果标志不包含PERF_EF_RELOAD,则不会写入任何内容。
+ 现在状态被重置为none,因为它既没有停止也没有更新(计数已经开始)。
+
+ *当被上下文切换出来时被调用。 然后,它检查出PMU中的所有事件,并调用 * stop* 来更新它们
+ 的计数。
+
+ - *stop* 被 *del* 和perf核心调用,标志为PERF_EF_UPDATE,它经常以相同的逻辑和 *read*
+ 共用同一个子程序。
+ 状态又一次变为PERF_HES_STOPPED和PERF_HES_UPTODATE。
+
+ - 这两对程序的生命周期: *add* 和 *del* 在任务切换时被反复调用;*start* 和 *stop* 在
+ perf核心需要快速停止和启动时也会被调用,比如在调整中断周期时。
+
+ 目前的实现已经足够了,将来可以很容易地扩展到功能。
+
+ A. 相关结构体
+ -------------
+
+ * struct pmu: include/linux/perf_event.h
+ * struct riscv_pmu: arch/riscv/include/asm/perf_event.h
+
+ 两个结构体都被设计为只读。
+
+ *struct pmu* 定义了一些函数指针接口,它们大多以 *struct perf_event* 作为主参数,根据
+ perf的内部状态机处理perf事件(详情请查看kernel/events/core.c)。
+
+ *struct riscv_pmu* 定义了PMU的具体参数。 命名遵循所有其它架构的惯例。
+
+ * struct perf_event: include/linux/perf_event.h
+ * struct hw_perf_event
+
+ 表示 perf 事件的通用结构体,以及硬件相关的细节。
+
+ * struct riscv_hw_events: arch/riscv/include/asm/perf_event.h
+
+ 保存事件状态的结构有两个固定成员。
+ 事件的数量和事件的数组。
+
+ 参考文献
+ --------
+
+ [1] https://github.com/riscv/riscv-linux/pull/124
+
+ [2] https://groups.google.com/a/groups.riscv.org/forum/#!topic/sw-dev/f19TmCNP6yA--
2.25.1
On Fri, Feb 26, 2021, at 2:41 AM, Yanteng Si wrote: quoted hunk This patch translates Documentation/riscv/patch-acceptance.rst into Chineae.
Signed-off-by: Yanteng Si <redacted>
Reviewed-by: Alex Shi <redacted>
---
.../zh_CN/riscv/patch-acceptance.rst | 32 +++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 Documentation/translations/zh_CN/riscv/patch-acceptance.rst
a/Documentation/translations/zh_CN/riscv/patch-acceptance.rst
b/Documentation/translations/zh_CN/riscv/patch-acceptance.rst
new file mode 100644
index 000000000000..75446871559f --- /dev/null
+++ b/Documentation/translations/zh_CN/riscv/patch-acceptance.rst @@ -0,0 +1,32 @@
+ .. SPDX-License-Identifier: GPL-2.0
+
+ .. include :: ../disclaimer-zh_CN.rst
+
+ :Original: :doc: `../../../riscv/patch-acceptance`
+ :Translator: Yanteng Si <siyanteng@loongson.cn>
+
+ .. _cn_riscv_patch-acceptance:
+
+
+ arch/riscv 开发者维护指南
+ =========================
+
+ 概述
+ ----
+ RISC-V指令集体系结构是公开开发的:
+ 正在进行的草案可供所有人查看和测试实现。新模块或者扩展草案可能会在开发过程中发
+ 生更改---有时以不兼容的方式对以前的草案进行更改。这种灵活性可能会给RISC-V Linux
+ 维护者带来挑战。Linux开发过程更喜欢经过良好检查和测试的代码,而不是试验代码。我
+ 们希望推广同样的规则到即将被内核合并的RISC-V相关代码。
+
+ 提交补遗清单
^附加的提交检查单?
Addendum means additional part to the regular patch submition check list.
+-------------------------
+如果RISC-V基金会将这些模块或扩展的规范列为“冻结”或“已批准”,则我们仅接受新模块
+或扩展的补丁。 (爱好者当然可以维护自己的Linux内 ^ such expression seems bogus in Chinese, should be
我们仅接受相关标准已经被RISC-V基金会标准为“已批准”或“已冻结”的扩展或模块的补丁。
核树,其中包含所需代码扩展草案 +的代码。) 爱好者 means hobbiest, I'd prefer 开发者 over 爱好者, as it's exactly Developer means.
+
+此外,RISC-V规范允许爱好者创建自己的自定义扩展。这些自定义拓展不需要通过RISC-V
+基金会的任何审核或批准。为了避免将爱好者一些特别的RISC-V拓展添加进内核代码带来
+的维护复杂性和对性能的潜在影响,我们将只接受RISC-V基金会正式冻结或批准的的扩展
+补丁。(爱好者当然可以维护自己的Linux内核树,其中包含他们想要的任何自定义扩展
+的代码。) Again, implementer means those who are implementing their own RISC-V core design.
s/爱好者/实施者 or 执行者 实现者?
thanks
--
2.25.1
--
- Jiaxun
On Fri, Feb 26, 2021, at 2:41 AM, Yanteng Si wrote: quoted hunk This patch translates Documentation/riscv/boot-image-header.rst intoChinese.
Signed-off-by: Yanteng Si <redacted>
Reviewed-by: Alex Shi <redacted>
---
.../zh_CN/riscv/boot-image-header.rst | 67 +++++++++++++++++++
1 file changed, 67 insertions(+)
create mode 100644 Documentation/translations/zh_CN/riscv/boot-image-header.rst
a/Documentation/translations/zh_CN/riscv/boot-image-header.rst
b/Documentation/translations/zh_CN/riscv/boot-image-header.rst
new file mode 100644
index 000000000000..fadfe08d03d5 --- /dev/null
+++ b/Documentation/translations/zh_CN/riscv/boot-image-header.rst @@ -0,0 +1,67 @@
+ .. include :: ../disclaimer-zh_CN.rst
+
+ :Original: :doc: `../../../riscv/boot-image-header`
+ :Translator: Yanteng Si <siyanteng@loongson.cn>
+
+ .. _cn_boot-image-header.rst:
+
+
+ ==========================
+ RISC-V Linux启动镜像文件头
+ ==========================
+
+ :Author: Atish Patra <atish.patra@wdc.com>
+ :Date: 20 May 2019
+
+ 此文档仅描述RISC-V Linux 启动文件头的详情。
+
+ TODO:
+ 写一个完整的启动指南。
+
+ 在解压后的Linux内核镜像中存在以下64字节的文件头::
+
+ u32 code0; /* Executable code * /
+ u32 code1; /* Executable code * /
+ u64 text_offset; /* Image load offset, little endian * /
+ u64 image_size; /* Effective Image size, little endian * /
+ u64 flags; /* kernel flags, little endian * /
+ u32 version; /* Version of this header * /
+ u32 res1 = 0; /* Reserved * /
+ u64 res2 = 0; /* Reserved * /
+ u64 magic = 0x5643534952; /* Magic number, little endian, "RISCV" * /
+ u32 magic2 = 0x05435352; /* Magic number 2, little endian, "RSC\x05" */
+ u32 res3; /* Reserved for PE COFF offset */
+
+这种头格式与PE/COFF文件头兼容,并在很大程度上受到ARM64文件头的启发。因此,ARM64
+和RISC-V文件头可以在未来合并为一个共同的头。
+
+注意
+====
+
+- 将来也可以复用这个文件头,用来对RISC-V的EFI桩提供支持。为了使内核镜像如同一个
+ EFI应用程序一样加载,EFI规范中规定在内核镜像的开始需要PE/COFF镜像文件头。为了
+ 支持EFI桩,应该用“MZ”魔术字符替换掉code0,并且res3(偏移量未0x3c)应指向PE/COFF 为0x3c -> 为 0x3c?
Also I'd prefer not to translate stub as it already become a well known noun.
+ 文件头的其余部分.
+
+- 表示文件头的版本号的bit位域 Drop bit
+
+ ========== ==========
+ Bits 0:15 次要 版本
+ Bits 16:31 主要 版本
+ ========== ==========
+
+ 这保持了新旧版本之间的兼容性。
+ 当前版本被定义为0.2。
+
+- 从版本0.2开始,结构体成员“magic”就已经被弃用,在之后的版本中,可能会移除掉它。
+ 最初,该成员应该与ARM64头的“magic”成员匹配,但遗憾的是并没有。
+ “magic2”成员代替“magic”成员与ARM64头相匹配。
+
+- 在当前的文件头,标志位域只剩下了一个。 剩下了一个位
+
+ ===== ==============================
+ Bit 0 内核字节序。1 if BE, 0 if LE.
+ ===== ==============================
+
+- 对于引导加载程序加载内核映像来说,image_size成员是强制性要写进文件头的,否则将引
+ 导失败。 Image size 成员对引导加载程序(or 加载器?) 而言是必须的。
--
2.25.1
--
- Jiaxun
OK. Thanks!
Yanteng
Jiaxun Yang [off-list ref] 于2021年2月26日周五 下午12:38写道:
On Fri, Feb 26, 2021, at 2:41 AM, Yanteng Si wrote: quoted This patch translates Documentation/riscv/boot-image-header.rst intoChinese.
Signed-off-by: Yanteng Si <redacted>
Reviewed-by: Alex Shi <redacted>
---
.../zh_CN/riscv/boot-image-header.rst | 67 +++++++++++++++++++
1 file changed, 67 insertions(+)
create mode 100644 Documentation/translations/zh_CN/riscv/boot-image-header.rst
diff --git
a/Documentation/translations/zh_CN/riscv/boot-image-header.rst
b/Documentation/translations/zh_CN/riscv/boot-image-header.rst
new file mode 100644
index 000000000000..fadfe08d03d5 --- /dev/null
+++ b/Documentation/translations/zh_CN/riscv/boot-image-header.rst @@ -0,0 +1,67 @@
+ .. include :: ../disclaimer-zh_CN.rst
+
+ :Original: :doc: `../../../riscv/boot-image-header`
+ :Translator: Yanteng Si <siyanteng@loongson.cn>
+
+ .. _cn_boot-image-header.rst:
+
+
+ ==========================
+ RISC-V Linux启动镜像文件头
+ ==========================
+
+ :Author: Atish Patra <atish.patra@wdc.com>
+ :Date: 20 May 2019
+
+ 此文档仅描述RISC-V Linux 启动文件头的详情。
+
+ TODO:
+ 写一个完整的启动指南。
+
+ 在解压后的Linux内核镜像中存在以下64字节的文件头::
+
+ u32 code0; /* Executable code * /
+ u32 code1; /* Executable code * /
+ u64 text_offset; /* Image load offset, little endian * /
+ u64 image_size; /* Effective Image size, little endian * /
+ u64 flags; /* kernel flags, little endian * /
+ u32 version; /* Version of this header * /
+ u32 res1 = 0; /* Reserved * /
+ u64 res2 = 0; /* Reserved * /
+ u64 magic = 0x5643534952; /* Magic number, little endian, "RISCV" * /
+ u32 magic2 = 0x05435352; /* Magic number 2, little endian, "RSC\x05"*/
+ u32 res3; /* Reserved for PE COFF offset */
+
+这种头格式与PE/COFF文件头兼容,并在很大程度上受到ARM64文件头的启发。因此,ARM64
+和RISC-V文件头可以在未来合并为一个共同的头。
+
+注意
+====
+
+- 将来也可以复用这个文件头,用来对RISC-V的EFI桩提供支持。为了使内核镜像如同一个
+ EFI应用程序一样加载,EFI规范中规定在内核镜像的开始需要PE/COFF镜像文件头。为了
+ 支持EFI桩,应该用“MZ”魔术字符替换掉code0,并且res3(偏移量未0x3c)应指向PE/COFF 为0x3c -> 为 0x3c?
Also I'd prefer not to translate stub as it already become a well known noun.
quoted + 文件头的其余部分.
+
+- 表示文件头的版本号的bit位域 Drop bit
quoted +
+ ========== ==========
+ Bits 0:15 次要 版本
+ Bits 16:31 主要 版本
+ ========== ==========
+
+ 这保持了新旧版本之间的兼容性。
+ 当前版本被定义为0.2。
+
+- 从版本0.2开始,结构体成员“magic”就已经被弃用,在之后的版本中,可能会移除掉它。
+ 最初,该成员应该与ARM64头的“magic”成员匹配,但遗憾的是并没有。
+ “magic2”成员代替“magic”成员与ARM64头相匹配。
+
+- 在当前的文件头,标志位域只剩下了一个。 剩下了一个位
quoted +
+ ===== ==============================
+ Bit 0 内核字节序。1 if BE, 0 if LE.
+ ===== ==============================
+
+- 对于引导加载程序加载内核映像来说,image_size成员是强制性要写进文件头的,否则将引
+ 导失败。 Image size 成员对引导加载程序(or 加载器?) 而言是必须的。
quoted --
2.25.1
--
- Jiaxun