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.

Dependency Surface

Detected Declarations

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

Implementation Notes