00001
00002
00003 #ifndef _CORE_IPC_MSG_HPP
00004 #define _CORE_IPC_MSG_HPP
00005
00006
00007 #include "src/ipc/lock.hpp"
00008 #include "src/ipc/sem.hpp"
00009 #include "src/common/blist.hpp"
00010 #include "src/memory/heap.hpp"
00011
00012 namespace Thread {
00013 class thread_t;
00014 };
00015
00016 namespace IPC {
00017 namespace Message {
00018
00019
00020 struct message
00021 {
00022 class mailbox *sender;
00023 uint32 size;
00024 uint64 time_stamp;
00025 uint32 flags;
00026 };
00027
00028
00029 class mailbox
00030 {
00031 friend int allocate_mailbox (mailbox *mbx, struct ::Thread::thread_t *owner, Memory::Heap::heapbox *hp);
00032 public:
00033
00034 IPC::Lock::lock_t lock_mail;
00035 struct sem_t sem_mail;
00036 blist_t volatile inbox;
00037 Memory::Heap::heapbox *heap;
00038 struct ::Thread::thread_t *thread;
00039 uint32 mail;
00040
00041 int new_mail(mailbox *sender, void *data, size_t size, uint32 flags);
00042 public:
00043 void done();
00044
00045 int ksend(mailbox *dest, void *data, size_t size, uint32 flags);
00046 int kreceive(message **msg);
00047 int kreceive(message **msg, mailbox *sender);
00048
00049 int count();
00050
00051 int free_msg(message *msg);
00052 };
00053
00054 int allocate_mailbox (mailbox *mbx, struct ::Thread::thread_t *owner, Memory::Heap::heapbox *hp);
00055
00056 };
00057 };
00058
00059 #include "src/thread/thread.hpp"
00060
00061 #endif