shared_memory.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_types.h"
  6. #include "core/hle/kernel/kernel.h"
  7. namespace Kernel {
  8. /// Permissions for mapped shared memory blocks
  9. enum class MemoryPermission : u32 {
  10. None = 0,
  11. Read = (1u << 0),
  12. Write = (1u << 1),
  13. ReadWrite = (Read | Write),
  14. DontCare = (1u << 28)
  15. };
  16. /**
  17. * Creates a shared memory object
  18. * @param name Optional name of shared memory object
  19. * @return Handle of newly created shared memory object
  20. */
  21. Handle CreateSharedMemory(const std::string& name="Unknown");
  22. /**
  23. * Maps a shared memory block to an address in system memory
  24. * @param handle Shared memory block handle
  25. * @param address Address in system memory to map shared memory block to
  26. * @param permissions Memory block map permissions (specified by SVC field)
  27. * @param other_permissions Memory block map other permissions (specified by SVC field)
  28. * @return Result of operation, 0 on success, otherwise error code
  29. */
  30. Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions,
  31. MemoryPermission other_permissions);
  32. /**
  33. * Gets a pointer to the shared memory block
  34. * @param handle Shared memory block handle
  35. * @param offset Offset from the start of the shared memory block to get pointer
  36. * @return Pointer to the shared memory block from the specified offset
  37. */
  38. u8* GetSharedMemoryPointer(Handle handle, u32 offset);
  39. } // namespace