The Pedigree Project  0.1
modules/subsys/native/include/pedigree/native/ipc/Ipc.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef _NATIVE_IPC_H
21 #define _NATIVE_IPC_H
22 
23 #include "pedigree/native/compiler.h"
24 #include "pedigree/native/types.h"
25 
26 namespace PedigreeIpc
27 {
30 {
31  public:
33  virtual ~StandardIpcMessage();
34 
35  virtual bool initialise();
36 
38  StandardIpcMessage(void *);
39 
40  virtual void *getBuffer() const
41  {
42  return static_cast<void *>(m_vAddr);
43  }
44 
45  protected:
46  void *m_vAddr;
47 };
48 
52 {
53  public:
54  SharedIpcMessage(size_t nBytes, void *existingHandle);
55  virtual ~SharedIpcMessage();
56 
57  virtual bool initialise();
58 
59  void *getHandle() const
60  {
61  return m_pHandle;
62  }
63 
64  size_t getSize() const
65  {
66  return m_nBytes;
67  }
68 
69  private:
70  size_t m_nBytes;
71  void *m_pHandle;
72 };
73 
76 typedef void *IpcEndpoint;
77 
79 EXPORTED_PUBLIC bool
80 send(IpcEndpoint *pEndpoint, StandardIpcMessage *pMessage, bool bAsync = false);
81 EXPORTED_PUBLIC bool recv(
82  IpcEndpoint *pEndpoint, StandardIpcMessage **pMessage, bool bAsync = false);
83 
84 EXPORTED_PUBLIC IpcEndpoint *getEndpoint(const char *name);
85 
86 EXPORTED_PUBLIC void createEndpoint(const char *name);
87 EXPORTED_PUBLIC void removeEndpoint(const char *name);
88 
91 }; // namespace PedigreeIpc
92 
93 #endif
A standard IPC message that is less than 4 KB in size.