pal_host.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* Copyright (C) 2014 OSCAR lab, Stony Brook University
  4. This file is part of Graphene Library OS.
  5. Graphene Library OS is free software: you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation, either version 3 of the
  8. License, or (at your option) any later version.
  9. Graphene Library OS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /*
  16. * pal_host.h
  17. *
  18. * This file contains definition of PAL host ABI.
  19. */
  20. #ifndef PAL_HOST_H
  21. #define PAL_HOST_H
  22. #ifndef IN_PAL
  23. # error "cannot be included outside PAL"
  24. #endif
  25. typedef union pal_handle
  26. {
  27. /* TSAI: Here we define the internal types of PAL_HANDLE
  28. * in PAL design, user has not to access the content inside the
  29. * handle, also there is no need to allocate the internal
  30. * handles, so we hide the type name of these handles on purpose.
  31. */
  32. struct {
  33. PAL_IDX type;
  34. PAL_REF ref;
  35. PAL_FLG flags;
  36. PAL_IDX fds[];
  37. } __in;
  38. struct {
  39. PAL_HDR __in;
  40. PAL_IDX fd;
  41. PAL_NUM offset;
  42. PAL_BOL append;
  43. PAL_BOL pass;
  44. PAL_STR realpath;
  45. } file;
  46. struct {
  47. PAL_HDR __in;
  48. PAL_IDX fd;
  49. PAL_NUM pipeid;
  50. PAL_IDX connid;
  51. PAL_BOL nonblocking;
  52. } pipe;
  53. struct {
  54. PAL_HDR __in;
  55. PAL_IDX fds[2];
  56. PAL_BOL nonblocking;
  57. } pipeprv;
  58. struct {
  59. PAL_HDR __in;
  60. PAL_IDX fd_in, fd_out;
  61. PAL_IDX dev_type;
  62. PAL_BOL destroy;
  63. PAL_STR realpath;
  64. } dev;
  65. struct {
  66. PAL_HDR __in;
  67. PAL_IDX fd;
  68. PAL_STR realpath;
  69. PAL_BUF buf;
  70. PAL_BUF ptr;
  71. PAL_BUF end;
  72. PAL_BOL endofstream;
  73. } dir;
  74. struct {
  75. PAL_HDR __in;
  76. PAL_IDX fd;
  77. } gipc;
  78. struct {
  79. PAL_HDR __in;
  80. PAL_IDX fd;
  81. PAL_BUF bind;
  82. PAL_BUF conn;
  83. PAL_BOL nonblocking;
  84. PAL_BOL reuseaddr;
  85. PAL_NUM linger;
  86. PAL_NUM receivebuf;
  87. PAL_NUM sendbuf;
  88. PAL_NUM receivetimeout;
  89. PAL_NUM sendtimeout;
  90. PAL_BOL tcp_cork;
  91. PAL_BOL tcp_keepalive;
  92. PAL_BOL tcp_nodelay;
  93. } sock;
  94. struct {
  95. PAL_HDR __in;
  96. PAL_IDX stream_in, stream_out;
  97. PAL_IDX cargo;
  98. PAL_IDX pid;
  99. PAL_BOL nonblocking;
  100. } process;
  101. struct {
  102. PAL_HDR __in;
  103. PAL_IDX cli;
  104. PAL_IDX srv;
  105. PAL_IDX port;
  106. PAL_BOL nonblocking;
  107. } mcast;
  108. struct {
  109. PAL_HDR __in;
  110. PAL_IDX tid;
  111. } thread;
  112. struct {
  113. PAL_HDR __in;
  114. struct atomic_int nwaiters;
  115. PAL_NUM max_value;
  116. union {
  117. struct mutex_handle mut;
  118. struct atomic_int i;
  119. } value;
  120. } semaphore;
  121. struct {
  122. PAL_HDR __in;
  123. struct atomic_int signaled;
  124. struct atomic_int nwaiters;
  125. PAL_BOL isnotification;
  126. } event;
  127. } * PAL_HANDLE;
  128. #define RFD(n) (00001 << (n))
  129. #define WFD(n) (00010 << (n))
  130. #define WRITEABLE(n) (00100 << (n))
  131. #define ERROR(n) (01000 << (n))
  132. #define MAX_FDS (3)
  133. #define HAS_FDS (00077)
  134. #define HANDLE_TYPE(handle) ((handle)->__in.type)
  135. #endif /* PAL_HOST_H */