drivers/firmware/google/coreboot_table.c

Source file repositories/reference/linux-study-clean/drivers/firmware/google/coreboot_table.c

File Facts

System
Linux kernel
Corpus path
drivers/firmware/google/coreboot_table.c
Extension
.c
Size
6352 bytes
Lines
278
Domain
Driver Families
Bucket
drivers/firmware
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.

Dependency Surface

Detected Declarations

Annotated Snippet

static int coreboot_bus_match(struct device *dev, const struct device_driver *drv)
{
	struct coreboot_device *device = CB_DEV(dev);
	const struct coreboot_driver *driver = CB_DRV(drv);
	const struct coreboot_device_id *id;

	if (!driver->id_table)
		return 0;

	for (id = driver->id_table; id->tag; id++) {
		if (device->entry.tag == id->tag)
			return 1;
	}

	return 0;
}

static int coreboot_bus_probe(struct device *dev)
{
	int ret = -ENODEV;
	struct coreboot_device *device = CB_DEV(dev);
	struct coreboot_driver *driver = CB_DRV(dev->driver);

	if (driver->probe)
		ret = driver->probe(device);

	return ret;
}

static void coreboot_bus_remove(struct device *dev)
{
	struct coreboot_device *device = CB_DEV(dev);
	struct coreboot_driver *driver = CB_DRV(dev->driver);

	if (driver->remove)
		driver->remove(device);
}

static int coreboot_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
	struct coreboot_device *device = CB_DEV(dev);
	u32 tag = device->entry.tag;

	return add_uevent_var(env, "MODALIAS=coreboot:t%08X", tag);
}

static const struct bus_type coreboot_bus_type = {
	.name		= "coreboot",
	.match		= coreboot_bus_match,
	.probe		= coreboot_bus_probe,
	.remove		= coreboot_bus_remove,
	.uevent		= coreboot_bus_uevent,
};

static void coreboot_device_release(struct device *dev)
{
	struct coreboot_device *device = CB_DEV(dev);

	kfree(device);
}

int __coreboot_driver_register(struct coreboot_driver *driver,
			       struct module *owner)
{
	driver->drv.bus = &coreboot_bus_type;
	driver->drv.owner = owner;

	return driver_register(&driver->drv);
}
EXPORT_SYMBOL(__coreboot_driver_register);

void coreboot_driver_unregister(struct coreboot_driver *driver)
{
	driver_unregister(&driver->drv);
}
EXPORT_SYMBOL(coreboot_driver_unregister);

static int coreboot_table_populate(struct device *dev, void *ptr, resource_size_t len)
{
	int i, ret;
	void *ptr_entry;
	struct coreboot_device *device;
	struct coreboot_table_entry *entry;
	struct coreboot_table_header *header = ptr;
	void *ptr_end;

	ptr_end = ptr + len;
	ptr_entry = ptr + header->header_bytes;
	for (i = 0; i < header->table_entries; i++) {
		if (ptr_entry + sizeof(*entry) > ptr_end)

Annotation

Implementation Notes