lib/crypto/powerpc/sha256.h
Source file repositories/reference/linux-study-clean/lib/crypto/powerpc/sha256.h
File Facts
- System
- Linux kernel
- Corpus path
lib/crypto/powerpc/sha256.h- Extension
.h- Size
- 1649 bytes
- Lines
- 59
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: implementation source
- Status
- source implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/switch_to.hlinux/preempt.h
Detected Declarations
function spe_beginfunction spe_endfunction sha256_blocks
Annotated Snippet
#include <asm/switch_to.h>
#include <linux/preempt.h>
/*
* MAX_BYTES defines the number of bytes that are allowed to be processed
* between preempt_disable() and preempt_enable(). SHA256 takes ~2,000
* operations per 64 bytes. e500 cores can issue two arithmetic instructions
* per clock cycle using one 32/64 bit unit (SU1) and one 32 bit unit (SU2).
* Thus 1KB of input data will need an estimated maximum of 18,000 cycles.
* Headroom for cache misses included. Even with the low end model clocked
* at 667 MHz this equals to a critical time window of less than 27us.
*
*/
#define MAX_BYTES 1024
extern void ppc_spe_sha256_transform(struct sha256_block_state *state,
const u8 *src, u32 blocks);
static void spe_begin(void)
{
/* We just start SPE operations and will save SPE registers later. */
preempt_disable();
enable_kernel_spe();
}
static void spe_end(void)
{
disable_kernel_spe();
/* reenable preemption */
preempt_enable();
}
static void sha256_blocks(struct sha256_block_state *state,
const u8 *data, size_t nblocks)
{
do {
/* cut input data into smaller blocks */
u32 unit = min_t(size_t, nblocks,
MAX_BYTES / SHA256_BLOCK_SIZE);
spe_begin();
ppc_spe_sha256_transform(state, data, unit);
spe_end();
data += unit * SHA256_BLOCK_SIZE;
nblocks -= unit;
} while (nblocks);
}
Annotation
- Immediate include surface: `asm/switch_to.h`, `linux/preempt.h`.
- Detected declarations: `function spe_begin`, `function spe_end`, `function sha256_blocks`.
- Atlas domain: Kernel Services / lib.
- 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.