Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * coreboot_table.h
4 *
5 * Internal header for coreboot table access.
6 *
7 * Copyright 2014 Gerd Hoffmann <kraxel@redhat.com>
8 * Copyright 2017 Google Inc.
9 * Copyright 2017 Samuel Holland <samuel@sholland.org>
10 */
11
12#ifndef __COREBOOT_TABLE_H
13#define __COREBOOT_TABLE_H
14
15#include <linux/coreboot.h>
16#include <linux/device.h>
17
18/* A device, additionally with information from coreboot. */
19struct coreboot_device {
20 struct device dev;
21 union {
22 struct coreboot_table_entry entry;
23 struct lb_cbmem_ref cbmem_ref;
24 struct lb_cbmem_entry cbmem_entry;
25 struct lb_framebuffer framebuffer;
26 DECLARE_FLEX_ARRAY(u8, raw);
27 };
28};
29
30static inline struct coreboot_device *dev_to_coreboot_device(struct device *dev)
31{
32 return container_of(dev, struct coreboot_device, dev);
33}
34
35/* A driver for handling devices described in coreboot tables. */
36struct coreboot_driver {
37 int (*probe)(struct coreboot_device *);
38 void (*remove)(struct coreboot_device *);
39 struct device_driver drv;
40 const struct coreboot_device_id *id_table;
41};
42
43/* use a macro to avoid include chaining to get THIS_MODULE */
44#define coreboot_driver_register(driver) \
45 __coreboot_driver_register(driver, THIS_MODULE)
46/* Register a driver that uses the data from a coreboot table. */
47int __coreboot_driver_register(struct coreboot_driver *driver,
48 struct module *owner);
49
50/* Unregister a driver that uses the data from a coreboot table. */
51void coreboot_driver_unregister(struct coreboot_driver *driver);
52
53/* module_coreboot_driver() - Helper macro for drivers that don't do
54 * anything special in module init/exit. This eliminates a lot of
55 * boilerplate. Each module may only use this macro once, and
56 * calling it replaces module_init() and module_exit()
57 */
58#define module_coreboot_driver(__coreboot_driver) \
59 module_driver(__coreboot_driver, coreboot_driver_register, \
60 coreboot_driver_unregister)
61
62#endif /* __COREBOOT_TABLE_H */