arch/x86/kernel/ksysfs.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/ksysfs.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/ksysfs.c- Extension
.c- Size
- 8078 bytes
- Lines
- 402
- 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/kobject.hlinux/string.hlinux/sysfs.hlinux/init.hlinux/stat.hlinux/slab.hlinux/mm.hlinux/io.hasm/setup.h
Detected Declarations
function Copyrightfunction boot_params_data_readfunction kobj_to_setup_data_nrfunction get_setup_data_paddrfunction get_setup_data_sizefunction type_showfunction setup_data_data_readfunction create_setup_data_nodefunction cleanup_setup_data_nodefunction get_setup_data_total_numfunction create_setup_data_nodesfunction boot_params_ksysfs_init
Annotated Snippet
if (nr == i) {
*paddr = pa_data;
return 0;
}
data = memremap(pa_data, sizeof(*data), MEMREMAP_WB);
if (!data)
return -ENOMEM;
pa_data = data->next;
memunmap(data);
i++;
}
return -EINVAL;
}
static int __init get_setup_data_size(int nr, size_t *size)
{
u64 pa_data = boot_params.hdr.setup_data, pa_next;
struct setup_indirect *indirect;
struct setup_data *data;
int i = 0;
u32 len;
while (pa_data) {
data = memremap(pa_data, sizeof(*data), MEMREMAP_WB);
if (!data)
return -ENOMEM;
pa_next = data->next;
if (nr == i) {
if (data->type == SETUP_INDIRECT) {
len = sizeof(*data) + data->len;
memunmap(data);
data = memremap(pa_data, len, MEMREMAP_WB);
if (!data)
return -ENOMEM;
indirect = (struct setup_indirect *)data->data;
if (indirect->type != SETUP_INDIRECT)
*size = indirect->len;
else
*size = data->len;
} else {
*size = data->len;
}
memunmap(data);
return 0;
}
pa_data = pa_next;
memunmap(data);
i++;
}
return -EINVAL;
}
static ssize_t type_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
struct setup_indirect *indirect;
struct setup_data *data;
int nr, ret;
u64 paddr;
u32 len;
ret = kobj_to_setup_data_nr(kobj, &nr);
if (ret)
return ret;
ret = get_setup_data_paddr(nr, &paddr);
if (ret)
return ret;
data = memremap(paddr, sizeof(*data), MEMREMAP_WB);
if (!data)
return -ENOMEM;
if (data->type == SETUP_INDIRECT) {
len = sizeof(*data) + data->len;
memunmap(data);
data = memremap(paddr, len, MEMREMAP_WB);
if (!data)
return -ENOMEM;
indirect = (struct setup_indirect *)data->data;
ret = sprintf(buf, "0x%x\n", indirect->type);
} else {
ret = sprintf(buf, "0x%x\n", data->type);
Annotation
- Immediate include surface: `linux/kobject.h`, `linux/string.h`, `linux/sysfs.h`, `linux/init.h`, `linux/stat.h`, `linux/slab.h`, `linux/mm.h`, `linux/io.h`.
- Detected declarations: `function Copyright`, `function boot_params_data_read`, `function kobj_to_setup_data_nr`, `function get_setup_data_paddr`, `function get_setup_data_size`, `function type_show`, `function setup_data_data_read`, `function create_setup_data_node`, `function cleanup_setup_data_node`, `function get_setup_data_total_num`.
- 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.