coreboot_table.h 2.2 KB

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