drivers/char/tpm/eventlog/common.c
Source file repositories/reference/linux-study-clean/drivers/char/tpm/eventlog/common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/tpm/eventlog/common.c- Extension
.c- Size
- 3730 bytes
- Lines
- 170
- Domain
- Driver Families
- Bucket
- drivers/char
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/seq_file.hlinux/fs.hlinux/security.hlinux/module.hlinux/tpm_eventlog.h../tpm.hcommon.h
Detected Declarations
function Copyrightfunction tpm_bios_measurements_releasefunction tpm_read_logfunction tpm_bios_log_setupfunction tpm_bios_log_teardown
Annotated Snippet
static const struct file_operations tpm_bios_measurements_ops = {
.owner = THIS_MODULE,
.open = tpm_bios_measurements_open,
.read = seq_read,
.llseek = seq_lseek,
.release = tpm_bios_measurements_release,
};
static int tpm_read_log(struct tpm_chip *chip)
{
int rc;
if (chip->log.bios_event_log != NULL) {
dev_dbg(&chip->dev,
"%s: ERROR - event log already initialized\n",
__func__);
return -EFAULT;
}
rc = tpm_read_log_acpi(chip);
if (rc != -ENODEV)
return rc;
rc = tpm_read_log_efi(chip);
if (rc != -ENODEV)
return rc;
return tpm_read_log_of(chip);
}
/*
* tpm_bios_log_setup() - Read the event log from the firmware
* @chip: TPM chip to use.
*
* If an event log is found then the securityfs files are setup to
* export it to userspace, otherwise nothing is done.
*/
void tpm_bios_log_setup(struct tpm_chip *chip)
{
const char *name = dev_name(&chip->dev);
struct dentry *dentry;
int log_version;
int rc = 0;
if (chip->flags & TPM_CHIP_FLAG_VIRTUAL)
return;
rc = tpm_read_log(chip);
if (rc < 0)
return;
log_version = rc;
chip->bios_dir = securityfs_create_dir(name, NULL);
/* NOTE: securityfs_create_dir can return ENODEV if securityfs is
* compiled out. The caller should ignore the ENODEV return code.
*/
if (IS_ERR(chip->bios_dir))
return;
chip->bin_log_seqops.chip = chip;
if (log_version == EFI_TCG2_EVENT_LOG_FORMAT_TCG_2)
chip->bin_log_seqops.seqops =
&tpm2_binary_b_measurements_seqops;
else
chip->bin_log_seqops.seqops =
&tpm1_binary_b_measurements_seqops;
dentry =
securityfs_create_file("binary_bios_measurements",
0440, chip->bios_dir,
(void *)&chip->bin_log_seqops,
&tpm_bios_measurements_ops);
if (IS_ERR(dentry))
goto err;
if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
chip->ascii_log_seqops.chip = chip;
chip->ascii_log_seqops.seqops =
&tpm1_ascii_b_measurements_seqops;
dentry =
securityfs_create_file("ascii_bios_measurements",
0440, chip->bios_dir,
(void *)&chip->ascii_log_seqops,
&tpm_bios_measurements_ops);
if (IS_ERR(dentry))
goto err;
}
Annotation
- Immediate include surface: `linux/seq_file.h`, `linux/fs.h`, `linux/security.h`, `linux/module.h`, `linux/tpm_eventlog.h`, `../tpm.h`, `common.h`.
- Detected declarations: `function Copyright`, `function tpm_bios_measurements_release`, `function tpm_read_log`, `function tpm_bios_log_setup`, `function tpm_bios_log_teardown`.
- Atlas domain: Driver Families / drivers/char.
- Implementation status: pattern 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.