1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <stdint.h> 20 21 #define APPLOADER_PORT "com.android.trusty.apploader" 22 23 enum apploader_command : uint32_t { 24 APPLOADER_REQ_SHIFT = 1, 25 APPLOADER_RESP_BIT = 1, 26 27 APPLOADER_CMD_LOAD_APPLICATION = (0 << APPLOADER_REQ_SHIFT), 28 APPLOADER_CMD_GET_VERSION = (1 << APPLOADER_REQ_SHIFT), 29 APPLOADER_CMD_UNLOAD_APPLICATION = (2 << APPLOADER_REQ_SHIFT), 30 }; 31 32 /** 33 * enum apploader_error - error codes for apploader 34 * @APPLOADER_NO_ERROR: no error 35 * @APPLOADER_ERR_UNKNOWN_CMD: unknown or not implemented command 36 * @APPLOADER_ERR_INVALID_CMD: invalid arguments or inputs passed to 37 * command 38 * @APPLOADER_ERR_NO_MEMORY: failed to allocate memory 39 * @APPLOADER_ERR_VERIFICATION_FAILED: failed to verify input application 40 * package for any reason, e.g., signature 41 * verification failed 42 * @APPLOADER_ERR_LOADING_FAILED: Trusty kernel or apploader service 43 * failed to load application 44 * @APPLOADER_ERR_ALREADY_EXISTS: application has already been loaded 45 * @APPLOADER_ERR_INTERNAL: miscellaneous or internal apploader 46 * error not covered by the above 47 * @APPLOADER_ERR_INVALID_VERSION: invalid application version 48 * @APPLOADER_ERR_POLICY_VIOLATION: signature verification succeeded but 49 * key+manifest combination not allowed 50 * by app loader policy engine 51 * @APPLOADER_ERR_NOT_ENCRYPTED: unmet application encryption requirement 52 */ 53 enum apploader_error : uint32_t { 54 APPLOADER_NO_ERROR = 0, 55 APPLOADER_ERR_UNKNOWN_CMD, 56 APPLOADER_ERR_INVALID_CMD, 57 APPLOADER_ERR_NO_MEMORY, 58 APPLOADER_ERR_VERIFICATION_FAILED, 59 APPLOADER_ERR_LOADING_FAILED, 60 APPLOADER_ERR_ALREADY_EXISTS, 61 APPLOADER_ERR_INTERNAL, 62 APPLOADER_ERR_INVALID_VERSION, 63 APPLOADER_ERR_POLICY_VIOLATION, 64 APPLOADER_ERR_NOT_ENCRYPTED, 65 }; 66 67 /** 68 * apploader_header - Serial header for communicating with apploader 69 * @cmd: the command; one of &enum apploader_command values. 70 */ 71 struct apploader_header { 72 uint32_t cmd; 73 } __packed; 74 75 /** 76 * apploader_load_app_req - Serial arguments for LOAD_APPLICATION command 77 * @package_size: size of the application package. 78 * 79 * Load an application from a given memory region. The request message also 80 * contains a handle for a memfd that contains the application package. 81 * 82 * The response is a &struct apploader_resp with the error code or 83 * %APPLOADER_NO_ERROR on success. 84 */ 85 struct apploader_load_app_req { 86 uint64_t package_size; 87 } __packed; 88 89 /** 90 * apploader_resp - Common header for all apploader responses 91 * @hdr - header with command value. 92 * @error - error code returned by peer; one of &enum apploader_error values. 93 * 94 * This structure is followed by the response-specific payload, if the command 95 * has one. 96 */ 97 struct apploader_resp { 98 struct apploader_header hdr; 99 uint32_t error; 100 } __packed; 101