drivers/firmware/efi/rci2-table.c
Source file repositories/reference/linux-study-clean/drivers/firmware/efi/rci2-table.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/efi/rci2-table.c- Extension
.c- Size
- 3114 bytes
- Lines
- 143
- Domain
- Driver Families
- Bucket
- drivers/firmware
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kobject.hlinux/device.hlinux/sysfs.hlinux/efi.hlinux/types.hlinux/io.h
Detected Declarations
struct rci2_table_global_hdrfunction checksumfunction efi_rci2_sysfs_init
Annotated Snippet
struct rci2_table_global_hdr {
u16 type;
u16 resvd0;
u16 hdr_len;
u8 rci2_sig[4];
u16 resvd1;
u32 resvd2;
u32 resvd3;
u8 major_rev;
u8 minor_rev;
u16 num_of_structs;
u32 rci2_len;
u16 rci2_chksum;
} __packed;
static u8 *rci2_base;
static u32 rci2_table_len;
unsigned long rci2_table_phys __ro_after_init = EFI_INVALID_TABLE_ADDR;
static __ro_after_init BIN_ATTR_SIMPLE_ADMIN_RO(rci2);
static u16 checksum(void)
{
u8 len_is_odd = rci2_table_len % 2;
u32 chksum_len = rci2_table_len;
u16 *base = (u16 *)rci2_base;
u8 buf[2] = {0};
u32 offset = 0;
u16 chksum = 0;
if (len_is_odd)
chksum_len -= 1;
while (offset < chksum_len) {
chksum += *base;
offset += 2;
base++;
}
if (len_is_odd) {
buf[0] = *(u8 *)base;
chksum += *(u16 *)(buf);
}
return chksum;
}
static int __init efi_rci2_sysfs_init(void)
{
struct kobject *tables_kobj;
int ret = -ENOMEM;
if (rci2_table_phys == EFI_INVALID_TABLE_ADDR)
return 0;
rci2_base = memremap(rci2_table_phys,
sizeof(struct rci2_table_global_hdr),
MEMREMAP_WB);
if (!rci2_base) {
pr_debug("RCI2 table init failed - could not map RCI2 table\n");
goto err;
}
if (strncmp(rci2_base +
offsetof(struct rci2_table_global_hdr, rci2_sig),
RCI_SIGNATURE, 4)) {
pr_debug("RCI2 table init failed - incorrect signature\n");
ret = -ENODEV;
goto err_unmap;
}
rci2_table_len = *(u32 *)(rci2_base +
offsetof(struct rci2_table_global_hdr,
rci2_len));
memunmap(rci2_base);
if (!rci2_table_len) {
pr_debug("RCI2 table init failed - incorrect table length\n");
goto err;
}
rci2_base = memremap(rci2_table_phys, rci2_table_len, MEMREMAP_WB);
if (!rci2_base) {
pr_debug("RCI2 table - could not map RCI2 table\n");
goto err;
}
if (checksum() != 0) {
pr_debug("RCI2 table - incorrect checksum\n");
Annotation
- Immediate include surface: `linux/kobject.h`, `linux/device.h`, `linux/sysfs.h`, `linux/efi.h`, `linux/types.h`, `linux/io.h`.
- Detected declarations: `struct rci2_table_global_hdr`, `function checksum`, `function efi_rci2_sysfs_init`.
- Atlas domain: Driver Families / drivers/firmware.
- 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.