db_ipc.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* Copyright (C) 2014 Stony Brook University
  2. This file is part of Graphene Library OS.
  3. Graphene Library OS is free software: you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public License
  5. as published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. Graphene Library OS is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. /*
  14. * db_ipc.c
  15. *
  16. * This file contains APIs for physical memory bulk copy across processes.
  17. */
  18. #include "pal_defs.h"
  19. #include "pal.h"
  20. #include "pal_internal.h"
  21. #include "pal_error.h"
  22. #include "api.h"
  23. PAL_HANDLE
  24. DkCreatePhysicalMemoryChannel (PAL_NUM * key)
  25. {
  26. ENTER_PAL_CALL(DkCreatePhysicalMemoryChannel);
  27. PAL_HANDLE handle = NULL;
  28. int ret = _DkCreatePhysicalMemoryChannel(&handle, key);
  29. if (ret < 0) {
  30. _DkRaiseFailure(-ret);
  31. handle = NULL;
  32. }
  33. LEAVE_PAL_CALL_RETURN(handle);
  34. }
  35. PAL_NUM
  36. DkPhysicalMemoryCommit (PAL_HANDLE channel, PAL_NUM entries, PAL_PTR * addrs,
  37. PAL_NUM * sizes)
  38. {
  39. ENTER_PAL_CALL(DkPhysicalMemoryCommit);
  40. if (!addrs || !sizes || !channel || !IS_HANDLE_TYPE(channel, gipc)) {
  41. _DkRaiseFailure(PAL_ERROR_INVAL);
  42. LEAVE_PAL_CALL_RETURN(0);
  43. }
  44. int ret = _DkPhysicalMemoryCommit(channel, entries, addrs, sizes);
  45. if (ret < 0) {
  46. _DkRaiseFailure(-ret);
  47. ret = 0;
  48. }
  49. LEAVE_PAL_CALL_RETURN(ret);
  50. }
  51. PAL_NUM
  52. DkPhysicalMemoryMap (PAL_HANDLE channel, PAL_NUM entries, PAL_PTR * addrs,
  53. PAL_NUM * sizes, PAL_FLG * prots)
  54. {
  55. ENTER_PAL_CALL(DkPhysicalMemoryMap);
  56. if (!sizes || !channel || !IS_HANDLE_TYPE(channel, gipc)) {
  57. _DkRaiseFailure(PAL_ERROR_INVAL);
  58. LEAVE_PAL_CALL_RETURN(0);
  59. }
  60. int ret = _DkPhysicalMemoryMap(channel, entries, addrs, sizes, prots);
  61. if (ret < 0) {
  62. _DkRaiseFailure(-ret);
  63. ret = 0;
  64. }
  65. LEAVE_PAL_CALL_RETURN(ret);
  66. }