| 1 |
|
| 2 | |
| 3 | * coreboot_table.h
|
| 4 | *
|
| 5 | * Internal header for coreboot table access.
|
| 6 | *
|
| 7 | * Copyright 2014 Gerd Hoffmann <[email protected]>
|
| 8 | * Copyright 2017 Google Inc.
|
| 9 | * Copyright 2017 Samuel Holland <[email protected]>
|
| 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 |
|
| 19 | struct 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 |
|
| 30 | static inline struct coreboot_device *dev_to_coreboot_device(struct device *dev)
|
| 31 | {
|
| 32 | return container_of(dev, struct coreboot_device, dev);
|
| 33 | }
|
| 34 |
|
| 35 |
|
| 36 | struct 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 |
|
| 44 | #define coreboot_driver_register(driver) \
|
| 45 | __coreboot_driver_register(driver, THIS_MODULE)
|
| 46 |
|
| 47 | int __coreboot_driver_register(struct coreboot_driver *driver,
|
| 48 | struct module *owner);
|
| 49 |
|
| 50 |
|
| 51 | void coreboot_driver_unregister(struct coreboot_driver *driver);
|
| 52 |
|
| 53 | |
| 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
|