• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/device.h>
16 
17 /* Coreboot table header structure */
18 struct coreboot_table_header {
19 	char signature[4];
20 	u32 header_bytes;
21 	u32 header_checksum;
22 	u32 table_bytes;
23 	u32 table_checksum;
24 	u32 table_entries;
25 };
26 
27 /* List of coreboot entry structures that is used */
28 /* Generic */
29 struct coreboot_table_entry {
30 	u32 tag;
31 	u32 size;
32 };
33 
34 /* Points to a CBMEM entry */
35 struct lb_cbmem_ref {
36 	u32 tag;
37 	u32 size;
38 
39 	u64 cbmem_addr;
40 };
41 
42 /* Describes framebuffer setup by coreboot */
43 struct lb_framebuffer {
44 	u32 tag;
45 	u32 size;
46 
47 	u64 physical_address;
48 	u32 x_resolution;
49 	u32 y_resolution;
50 	u32 bytes_per_line;
51 	u8  bits_per_pixel;
52 	u8  red_mask_pos;
53 	u8  red_mask_size;
54 	u8  green_mask_pos;
55 	u8  green_mask_size;
56 	u8  blue_mask_pos;
57 	u8  blue_mask_size;
58 	u8  reserved_mask_pos;
59 	u8  reserved_mask_size;
60 };
61 
62 /* A device, additionally with information from coreboot. */
63 struct coreboot_device {
64 	struct device dev;
65 	union {
66 		struct coreboot_table_entry entry;
67 		struct lb_cbmem_ref cbmem_ref;
68 		struct lb_framebuffer framebuffer;
69 		DECLARE_FLEX_ARRAY(u8, raw);
70 	};
71 };
72 
73 /* A driver for handling devices described in coreboot tables. */
74 struct coreboot_driver {
75 	int (*probe)(struct coreboot_device *);
76 	void (*remove)(struct coreboot_device *);
77 	struct device_driver drv;
78 	u32 tag;
79 };
80 
81 /* Register a driver that uses the data from a coreboot table. */
82 int coreboot_driver_register(struct coreboot_driver *driver);
83 
84 /* Unregister a driver that uses the data from a coreboot table. */
85 void coreboot_driver_unregister(struct coreboot_driver *driver);
86 
87 /* module_coreboot_driver() - Helper macro for drivers that don't do
88  * anything special in module init/exit.  This eliminates a lot of
89  * boilerplate.  Each module may only use this macro once, and
90  * calling it replaces module_init() and module_exit()
91  */
92 #define module_coreboot_driver(__coreboot_driver) \
93 	module_driver(__coreboot_driver, coreboot_driver_register, \
94 			coreboot_driver_unregister)
95 
96 #endif /* __COREBOOT_TABLE_H */
97