arch/x86/kernel/apm_32.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/apm_32.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/apm_32.c- Extension
.c- Size
- 69702 bytes
- Lines
- 2410
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/poll.hlinux/types.hlinux/stddef.hlinux/timer.hlinux/fcntl.hlinux/slab.hlinux/stat.hlinux/proc_fs.hlinux/seq_file.hlinux/miscdevice.hlinux/apm_bios.hlinux/init.hlinux/time.hlinux/sched/signal.hlinux/sched/cputime.hlinux/pm.hlinux/capability.hlinux/device.hlinux/kernel.hlinux/freezer.hlinux/smp.hlinux/dmi.hlinux/suspend.hlinux/kthread.hlinux/jiffies.hlinux/acpi.hlinux/syscore_ops.hlinux/i8253.hlinux/cpuidle.hlinux/uaccess.hasm/desc.h
Detected Declarations
struct apm_userstruct apm_bios_callfunction apm_errorfunction __apm_irq_savefunction apm_irq_restorefunction AHfunction on_cpu0function apm_bios_callfunction __apm_bios_call_simplefunction apm_bios_call_simplefunction apm_driver_versionfunction returnedfunction numberfunction set_system_power_statefunction isfunction apm_do_busyfunction apm_cpu_idlefunction apm_power_offfunction apm_enable_power_managementfunction apm_get_power_statusfunction systemfunction apm_console_blankfunction queue_emptyfunction get_queued_eventfunction queue_eventfunction reinit_timerfunction suspendfunction standbyfunction get_eventfunction check_eventsfunction apm_event_handlerfunction apm_mainloopfunction check_apm_userfunction do_readfunction do_pollfunction do_ioctlfunction do_releasefunction do_openfunction proc_apm_showfunction apmfunction apm_setupfunction print_if_truefunction broken_ps2_resumefunction set_realmode_power_offfunction set_apm_intsfunction apm_is_horkedfunction apm_is_horked_d850mdfunction apm_likes_to_melt
Annotated Snippet
static const struct file_operations apm_bios_fops = {
.owner = THIS_MODULE,
.read = do_read,
.poll = do_poll,
.unlocked_ioctl = do_ioctl,
.open = do_open,
.release = do_release,
.llseek = noop_llseek,
};
static struct miscdevice apm_device = {
APM_MINOR_DEV,
"apm_bios",
&apm_bios_fops
};
/* Simple "print if true" callback */
static int __init print_if_true(const struct dmi_system_id *d)
{
printk("%s\n", d->ident);
return 0;
}
/*
* Some Bioses enable the PS/2 mouse (touchpad) at resume, even if it was
* disabled before the suspend. Linux used to get terribly confused by that.
*/
static int __init broken_ps2_resume(const struct dmi_system_id *d)
{
printk(KERN_INFO "%s machine detected. Mousepad Resume Bug "
"workaround hopefully not needed.\n", d->ident);
return 0;
}
/* Some bioses have a broken protected mode poweroff and need to use realmode */
static int __init set_realmode_power_off(const struct dmi_system_id *d)
{
if (apm_info.realmode_power_off == 0) {
apm_info.realmode_power_off = 1;
printk(KERN_INFO "%s bios detected. "
"Using realmode poweroff only.\n", d->ident);
}
return 0;
}
/* Some laptops require interrupts to be enabled during APM calls */
static int __init set_apm_ints(const struct dmi_system_id *d)
{
if (apm_info.allow_ints == 0) {
apm_info.allow_ints = 1;
printk(KERN_INFO "%s machine detected. "
"Enabling interrupts during APM calls.\n", d->ident);
}
return 0;
}
/* Some APM bioses corrupt memory or just plain do not work */
static int __init apm_is_horked(const struct dmi_system_id *d)
{
if (apm_info.disabled == 0) {
apm_info.disabled = 1;
printk(KERN_INFO "%s machine detected. "
"Disabling APM.\n", d->ident);
}
return 0;
}
static int __init apm_is_horked_d850md(const struct dmi_system_id *d)
{
if (apm_info.disabled == 0) {
apm_info.disabled = 1;
printk(KERN_INFO "%s machine detected. "
"Disabling APM.\n", d->ident);
printk(KERN_INFO "This bug is fixed in bios P15 which is available for\n");
printk(KERN_INFO "download from support.intel.com\n");
}
return 0;
}
/* Some APM bioses hang on APM idle calls */
static int __init apm_likes_to_melt(const struct dmi_system_id *d)
{
if (apm_info.forbid_idle == 0) {
apm_info.forbid_idle = 1;
printk(KERN_INFO "%s machine detected. "
"Disabling APM idle calls.\n", d->ident);
}
return 0;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/poll.h`, `linux/types.h`, `linux/stddef.h`, `linux/timer.h`, `linux/fcntl.h`, `linux/slab.h`, `linux/stat.h`.
- Detected declarations: `struct apm_user`, `struct apm_bios_call`, `function apm_error`, `function __apm_irq_save`, `function apm_irq_restore`, `function AH`, `function on_cpu0`, `function apm_bios_call`, `function __apm_bios_call_simple`, `function apm_bios_call_simple`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.