• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
48 enum apploader_error : uint32_t {
49     APPLOADER_NO_ERROR = 0,
50     APPLOADER_ERR_UNKNOWN_CMD,
51     APPLOADER_ERR_INVALID_CMD,
52     APPLOADER_ERR_NO_MEMORY,
53     APPLOADER_ERR_VERIFICATION_FAILED,
54     APPLOADER_ERR_LOADING_FAILED,
55     APPLOADER_ERR_ALREADY_EXISTS,
56     APPLOADER_ERR_INTERNAL,
57 };
58 
59 /**
60  * apploader_header - Serial header for communicating with apploader
61  * @cmd: the command; one of &enum apploader_command values.
62  */
63 struct apploader_header {
64     uint32_t cmd;
65 } __packed;
66 
67 /**
68  * apploader_load_app_req - Serial arguments for LOAD_APPLICATION command
69  * @package_size: size of the application package.
70  *
71  * Load an application from a given memory region. The request message also
72  * contains a handle for a memfd that contains the application package.
73  *
74  * The response is a &struct apploader_resp with the error code or
75  * %APPLOADER_NO_ERROR on success.
76  */
77 struct apploader_load_app_req {
78     uint64_t package_size;
79 } __packed;
80 
81 /**
82  * apploader_resp - Common header for all apploader responses
83  * @hdr - header with command value.
84  * @error - error code returned by peer; one of &enum apploader_error values.
85  *
86  * This structure is followed by the response-specific payload, if the command
87  * has one.
88  */
89 struct apploader_resp {
90     struct apploader_header hdr;
91     uint32_t error;
92 } __packed;
93