42#include <sdk/config.h>
48#include <asmp/mptask.h>
49#include <asmp/mpshm.h>
51#include <asmp/mpmutex.h>
53#include <multi_print.h>
60#define MPDBG(format, ...) printf("DEBUG: " format, ##__VA_ARGS__)
62#define MPDBG(format, ...)
64#define MPERR(format, ...) printf("ERROR: " format, ##__VA_ARGS__)
69#define MP_RECV_BLOCKING (0)
70#define MP_RECV_POLLING (MPMQ_NONBLOCK)
72#define MP_GET_CPUID() (*(volatile int *)0x4e002040)
78#define MPLOG_PREFIX "[Sub1] "
80#define MPLOG_PREFIX "[Sub2] "
82#define MPLOG_PREFIX "[Sub3] "
84#define MPLOG_PREFIX "[Sub4] "
86#define MPLOG_PREFIX "[Sub5] "
88#define MPLOG_PREFIX "[Main] "
91#define MPLog(fmt, ...) do { \
93 flags = printlock(); \
94 sync_printf(MPLOG_PREFIX fmt, ##__VA_ARGS__); \
157 int Send(int8_t msgid, uint32_t msgdata,
int subid = 0);
159 int Send(int8_t msgid, uint32_t msgdata,
int subid);
174 int Recv(int8_t *msgid, uint32_t *msgdata,
int subid = 0);
176 int Recv(int8_t *msgid, uint32_t *msgdata,
int subid);
191 int Send(int8_t msgid,
void *msgaddr,
int subid = 0);
193 int Send(int8_t msgid,
void *msgaddr,
int subid);
208 int Recv(int8_t *msgid,
void *msgaddr,
int subid = 0);
210 int Recv(int8_t *msgid,
void *msgaddr,
int subid);
224 template <
typename T>
int SendObject(T &t,
int subid = 0);
226 template <
typename T>
int SendObject(T &t,
int subid);
241 template <
typename T>
int RecvObject(T &t,
int subid = 0);
243 template <
typename T>
int RecvObject(T &t,
int subid);
321 uint32_t _recvTimeout;
322 mpmq_t _mq[MP_MAX_SUBID];
323 struct ResourceManagement {
326 uint32_t reserved[2];
327 uint32_t resource[4];
330 int checkid(
int subid);
332 mptask_t _mptask[MP_MAX_SUBID];
334 int unload(
int subid);
352 ret = checkid(subid);
357 size_t msgsz =
sizeof(T);
364 MPDBG(
"Send(&object) failure. %d\n", ret);
377 ret = checkid(subid);
382 size_t msgsz =
sizeof(T);
387 ret =
Recv(&rsz, (uint32_t*)&vp, subid);
389 if ((ret <= 0) || (msgsz != ret)) {
390 MPDBG(
"Recv(&object) failure. %d\n", ret);
391 mpmq_send(&_mq[subid], -1, 0);
395 memcpy(&t, vp, msgsz);
397 ret = mpmq_send(&_mq[subid], 0, 0);
399 MPDBG(
"mpmq_send() failure. %d\n", ret);
This is the interface for MP (Multi-Processor).
Definition: MP.h:108
int Recv(int8_t *msgid, void *msgaddr, int subid)
Receive the address of any message from the other processor.
int Send(int8_t msgid, void *msgaddr, int subid)
Send the address of any message to the other processor.
void * AllocSharedMemory(size_t size)
Allocate memory from shared memory.
uint32_t Virt2Phys(void *virt)
Convert virtual address to physical address.
int SendWaitComplete(int subid)
Wait for the object to be sent.
int begin(int subid)
Start communication with the other processor.
void DisableConsole()
Disable console.
int Recv(int8_t *msgid, uint32_t *msgdata, int subid)
Receive any 32bit-data from the other processor.
int Send(int8_t msgid, uint32_t msgdata, int subid)
Send any 32bit-data to the other processor.
uint32_t GetRecvTimeout()
Get timeout of receiver.
void RecvTimeout(uint32_t timeout)
Set timeout of receiver.
void EnableConsole()
Enable console.
void FreeSharedMemory(void *addr)
Free memory from shared memory.
void GetMemoryInfo(int &usedMem, int &freeMem, int &largestFreeMem)
Get memory information.
int end(int subid)
End communication with the other processor.
int SendObject(T &t, int subid)
Send any object to the other processor.
Definition: MP.h:348
int RecvObject(T &t, int subid)
Receive any object from the other processor.
Definition: MP.h:371