62 lines
2.1 KiB
C
62 lines
2.1 KiB
C
/**
|
|
* fdt implementation of Asagiri
|
|
* Copyright (C) 2023 Asagiri contributors
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef _ASAGIRI_FDT_H
|
|
#define _ASAGIRI_FDT_H
|
|
|
|
#define SWAP_UINT32(x) (((x) >> 24) | \
|
|
(((x) & 0x00FF0000) >> 8) | \
|
|
(((x) & 0x0000FF00) << 8) | \
|
|
((x) << 24))
|
|
|
|
#include <bits/alltypes.h>
|
|
|
|
typedef struct fdt_header {
|
|
uint32_t magic; /* Magic value identifying FDT */
|
|
uint32_t totalsize; /* Total size of FDT including the header */
|
|
uint32_t off_dt_struct; /* Offset from beginning of the FDT to the structure block */
|
|
uint32_t off_dt_strings; /* Offset from beginning of the FDT to the strings block */
|
|
uint32_t off_mem_rsvmap; /* Offset from beginning of the FDT to the memory reservation map */
|
|
uint32_t version; /* FDT version */
|
|
uint32_t last_comp_version; /* Last compatible version */
|
|
uint32_t boot_cpuid_phys; /* Boot CPU ID */
|
|
uint32_t size_dt_strings; /* Size of the strings block */
|
|
uint32_t size_dt_struct; /* Size of the structure block */
|
|
} fdt_header;
|
|
|
|
typedef struct fdt_prop {
|
|
uint32_t nameoff;
|
|
uint32_t len;
|
|
uint32_t* data;
|
|
} fdt_prop;
|
|
|
|
enum {
|
|
FDT_BEGIN_NODE = 0x1,
|
|
FDT_END_NODE = 0x2,
|
|
FDT_PROP = 0x3,
|
|
FDT_NOP = 0x4,
|
|
FDT_END = 0x9
|
|
};
|
|
|
|
fdt_prop fdt_get_prop(uint32_t*);
|
|
uint32_t* fdt_get_addr(const char*);
|
|
void fdt_init();
|
|
void print_fdt();
|
|
|
|
#endif
|