arch/riscv/include/asm/bitrev.h
Source file repositories/reference/linux-study-clean/arch/riscv/include/asm/bitrev.h
File Facts
- System
- Linux kernel
- Corpus path
arch/riscv/include/asm/bitrev.h- Extension
.h- Size
- 1033 bytes
- Lines
- 52
- Domain
- Architecture Layer
- Bucket
- arch/riscv
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
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/types.hasm/cpufeature-macros.hasm/hwcap.hasm-generic/bitops/__bitrev.h
Detected Declarations
function __arch_bitrev32function __arch_bitrev16function __arch_bitrev8
Annotated Snippet
#ifndef __ASM_BITREV_H
#define __ASM_BITREV_H
#include <linux/types.h>
#include <asm/cpufeature-macros.h>
#include <asm/hwcap.h>
#include <asm-generic/bitops/__bitrev.h>
static __always_inline __attribute_const__ u32 __arch_bitrev32(u32 x)
{
unsigned long result;
if (!riscv_has_extension_likely(RISCV_ISA_EXT_ZBKB))
return generic___bitrev32(x);
asm volatile(
".option push\n"
".option arch,+zbkb\n"
"rev8 %0, %1\n"
"brev8 %0, %0\n"
".option pop"
: "=r" (result) : "r" ((long)x)
);
return result >> (__riscv_xlen - 32);
}
static __always_inline __attribute_const__ u16 __arch_bitrev16(u16 x)
{
return __arch_bitrev32(x) >> 16;
}
static __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x)
{
unsigned long result;
if (!riscv_has_extension_likely(RISCV_ISA_EXT_ZBKB))
return generic___bitrev8(x);
asm volatile(
".option push\n"
".option arch,+zbkb\n"
"brev8 %0, %1\n"
".option pop"
: "=r" (result) : "r" ((long)x)
);
return result;
}
#endif
Annotation
- Immediate include surface: `linux/types.h`, `asm/cpufeature-macros.h`, `asm/hwcap.h`, `asm-generic/bitops/__bitrev.h`.
- Detected declarations: `function __arch_bitrev32`, `function __arch_bitrev16`, `function __arch_bitrev8`.
- Atlas domain: Architecture Layer / arch/riscv.
- Implementation status: source implementation candidate.
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.