summaryrefslogtreecommitdiff
path: root/firmware/include/bmpblk_header.h
blob: 70e480a5f757786f3b879ce710025317fea7e061 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 *
 * Data structure definitions for firmware screen block (BMPBLOCK).
 *
 * The BmpBlock structure looks like:
 *  +-----------------------------------------+
 *  |             BmpBlock Header             |
 *  +-----------------------------------------+
 *  |             ScreenLayout[0]             | \
 *  +-----------------------------------------+  |
 *  |             ScreenLayout[1]             |  |
 *  +-----------------------------------------+  Localization[0]
 *  |                  ...                    |  |
 *  +-----------------------------------------+  |
 *  | ScreenLayout[number_of_screenlayouts-1] | /
 *  +-----------------------------------------+
 *  |             ScreenLayout[0]             | \
 *  +-----------------------------------------+  Localization[1]
 *  |                  ...                    | /
 *  +-----------------------------------------+        ...
 *  |             ScreenLayout[0]             | \
 *  +-----------------------------------------+  Localization[
 *  |                  ...                    | /   number_of_localizations-1]
 *  +-----------------------------------------+
 *  |              ImageInfo[0]               |
 *  +-----------------------------------------+
 *  |              Image Content              |
 *  +-----------------------------------------+
 *  |              ImageInfo[2]               |  ImageInfo is 4-byte aligned.
 *  +-----------------------------------------+
 *  |              Image Content              |
 *  +-----------------------------------------+
 *  |                  ...                    |
 *  +-----------------------------------------+
 *  |      ImageInfo[number_fo_images-1]      |
 *  +-----------------------------------------+
 *  |              Image Content              |
 *  +-----------------------------------------+
 *  |        List of locale names             |
 *  +-----------------------------------------+
 */
#ifndef VBOOT_REFERENCE_BMPBLK_HEADER_H_
#define VBOOT_REFERENCE_BMPBLK_HEADER_H_
#include <stdint.h>

#define BMPBLOCK_SIGNATURE      "$BMP"
#define BMPBLOCK_SIGNATURE_SIZE (4)

#define BMPBLOCK_MAJOR_VERSION  (0x0002)
#define BMPBLOCK_MINOR_VERSION  (0x0000)

#define MAX_IMAGE_IN_LAYOUT     (16)

/* BMPBLOCK header, describing how many screen layouts and image infos */
typedef struct BmpBlockHeader {
	/* BMPBLOCK_SIGNATURE $BMP */
	uint8_t  signature[BMPBLOCK_SIGNATURE_SIZE];
	uint16_t major_version;            /* see BMPBLOCK_MAJOR_VER */
	uint16_t minor_version;            /* see BMPBLOCK_MINOR_VER */
	uint32_t number_of_localizations;  /* Number of localizations */
	/* Number of screen layouts in each localization */
	uint32_t number_of_screenlayouts;
	uint32_t number_of_imageinfos;     /* Number of image infos */
	/* Offset of locale-translation string */
	uint32_t locale_string_offset;
	uint32_t reserved[2];
} __attribute__((packed)) BmpBlockHeader;

/* Screen layout, describing how to stack multiple images on screen */
typedef struct ScreenLayout {
	/*
	 * Images contained in the screen. Will be rendered from 0 to
	 * (number_of_images-1).
	 */
	struct {
		/* (X,Y) offset of image to be rendered */
		uint32_t x;
		uint32_t y;
		/* Offset of image info from start of BMPBLOCK; 0=end it. */
		uint32_t image_info_offset;
	} images[MAX_IMAGE_IN_LAYOUT];
} __attribute__((packed)) ScreenLayout;

/* Constants for screen index */
typedef enum ScreenIndex {
	SCREEN_DEVELOPER_WARNING = 0,
	SCREEN_RECOVERY_REMOVE,
	SCREEN_RECOVERY_NO_GOOD,
	SCREEN_RECOVERY_INSERT,
	SCREEN_RECOVERY_TO_DEV,
	SCREEN_DEVELOPER_TO_NORM,
	SCREEN_WAIT,
	SCREEN_TO_NORM_CONFIRMED,
        SCREEN_CHARGING,
        SCREEN_CHARGING_EMPTY,
        SCREEN_WRONG_ADAPTER,
	MAX_VALID_SCREEN_INDEX,
	SCREEN_BLANK = ~0UL,
} ScreenIndex;

/* Image info, describing the information of the image block */
typedef struct ImageInfo {
	uint32_t tag;              /* Tag it as a special image, like HWID */
	uint32_t width;            /* Width of the image */
	uint32_t height;           /* Height of the image */
	uint32_t format;           /* File format of the image */
	uint32_t compression;      /* Compression method for the image file */
	uint32_t original_size;    /* Size of the original uncompressed image */
	/*
	 * Size of the compressed image; if image is not compressed, this will
	 * be the same as the original size.
	 */
	uint32_t compressed_size;
	uint32_t reserved;
  /* NOTE: The actual image content (if any) follows immediately. */
} __attribute__((packed)) ImageInfo;

/* Constants for ImageInfo.tag */
typedef enum ImageTag {
	TAG_NONE = 0,
	TAG_HWID,
	TAG_HWID_RTOL,  /* "right-to-left", ie, right-justified HWID */
} ImageTag;

/* Constants for ImageInfo.format */
typedef enum ImageFormat {
	FORMAT_INVALID = 0,
	FORMAT_BMP,
	FORMAT_FONT,
} ImageFormat;

/*
 * These magic image names can be used in the .yaml file to indicate that the
 * ASCII HWID should be displayed. For RENDER_HWID, the image coordinates
 * specify upper-left corner of the HWID string. For RENDER_HWID_RTOL, they
 * indicate the upper-right corner (handy for right-to-left languages).
 */
#define RENDER_HWID       "$HWID"
#define RENDER_HWID_RTOL  "$HWID.rtol"

#endif  /* VBOOT_REFERENCE_BMPBLK_HEADER_H_ */