db_ipc.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. TRACE_HEAP(handle);
  34. LEAVE_PAL_CALL_RETURN(handle);
  35. }
  36. PAL_NUM
  37. DkPhysicalMemoryCommit (PAL_HANDLE channel, PAL_NUM entries, PAL_PTR * addrs,
  38. PAL_NUM * sizes)
  39. {
  40. ENTER_PAL_CALL(DkPhysicalMemoryCommit);
  41. if (!addrs || !sizes || !channel || !IS_HANDLE_TYPE(channel, gipc)) {
  42. _DkRaiseFailure(PAL_ERROR_INVAL);
  43. LEAVE_PAL_CALL_RETURN(0);
  44. }
  45. int ret = _DkPhysicalMemoryCommit(channel, entries, addrs, sizes);
  46. if (ret < 0) {
  47. _DkRaiseFailure(-ret);
  48. ret = 0;
  49. }
  50. LEAVE_PAL_CALL_RETURN(ret);
  51. }
  52. PAL_NUM
  53. DkPhysicalMemoryMap (PAL_HANDLE channel, PAL_NUM entries, PAL_PTR * addrs,
  54. PAL_NUM * sizes, PAL_FLG * prots)
  55. {
  56. ENTER_PAL_CALL(DkPhysicalMemoryMap);
  57. if (!sizes || !channel || !IS_HANDLE_TYPE(channel, gipc)) {
  58. _DkRaiseFailure(PAL_ERROR_INVAL);
  59. LEAVE_PAL_CALL_RETURN(0);
  60. }
  61. int ret = _DkPhysicalMemoryMap(channel, entries, addrs, sizes, prots);
  62. if (ret < 0) {
  63. _DkRaiseFailure(-ret);
  64. ret = 0;
  65. }
  66. LEAVE_PAL_CALL_RETURN(ret);
  67. }