db_ipc.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 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 Lesser 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 Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /*
  16. * db_ipc.c
  17. *
  18. * This file contains APIs for physical memory bulk copy across processes.
  19. */
  20. #include "pal_defs.h"
  21. #include "pal.h"
  22. #include "pal_internal.h"
  23. #include "pal_error.h"
  24. #include "api.h"
  25. PAL_HANDLE
  26. DkCreatePhysicalMemoryChannel (PAL_NUM * key)
  27. {
  28. ENTER_PAL_CALL(DkCreatePhysicalMemoryChannel);
  29. PAL_HANDLE handle = NULL;
  30. int ret = _DkCreatePhysicalMemoryChannel(&handle, key);
  31. if (ret < 0) {
  32. _DkRaiseFailure(-ret);
  33. handle = NULL;
  34. }
  35. TRACE_HEAP(handle);
  36. LEAVE_PAL_CALL_RETURN(handle);
  37. }
  38. PAL_NUM
  39. DkPhysicalMemoryCommit (PAL_HANDLE channel, PAL_NUM entries, PAL_PTR * addrs,
  40. PAL_NUM * sizes, PAL_FLG flags)
  41. {
  42. ENTER_PAL_CALL(DkPhysicalMemoryCommit);
  43. if (!addrs || !sizes || !channel || !IS_HANDLE_TYPE(channel, gipc)) {
  44. _DkRaiseFailure(PAL_ERROR_INVAL);
  45. LEAVE_PAL_CALL_RETURN(0);
  46. }
  47. int ret = _DkPhysicalMemoryCommit(channel, entries, addrs, sizes, flags);
  48. if (ret < 0) {
  49. _DkRaiseFailure(-ret);
  50. ret = 0;
  51. }
  52. LEAVE_PAL_CALL_RETURN(ret);
  53. }
  54. PAL_NUM
  55. DkPhysicalMemoryMap (PAL_HANDLE channel, PAL_NUM entries, PAL_PTR * addrs,
  56. PAL_NUM * sizes, PAL_FLG * prots)
  57. {
  58. ENTER_PAL_CALL(DkPhysicalMemoryMap);
  59. if (!sizes || !channel || !IS_HANDLE_TYPE(channel, gipc)) {
  60. _DkRaiseFailure(PAL_ERROR_INVAL);
  61. LEAVE_PAL_CALL_RETURN(0);
  62. }
  63. int ret = _DkPhysicalMemoryMap(channel, entries, addrs, sizes, prots);
  64. if (ret < 0) {
  65. _DkRaiseFailure(-ret);
  66. ret = 0;
  67. }
  68. LEAVE_PAL_CALL_RETURN(ret);
  69. }