151b58561SPaul Burton /* 251b58561SPaul Burton * Flattened Image Tree loader. 351b58561SPaul Burton * 451b58561SPaul Burton * Copyright (c) 2016 Imagination Technologies 551b58561SPaul Burton * 651b58561SPaul Burton * This library is free software; you can redistribute it and/or 751b58561SPaul Burton * modify it under the terms of the GNU Lesser General Public 851b58561SPaul Burton * License as published by the Free Software Foundation; either 961f3c91aSChetan Pant * version 2.1 of the License, or (at your option) any later version. 1051b58561SPaul Burton * 1151b58561SPaul Burton * This library is distributed in the hope that it will be useful, 1251b58561SPaul Burton * but WITHOUT ANY WARRANTY; without even the implied warranty of 1351b58561SPaul Burton * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1451b58561SPaul Burton * Lesser General Public License for more details. 1551b58561SPaul Burton * 1651b58561SPaul Burton * You should have received a copy of the GNU Lesser General Public 1751b58561SPaul Burton * License along with this library; if not, see <http://www.gnu.org/licenses/>. 1851b58561SPaul Burton */ 1951b58561SPaul Burton 2051b58561SPaul Burton #ifndef HW_LOADER_FIT_H 2151b58561SPaul Burton #define HW_LOADER_FIT_H 2251b58561SPaul Burton 23d8e39b70SMarkus Armbruster #include "exec/hwaddr.h" 2451b58561SPaul Burton 2551b58561SPaul Burton struct fit_loader_match { 2651b58561SPaul Burton const char *compatible; 2751b58561SPaul Burton const void *data; 2851b58561SPaul Burton }; 2951b58561SPaul Burton 3051b58561SPaul Burton struct fit_loader { 3151b58561SPaul Burton const struct fit_loader_match *matches; 3251b58561SPaul Burton hwaddr (*addr_to_phys)(void *opaque, uint64_t addr); 33*db0dd335SPeter Maydell void *(*fdt_filter)(void *opaque, const void *fdt, 3451b58561SPaul Burton const void *match_data, hwaddr *load_addr); 3551b58561SPaul Burton const void *(*kernel_filter)(void *opaque, const void *kernel, 3651b58561SPaul Burton hwaddr *load_addr, hwaddr *entry_addr); 3751b58561SPaul Burton }; 3851b58561SPaul Burton 39*db0dd335SPeter Maydell /** 40*db0dd335SPeter Maydell * load_fit: load a FIT format image 41*db0dd335SPeter Maydell * @ldr: structure defining board specific properties and hooks 42*db0dd335SPeter Maydell * @filename: image to load 43*db0dd335SPeter Maydell * @pfdt: pointer to update with address of FDT blob 44*db0dd335SPeter Maydell * @opaque: opaque value passed back to the hook functions in @ldr 45*db0dd335SPeter Maydell * Returns: 0 on success, or a negative errno on failure 46*db0dd335SPeter Maydell * 47*db0dd335SPeter Maydell * @pfdt is used to tell the caller about the FDT blob. On return, it 48*db0dd335SPeter Maydell * has been set to point to the FDT blob, and it is now the caller's 49*db0dd335SPeter Maydell * responsibility to free that memory with g_free(). Usually the caller 50*db0dd335SPeter Maydell * will want to pass in &machine->fdt here, to record the FDT blob for 51*db0dd335SPeter Maydell * the dumpdtb option and QMP/HMP commands. 52*db0dd335SPeter Maydell */ 53*db0dd335SPeter Maydell int load_fit(const struct fit_loader *ldr, const char *filename, void **pfdt, 54*db0dd335SPeter Maydell void *opaque); 5551b58561SPaul Burton 5651b58561SPaul Burton #endif /* HW_LOADER_FIT_H */ 57