1 // Copyright 2018 The Fuchsia 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 #pragma once
6
7 #ifndef __ASSEMBLER__
8 #include <stdint.h>
9 #endif
10
11 // Zircon Boot Image format (ZBI).
12 //
13 // A Zircon Boot Image consists of a container header followed by boot
14 // items. Each boot item has a header (zbi_header_t) and then a payload of
15 // zbi_header_t.length bytes, which can be any size. The zbi_header_t.type
16 // field indicates how to interpret the payload. Many types specify an
17 // additional type-specific header that begins a variable-sized payload.
18 // zbi_header_t.length does not include the zbi_header_t itself, but does
19 // include any type-specific headers as part of the payload. All fields in
20 // all header formats are little-endian.
21 //
22 // Padding bytes appear after each item as needed to align the payload size
23 // up to a ZBI_ALIGNMENT (8-byte) boundary. This padding is not reflected
24 // in the zbi_header_t.length value.
25 //
26 // A "complete" ZBI can be booted by a Zircon-compatible boot loader.
27 // It contains one ZBI_TYPE_KERNEL_{ARCH} boot item that must come first,
28 // followed by any number of additional boot items, which must include
29 // exactly one ZBI_TYPE_STORAGE_BOOTFS item.
30 //
31 // A partial ZBI cannot be booted, and is only used during the build process.
32 // It contains one or more boot items and can be combined with other ZBIs to
33 // make a complete ZBI.
34
35 // All items begin at an 8-byte aligned offset into the image.
36 #ifdef __ASSEMBLER__
37 #define ZBI_ALIGNMENT (8)
38 #else
39 #define ZBI_ALIGNMENT (8u)
40 #endif
41
42 // Round n up to the next 8 byte boundary
43 #ifndef __ASSEMBLER__
44 #ifdef __cplusplus
45 constexpr
46 #endif
ZBI_ALIGN(uint32_t n)47 static inline uint32_t ZBI_ALIGN(uint32_t n) {
48 return ((n + ZBI_ALIGNMENT - 1) & -ZBI_ALIGNMENT);
49 }
50 #endif
51
52 // LSW of sha256("bootdata")
53 #define ZBI_CONTAINER_MAGIC (0x868cf7e6)
54
55 // LSW of sha256("bootitem")
56 #define ZBI_ITEM_MAGIC (0xb5781729)
57
58 // This flag is always required.
59 #define ZBI_FLAG_VERSION (0x00010000)
60
61 // ZBI items with the CRC32 flag must have a valid crc32.
62 // Otherwise their crc32 field must contain ZBI_ITEM_NO_CRC32
63 #define ZBI_FLAG_CRC32 (0x00020000)
64
65 // Value for zbi_header_t.crc32 when ZBI_FLAG_CRC32 is not set.
66 #define ZBI_ITEM_NO_CRC32 (0x4a87e8d6)
67
68 #ifndef __ASSEMBLER__
69 // Each header must be 8-byte aligned. The length field specifies the
70 // actual payload length and does not include the size of padding.
71 typedef struct {
72 // ZBI_TYPE_* constant, see below.
73 uint32_t type;
74
75 // Size of the payload immediately following this header. This
76 // does not include the header itself nor any alignment padding
77 // after the payload.
78 uint32_t length;
79
80 // Type-specific extra data. Each type specifies the use of this
81 // field; see below. When not explicitly specified, it should be zero.
82 uint32_t extra;
83
84 // Flags for this item. This must always include ZBI_FLAG_VERSION.
85 // It should contain ZBI_FLAG_CRC32 for any item where it's feasible
86 // to compute the CRC32 at build time. Other flags are specific to
87 // each type; see below.
88 uint32_t flags;
89
90 // For future expansion. Set to 0.
91 uint32_t reserved0;
92 uint32_t reserved1;
93
94 // Must be ZBI_ITEM_MAGIC.
95 uint32_t magic;
96
97 // Must be the CRC32 of payload if ZBI_FLAG_CRC32 is set,
98 // otherwise must be ZBI_ITEM_NO_CRC32.
99 uint32_t crc32;
100 } zbi_header_t;
101 #endif
102
103 // Be sure to add new types to ZBI_ALL_TYPES.
104 #define ZBI_ALL_TYPES(macro) \
105 macro(ZBI_TYPE_CONTAINER, "CONTAINER", ".bin") \
106 macro(ZBI_TYPE_KERNEL_X64, "KERNEL_X64", ".bin") \
107 macro(ZBI_TYPE_KERNEL_ARM64, "KERNEL_ARM64", ".bin") \
108 macro(ZBI_TYPE_DISCARD, "DISCARD", ".bin") \
109 macro(ZBI_TYPE_STORAGE_RAMDISK, "RAMDISK", ".bin") \
110 macro(ZBI_TYPE_STORAGE_BOOTFS, "BOOTFS", ".bin") \
111 macro(ZBI_TYPE_CMDLINE, "CMDLINE", ".txt") \
112 macro(ZBI_TYPE_CRASHLOG, "CRASHLOG", ".bin") \
113 macro(ZBI_TYPE_NVRAM, "NVRAM", ".bin") \
114 macro(ZBI_TYPE_PLATFORM_ID, "PLATFORM_ID", ".bin") \
115 macro(ZBI_TYPE_CPU_CONFIG, "CPU_CONFIG", ".bin") /* Deprecated */ \
116 macro(ZBI_TYPE_CPU_TOPOLOGY, "CPU_TOPOLOGY", ".bin") \
117 macro(ZBI_TYPE_MEM_CONFIG, "MEM_CONFIG", ".bin") \
118 macro(ZBI_TYPE_KERNEL_DRIVER, "KERNEL_DRIVER", ".bin") \
119 macro(ZBI_TYPE_ACPI_RSDP, "ACPI_RSDP", ".bin") \
120 macro(ZBI_TYPE_SMBIOS, "SMBIOS", ".bin") \
121 macro(ZBI_TYPE_EFI_MEMORY_MAP, "EFI_MEMORY_MAP", ".bin") \
122 macro(ZBI_TYPE_EFI_SYSTEM_TABLE, "EFI_SYSTEM_TABLE", ".bin") \
123 macro(ZBI_TYPE_E820_TABLE, "E820_TABLE", ".bin") \
124 macro(ZBI_TYPE_DEBUG_UART, "DEBUG_UART", ".bin") \
125 macro(ZBI_TYPE_FRAMEBUFFER, "FRAMEBUFFER", ".bin") \
126 macro(ZBI_TYPE_DRV_MAC_ADDRESS, "DRV_MAC_ADDRESS", ".bin") \
127 macro(ZBI_TYPE_DRV_PARTITION_MAP, "DRV_PARTITION_MAP", ".bin") \
128 macro(ZBI_TYPE_BOOT_CONFIG, "BOOT_CONFIG", ".bin") \
129 macro(ZBI_TYPE_BOOT_VERSION, "BOOT_VERSION", ".bin")
130
131 // Each ZBI starts with a container header.
132 // length: Total size of the image after this header.
133 // This includes all item headers, payloads, and padding.
134 // It does not include the container header itself.
135 // Must be a multiple of ZBI_ALIGNMENT.
136 // extra: Must be ZBI_CONTAINER_MAGIC.
137 // flags: Must be ZBI_FLAG_VERSION and no other flags.
138 #define ZBI_TYPE_CONTAINER (0x544f4f42) // BOOT
139
140 // Define a container header in assembly code. The symbol name is defined
141 // as a local label; use .global symbol to make it global. The length
142 // argument can use assembly label arithmetic like any immediate operand.
143 #ifdef __ASSEMBLER__
144 #define ZBI_CONTAINER_HEADER(symbol, length) \
145 .balign ZBI_ALIGNMENT; \
146 symbol: \
147 .int ZBI_TYPE_CONTAINER; \
148 .int (length); \
149 .int ZBI_CONTAINER_MAGIC; \
150 .int ZBI_FLAG_VERSION; \
151 .int 0; \
152 .int 0; \
153 .int ZBI_ITEM_MAGIC; \
154 .int ZBI_ITEM_NO_CRC32; \
155 .size symbol, . - symbol; \
156 .type symbol, %object
157 #else
158 #define ZBI_CONTAINER_HEADER(length) { \
159 ZBI_TYPE_CONTAINER, \
160 (length), \
161 ZBI_CONTAINER_MAGIC, \
162 ZBI_FLAG_VERSION, \
163 0, \
164 0, \
165 ZBI_ITEM_MAGIC, \
166 ZBI_ITEM_NO_CRC32, \
167 }
168 #endif
169
170
171 // The kernel image. In a complete ZBI this item must always be first,
172 // immediately after the ZBI_TYPE_CONTAINER header. The contiguous memory
173 // image of the kernel is formed from the ZBI_TYPE_CONTAINER header, the
174 // ZBI_TYPE_KERNEL_{ARCH} header, and the payload.
175 //
176 // The boot loader loads the whole image starting with the container header
177 // through to the end of the kernel item's payload into contiguous physical
178 // memory. It then constructs a partial ZBI elsewhere in memory, which has
179 // a ZBI_TYPE_CONTAINER header of its own followed by all the other items
180 // that were in the booted ZBI plus other items synthesized by the boot
181 // loader to describe the machine. This partial ZBI must be placed at an
182 // address (where the container header is found) that is aligned to the
183 // machine's page size. The precise protocol for transferring control to
184 // the kernel's entry point varies by machine.
185 //
186 // On all machines, the kernel requires some amount of scratch memory to be
187 // available immediately after the kernel image at boot. It needs this
188 // space for early setup work before it has a chance to read any memory-map
189 // information from the boot loader. The `reserve_memory_size` field tells
190 // the boot loader how much space after the kernel's load image it must
191 // leave available for the kernel's use. The boot loader must place its
192 // constructed ZBI or other reserved areas at least this many bytes after
193 // the kernel image.
194 //
195 // x86-64
196 //
197 // The kernel assumes it was loaded at a fixed physical address of
198 // 0x100000 (1MB). zbi_kernel_t.entry is the absolute physical address
199 // of the PC location where the kernel will start.
200 // TODO(SEC-31): Perhaps this will change??
201 // The processor is in 64-bit mode with direct virtual to physical
202 // mapping covering the physical memory where the kernel and
203 // bootloader-constructed ZBI were loaded, which must be below 4GB.
204 // The %rsi register (or %esi, since the high 32 bits must be zero)
205 // holds the physical address of the bootloader-constructed ZBI.
206 // All other registers are unspecified.
207 //
208 // ARM64
209 //
210 // zbi_kernel_t.entry is an offset from the beginning of the image
211 // (i.e., the ZBI_TYPE_CONTAINER header before the ZBI_TYPE_KERNEL_ARM64
212 // header) to the PC location in the image where the kernel will
213 // start. The processor is in physical address mode at EL1 or
214 // above. The kernel image and the bootloader-constructed ZBI each
215 // can be loaded anywhere in physical memory. The x0 register
216 // holds the physical address of the bootloader-constructed ZBI.
217 // All other registers are unspecified.
218 //
219 #define ZBI_TYPE_KERNEL_PREFIX (0x004e524b) // KRN\0
220 #define ZBI_TYPE_KERNEL_MASK (0x00FFFFFF)
221 #define ZBI_TYPE_KERNEL_X64 (0x4c4e524b) // KRNL
222 #define ZBI_TYPE_KERNEL_ARM64 (0x384e524b) // KRN8
223 #define ZBI_IS_KERNEL_BOOTITEM(x) (((x) & ZBI_TYPE_KERNEL_MASK) == \
224 ZBI_TYPE_KERNEL_PREFIX)
225
226 #ifndef __ASSEMBLER__
227 typedef struct {
228 // Entry-point address. The interpretation of this differs by machine.
229 uint64_t entry;
230 // Minimum amount (in bytes) of scratch memory that the kernel requires
231 // immediately after its load image.
232 uint64_t reserve_memory_size;
233 } zbi_kernel_t;
234
235 // The whole contiguous image loaded into memory by the boot loader.
236 typedef struct {
237 zbi_header_t hdr_file;
238 zbi_header_t hdr_kernel;
239 zbi_kernel_t data_kernel;
240 uint8_t contents[/*hdr_kernel.length - sizeof(zbi_kernel_t)*/];
241 // data_kernel.reserve_memory_size bytes in memory are free after contents.
242 } zircon_kernel_t;
243 #endif
244
245
246 // A discarded item that should just be ignored. This is used for an
247 // item that was already processed and should be ignored by whatever
248 // stage is now looking at the ZBI. An earlier stage already "consumed"
249 // this information, but avoided copying data around to remove it from
250 // the ZBI item stream.
251 #define ZBI_TYPE_DISCARD (0x50494b53) // SKIP
252
253
254 // ZBI_TYPE_STORAGE_* types represent an image that might otherwise
255 // appear on some block storage device, i.e. a RAM disk of some sort.
256 // All zbi_header_t fields have the same meanings for all these types.
257 // The interpretation of the payload (after possible decompression) is
258 // indicated by the specific zbi_header_t.type value.
259 //
260 // If ZBI_FLAG_STORAGE_COMPRESSED is set in zbi_header_t.flags, then the
261 // payload is compressed with LZ4 and zbi_header_t.extra gives the exact
262 // size of the decompressed payload. If ZBI_FLAG_STORAGE_COMPRESSED is
263 // not set, then zbi_header_t.extra matches zbi_header_t.length.
264 //
265 // TODO(mcgrathr): Document or point to the details of the LZ4 header format.
266 #define ZBI_FLAG_STORAGE_COMPRESSED (0x00000001)
267
268 // A virtual disk image. This is meant to be treated as if it were a
269 // storage device. The payload (after decompression) is the contents of
270 // the storage device, in whatever format that might be.
271 #define ZBI_TYPE_STORAGE_RAMDISK (0x4b534452) // RDSK
272
273 // The /boot filesystem in BOOTFS format, specified below.
274 // A complete ZBI must have exactly one ZBI_TYPE_STORAGE_BOOTFS item.
275 // Zircon [userboot](../../../../docs/userboot.md) handles the contents
276 // of this filesystem.
277 #define ZBI_TYPE_STORAGE_BOOTFS (0x42534642) // BFSB
278
279 // The payload (after decompression) of an item in BOOTFS format consists
280 // of separate "file" images that are each aligned to ZBI_BOOTFS_PAGE_SIZE
281 // bytes from the beginning of the item payload. The first "file" consists
282 // of a zbi_bootfs_header_t followed by directory entries.
283 #define ZBI_BOOTFS_PAGE_SIZE (4096u)
284
285 #define ZBI_BOOTFS_PAGE_ALIGN(size) \
286 (((size) + ZBI_BOOTFS_PAGE_SIZE - 1) & -ZBI_BOOTFS_PAGE_SIZE)
287
288 #ifndef __ASSEMBLER__
289 typedef struct {
290 // Must be ZBI_BOOTFS_MAGIC.
291 uint32_t magic;
292
293 // Size in bytes of all the directory entries.
294 // Does not include the size of the zbi_bootfs_header_t.
295 uint32_t dirsize;
296
297 // Reserved for future use. Set to 0.
298 uint32_t reserved0;
299 uint32_t reserved1;
300 } zbi_bootfs_header_t;
301 #endif
302
303 // LSW of sha256("bootfs")
304 #define ZBI_BOOTFS_MAGIC (0xa56d3ff9)
305
306 // Each directory entry holds a pathname and gives the offset and size
307 // of the contents of the file by that name.
308 #ifndef __ASSEMBLER__
309 typedef struct {
310 // Length of the name[] field at the end. This length includes the
311 // NUL terminator, which must be present, but does not include any
312 // alignment padding required before the next directory entry.
313 uint32_t name_len;
314
315 // Length of the file in bytes. This is an exact size that is not
316 // rounded, though the file is always padded with zeros up to a
317 // multiple of ZBI_BOOTFS_PAGE_SIZE.
318 uint32_t data_len;
319
320 // Offset from the beginning of the payload (zbi_bootfs_header_t) to
321 // the file's data. This must be a multiple of ZBI_BOOTFS_PAGE_SIZE.
322 uint32_t data_off;
323
324 // Pathname of the file, a UTF-8 string. This must include a NUL
325 // terminator at the end. It must not begin with a '/', but it may
326 // contain '/' separators for subdirectories.
327 char name[];
328 } zbi_bootfs_dirent_t;
329 #endif
330
331 // Each directory entry has a variable size of [16,268] bytes that
332 // must be a multiple of 4 bytes.
333 #define ZBI_BOOTFS_DIRENT_SIZE(name_len) \
334 ((sizeof(zbi_bootfs_dirent_t) + (name_len) + 3) & -(size_t)4)
335
336 // zbi_bootfs_dirent_t.name_len must be > 1 and <= ZBI_BOOTFS_MAX_NAME_LEN.
337 #define ZBI_BOOTFS_MAX_NAME_LEN (256)
338
339
340 // The remaining types are used to communicate information from the boot
341 // loader to the kernel. Usually these are synthesized in memory by the
342 // boot loader, but they can also be included in a ZBI along with the
343 // kernel and BOOTFS. Some boot loaders may set the zbi_header_t flags
344 // and crc32 fields to zero, though setting them to ZBI_FLAG_VERSION and
345 // ZBI_ITEM_NO_CRC32 is specified. The kernel doesn't check.
346
347
348 // A kernel command line fragment, a NUL-terminated UTF-8 string.
349 // Multiple ZBI_TYPE_CMDLINE items can appear. They are treated as if
350 // concatenated with ' ' between each item, in the order they appear:
351 // first items in the complete ZBI containing the kernel; then items in
352 // the ZBI synthesized by the boot loader. The kernel interprets the
353 // [whole command line](../../../../docs/kernel_cmdline.md).
354 #define ZBI_TYPE_CMDLINE (0x4c444d43) // CMDL
355
356 // The crash log from the previous boot, a UTF-8 string.
357 #define ZBI_TYPE_CRASHLOG (0x4d4f4f42) // BOOM
358
359 // Physical memory region that will persist across warm boots.
360 // zbi_nvram_t gives the physical base address and length in bytes.
361 #define ZBI_TYPE_NVRAM (0x4c4c564e) // NVLL
362 // This reflects a typo we need to support for a while.
363 #define ZBI_TYPE_NVRAM_DEPRECATED (0x4c4c5643) // CVLL
364 #ifndef __ASSEMBLER__
365 typedef struct {
366 uint64_t base;
367 uint64_t length;
368 } zbi_nvram_t;
369 #endif
370
371 #define ZBI_BOARD_NAME_LEN 32
372
373 // Platform ID Information.
374 #define ZBI_TYPE_PLATFORM_ID (0x44494C50) // PLID
375 #ifndef __ASSEMBLER__
376 typedef struct {
377 uint32_t vid;
378 uint32_t pid;
379 char board_name[ZBI_BOARD_NAME_LEN];
380 } zbi_platform_id_t;
381 #endif
382
383 // CPU configuration, a zbi_cpu_config_t header followed by one or more
384 // zbi_cpu_cluster_t entries. zbi_header_t.length must equal
385 // zbi_cpu_config_t.cluster_count * sizeof(zbi_cpu_cluster_t).
386 #define ZBI_TYPE_CPU_CONFIG (0x43555043) // CPUC
387 #ifndef __ASSEMBLER__
388 typedef struct {
389 // Number of CPU cores in the cluster.
390 uint32_t cpu_count;
391
392 // Reserved for future use. Set to 0.
393 uint32_t type;
394 uint32_t flags;
395 uint32_t reserved;
396 } zbi_cpu_cluster_t;
397
398 typedef struct {
399 // Number of zbi_cpu_cluster_t entries following this header.
400 uint32_t cluster_count;
401
402 // Reserved for future use. Set to 0.
403 uint32_t reserved[3];
404
405 // cluster_count entries follow.
406 zbi_cpu_cluster_t clusters[];
407 } zbi_cpu_config_t;
408 #endif
409
410 #define ZBI_TYPE_CPU_TOPOLOGY (0x544F504F) // TOPO
411
412 #ifndef __ASSEMBLER__
413
414 #define ZBI_MAX_SMT 4
415
416 // These are Used in the flags field of zbi_topology_processor_t.
417
418 // This is the processor that boots the system and the last to be shutdown.
419 #define ZBI_TOPOLOGY_PROCESSOR_PRIMARY 0b1
420
421 // This is the processor that handles all interrupts, some architectures will
422 // not have one.
423 #define ZBI_TOPOLOGY_PROCESSOR_INTERRUPT 0b10
424
425 #define ZBI_TOPOLOGY_NO_PARENT 0xFFFF
426
427 typedef enum {
428 ZBI_TOPOLOGY_ARCH_UNDEFINED = 0, // Intended primarily for testing.
429 ZBI_TOPOLOGY_ARCH_X86 = 1,
430 ZBI_TOPOLOGY_ARCH_ARM = 2,
431 } zbi_topology_architecture_t;
432
433 typedef struct {
434 // Cluster ids for each level, one being closest to the cpu.
435 // These map to aff1, aff2, and aff3 values in the ARM registers.
436 uint8_t cluster_1_id;
437 uint8_t cluster_2_id;
438 uint8_t cluster_3_id;
439
440 // Id of the cpu inside of the bottom-most cluster, aff0 value.
441 uint8_t cpu_id;
442
443 // The GIC interface number for this processor.
444 // In GIC v3+ this is not necessary as the processors are addressed by their
445 // affinity routing (all cluster ids followed by cpu_id).
446 uint8_t gic_id;
447 } zbi_topology_arm_info_t;
448
449 typedef struct {
450 uint32_t apic_id;
451 } zbi_topology_x86_info_t;
452
453 typedef struct {
454 uint16_t logical_ids[ZBI_MAX_SMT];
455 uint8_t logical_id_count;
456
457 uint16_t flags;
458
459 // Should be one of zbi_topology_arm_info_t.
460 // If UNDEFINED then nothing will be set in arch_info.
461 uint8_t architecture;
462 union {
463 zbi_topology_arm_info_t arm;
464 zbi_topology_x86_info_t x86;
465 } architecture_info;
466
467 } zbi_topology_processor_t;
468
469 typedef struct {
470 // Relative performance level of this processor in the system, with 0
471 // representing the lowest performance.
472 // For example on a two cluster ARM big.LITTLE system 0 would be the little
473 // cores and 1 would represent the big cores.
474 uint8_t performance_class;
475 } zbi_topology_cluster_t;
476
477 typedef struct {
478 // Starting and ending memory addresses of this numa region.
479 uint64_t start_address;
480 uint64_t end_address;
481 } zbi_topology_numa_region_t;
482
483 typedef enum {
484 ZBI_TOPOLOGY_ENTITY_UNDEFINED = 0, // Unused default.
485 ZBI_TOPOLOGY_ENTITY_PROCESSOR = 1,
486 ZBI_TOPOLOGY_ENTITY_CLUSTER = 2,
487 ZBI_TOPOLOGY_ENTITY_CACHE = 3,
488 ZBI_TOPOLOGY_ENTITY_DIE = 4,
489 ZBI_TOPOLOGY_ENTITY_SOCKET = 5,
490 ZBI_TOPOLOGY_ENTITY_POWER_PLANE = 6,
491 ZBI_TOPOLOGY_ENTITY_NUMA_REGION = 7,
492 } zbi_topology_entity_type_t;
493
494 typedef struct {
495 // Should be one of zbi_topology_entity_type_t.
496 uint8_t entity_type;
497 uint16_t parent_index;
498 union {
499 zbi_topology_processor_t processor;
500 zbi_topology_cluster_t cluster;
501 zbi_topology_numa_region_t numa_region;
502 } entity;
503 } zbi_topology_node_t;
504
505 #endif
506
507 // Memory configuration, one or more zbi_mem_range_t entries.
508 // zbi_header_t.length is sizeof(zbi_mem_range_t) times the number of entries.
509 #define ZBI_TYPE_MEM_CONFIG (0x434D454D) // MEMC
510 #ifndef __ASSEMBLER__
511 typedef struct {
512 uint64_t paddr;
513 uint64_t length;
514 uint32_t type;
515 uint32_t reserved;
516 } zbi_mem_range_t;
517 #endif
518 #define ZBI_MEM_RANGE_RAM (1)
519 #define ZBI_MEM_RANGE_PERIPHERAL (2)
520 #define ZBI_MEM_RANGE_RESERVED (3)
521
522 // Kernel driver configuration. The zbi_header_t.extra field gives a
523 // KDRV_* type that determines the payload format.
524 // See [driver-config.h](<zircon/boot/driver-config.h>) for details.
525 #define ZBI_TYPE_KERNEL_DRIVER (0x5652444B) // KDRV
526
527 // ACPI Root Table Pointer, a uint64_t physical address.
528 #define ZBI_TYPE_ACPI_RSDP (0x50445352) // RSDP
529
530 // SMBIOS entry point, a uint64_t physical address.
531 #define ZBI_TYPE_SMBIOS (0x49424d53) // SMBI
532
533 // EFI memory map, a uint64_t entry size followed by a sequence of
534 // EFI memory descriptors aligned on that entry size.
535 #define ZBI_TYPE_EFI_MEMORY_MAP (0x4d494645) // EFIM
536
537 // EFI system table, a uint64_t physical address.
538 #define ZBI_TYPE_EFI_SYSTEM_TABLE (0x53494645) // EFIS
539
540 // E820 memory table, an array of e820entry_t.
541 #define ZBI_TYPE_E820_TABLE (0x30323845) // E820
542
543 /* EFI Variable for Crash Log */
544 #define ZIRCON_VENDOR_GUID \
545 {0x82305eb2, 0xd39e, 0x4575, {0xa0, 0xc8, 0x6c, 0x20, 0x72, 0xd0, 0x84, 0x4c}}
546 #define ZIRCON_CRASHLOG_EFIVAR \
547 { 'c', 'r', 'a', 's', 'h', 'l', 'o', 'g', 0 };
548 #define ZIRCON_CRASHLOG_EFIATTR \
549 (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)
550
551 // Debug serial port, a zbi_uart_t entry.
552 #define ZBI_TYPE_DEBUG_UART (0x54524155) // UART
553 #ifndef __ASSEMBLER__
554 typedef struct {
555 uint64_t base;
556 uint32_t type;
557 uint32_t irq;
558 } zbi_uart_t;
559 #endif
560 #define ZBI_UART_NONE (0)
561 #define ZBI_UART_PC_PORT (1)
562 #define ZBI_UART_PC_MMIO (2)
563
564 // Framebuffer parameters, a zbi_swfb_t entry.
565 #define ZBI_TYPE_FRAMEBUFFER (0x42465753) // SWFB
566
567 // A copy of the boot configuration stored as a kvstore
568 // within the sysconfig partition.
569 #define ZBI_TYPE_BOOT_CONFIG (0x47464342) // BCFG
570
571 // A copy of the boot version stored within the sysconfig
572 // partition
573 #define ZBI_TYPE_BOOT_VERSION (0x53525642) // BVRS
574
575 #ifndef __ASSEMBLER__
576 typedef struct {
577 // Physical memory address.
578 uint64_t base;
579
580 // Pixel layout and format.
581 // See [../pixelformat.h](<zircon/pixelformat.h>).
582 uint32_t width;
583 uint32_t height;
584 uint32_t stride;
585 uint32_t format;
586 } zbi_swfb_t;
587 #endif
588
589
590 // ZBI_TYPE_DRV_* types (LSB is 'm') contain driver metadata.
591 #define ZBI_TYPE_DRV_METADATA(type) (((type) & 0xFF) == 0x6D) // 'm'
592
593 // MAC address for Ethernet, Wifi, Bluetooth, etc. zbi_header_t.extra
594 // is a board-specific index to specify which device the MAC address
595 // applies to. zbi_header_t.length gives the size in bytes, which
596 // varies depending on the type of address appropriate for the device.
597 #define ZBI_TYPE_DRV_MAC_ADDRESS (0x43414D6D) // mMAC
598
599 // A partition map for a storage device, a zbi_partition_map_t header
600 // followed by one or more zbi_partition_t entries. zbi_header_t.extra
601 // is a board-specific index to specify which device this applies to.
602 #define ZBI_TYPE_DRV_PARTITION_MAP (0x5452506D) // mPRT
603 #define ZBI_PARTITION_NAME_LEN (32)
604 #define ZBI_PARTITION_GUID_LEN (16)
605 #ifndef __ASSEMBLER__
606 typedef struct {
607 // GUID specifying the format and use of data stored in the partition.
608 uint8_t type_guid[ZBI_PARTITION_GUID_LEN];
609
610 // GUID unique to this partition.
611 uint8_t uniq_guid[ZBI_PARTITION_GUID_LEN];
612
613 // First and last block occupied by this partition.
614 uint64_t first_block;
615 uint64_t last_block;
616
617 // Reserved for future use. Set to 0.
618 uint64_t flags;
619
620 char name[ZBI_PARTITION_NAME_LEN];
621 } zbi_partition_t;
622
623 typedef struct {
624 // Total blocks used on the device.
625 uint64_t block_count;
626 // Size of each block in bytes.
627 uint64_t block_size;
628
629 // Number of partitions in the map.
630 uint32_t partition_count;
631
632 // Reserved for future use.
633 uint32_t reserved;
634
635 // Device GUID.
636 uint8_t guid[ZBI_PARTITION_GUID_LEN];
637
638 // partition_count partition entries follow.
639 zbi_partition_t partitions[];
640 } zbi_partition_map_t;
641 #endif
642