Documentation/arch/loongarch/introduction.rst
Source file repositories/reference/linux-study-clean/Documentation/arch/loongarch/introduction.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/arch/loongarch/introduction.rst- Extension
.rst- Size
- 16794 bytes
- Lines
- 391
- 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
=========================
Introduction to LoongArch
=========================
LoongArch is a new RISC ISA, which is a bit like MIPS or RISC-V. There are
currently 3 variants: a reduced 32-bit version (LA32R), a standard 32-bit
version (LA32S) and a 64-bit version (LA64). There are 4 privilege levels
(PLVs) defined in LoongArch: PLV0~PLV3, from high to low. Kernel runs at PLV0
while applications run at PLV3. This document introduces the registers, basic
instruction set, virtual memory and some other topics of LoongArch.
Registers
=========
LoongArch registers include general purpose registers (GPRs), floating point
registers (FPRs), vector registers (VRs) and control status registers (CSRs)
used in privileged mode (PLV0).
GPRs
----
LoongArch has 32 GPRs ( ``$r0`` ~ ``$r31`` ); each one is 32-bit wide in LA32
and 64-bit wide in LA64. ``$r0`` is hard-wired to zero, and the other registers
are not architecturally special. (Except ``$r1``, which is hard-wired as the
link register of the BL instruction.)
The kernel uses a variant of the LoongArch register convention, as described in
the LoongArch ELF psABI spec, in :ref:`References <loongarch-references>`:
================= =============== =================== ============
Name Alias Usage Preserved
across calls
================= =============== =================== ============
``$r0`` ``$zero`` Constant zero Unused
``$r1`` ``$ra`` Return address No
``$r2`` ``$tp`` TLS/Thread pointer Unused
``$r3`` ``$sp`` Stack pointer Yes
``$r4``-``$r11`` ``$a0``-``$a7`` Argument registers No
``$r4``-``$r5`` ``$v0``-``$v1`` Return value No
``$r12``-``$r20`` ``$t0``-``$t8`` Temp registers No
``$r21`` ``$u0`` Percpu base address Unused
``$r22`` ``$fp`` Frame pointer Yes
``$r23``-``$r31`` ``$s0``-``$s8`` Static registers Yes
================= =============== =================== ============
.. Note::
The register ``$r21`` is reserved in the ELF psABI, but used by the Linux
kernel for storing the percpu base address. It normally has no ABI name,
but is called ``$u0`` in the kernel. You may also see ``$v0`` or ``$v1``
in some old code,however they are deprecated aliases of ``$a0`` and ``$a1``
respectively.
FPRs
----
LoongArch has 32 FPRs ( ``$f0`` ~ ``$f31`` ) when FPU is present. Each one is
64-bit wide on the LA64 cores.
The floating-point register convention is the same as described in the
LoongArch ELF psABI spec:
================= ================== =================== ============
Name Alias Usage Preserved
across calls
================= ================== =================== ============
``$f0``-``$f7`` ``$fa0``-``$fa7`` Argument registers No
``$f0``-``$f1`` ``$fv0``-``$fv1`` Return value No
``$f8``-``$f23`` ``$ft0``-``$ft15`` Temp registers No
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.