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 
48 #define BMPBLOCK_SIGNATURE      "$BMP"
49 #define BMPBLOCK_SIGNATURE_SIZE (4)
50 
51 #define BMPBLOCK_MAJOR_VERSION  (0x0002)
52 #define BMPBLOCK_MINOR_VERSION  (0x0000)
53 
54 #define MAX_IMAGE_IN_LAYOUT     (16)
55 
56 /* BMPBLOCK header, describing how many screen layouts and image infos */
57 typedef struct BmpBlockHeader {
58 	/* BMPBLOCK_SIGNATURE $BMP */
59 	uint8_t  signature[BMPBLOCK_SIGNATURE_SIZE];
60 	uint16_t major_version;            /* see BMPBLOCK_MAJOR_VER */
61 	uint16_t minor_version;            /* see BMPBLOCK_MINOR_VER */
62 	uint32_t number_of_localizations;  /* Number of localizations */
63 	/* Number of screen layouts in each localization */
64 	uint32_t number_of_screenlayouts;
65 	uint32_t number_of_imageinfos;     /* Number of image infos */
66 	/* Offset of locale-translation string */
67 	uint32_t locale_string_offset;
68 	uint32_t reserved[2];
69 } __attribute__((packed)) BmpBlockHeader;
70 
71 /* Screen layout, describing how to stack multiple images on screen */
72 typedef struct ScreenLayout {
73 	/*
74 	 * Images contained in the screen. Will be rendered from 0 to
75 	 * (number_of_images-1).
76 	 */
77 	struct {
78 		/* (X,Y) offset of image to be rendered */
79 		uint32_t x;
80 		uint32_t y;
81 		/* Offset of image info from start of BMPBLOCK; 0=end it. */
82 		uint32_t image_info_offset;
83 	} images[MAX_IMAGE_IN_LAYOUT];
84 } __attribute__((packed)) ScreenLayout;
85 
86 /* Constants for screen index */
87 typedef enum ScreenIndex {
88 	SCREEN_DEVELOPER_WARNING = 0,
89 	SCREEN_RECOVERY_REMOVE,
90 	SCREEN_RECOVERY_NO_GOOD,
91 	SCREEN_RECOVERY_INSERT,
92 	SCREEN_RECOVERY_TO_DEV,
93 	SCREEN_DEVELOPER_TO_NORM,
94 	SCREEN_WAIT,
95 	SCREEN_TO_NORM_CONFIRMED,
96 	MAX_VALID_SCREEN_INDEX,
97 	SCREEN_BLANK = ~0UL,
98 } ScreenIndex;
99 
100 /* Image info, describing the information of the image block */
101 typedef struct ImageInfo {
102 	uint32_t tag;              /* Tag it as a special image, like HWID */
103 	uint32_t width;            /* Width of the image */
104 	uint32_t height;           /* Height of the image */
105 	uint32_t format;           /* File format of the image */
106 	uint32_t compression;      /* Compression method for the image file */
107 	uint32_t original_size;    /* Size of the original uncompressed image */
108 	/*
109 	 * Size of the compressed image; if image is not compressed, this will
110 	 * be the same as the original size.
111 	 */
112 	uint32_t compressed_size;
113 	uint32_t reserved;
114   /* NOTE: The actual image content (if any) follows immediately. */
115 } __attribute__((packed)) ImageInfo;
116 
117 /* Constants for ImageInfo.tag */
118 typedef enum ImageTag {
119 	TAG_NONE = 0,
120 	TAG_HWID,
121 	TAG_HWID_RTOL,  /* "right-to-left", ie, right-justified HWID */
122 } ImageTag;
123 
124 /* Constants for ImageInfo.format */
125 typedef enum ImageFormat {
126 	FORMAT_INVALID = 0,
127 	FORMAT_BMP,
128 	FORMAT_FONT,
129 } ImageFormat;
130 
131 /*
132  * These magic image names can be used in the .yaml file to indicate that the
133  * ASCII HWID should be displayed. For RENDER_HWID, the image coordinates
134  * specify upper-left corner of the HWID string. For RENDER_HWID_RTOL, they
135  * indicate the upper-right corner (handy for right-to-left languages).
136  */
137 #define RENDER_HWID       "$HWID"
138 #define RENDER_HWID_RTOL  "$HWID.rtol"
139 
140 #endif  /* VBOOT_REFERENCE_BMPBLK_HEADER_H_ */
141