1 /* 2 * Copyright (c) 2014, Mentor Graphics Corporation 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 /************************************************************************** 9 * FILE NAME 10 * 11 * remoteproc_loader.h 12 * 13 * COMPONENT 14 * 15 * OpenAMP stack. 16 * 17 * DESCRIPTION 18 * 19 * This file provides definitions for remoteproc loader 20 * 21 * 22 **************************************************************************/ 23 #ifndef REMOTEPROC_LOADER_H_ 24 #define REMOTEPROC_LOADER_H_ 25 26 #include <metal/io.h> 27 #include <metal/list.h> 28 #include <metal/sys.h> 29 #include <openamp/remoteproc.h> 30 31 #if defined __cplusplus 32 extern "C" { 33 #endif 34 35 /* Loader feature macros */ 36 #define SUPPORT_SEEK 1UL 37 38 /* Remoteproc loader any address */ 39 #define RPROC_LOAD_ANYADDR ((metal_phys_addr_t)-1) 40 41 /* Remoteproc loader Executable Image Parsing States */ 42 /* Remoteproc loader parser initial state */ 43 #define RPROC_LOADER_NOT_READY 0x0L 44 /* Remoteproc loader ready to load, even it can be not finish parsing */ 45 #define RPROC_LOADER_READY_TO_LOAD 0x10000L 46 /* Remoteproc loader post data load */ 47 #define RPROC_LOADER_POST_DATA_LOAD 0x20000L 48 /* Remoteproc loader finished loading */ 49 #define RPROC_LOADER_LOAD_COMPLETE 0x40000L 50 /* Remoteproc loader state mask */ 51 #define RPROC_LOADER_MASK 0x00FF0000L 52 /* Remoteproc loader private mask */ 53 #define RPROC_LOADER_PRIVATE_MASK 0x0000FFFFL 54 /* Remoteproc loader reserved mask */ 55 #define RPROC_LOADER_RESERVED_MASK 0x0F000000L 56 57 /** 58 * struct image_store_ops - user defined image store operations 59 * @open: user defined callback to open the "firmware" to prepare loading 60 * @close: user defined callback to close the "firmware" to clean up 61 * after loading 62 * @load: user defined callback to load the firmware contents to target 63 * memory or local memory 64 * @features: loader supported features. e.g. seek 65 */ 66 struct image_store_ops { 67 int (*open)(void *store, const char *path, const void **img_data); 68 void (*close)(void *store); 69 int (*load)(void *store, size_t offset, size_t size, 70 const void **data, 71 metal_phys_addr_t pa, 72 struct metal_io_region *io, char is_blocking); 73 unsigned int features; 74 }; 75 76 /** 77 * struct loader_ops - loader operations 78 * @load_header: define how to get the executable headers 79 * @load_data: define how to load the target data 80 * @locate_rsc_table: define how to get the resource table target address, 81 * offset to the ELF image file and size of the resource 82 * table. 83 * @release: define how to release the loader 84 * @get_entry: get entry address 85 * @get_load_state: get load state from the image information 86 */ 87 struct loader_ops { 88 int (*load_header)(const void *img_data, size_t offset, size_t len, 89 void **img_info, int last_state, 90 size_t *noffset, size_t *nlen); 91 int (*load_data)(struct remoteproc *rproc, 92 const void *img_data, size_t offset, size_t len, 93 void **img_info, int last_load_state, 94 metal_phys_addr_t *da, 95 size_t *noffset, size_t *nlen, 96 unsigned char *padding, size_t *nmemsize); 97 int (*locate_rsc_table)(void *img_info, metal_phys_addr_t *da, 98 size_t *offset, size_t *size); 99 void (*release)(void *img_info); 100 metal_phys_addr_t (*get_entry)(void *img_info); 101 int (*get_load_state)(void *img_info); 102 }; 103 104 #if defined __cplusplus 105 } 106 #endif 107 108 #endif /* REMOTEPROC_LOADER_H_ */ 109