Home | History | Annotate | Download | only in src
      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 struct dt_table_entry {
     50   uint32_t dt_size;
     51   uint32_t dt_offset;         /* offset from head of dt_table_header */
     52 
     53   uint32_t id;                /* optional, must be zero if unused */
     54   uint32_t rev;               /* optional, must be zero if unused */
     55   uint32_t custom[4];         /* optional, must be zero if unused */
     56 };
     57 
     58 void dt_table_header_init(struct dt_table_header *header);
     59 
     60 #endif
     61