arch/x86/kernel/cpu/mtrr/legacy.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/cpu/mtrr/legacy.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/cpu/mtrr/legacy.c- Extension
.c- Size
- 1968 bytes
- Lines
- 95
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/slab.hlinux/syscore_ops.hasm/cpufeature.hasm/mtrr.hasm/processor.hmtrr.h
Detected Declarations
struct mtrr_valuefunction mtrr_set_iffunction mtrr_savefunction mtrr_restorefunction mtrr_register_syscore
Annotated Snippet
struct mtrr_value {
mtrr_type ltype;
unsigned long lbase;
unsigned long lsize;
};
static struct mtrr_value *mtrr_value;
static int mtrr_save(void *data)
{
int i;
if (!mtrr_value)
return -ENOMEM;
for (i = 0; i < num_var_ranges; i++) {
mtrr_if->get(i, &mtrr_value[i].lbase,
&mtrr_value[i].lsize,
&mtrr_value[i].ltype);
}
return 0;
}
static void mtrr_restore(void *data)
{
int i;
for (i = 0; i < num_var_ranges; i++) {
if (mtrr_value[i].lsize) {
mtrr_if->set(i, mtrr_value[i].lbase,
mtrr_value[i].lsize,
mtrr_value[i].ltype);
}
}
}
static const struct syscore_ops mtrr_syscore_ops = {
.suspend = mtrr_save,
.resume = mtrr_restore,
};
static struct syscore mtrr_syscore = {
.ops = &mtrr_syscore_ops,
};
void mtrr_register_syscore(void)
{
mtrr_value = kzalloc_objs(*mtrr_value, num_var_ranges);
/*
* The CPU has no MTRR and seems to not support SMP. They have
* specific drivers, we use a tricky method to support
* suspend/resume for them.
*
* TBD: is there any system with such CPU which supports
* suspend/resume? If no, we should remove the code.
*/
register_syscore(&mtrr_syscore);
}
Annotation
- Immediate include surface: `linux/types.h`, `linux/slab.h`, `linux/syscore_ops.h`, `asm/cpufeature.h`, `asm/mtrr.h`, `asm/processor.h`, `mtrr.h`.
- Detected declarations: `struct mtrr_value`, `function mtrr_set_if`, `function mtrr_save`, `function mtrr_restore`, `function mtrr_register_syscore`.
- Atlas domain: Architecture Layer / arch/x86.
- 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.