• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef DT_TABLE_H
18 #define DT_TABLE_H
19 
20 #include <stdint.h>
21 
22 /*
23  * For the image layout, refer README.md for the detail
24  */
25 
26 #define DT_TABLE_MAGIC 0xd7b7ab1e
27 #define DT_TABLE_DEFAULT_PAGE_SIZE 2048
28 #define DT_TABLE_DEFAULT_VERSION 0
29 
30 struct dt_table_header {
31   uint32_t magic;             /* DT_TABLE_MAGIC */
32   uint32_t total_size;        /* includes dt_table_header + all dt_table_entry
33                                  and all dtb/dtbo */
34   uint32_t header_size;       /* sizeof(dt_table_header) */
35 
36   uint32_t dt_entry_size;     /* sizeof(dt_table_entry) */
37   uint32_t dt_entry_count;    /* number of dt_table_entry */
38   uint32_t dt_entries_offset; /* offset to the first dt_table_entry
39                                  from head of dt_table_header.
40                                  The value will be equal to header_size if
41                                  no padding is appended */
42 
43   uint32_t page_size;         /* flash page size we assume */
44   uint32_t version;           /* DTBO image version, the current version is 0.
45                                  The version will be incremented when the dt_table_header
46                                  struct is updated. */
47 };
48 
49 enum dt_compression_info {
50     NO_COMPRESSION,
51     ZLIB_COMPRESSION,
52     GZIP_COMPRESSION
53 };
54 
55 struct dt_table_entry {
56   uint32_t dt_size;
57   uint32_t dt_offset;         /* offset from head of dt_table_header */
58 
59   uint32_t id;                /* optional, must be zero if unused */
60   uint32_t rev;               /* optional, must be zero if unused */
61   uint32_t custom[4];         /* optional, must be zero if unused */
62 };
63 
64 struct dt_table_entry_v1 {
65   uint32_t dt_size;
66   uint32_t dt_offset;         /* offset from head of dt_table_header */
67 
68   uint32_t id;                /* optional, must be zero if unused */
69   uint32_t rev;               /* optional, must be zero if unused */
70   uint32_t flags;             /* For version 1 of dt_table_header, the 4 least significant bits
71                                  of 'flags' will be used indicate the compression
72                                  format of the DT entry as per the enum 'dt_compression_info' */
73   uint32_t custom[3];         /* optional, must be zero if unused */
74 };
75 enum DT_TYPE { DTB, ACPI };
76 
77 void dt_table_header_init(struct dt_table_header *header, enum DT_TYPE dt_type);
78 
79 #endif
80