tools/testing/selftests/powerpc/include/instructions.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/include/instructions.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/include/instructions.h- Extension
.h- Size
- 4759 bytes
- Lines
- 147
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
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
stdio.hstdlib.h
Detected Declarations
function copyfunction copy_firstfunction pastefunction paste_last
Annotated Snippet
#ifndef _SELFTESTS_POWERPC_INSTRUCTIONS_H
#define _SELFTESTS_POWERPC_INSTRUCTIONS_H
#include <stdio.h>
#include <stdlib.h>
/* This defines the "copy" instruction from Power ISA 3.0 Book II, section 4.4. */
#define __COPY(RA, RB, L) \
(0x7c00060c | (RA) << (31-15) | (RB) << (31-20) | (L) << (31-10))
#define COPY(RA, RB, L) \
.long __COPY((RA), (RB), (L))
static inline void copy(void *i)
{
asm volatile(str(COPY(0, %0, 0))";"
:
: "b" (i)
: "memory"
);
}
static inline void copy_first(void *i)
{
asm volatile(str(COPY(0, %0, 1))";"
:
: "b" (i)
: "memory"
);
}
/* This defines the "paste" instruction from Power ISA 3.0 Book II, section 4.4. */
#define __PASTE(RA, RB, L, RC) \
(0x7c00070c | (RA) << (31-15) | (RB) << (31-20) | (L) << (31-10) | (RC) << (31-31))
#define PASTE(RA, RB, L, RC) \
.long __PASTE((RA), (RB), (L), (RC))
static inline int paste(void *i)
{
int cr;
asm volatile(str(PASTE(0, %1, 0, 0))";"
"mfcr %0;"
: "=r" (cr)
: "b" (i)
: "memory"
);
return cr;
}
static inline int paste_last(void *i)
{
int cr;
asm volatile(str(PASTE(0, %1, 1, 1))";"
"mfcr %0;"
: "=r" (cr)
: "b" (i)
: "memory"
);
return cr;
}
#define PPC_INST_COPY __COPY(0, 0, 0)
#define PPC_INST_COPY_FIRST __COPY(0, 0, 1)
#define PPC_INST_PASTE __PASTE(0, 0, 0, 0)
#define PPC_INST_PASTE_LAST __PASTE(0, 0, 1, 1)
/* This defines the prefixed load/store instructions */
#ifdef __ASSEMBLER__
# define stringify_in_c(...) __VA_ARGS__
#else
# define __stringify_in_c(...) #__VA_ARGS__
# define stringify_in_c(...) __stringify_in_c(__VA_ARGS__) " "
#endif
#define __PPC_RA(a) (((a) & 0x1f) << 16)
#define __PPC_RS(s) (((s) & 0x1f) << 21)
#define __PPC_RT(t) __PPC_RS(t)
#define __PPC_PREFIX_R(r) (((r) & 0x1) << 20)
#define PPC_PREFIX_MLS 0x06000000
#define PPC_PREFIX_8LS 0x04000000
#define PPC_INST_LBZ 0x88000000
#define PPC_INST_LHZ 0xa0000000
#define PPC_INST_LHA 0xa8000000
#define PPC_INST_LWZ 0x80000000
#define PPC_INST_STB 0x98000000
#define PPC_INST_STH 0xb0000000
#define PPC_INST_STW 0x90000000
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`.
- Detected declarations: `function copy`, `function copy_first`, `function paste`, `function paste_last`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.