arch/loongarch/lib/unaligned.S
Source file repositories/reference/linux-study-clean/arch/loongarch/lib/unaligned.S
File Facts
- System
- Linux kernel
- Corpus path
arch/loongarch/lib/unaligned.S- Extension
.S- Size
- 1439 bytes
- Lines
- 84
- Domain
- Architecture Layer
- Bucket
- arch/loongarch
- Inferred role
- Architecture Layer: arch/loongarch
- Status
- atlas-only
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
Dependency Surface
linux/linkage.hasm/asm.hasm/asmmacro.hasm/asm-extable.hasm/errno.hasm/regdef.h
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#include <linux/linkage.h>
#include <asm/asm.h>
#include <asm/asmmacro.h>
#include <asm/asm-extable.h>
#include <asm/errno.h>
#include <asm/regdef.h>
.L_fixup_handle_unaligned:
li.w a0, -EFAULT
jr ra
/*
* unsigned long unaligned_read(void *addr, void *value, unsigned long n, bool sign)
*
* a0: addr
* a1: value
* a2: n
* a3: sign
*/
SYM_FUNC_START(unaligned_read)
beqz a2, 5f
li.w t2, 0
LONG_ADDI t0, a2, -1
PTR_SLLI t1, t0, LONGLOG
PTR_ADD a0, a0, t0
beqz a3, 2f
1: ld.b t3, a0, 0
b 3f
2: ld.bu t3, a0, 0
3: LONG_SLLV t3, t3, t1
or t2, t2, t3
LONG_ADDI t1, t1, -8
PTR_ADDI a0, a0, -1
PTR_ADDI a2, a2, -1
bgtz a2, 2b
4: LONG_S t2, a1, 0
move a0, a2
jr ra
5: li.w a0, -EFAULT
jr ra
_asm_extable 1b, .L_fixup_handle_unaligned
_asm_extable 2b, .L_fixup_handle_unaligned
_asm_extable 4b, .L_fixup_handle_unaligned
SYM_FUNC_END(unaligned_read)
/*
* unsigned long unaligned_write(void *addr, unsigned long value, unsigned long n)
*
* a0: addr
* a1: value
* a2: n
*/
SYM_FUNC_START(unaligned_write)
beqz a2, 3f
li.w t0, 0
1: LONG_SRLV t1, a1, t0
2: st.b t1, a0, 0
LONG_ADDI t0, t0, 8
PTR_ADDI a2, a2, -1
PTR_ADDI a0, a0, 1
bgtz a2, 1b
Annotation
- Immediate include surface: `linux/linkage.h`, `asm/asm.h`, `asm/asmmacro.h`, `asm/asm-extable.h`, `asm/errno.h`, `asm/regdef.h`.
- Atlas domain: Architecture Layer / arch/loongarch.
- 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.