metal_device
metal_device
IPI metal device
IPI metal device
TTC metal device
TTC metal device
SHM metal device
SHM metal device

(处理器间中断)是一个处理器中断另一个处理器的机制。 这通常用于多处理器系统中的处理器间通信和同步。 Libmetal 提供了一个 IPI API,允许软件在不同的处理器之间发送和接收中断,而不管它们的架构如何。

(处理器间中断)是一个处理器中断另一个处理器的机制。 这通常用于多处理器系统中的处理器间通信和同步。 Libmetal 提供了一个 IPI API,允许软件在不同的处理器之间发送和接收中断,而不管它们的架构如何。

(时间触发通信)是一种基于公共时钟同步两个或多个处理器的机制。 这对于实现实时系统非常有用,其中精确计时至关重要。 Libmetal 提供了一个 TTC API,允许软件配置和管理 TTC 硬件,以及基于 TTC 时钟发送和接收消息。

(时间触发通信)是一种基于公共时钟同步两个或多个处理器的机制。 这对于实现实时系统非常有用,其中精确计时至关重要。 Libmetal 提供了一个 TTC API,允许软件配置和管理 TTC 硬件,以及基于 TTC 时钟发送和接收消息。

(共享内存) 是一种让两个或多个处理器共享公共内存区域的机制。 这对于实现处理器间通信和同步以及在不同处理器之间共享数据很有用。 Libmetal 提供了一个 SHM API,允许软件分配和释放共享内存区域,以及读取和写入这些区域的数据。

(共享内存) 是一种让两个或多个处理器共享公共内存区域的机制。 这对于实现处理器间通信和同步以及在不同处理器之间共享数据很有用。 Libmetal 提供了一个 SHM API,允许软件分配和释放共享内存区域,以及读取和写入这些区域的数据。
int ipi_latency_demod()
int ipi_latency_demod()
struct channel_s
struct channel_s
struct metal_io_region *ipi_io; /* IPI metal i/o region */
struct metal_io_region *ipi_io; /* IPI meta...
struct metal_io_region *shm_io; /* Shared memory metal i/o region */
struct metal_io_region *shm_io; /* Shared m...
struct metal_io_region *ttc_io; /* TTC metal i/o region */
struct metal_io_region *ttc_io; /* TTC meta...
uint32_t ipi_mask;             /* RPU IPI mask */
uint32_t ipi_mask;             /* RPU IPI m...
atomic_int remote_nkicked;     /* 0 - kicked from remote */
atomic_int remote_nkicked;     /* 0 - kicke...
ch
ch
int sys_init()
int sys_init()
enable_caches();
enable_caches();
struct metal_init_params metal_param
struct metal_init_params metal_param
metal_log_handler      log_handler;
metal_log_handler      log_handler;
enum metal_log_level       log_level;
enum metal_log_level       log_level;
init_uart();
init_uart();
init_irq()
init_irq()
port
port
port
port
port
port
/* Initialize libmetal environment */
  metal_init(&metal_param);
/* Initialize libmetal environment */...
/* Initialize metal Xilinx IRQ controller */
    ret = metal_xlnx_irq_init();
/* Initialize metal Xilinx IRQ controller */...
port
port
/* Register libmetal devices */
platform_register_metal_device();
/* Register libmetal devices */...
/* Open libmetal devices which have been registered */
open_metal_devices();
/* Open libmetal devices which have been registered */...
int open_metal_devices(void)
int open_metal_devices(void)
/* Open TTC device */
    ret = metal_device_open(BUS_NAME, TTC_DEV_NAME,&ttc_dev);
/* Open TTC device */...
/* Open shared memory device */
    ret = metal_device_open(BUS_NAME, SHM_DEV_NAME,&shm_dev);
/* Open shared memory device */...
/* Open IPI device */
    ret = metal_device_open(BUS_NAME, IPI_DEV_NAME,&ipi_dev);
/* Open IPI device */...
application
applica...
void close_metal_devices(void)
void close_metal_devices(void)
/* Close IPI device */
metal_device_close(ipi_dev);
/* Close IPI device */...
/* Close TTC device */
metal_device_close(ttc_dev);
/* Close TTC device */...
/* Close shared memory device */
metal_device_close(shm_dev);
/* Close shared memory device */...
void sys_cleanup()
void sys_cleanup()
/* Close libmetal devices which have been opened */
close_metal_devices();
/* Close libmetal devices which have been...
/* Finish libmetal environment */
    metal_finish();
/* Finish libmetal environment */...
disable_caches();
disable_caches();
static struct metal_device metal_dev_table[]
{
/* IPI device */
        .name = IPI_DEV_NAME,
        .bus = NULL,
        .num_regions = 1,
        .regions = {
            {
                .virt = (void *)IPI_BASE_ADDR,
                .physmap = &metal_phys[0],
                .size = 0x1000,
                .page_shift = DEFAULT_PAGE_SHIFT,
                .page_mask = DEFAULT_PAGE_MASK,
                .mem_flags = DEVICE_NONSHARED | PRIV_RW_USER_RW,
                .ops = {NULL},
            }},
        .node = {NULL},
        .irq_num = 1,
        .irq_info = (void *)IPI_IRQ_VECT_ID,
}
static struct metal_device metal_dev_table[] =...
const metal_phys_addr_t metal_phys[]
const metal_phys_addr_t metal...
IPI_BASE_ADDR
IPI_BASE_ADDR
SHM_BASE_ADDR
SHM_BASE_ADDR
TTC0_BASE_ADDR
TTC0_BASE_ADDR
struct metal_device
struct metal_device
*ipi_dev
*ipi_dev
*shm_dev
*shm_dev
*ttc_dev
*ttc_dev
sys_init.c
sys_init.c
实例化设备
实例化设备
main()
main()
libmetal_amp_demod.c
libmetal_amp_demod.c
Setup libmetal resources
sys_init();
Setup libmetal resources...
Run the shared memory throughput demo
shmem_throughput_demod();
Run the shared memory throughput demo...
Run the shared memory latency demo
shmem_latency_demod();
Run the shared memory latency demo...
Run the ipi latency demo
ipi_latency_demod();
Run the ipi latency demo...
Run the IPI with shared memory demo
ipi_shmem_demod();
Run the IPI with shared memory demo...
Run the atomic across shared memory demo
atomic_shmem_demod();
Run the atomic across shared memory demo...
Run the shared memory demo
shmem_demod();
Run the shared memory demo...
Cleanup libmetal resources
sys_cleanup();
Cleanup libmetal resources...
shmem_echod() - Show use of shared memory with libmetal.
Wait for message from APU. Once received, read and echo it back.
shmem_echod() - Show use of shared memory wit...
reset_timer() - function to reset TTC counter
Set the RST bit in the Count Control Reg.
stop_timer() - function to stop TTC counter
Set the disable bit in the Count Control Reg.
reset_timer() - function to reset TTC counter...
ipi_irq_handler() - IPI interrupt handler
measure_ipi_latencyd() - measure IPI latency with libmetal Loop until APU tells RPU to stop via shared memory.
ipi_irq_handler() - IPI interrupt handler...
shm
shm
ttc
ttc
ipi
ipi
shmem_demo.c(主机 APU)
shmem_demo.c(主机 APU)
1.Open the shared memory device.
1.Open the shared memory device.
2.Clear the demo control TX/RX available values in shared memory.
2.Clear the demo control TX/RX available value...
3.APU set demo control in shared memory to notify RPU demo has started
3.APU set demo control in shared memory to not...
4.APU will write message to the shared memory.
4.APU will write message to the shared memory.
5.APU will increase TX avail values in the shared memory to notify RPU there is a message ready to read.
5.APU will increase TX avail values in the sha...
6.APU will poll the RX avail value in th shared memory to see if RPU has echoed back the message into the shared memory.
6.APU will poll the RX avail value in th share...
7.When APU knows there is new RX message available, it will read the RX message from the shared memory.
7.When APU knows there is new RX message avail...
8.APU will verify the message to see if it matches the one it has sent.
8.APU will verify the message to see if it mat...
9.Close the shared memory device.
9.Close the shared memory device.
shmem_demo.c(从机 RPU)
shmem_demo.c(从机 RPU)
1.Get the shared memory device I/O region.
1.Get the shared memory device I/O region.
2.Clear the demo control value in shared memory.
2.Clear the demo control value in shared memor...
3.Check the demo control value in the shared memory to wait for APU to start the demo.
3.Check the demo control value in the shared m...
4.Once the demo control value indicates the demo starts, it polls on RX available value to see if there is new RX message available.
4.Once the demo control value indicates the de...
5.If there is a new RX message available, it reads the message from the shared memory.
5.If there is a new RX message available, it r...
6.It echos back the message to the shared memory.
6.It echos back the message to the shared memo...
7.AIt increases the TX available value in the shared memory to notify the other end there is a message available to read.
7.AIt increases the TX available value in the...
8.Check if the demo control value and the RX available values to see if demo finishes and if there is new RX data available.
8.Check if the demo control value and the RX a...
主从机通信交互
主从机通信交互
Table
偏移
偏移
大小
大小
说明
说明
0
0
4Bytes
4Bytes
DEMO control status shows if demo starts or not
DEMO control status shows if demo starts or not
0x04
0x04
4Bytes
4Bytes
number of APU to RPU buffers available to RPU
number of APU to RPU buffers available to RPU
0x08
0x08
4Bytes
4Bytes
number of APU to RPU buffers consumed by RPU
number of APU to RPU buffers consumed by RPU
0x0c
0x0c
4Bytes
4Bytes
number of RPU to APU buffers available to APU
number of RPU to APU buffers available to APU
0x10
0x10
4Bytes
4Bytes
number of RPU to APU buffers consumed by APU
number of RPU to APU buffers consumed by APU
0x14
0x14
1KBytes
1KBytes
APU to RPU buffer
APU to RPU buffer
0x800
0x800
1KBytes
1KBytes
RPU to APU buffer
RPU to APU buffer
Text is not SVG - cannot display