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 15 #ifndef LLVM_TOOLS_LLI_REMOTETARGETMESSAGE_H 16 #define LLVM_TOOLS_LLI_REMOTETARGETMESSAGE_H 17 18 namespace llvm { 19 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. 24 // 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. 29 // 30 // Quick description of the protocol: 31 // 32 // { Header + Payload Size + Payload } 33 // 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. 38 // 39 // The current four known exchanges are: 40 // 41 // * Allocate Space: 42 // Parent: { LLI_AllocateSpace, 8, Alignment, Size } 43 // Child: { LLI_AllocationResult, 8, Address } 44 // 45 // * Load Data: 46 // Parent: { LLI_LoadDataSection, 8+Size, Address, Data } 47 // Child: { LLI_LoadComplete, 4, StatusCode } 48 // 49 // * Load Code: 50 // Parent: { LLI_LoadCodeSection, 8+Size, Address, Code } 51 // Child: { LLI_LoadComplete, 4, StatusCode } 52 // 53 // * Execute Code: 54 // Parent: { LLI_Execute, 8, Address } 55 // Child: { LLI_ExecutionResult, 4, Result } 56 // 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. 60 61 enum LLIMessageType { 62 LLI_Error = -1, 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) 66 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 70 71 LLI_Execute, // Data = uint64_t Address 72 LLI_ExecutionResult, // Data = uint32_t Result 73 74 LLI_Terminate // Data = not used 75 }; 76 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 81 }; 82 83 } // end namespace llvm 84 85 #endif 86