Documentation/translations/zh_CN/arch/loongarch/introduction.rst
Source file repositories/reference/linux-study-clean/Documentation/translations/zh_CN/arch/loongarch/introduction.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/translations/zh_CN/arch/loongarch/introduction.rst- Extension
.rst- Size
- 16715 bytes
- Lines
- 354
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
.. SPDX-License-Identifier: GPL-2.0
.. include:: ../../disclaimer-zh_CN.rst
:Original: Documentation/arch/loongarch/introduction.rst
:Translator: Huacai Chen <chenhuacai@loongson.cn>
=============
LoongArch介绍
=============
LoongArch是一种新的RISC ISA,在一定程度上类似于MIPS和RISC-V。LoongArch指令集
包括一个精简32位版(LA32R)、一个标准32位版(LA32S)、一个64位版(LA64)。
LoongArch定义了四个特权级(PLV0~PLV3),其中PLV0是最高特权级,用于内核;而PLV3
是最低特权级,用于应用程序。本文档介绍了LoongArch的寄存器、基础指令集、虚拟内
存以及其他一些主题。
寄存器
======
LoongArch的寄存器包括通用寄存器(GPRs)、浮点寄存器(FPRs)、向量寄存器(VRs)
和用于特权模式(PLV0)的控制状态寄存器(CSRs)。
通用寄存器
----------
LoongArch包括32个通用寄存器( ``$r0`` ~ ``$r31`` ),LA32中每个寄存器为32位宽,
LA64中每个寄存器为64位宽。 ``$r0`` 的内容总是固定为0,而其他寄存器在体系结构层面
没有特殊功能。( ``$r1`` 算是一个例外,在BL指令中固定用作链接返回寄存器。)
内核使用了一套LoongArch寄存器约定,定义在LoongArch ELF psABI规范中,详细描述参见
:ref:`参考文献 <loongarch-references-zh_CN>`:
================= =============== =================== ==========
寄存器名 别名 用途 跨调用保持
================= =============== =================== ==========
``$r0`` ``$zero`` 常量0 不使用
``$r1`` ``$ra`` 返回地址 否
``$r2`` ``$tp`` TLS/线程信息指针 不使用
``$r3`` ``$sp`` 栈指针 是
``$r4``-``$r11`` ``$a0``-``$a7`` 参数寄存器 否
``$r4``-``$r5`` ``$v0``-``$v1`` 返回值 否
``$r12``-``$r20`` ``$t0``-``$t8`` 临时寄存器 否
``$r21`` ``$u0`` 每CPU变量基地址 不使用
``$r22`` ``$fp`` 帧指针 是
``$r23``-``$r31`` ``$s0``-``$s8`` 静态寄存器 是
================= =============== =================== ==========
.. note::
注意: ``$r21`` 寄存器在ELF psABI中保留未使用,但是在Linux内核用于保
存每CPU变量基地址。该寄存器没有ABI命名,不过在内核中称为 ``$u0`` 。在
一些遗留代码中有时可能见到 ``$v0`` 和 ``$v1`` ,它们是 ``$a0`` 和
``$a1`` 的别名,属于已经废弃的用法。
浮点寄存器
----------
当系统中存在FPU时,LoongArch有32个浮点寄存器( ``$f0`` ~ ``$f31`` )。在LA64
的CPU核上,每个寄存器均为64位宽。
浮点寄存器的使用约定与LoongArch ELF psABI规范的描述相同:
================= ================== =================== ==========
寄存器名 别名 用途 跨调用保持
================= ================== =================== ==========
``$f0``-``$f7`` ``$fa0``-``$fa7`` 参数寄存器 否
``$f0``-``$f1`` ``$fv0``-``$fv1`` 返回值 否
``$f8``-``$f23`` ``$ft0``-``$ft15`` 临时寄存器 否
``$f24``-``$f31`` ``$fs0``-``$fs7`` 静态寄存器 是
================= ================== =================== ==========
Annotation
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.