From d2dbbb85a5d6f560ca727e9adf87ab3227431ae1 Mon Sep 17 00:00:00 2001 From: pjht Date: Sat, 31 Aug 2019 16:46:21 -0500 Subject: [PATCH] Fix IPC issues (I suspect looparound issues) --- kernel/cpu/i386/mailboxes.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/kernel/cpu/i386/mailboxes.c b/kernel/cpu/i386/mailboxes.c index a3fe551..f6ad95b 100644 --- a/kernel/cpu/i386/mailboxes.c +++ b/kernel/cpu/i386/mailboxes.c @@ -56,21 +56,11 @@ void kernel_mailbox_send_msg(Message* user_msg) { void kernel_mailbox_get_msg(uint32_t box, Message* recv_msg, uint32_t buffer_sz) { Mailbox mailbox=mailboxes[box]; if (mailbox.msg_store[mailbox.rd].size==0) { - mailbox.rd++; - if (mailbox.rd==mailbox.size) { - mailbox.rd=0; - } - if (mailbox.msg_store[mailbox.rd].size==0) { - mailbox.rd--; - if (mailbox.rd==(2^32)-1) { - mailbox.rd=mailbox.size-1; - } - recv_msg->size=0; - recv_msg->from=0; - serial_printf("Box %d attempted to get a message, but there were none.\n",box); - mailboxes[box]=mailbox; - return; - } + recv_msg->size=0; + recv_msg->from=0; + serial_printf("Box %d attempted to get a message, but there were none.\n",box); + mailboxes[box]=mailbox; + return; } recv_msg->from=mailbox.msg_store[mailbox.rd].from; recv_msg->to=mailbox.msg_store[mailbox.rd].to; @@ -90,10 +80,7 @@ void kernel_mailbox_get_msg(uint32_t box, Message* recv_msg, uint32_t buffer_sz) mailbox.rd=0; } if (mailbox.rd>mailbox.wr) { - mailbox.rd=mailbox.wr-1; - if (mailbox.rd==(2^32)-1) { - mailbox.rd=mailbox.size-1; - } + mailbox.rd=mailbox.wr; } serial_printf("Box %d got a message from box %d.\n",box,recv_msg->from); mailboxes[box]=mailbox;