arch/x86/xen/apic.c
Source file repositories/reference/linux-study-clean/arch/x86/xen/apic.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/xen/apic.c- Extension
.c- Size
- 2939 bytes
- Lines
- 149
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/thread_info.hasm/x86_init.hasm/apic.hasm/io_apic.hasm/xen/hypercall.hxen/xen.hxen/interface/physdev.hxen-ops.h
Detected Declarations
function xen_io_apic_readfunction xen_get_apic_idfunction xen_apic_readfunction xen_apic_writefunction xen_apic_eoifunction xen_apic_icr_readfunction xen_apic_icr_writefunction xen_apic_probe_pvfunction xen_madt_oem_checkfunction xen_cpu_present_to_apicidfunction xen_init_apic
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <linux/init.h>
#include <linux/thread_info.h>
#include <asm/x86_init.h>
#include <asm/apic.h>
#include <asm/io_apic.h>
#include <asm/xen/hypercall.h>
#include <xen/xen.h>
#include <xen/interface/physdev.h>
#include "xen-ops.h"
static unsigned int xen_io_apic_read(unsigned apic, unsigned reg)
{
struct physdev_apic apic_op;
int ret;
apic_op.apic_physbase = mpc_ioapic_addr(apic);
apic_op.reg = reg;
ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op);
if (!ret)
return apic_op.value;
/* fallback to return an emulated IO_APIC values */
if (reg == 0x1)
return 0x00170020;
else if (reg == 0x0)
return apic << 24;
return 0xfd;
}
static u32 xen_get_apic_id(u32 x)
{
return ((x)>>24) & 0xFFu;
}
static u32 xen_apic_read(u32 reg)
{
struct xen_platform_op op = {
.cmd = XENPF_get_cpuinfo,
.interface_version = XENPF_INTERFACE_VERSION,
};
int ret, cpu;
if (reg == APIC_LVR)
return 0x14;
if (reg != APIC_ID)
return 0;
cpu = smp_processor_id();
if (!xen_initial_domain())
return cpu ? cpuid_to_apicid[cpu] << 24 : 0;
op.u.pcpu_info.xen_cpuid = cpu;
ret = HYPERVISOR_platform_op(&op);
if (ret)
op.u.pcpu_info.apic_id = BAD_APICID;
return op.u.pcpu_info.apic_id << 24;
}
static void xen_apic_write(u32 reg, u32 val)
{
if (reg == APIC_LVTPC) {
(void)pmu_apic_update(reg);
return;
}
/* Warn to see if there's any stray references */
WARN(1,"register: %x, value: %x\n", reg, val);
}
static void xen_apic_eoi(void)
{
WARN_ON_ONCE(1);
}
static u64 xen_apic_icr_read(void)
{
return 0;
}
static void xen_apic_icr_write(u32 low, u32 id)
{
/* Warn to see if there's any stray references */
WARN_ON(1);
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/thread_info.h`, `asm/x86_init.h`, `asm/apic.h`, `asm/io_apic.h`, `asm/xen/hypercall.h`, `xen/xen.h`, `xen/interface/physdev.h`.
- Detected declarations: `function xen_io_apic_read`, `function xen_get_apic_id`, `function xen_apic_read`, `function xen_apic_write`, `function xen_apic_eoi`, `function xen_apic_icr_read`, `function xen_apic_icr_write`, `function xen_apic_probe_pv`, `function xen_madt_oem_check`, `function xen_cpu_present_to_apicid`.
- 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.