Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * coreboot_table.h
0004  *
0005  * Internal header for coreboot table access.
0006  *
0007  * Copyright 2014 Gerd Hoffmann <kraxel@redhat.com>
0008  * Copyright 2017 Google Inc.
0009  * Copyright 2017 Samuel Holland <samuel@sholland.org>
0010  */
0011 
0012 #ifndef __COREBOOT_TABLE_H
0013 #define __COREBOOT_TABLE_H
0014 
0015 #include <linux/device.h>
0016 
0017 /* Coreboot table header structure */
0018 struct coreboot_table_header {
0019     char signature[4];
0020     u32 header_bytes;
0021     u32 header_checksum;
0022     u32 table_bytes;
0023     u32 table_checksum;
0024     u32 table_entries;
0025 };
0026 
0027 /* List of coreboot entry structures that is used */
0028 /* Generic */
0029 struct coreboot_table_entry {
0030     u32 tag;
0031     u32 size;
0032 };
0033 
0034 /* Points to a CBMEM entry */
0035 struct lb_cbmem_ref {
0036     u32 tag;
0037     u32 size;
0038 
0039     u64 cbmem_addr;
0040 };
0041 
0042 /* Describes framebuffer setup by coreboot */
0043 struct lb_framebuffer {
0044     u32 tag;
0045     u32 size;
0046 
0047     u64 physical_address;
0048     u32 x_resolution;
0049     u32 y_resolution;
0050     u32 bytes_per_line;
0051     u8  bits_per_pixel;
0052     u8  red_mask_pos;
0053     u8  red_mask_size;
0054     u8  green_mask_pos;
0055     u8  green_mask_size;
0056     u8  blue_mask_pos;
0057     u8  blue_mask_size;
0058     u8  reserved_mask_pos;
0059     u8  reserved_mask_size;
0060 };
0061 
0062 /* A device, additionally with information from coreboot. */
0063 struct coreboot_device {
0064     struct device dev;
0065     union {
0066         struct coreboot_table_entry entry;
0067         struct lb_cbmem_ref cbmem_ref;
0068         struct lb_framebuffer framebuffer;
0069     };
0070 };
0071 
0072 /* A driver for handling devices described in coreboot tables. */
0073 struct coreboot_driver {
0074     int (*probe)(struct coreboot_device *);
0075     void (*remove)(struct coreboot_device *);
0076     struct device_driver drv;
0077     u32 tag;
0078 };
0079 
0080 /* Register a driver that uses the data from a coreboot table. */
0081 int coreboot_driver_register(struct coreboot_driver *driver);
0082 
0083 /* Unregister a driver that uses the data from a coreboot table. */
0084 void coreboot_driver_unregister(struct coreboot_driver *driver);
0085 
0086 /* module_coreboot_driver() - Helper macro for drivers that don't do
0087  * anything special in module init/exit.  This eliminates a lot of
0088  * boilerplate.  Each module may only use this macro once, and
0089  * calling it replaces module_init() and module_exit()
0090  */
0091 #define module_coreboot_driver(__coreboot_driver) \
0092     module_driver(__coreboot_driver, coreboot_driver_register, \
0093             coreboot_driver_unregister)
0094 
0095 #endif /* __COREBOOT_TABLE_H */