RemoteTargetMessage.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //===---- RemoteTargetMessage.h - LLI out-of-process message protocol -----===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // Definition of the LLIMessageType enum which is used for communication with a
  11. // child process for remote execution.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_TOOLS_LLI_REMOTETARGETMESSAGE_H
  15. #define LLVM_TOOLS_LLI_REMOTETARGETMESSAGE_H
  16. namespace llvm {
  17. // LLI messages from parent-to-child or vice versa follow an exceedingly simple
  18. // protocol where the first four bytes represent the message type, the next
  19. // four bytes represent the size of data for the command and following bytes
  20. // represent the actual data.
  21. //
  22. // The protocol is not intended to be robust, secure or fault-tolerant. It is
  23. // only here for testing purposes and is therefore intended to be the simplest
  24. // implementation that will work. It is assumed that the parent and child
  25. // share characteristics like endianness.
  26. //
  27. // Quick description of the protocol:
  28. //
  29. // { Header + Payload Size + Payload }
  30. //
  31. // The protocol message consist of a header, the payload size (which can be
  32. // zero), and the payload itself. The payload can contain any number of items,
  33. // and the size has to be the sum of them all. Each end is responsible for
  34. // reading/writing the correct number of items with the correct sizes.
  35. //
  36. // The current four known exchanges are:
  37. //
  38. // * Allocate Space:
  39. // Parent: { LLI_AllocateSpace, 8, Alignment, Size }
  40. // Child: { LLI_AllocationResult, 8, Address }
  41. //
  42. // * Load Data:
  43. // Parent: { LLI_LoadDataSection, 8+Size, Address, Data }
  44. // Child: { LLI_LoadComplete, 4, StatusCode }
  45. //
  46. // * Load Code:
  47. // Parent: { LLI_LoadCodeSection, 8+Size, Address, Code }
  48. // Child: { LLI_LoadComplete, 4, StatusCode }
  49. //
  50. // * Execute Code:
  51. // Parent: { LLI_Execute, 8, Address }
  52. // Child: { LLI_ExecutionResult, 4, Result }
  53. //
  54. // It is the responsibility of either side to check for correct headers,
  55. // sizes and payloads, since any inconsistency would misalign the pipe, and
  56. // result in data corruption.
  57. enum LLIMessageType {
  58. LLI_Error = -1,
  59. LLI_ChildActive = 0, // Data = not used
  60. LLI_AllocateSpace, // Data = struct { uint32_t Align, uint_32t Size }
  61. LLI_AllocationResult, // Data = uint64_t Address (child memory space)
  62. LLI_LoadCodeSection, // Data = uint64_t Address, void * SectionData
  63. LLI_LoadDataSection, // Data = uint64_t Address, void * SectionData
  64. LLI_LoadResult, // Data = uint32_t LLIMessageStatus
  65. LLI_Execute, // Data = uint64_t Address
  66. LLI_ExecutionResult, // Data = uint32_t Result
  67. LLI_Terminate // Data = not used
  68. };
  69. enum LLIMessageStatus {
  70. LLI_Status_Success = 0, // Operation succeeded
  71. LLI_Status_NotAllocated, // Address+Size not allocated in child space
  72. LLI_Status_IncompleteMsg // Size received doesn't match request
  73. };
  74. } // end namespace llvm
  75. #endif