/** * @brief platform_register_metal_device() - Statically Register libmetal * devices. * This function registers the IPI, shared memory and * TTC devices to the libmetal generic bus. * Libmetal uses bus structure to group the devices. Before you can * access the device with libmetal device operation, you will need to * register the device to a libmetal supported bus. * For non-Linux system, libmetal only supports "generic" bus, which is * used to manage the memory mapped devices. * * @return 0 - succeeded, non-zero for failures. */ int platform_register_metal_device(void) { unsigned int i; int ret; struct metal_device *dev; for (i = 0; i < sizeof(metal_dev_table)/sizeof(struct metal_device); i++) { dev = &metal_dev_table[i]; xil_printf("registering: %d, name=%s\n", i, dev->name); ret = metal_register_generic_device(dev); if (ret) return ret; } return 0; }
static struct remoteproc * platform_create_proc(int proc_index, int rsc_index) { void *rsc_table; int rsc_size; int ret; metal_phys_addr_t pa; (void) proc_index; rsc_table = get_resource_table(rsc_index, &rsc_size); /* Register IPI device */ (void)metal_register_generic_device(&scugic_device); /* Initialize remoteproc instance */ if (!remoteproc_init(&rproc_inst, &zynq_a9_proc_ops, &rproc_priv)) return NULL; /* * Mmap shared memories * Or shall we constraint that they will be set as carved out * in the resource table? */ /* mmap resource table */ pa = (metal_phys_addr_t)rsc_table; (void *)remoteproc_mmap(&rproc_inst, &pa, NULL, rsc_size, NORM_NONCACHE | STRONG_ORDERED, &rproc_inst.rsc_io); /* mmap shared memory */ pa = SHARED_MEM_PA; (void *)remoteproc_mmap(&rproc_inst, &pa, NULL, SHARED_MEM_SIZE, NORM_NONCACHE | STRONG_ORDERED, NULL); /* parse resource table to remoteproc */ ret = remoteproc_set_rsc_table(&rproc_inst, rsc_table, rsc_size); if (ret) { xil_printf("Failed to intialize remoteproc\r\n"); remoteproc_remove(&rproc_inst); return NULL; } xil_printf("Initialize remoteproc successfully.\r\n"); return &rproc_inst; }