opuntiaOS - an operating system targeting x86 and ARMv7
at master 1.4 kB view raw
1/* 2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors. 3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com> 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9#ifndef _BOOT_LIBBOOT_DEVTREE_DEVTREE_H 10#define _BOOT_LIBBOOT_DEVTREE_DEVTREE_H 11 12#include <libboot/mem/mem.h> 13#include <libboot/types.h> 14 15#define DEVTREE_HEADER_SIGNATURE ("odtr3") 16#define DEVTREE_HEADER_SIGNATURE_LEN (sizeof(DEVTREE_HEADER_SIGNATURE) - 1) 17 18struct PACKED devtree_header { 19 char signature[8]; 20 uint32_t revision; 21 uint32_t flags; 22 uint32_t entries_count; 23 uint32_t name_list_offset; 24}; 25typedef struct devtree_header devtree_header_t; 26 27#define DEVTREE_ENTRY_FLAGS_MMIO = (1 << 0) 28#define DEVTREE_ENTRY_TYPE_IO (0) 29#define DEVTREE_ENTRY_TYPE_FB (1) 30#define DEVTREE_ENTRY_TYPE_UART (2) 31#define DEVTREE_ENTRY_TYPE_RAM (3) 32#define DEVTREE_ENTRY_TYPE_STORAGE (4) 33#define DEVTREE_ENTRY_TYPE_BUS_CONTROLLER (5) 34 35struct PACKED devtree_entry { 36 uint32_t type; 37 uint32_t flags; 38 uint32_t paddr; 39 uint32_t rel_name_offset; 40}; 41typedef struct devtree_entry devtree_entry_t; 42 43int devtree_init(void* devtree, size_t size); 44const char* devtree_name_of_entry(devtree_entry_t* en); 45devtree_entry_t* devtree_find_device(const char* name); 46void* devtree_start(); 47size_t devtree_size(); 48 49#endif // _BOOT_LIBBOOT_DEVTREE_DEVTREE_H