Xeon-SP boards: Factor out OCP VPD `get_cxl_mode()` impl
[coreboot2.git] / util / archive / archive.h
blobc726bb7a5be04915bbc308c6053869a3ffebda25
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef __ARCHIVE_H
4 #define __ARCHIVE_H
6 #include <stdint.h>
8 /*
9 * Archive file layout:
11 * +----------------------------------+
12 * | root header |
13 * +----------------------------------+
14 * | file_header[0] |
15 * +----------------------------------+
16 * | file_header[1] |
17 * +----------------------------------+
18 * | ... |
19 * +----------------------------------+
20 * | file_header[count-1] |
21 * +----------------------------------+
22 * | file(0) content |
23 * +----------------------------------+
24 * | file(1) content |
25 * +----------------------------------+
26 * | ... |
27 * +----------------------------------+
28 * | file(count-1) content |
29 * +----------------------------------+
32 #define VERSION 0
33 #define CBAR_MAGIC "CBAR"
34 #define NAME_LENGTH 32
36 /* Root header */
37 struct directory {
38 char magic[4];
39 uint32_t version; /* version of the header. little endian */
40 uint32_t size; /* total size of archive. little endian */
41 uint32_t count; /* number of files. little endian */
44 /* File header */
45 struct dentry {
46 /* file name. null-terminated if shorter than NAME_LENGTH */
47 char name[NAME_LENGTH];
48 /* file offset from the root header. little endian */
49 uint32_t offset;
50 /* file size. little endian */
51 uint32_t size;
54 static inline struct dentry *get_first_dentry(const struct directory *dir)
56 return (struct dentry *)(dir + 1);
59 static inline uint32_t get_first_offset(const struct directory *dir)
61 return sizeof(struct directory) + sizeof(struct dentry) * dir->count;
64 #endif