bmpblk_header.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
  2. * Use of this source code is governed by a BSD-style license that can be
  3. * found in the LICENSE file.
  4. *
  5. * Data structure definitions for firmware screen block (BMPBLOCK).
  6. *
  7. * The BmpBlock structure looks like:
  8. * +-----------------------------------------+
  9. * | BmpBlock Header |
  10. * +-----------------------------------------+
  11. * | ScreenLayout[0] | \
  12. * +-----------------------------------------+ |
  13. * | ScreenLayout[1] | |
  14. * +-----------------------------------------+ Localization[0]
  15. * | ... | |
  16. * +-----------------------------------------+ |
  17. * | ScreenLayout[number_of_screenlayouts-1] | /
  18. * +-----------------------------------------+
  19. * | ScreenLayout[0] | \
  20. * +-----------------------------------------+ Localization[1]
  21. * | ... | /
  22. * +-----------------------------------------+ ...
  23. * | ScreenLayout[0] | \
  24. * +-----------------------------------------+ Localization[
  25. * | ... | / number_of_localizations-1]
  26. * +-----------------------------------------+
  27. * | ImageInfo[0] |
  28. * +-----------------------------------------+
  29. * | Image Content |
  30. * +-----------------------------------------+
  31. * | ImageInfo[2] | ImageInfo is 4-byte aligned.
  32. * +-----------------------------------------+
  33. * | Image Content |
  34. * +-----------------------------------------+
  35. * | ... |
  36. * +-----------------------------------------+
  37. * | ImageInfo[number_fo_images-1] |
  38. * +-----------------------------------------+
  39. * | Image Content |
  40. * +-----------------------------------------+
  41. * | List of locale names |
  42. * +-----------------------------------------+
  43. */
  44. #ifndef VBOOT_REFERENCE_BMPBLK_HEADER_H_
  45. #define VBOOT_REFERENCE_BMPBLK_HEADER_H_
  46. #include <stdint.h>
  47. #define BMPBLOCK_SIGNATURE "$BMP"
  48. #define BMPBLOCK_SIGNATURE_SIZE (4)
  49. #define BMPBLOCK_MAJOR_VERSION (0x0002)
  50. #define BMPBLOCK_MINOR_VERSION (0x0000)
  51. #define MAX_IMAGE_IN_LAYOUT (16)
  52. /* BMPBLOCK header, describing how many screen layouts and image infos */
  53. typedef struct BmpBlockHeader {
  54. /* BMPBLOCK_SIGNATURE $BMP */
  55. uint8_t signature[BMPBLOCK_SIGNATURE_SIZE];
  56. uint16_t major_version; /* see BMPBLOCK_MAJOR_VER */
  57. uint16_t minor_version; /* see BMPBLOCK_MINOR_VER */
  58. uint32_t number_of_localizations; /* Number of localizations */
  59. /* Number of screen layouts in each localization */
  60. uint32_t number_of_screenlayouts;
  61. uint32_t number_of_imageinfos; /* Number of image infos */
  62. /* Offset of locale-translation string */
  63. uint32_t locale_string_offset;
  64. uint32_t reserved[2];
  65. } __attribute__((packed)) BmpBlockHeader;
  66. /* Screen layout, describing how to stack multiple images on screen */
  67. typedef struct ScreenLayout {
  68. /*
  69. * Images contained in the screen. Will be rendered from 0 to
  70. * (number_of_images-1).
  71. */
  72. struct {
  73. /* (X,Y) offset of image to be rendered */
  74. uint32_t x;
  75. uint32_t y;
  76. /* Offset of image info from start of BMPBLOCK; 0=end it. */
  77. uint32_t image_info_offset;
  78. } images[MAX_IMAGE_IN_LAYOUT];
  79. } __attribute__((packed)) ScreenLayout;
  80. /* Constants for screen index */
  81. typedef enum ScreenIndex {
  82. SCREEN_DEVELOPER_WARNING = 0,
  83. SCREEN_RECOVERY_REMOVE,
  84. SCREEN_RECOVERY_NO_GOOD,
  85. SCREEN_RECOVERY_INSERT,
  86. SCREEN_RECOVERY_TO_DEV,
  87. SCREEN_DEVELOPER_TO_NORM,
  88. SCREEN_WAIT,
  89. SCREEN_TO_NORM_CONFIRMED,
  90. SCREEN_OS_BROKEN,
  91. MAX_VALID_SCREEN_INDEX,
  92. SCREEN_BLANK = ~0UL,
  93. } ScreenIndex;
  94. /* Image info, describing the information of the image block */
  95. typedef struct ImageInfo {
  96. uint32_t tag; /* Tag it as a special image, like HWID */
  97. uint32_t width; /* Width of the image */
  98. uint32_t height; /* Height of the image */
  99. uint32_t format; /* File format of the image */
  100. uint32_t compression; /* Compression method for the image file */
  101. uint32_t original_size; /* Size of the original uncompressed image */
  102. /*
  103. * Size of the compressed image; if image is not compressed, this will
  104. * be the same as the original size.
  105. */
  106. uint32_t compressed_size;
  107. uint32_t reserved;
  108. /* NOTE: The actual image content (if any) follows immediately. */
  109. } __attribute__((packed)) ImageInfo;
  110. /* Constants for ImageInfo.tag */
  111. typedef enum ImageTag {
  112. TAG_NONE = 0,
  113. TAG_HWID,
  114. TAG_HWID_RTOL, /* "right-to-left", ie, right-justified HWID */
  115. } ImageTag;
  116. /* Constants for ImageInfo.format */
  117. typedef enum ImageFormat {
  118. FORMAT_INVALID = 0,
  119. FORMAT_BMP,
  120. FORMAT_FONT,
  121. } ImageFormat;
  122. /*
  123. * These magic image names can be used in the .yaml file to indicate that the
  124. * ASCII HWID should be displayed. For RENDER_HWID, the image coordinates
  125. * specify upper-left corner of the HWID string. For RENDER_HWID_RTOL, they
  126. * indicate the upper-right corner (handy for right-to-left languages).
  127. */
  128. #define RENDER_HWID "$HWID"
  129. #define RENDER_HWID_RTOL "$HWID.rtol"
  130. #endif /* VBOOT_REFERENCE_BMPBLK_HEADER_H_ */