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