#include <internal/utilities.h>#include <metal/alloc.h>#include <metal/log.h>#include <metal/utilities.h>#include <openamp/elf_loader.h>#include <openamp/remoteproc.h>#include <openamp/remoteproc_loader.h>#include <openamp/remoteproc_virtio.h>#include "rsc_table_parser.h"Functions | |
| static const struct loader_ops * | remoteproc_check_fw_format (const void *img_data, size_t img_len) |
| static struct remoteproc_mem * | remoteproc_get_mem (struct remoteproc *rproc, const char *name, metal_phys_addr_t pa, metal_phys_addr_t da, void *va, size_t size, struct remoteproc_mem *buf) |
| static metal_phys_addr_t | remoteproc_datopa (struct remoteproc_mem *mem, metal_phys_addr_t da) |
| static metal_phys_addr_t | remoteproc_patoda (struct remoteproc_mem *mem, metal_phys_addr_t pa) |
| static void * | remoteproc_get_rsc_table (struct remoteproc *rproc, void *store, const struct image_store_ops *store_ops, size_t offset, size_t len) |
| static int | remoteproc_parse_rsc_table (struct remoteproc *rproc, struct resource_table *rsc_table, size_t rsc_size) |
| int | remoteproc_set_rsc_table (struct remoteproc *rproc, struct resource_table *rsc_table, size_t rsc_size) |
| Parse and set resource table of remoteproc. More... | |
| struct remoteproc * | remoteproc_init (struct remoteproc *rproc, const struct remoteproc_ops *ops, void *priv) |
| Initializes remoteproc resource. More... | |
| int | remoteproc_remove (struct remoteproc *rproc) |
| Remove remoteproc resource. More... | |
| int | remoteproc_config (struct remoteproc *rproc, void *data) |
| This function configures the remote processor to get it ready to load and run executable. More... | |
| int | remoteproc_start (struct remoteproc *rproc) |
| This function starts the remote processor. More... | |
| int | remoteproc_stop (struct remoteproc *rproc) |
| This function stops the remote processor but it will not release its resource. More... | |
| int | remoteproc_shutdown (struct remoteproc *rproc) |
| This function shuts down the remote processor and releases its resources. More... | |
| void | remoteproc_init_mem (struct remoteproc_mem *mem, const char *name, metal_phys_addr_t pa, metal_phys_addr_t da, size_t size, struct metal_io_region *io) |
| Initialize remoteproc memory. More... | |
| void | remoteproc_add_mem (struct remoteproc *rproc, struct remoteproc_mem *mem) |
| Add remoteproc memory. More... | |
| struct metal_io_region * | remoteproc_get_io_with_name (struct remoteproc *rproc, const char *name) |
| Get remoteproc memory I/O region with name. More... | |
| struct metal_io_region * | remoteproc_get_io_with_pa (struct remoteproc *rproc, metal_phys_addr_t pa) |
| Get remoteproc memory I/O region with physical address. More... | |
| struct metal_io_region * | remoteproc_get_io_with_da (struct remoteproc *rproc, metal_phys_addr_t da, unsigned long *offset) |
| Get remoteproc memory I/O region with device address. More... | |
| struct metal_io_region * | remoteproc_get_io_with_va (struct remoteproc *rproc, void *va) |
| Get remoteproc memory I/O region with virtual address. More... | |
| void * | remoteproc_mmap (struct remoteproc *rproc, metal_phys_addr_t *pa, metal_phys_addr_t *da, size_t size, unsigned int attribute, struct metal_io_region **io) |
| Remoteproc mmap memory. More... | |
| int | remoteproc_load (struct remoteproc *rproc, const char *path, void *store, const struct image_store_ops *store_ops, void **img_info) |
| Loads the executable. More... | |
| int | remoteproc_load_noblock (struct remoteproc *rproc, const void *img_data, size_t offset, size_t len, void **img_info, metal_phys_addr_t *pa, struct metal_io_region **io, size_t *noffset, size_t *nlen, size_t *nmlen, unsigned char *padding) |
| Loads the executable. More... | |
| unsigned int | remoteproc_allocate_id (struct remoteproc *rproc, unsigned int start, unsigned int end) |
| Allocate notifyid for resource. More... | |
| static int | remoteproc_virtio_notify (void *priv, uint32_t id) |
| struct virtio_device * | remoteproc_create_virtio (struct remoteproc *rproc, int vdev_id, unsigned int role, void(*rst_cb)(struct virtio_device *vdev)) |
| Create virtio device, it returns pointer to the created virtio device. More... | |
| void | remoteproc_remove_virtio (struct remoteproc *rproc, struct virtio_device *vdev) |
| Remove virtio device. More... | |
| int | remoteproc_get_notification (struct remoteproc *rproc, uint32_t notifyid) |
| remoteproc is got notified, it will check its subdevices for the notification More... | |
| void remoteproc_add_mem | ( | struct remoteproc * | rproc, |
| struct remoteproc_mem * | mem | ||
| ) |
Add remoteproc memory.
| rproc | Pointer to remoteproc |
| mem | Pointer to remoteproc memory |
| unsigned int remoteproc_allocate_id | ( | struct remoteproc * | rproc, |
| unsigned int | start, | ||
| unsigned int | end | ||
| ) |
Allocate notifyid for resource.
| rproc | Pointer to the remoteproc instance |
| start | Start of the id range |
| end | End of the id range |
|
static |
| int remoteproc_config | ( | struct remoteproc * | rproc, |
| void * | data | ||
| ) |
This function configures the remote processor to get it ready to load and run executable.
| rproc | Pointer to remoteproc instance to start |
| data | Configuration data |
| struct virtio_device* remoteproc_create_virtio | ( | struct remoteproc * | rproc, |
| int | vdev_id, | ||
| unsigned int | role, | ||
| void(*)(struct virtio_device *vdev) | rst_cb | ||
| ) |
Create virtio device, it returns pointer to the created virtio device.
| rproc | Pointer to the remoteproc instance |
| vdev_id | virtio device ID |
| role | virtio device role |
| rst_cb | virtio device reset callback |
|
static |
| struct metal_io_region* remoteproc_get_io_with_da | ( | struct remoteproc * | rproc, |
| metal_phys_addr_t | da, | ||
| unsigned long * | offset | ||
| ) |
Get remoteproc memory I/O region with device address.
| rproc | Pointer to the remote processor |
| da | Device address |
| offset | I/O region offset of the device address |
| struct metal_io_region* remoteproc_get_io_with_name | ( | struct remoteproc * | rproc, |
| const char * | name | ||
| ) |
Get remoteproc memory I/O region with name.
| rproc | Pointer to the remote processor |
| name | Name of the shared memory |
| struct metal_io_region* remoteproc_get_io_with_pa | ( | struct remoteproc * | rproc, |
| metal_phys_addr_t | pa | ||
| ) |
Get remoteproc memory I/O region with physical address.
| rproc | Pointer to the remote processor |
| pa | Physical address |
| struct metal_io_region* remoteproc_get_io_with_va | ( | struct remoteproc * | rproc, |
| void * | va | ||
| ) |
Get remoteproc memory I/O region with virtual address.
| rproc | Pointer to the remote processor |
| va | Virtual address |
|
static |
| int remoteproc_get_notification | ( | struct remoteproc * | rproc, |
| uint32_t | notifyid | ||
| ) |
remoteproc is got notified, it will check its subdevices for the notification
| rproc | Pointer to the remoteproc instance |
| notifyid | Notification id |
|
static |
| struct remoteproc* remoteproc_init | ( | struct remoteproc * | rproc, |
| const struct remoteproc_ops * | ops, | ||
| void * | priv | ||
| ) |
Initializes remoteproc resource.
| rproc | Pointer to remoteproc instance |
| ops | Pointer to remoteproc operations |
| priv | Pointer to private data |
| void remoteproc_init_mem | ( | struct remoteproc_mem * | mem, |
| const char * | name, | ||
| metal_phys_addr_t | pa, | ||
| metal_phys_addr_t | da, | ||
| size_t | size, | ||
| struct metal_io_region * | io | ||
| ) |
Initialize remoteproc memory.
| mem | Pointer to remoteproc memory |
| name | Memory name (max string size RPROC_MAX_NAME_LEN) |
| pa | Physical address |
| da | Device address |
| size | Memory size |
| io | Pointer to the I/O region |
| int remoteproc_load | ( | struct remoteproc * | rproc, |
| const char * | path, | ||
| void * | store, | ||
| const struct image_store_ops * | store_ops, | ||
| void ** | img_info | ||
| ) |
Loads the executable.
Expects the user application defines how to open the executable file and how to get data from the executable file and how to load data to the target memory.
| rproc | Pointer to the remoteproc instance |
| path | Optional path to the image file |
| store | Pointer to user defined image store argument |
| store_ops | Pointer to image store operations |
| img_info | Pointer to memory which stores image information used by remoteproc loader |
| int remoteproc_load_noblock | ( | struct remoteproc * | rproc, |
| const void * | img_data, | ||
| size_t | offset, | ||
| size_t | len, | ||
| void ** | img_info, | ||
| metal_phys_addr_t * | pa, | ||
| struct metal_io_region ** | io, | ||
| size_t * | noffset, | ||
| size_t * | nlen, | ||
| size_t * | nmlen, | ||
| unsigned char * | padding | ||
| ) |
Loads the executable.
Expects the caller has loaded image data to local memory and passed to the this function. If the function needs more image data it will return the next expected image data offset and the next expected image data length. If the function requires the caller to download image data to the target memory, it will also return the target physical address besides the offset and length. This function can be used to load firmware in stream mode. In this mode, you cannot do seek to the executable file. If the executable is ELF, it cannot get the resource table section before it loads the full ELF file. Furthermore, application usually don't store the data which is loaded to local memory in streaming mode, and thus, in this mode, it will load the binary to the target memory before it gets the resource table. And thus, when calling this function don't put the target executable memory in the resource table, as this function will parse the resource table after it loads the binary to target memory.
| rproc | Pointer to the remoteproc instance |
| img_data | Pointer to image data for remoteproc loader to parse |
| offset | Image data offset to the beginning of the image file |
| len | Image data length |
| img_info | Pointer to memory which stores image information used by remoteproc loader |
| pa | Pointer to the target memory physical address. If the next expected data doesn't need to load to the target memory, the function will set it to ANY. |
| io | Pointer to the io region. If the next expected data doesn't need to load to the target memory, the function will set it to NULL. |
| noffset | Pointer to the next image data offset to the beginning of the image file needs to load to local or to the target memory. |
| nlen | Pointer to the next image data length needs to load to local or to the target memory. |
| nmlen | Pointer to the memory size. It is only used when the next expected data is going to be loaded to the target memory. E.g. in ELF, it is possible that loadable segment in memory is larger that the segment data in the ELF file. In this case, application will need to pad the rest of the memory with padding. |
| padding | Pointer to the padding value. It is only used when the next expected data is going to be loaded to the target memory and the target memory size is larger than the segment data in the executable file. |
| void* remoteproc_mmap | ( | struct remoteproc * | rproc, |
| metal_phys_addr_t * | pa, | ||
| metal_phys_addr_t * | da, | ||
| size_t | size, | ||
| unsigned int | attribute, | ||
| struct metal_io_region ** | io | ||
| ) |
Remoteproc mmap memory.
| rproc | Pointer to the remote processor |
| pa | Physical address pointer |
| da | Device address pointer |
| size | Size of the memory |
| attribute | Memory attribute |
| io | Pointer to the I/O region |
|
static |
|
static |
| int remoteproc_remove | ( | struct remoteproc * | rproc | ) |
Remove remoteproc resource.
| rproc | Pointer to remoteproc instance |
| void remoteproc_remove_virtio | ( | struct remoteproc * | rproc, |
| struct virtio_device * | vdev | ||
| ) |
Remove virtio device.
| rproc | Pointer to the remoteproc instance |
| vdev | Pointer to the virtio device |
| int remoteproc_set_rsc_table | ( | struct remoteproc * | rproc, |
| struct resource_table * | rsc_table, | ||
| size_t | rsc_size | ||
| ) |
Parse and set resource table of remoteproc.
| rproc | Pointer to remoteproc instance |
| rsc_table | Pointer to resource table |
| rsc_size | Resource table size |
| int remoteproc_shutdown | ( | struct remoteproc * | rproc | ) |
This function shuts down the remote processor and releases its resources.
| rproc | Pointer to remoteproc instance |
| int remoteproc_start | ( | struct remoteproc * | rproc | ) |
This function starts the remote processor.
It assumes the firmware is already loaded.
| rproc | Pointer to remoteproc instance to start |
| int remoteproc_stop | ( | struct remoteproc * | rproc | ) |
This function stops the remote processor but it will not release its resource.
| rproc | Pointer to remoteproc instance |
|
static |