This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

how to write resource table for remoteproc (dsp c67)

Other Parts Discussed in Thread: DA8XX, OMAPL138

Hi everyone,


I try to write the dsp code, let remoteproc load it as firmware, then use

modprobe remoteproc
modprobe da8xx_remoteproc
modprobe virtio_rpmsg_bus

to run it.

After I trace the remoteproc_core.c, I guess I need write resource table for virtio device, but I cannot find any document.

I want to reference IPC 3.X code, but I am not familiar xdc and dsp code.

Could you give me some suggestion or about virtio queue communication?

The code I ref: henryomd.blogspot.tw/2015/02/zynq-amp-linux-on-cpu0-and-bare-metal.html

#define RAM_ADDR 0xc60000


typedef unsigned int u32;
typedef unsigned char u8;

#define offsetof(s,m) (u32)&(((s *)0)->m)


struct resource_table {//Just copied from linux/remoteproc.h
 u32 ver;//Must be 1 for remoteproc module!
 u32 num;
 u32 reserved[2];
 u32 offset[1];
};

enum fw_resource_type {
 RSC_CARVEOUT = 0,
 RSC_DEVMEM = 1,
 RSC_TRACE = 2,
 RSC_VDEV = 3,
 RSC_MMU  = 4,
 RSC_LAST = 5,
};

struct fw_rsc_carveout {
 u32 type;//from struct fw_rsc_hdr
 u32 da;
 u32 pa;
 u32 len;
 u32 flags;
 u32 reserved;
 u8 name[32];
};


const struct rproc_resource
{
    struct resource_table base;
    //u32 offset[4];
    struct fw_rsc_carveout code_cout;
}
ti_ipc_remoteproc_rt __attribute__ ((section (".rtable"))) =
{
 .base = { .ver = 1, .num = 1, .reserved = { 0, 0 },
   .offset = { offsetof(struct rproc_resource, code_cout) },
 },
 .code_cout = {
    //.type = RSC_CARVEOUT, .da = RAM_ADDR, .pa = RAM_ADDR, .len = 1<<19,
    .type = RSC_VDEV, .da = RAM_ADDR, .pa = RAM_ADDR, .len = 1<<19,
    .flags=0, .reserved=0, .name="CPU1CODE",
 },
};


int main()
{

  int a = ti_ipc_remoteproc_rt.base.offset; // if no use ti_ipc_remoteproc_rt, compile will optimize the variable (don't generate it)
    volatile unsigned int *message;

    message = (unsigned int *)0xc7000000;
    *message = 0xabcdef98;
    *(message + 1)= a;

    while(1);

    return 0;
}

my linker script:

/* =========================================================================*
 * OMAPL138_DSP.cmd - Linker Command File for Linking OMAPL138 DSP Programs    *
 *                                                                             *
 * These linker options are for command line linking only. For IDE linking, *
 * you should set your linker options in Project Properties.                *
 *         -c                    Link Using C Conventions                        *
 *        -stack     0x1000        Software Stack Size                                *
 *        -heap    0x1000        Heap Area Size                                    *
 * =========================================================================*/
-stack 0x1000
-heap 0x1000
 
/* =========================================================================*
 *                         Specify the System Memory Map                        *
 * =========================================================================*/
MEMORY
{
    entry_point:        o = 0xc5182800        l = 0x00000080
    L22:        o = 0x11800080        l = 0x0003FF80
    L1P:    o = 0x11E00000        l = 0x00008000
    L1D:    o = 0x11F00000        l = 0x00008000
    L2:    o = 0xC5000000        l = 0x00100000
}
 
/* =========================================================================*
 *                 Specify the Sections Allocation into Memory                    *
 * =========================================================================*/
SECTIONS
{
    .text:_c_int00 >     entry_point
    .cinit        >        L2                /* Initialization Tables            */
    .pinit        >        L2                /* C++ Constructor Tables            */
    .const        >        L2                /* Constant Data                    */
    .switch        >        L2                /* Jump Tables                        */
    .text        >        L2                /* Executable Code                    */
    
    .bss        >        L2                /* Global & Static Variables         */
    .far        >        L2                /* Far Global & Static Variables    */
    .stack        >        L2                /* Software System Stack            */
    .sysmem        >        L2                /* Dynamic Memory Allocation Area     */
    
    .cio        >        L2                /* C I/O Buffer                        */
    .vecs        >        L2                /* Interrupt Vectors                */
 
    .data        >        L2
    .args        >        L2
    .ppinfo        >        L2
    .ppdata        >        L2
    
    /* EABI Sections */
    .binit             >          L2
    .init_array        >          L2
    .neardata          >          L2
    .fardata           >          L2
    .rodata            >          L2
    .c6xabi.exidx      >          L2
    .c6xabi.extab      >          L2
 
.resource_table : {
   __rtable_start = .;
   *(.rtable)
   __rtable_end = .;
} > L2
 
    
}