示例#1
0
文件: sys_arch.c 项目: AKuHAK2/ps2sdk
void sys_mbox_post(sys_mbox_t *mbox, void *msg)
{
	arch_message *MsgPkt;
	MsgPkt=alloc_msg();
	MsgPkt->sys_msg = msg;
	SendMbx(*mbox, (iop_message_t *)MsgPkt);
}
示例#2
0
void sys_mbox_post(sys_mbox_t mbid, void *sys_msg)
{
	arch_message *msg;
	//This function should only be invoked by ps2ip_input. It'll be invoked from an interrupt-context and the pMBox is non-full.

    // FIXME: Not sure if this is the best thing to do, will this lock up the only thread which will free up a message??
    while((msg = alloc_msg()) == NULL) { DelayThread(100); }

    msg->sys_msg = sys_msg;
    SendMbx(mbid, (iop_message_t *) msg);
}
示例#3
0
文件: sys_arch.c 项目: AKuHAK2/ps2sdk
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg){
	arch_message *MsgPkt;
	err_t result;

	if((MsgPkt = try_alloc_msg()) != NULL){
		MsgPkt->sys_msg = msg;
		SendMbx(*mbox, (iop_message_t *)MsgPkt);
		result=ERR_OK;
	}
	else result=ERR_MEM;

	return result;
}
示例#4
0
void basicPollingTest() {
	static const int msgCount = 3;
	int i = 0;
	MSG msg[msgCount];
	
	iop_mbx_t mbxInfo = {};
	mbxInfo.option = 0;
	mbxInfo.attr   = MBA_THFIFO | MBA_MSFIFO;
	s32 mbxId = CreateMbx(&mbxInfo);
	
	{
		s32 result = PollMbx(NULL, mbxId);
		printf("  polling from empty box: %d\n", result);
	}
	
	for (i = 0; i < msgCount; i++) {
		memset(&msg[i], 0, sizeof(MSG));
		msg[i].header.priority = msgCount - i;
		msg[i].payload         = i + 1;
		SendMbx(mbxId, &msg[i]);
	}
	
	printf("  box contents before polling: ");
	printMbx(mbxId);
	
	{
		MSG* msg = NULL;
		s32 result = PollMbx((void**)&msg, mbxId);
		printf("  polling from non-empty box: %d, message: %d\n", 
			result, msg->payload);
	}
	
	printf("  box contents after polling: ");
	printMbx(mbxId);
	
	DeleteMbx(mbxId);
}