summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 655e99b)
raw | patch | inline | side by side (parent: 655e99b)
author | Chris Ring <cring@ti.com> | |
Mon, 14 Apr 2014 15:22:33 +0000 (08:22 -0700) | ||
committer | Chris Ring <cring@ti.com> | |
Tue, 15 Apr 2014 20:03:03 +0000 (13:03 -0700) |
Replace hard-coded vring addrs with runtime addrs read from
the resource table. This reduces the number of things to change
if the memory map moves around.
the resource table. This reduces the number of things to change
if the memory map moves around.
packages/ti/ipc/family/vayu/VirtQueue.c | patch | blob | history |
index 639cf66547ad97f2b09cbf50b4a0f332e237786f..bc23e1e44758628e69b62b812f2797bbce92b3ad 100644 (file)
#include <ti/sysbios/gates/GateHwi.h>
#include <ti/sysbios/hal/Cache.h>
+#include <ti/ipc/remoteproc/Resource.h>
#include <ti/ipc/MultiProc.h>
#include <ti/ipc/rpmsg/virtio_ring.h>
/* Used for defining the size of the virtqueue registry */
#define NUM_QUEUES 2
-/* Predefined device addresses */
-#ifdef DSP
-#define IPC_MEM_VRING0 0xA0000000
-#define IPC_MEM_VRING1 0xA0004000
-#else
-#define IPC_MEM_VRING0 0x60000000
-#define IPC_MEM_VRING1 0x60004000
-#endif
-
/*
* Size of the virtqueues (expressed in number of buffers supported,
* and must be power of two)
/* Gate to protect from multiple threads */
GateHwi_Handle gateH;
+
+ /* Base phys addr - used for quick pa/va translations */
+ UInt32 basePa;
+
+ /* Base virt addr - used for quick pa/va translations */
+ UInt32 baseVa;
} VirtQueue_Object;
/* module diags mask */
}
}
-static inline Void * mapPAtoVA(UInt pa)
+static inline Void * _VirtQueue_getVA(VirtQueue_Handle vq, UInt32 pa)
{
- return (Void *)((pa & 0x000fffffU) | IPC_MEM_VRING0);
+ return (Void *)(pa - vq->basePa + vq->baseVa);
}
/*!
*/
head = vq->vring.avail->ring[vq->last_avail_idx++ % vq->vring.num];
- *buf = mapPAtoVA(vq->vring.desc[head].addr);
+ *buf = _VirtQueue_getVA(vq, vq->vring.desc[head].addr);
*len = vq->vring.desc[head].len;
}
GateHwi_leave(vq->gateH, key);
@@ -431,6 +429,7 @@ VirtQueue_Handle VirtQueue_create(UInt16 remoteProcId, VirtQueue_Params *params,
{
VirtQueue_Object *vq;
Void *vringAddr;
+ Int result;
/* Perform initialization we can't do in Instance_init (being non-XDC): */
_VirtQueue_init();
@@ -456,12 +455,14 @@ VirtQueue_Handle VirtQueue_create(UInt16 remoteProcId, VirtQueue_Params *params,
switch (vq->id) {
/* IPC transport vrings */
case ID_SELF_TO_HOST:
- /* slave -> HOST */
- vringAddr = (struct vring *) IPC_MEM_VRING0;
- break;
case ID_HOST_TO_SELF:
- /* HOST -> slave */
- vringAddr = (struct vring *) IPC_MEM_VRING1;
+ vq->basePa = (UInt32)Resource_getVringDA(vq->id);
+ Assert_isTrue(vq->basePa != NULL, NULL);
+
+ result = Resource_physToVirt(vq->basePa, &(vq->baseVa));
+ Assert_isTrue(result == Resource_S_SUCCESS, (Assert_Id)NULL);
+
+ vringAddr = (Void *)vq->baseVa;
break;
default:
GateHwi_delete(&vq->gateH);