• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 <lk/compiler.h>
20 #include <stdint.h>
21 
22 #define HWBCC_PORT "com.android.trusty.hwbcc"
23 
24 /**
25  * enum hwbcc_cmd - BCC service commands.
26  * @HWBCC_CMD_REQ_SHIFT: Bitshift of the command index.
27  * @HWBCC_CMD_RESP_BIT:  Bit indicating that this is a response.
28  * @HWBCC_CMD_GET_DICE_ARTIFACTS: Get the DICE artifacts derived for a
29  * child node of Trusty in the DICE chain in non-secure world (e.g. ABL).
30  * @HWBCC_CMD_NS_DEPRIVILEGE: Deprivilege hwbcc from serving calls
31  * to non-secure clients.
32  */
33 enum hwbcc_cmd {
34     HWBCC_CMD_REQ_SHIFT = 1,
35     HWBCC_CMD_RESP_BIT = 1,
36     HWBCC_CMD_GET_DICE_ARTIFACTS = 3 << HWBCC_CMD_REQ_SHIFT,
37     HWBCC_CMD_NS_DEPRIVILEGE = 4 << HWBCC_CMD_REQ_SHIFT,
38 };
39 
40 /**
41  * struct hwbcc_req_hdr - Generic header for all hwbcc requests.
42  * @cmd:       The command to be run. Commands are described in hwbcc_cmd.
43  * @test_mode: Whether or not RKP is making a test request.
44  * @context:   Device specific context information passed in by the client.
45  *             This is opaque to the generic Trusty code. This is required
46  *             to make decisions about device specific behavior in the
47  *             implementations of certain hwbcc interface methods. For e.g.
48  *             w.r.t get_dice_artifacts, context can supply information
49  *             about which secure/non-secure DICE child node is requesting
50  *             the dice_artifacts and the implementations can use such
51  *             information to derive dice artifacts specific to the
52  *             particular child node.
53  */
54 struct hwbcc_req_hdr {
55     uint32_t cmd;
56     uint32_t test_mode;
57     uint64_t context;
58 };
59 STATIC_ASSERT(sizeof(struct hwbcc_req_hdr) == 16);
60 
61 /**
62  * struct hwbcc_resp_hdr - Generic header for all hwbcc requests.
63  * @cmd:          Command identifier - %HWBCC_CMD_RSP_BIT or'ed with the command
64  *                identifier of the corresponding request.
65  * @status:       Whether or not the cmd succeeded, or how it failed.
66  * @payload_size: Size of response payload that follows this struct.
67  */
68 struct hwbcc_resp_hdr {
69     uint32_t cmd;
70     int32_t status;
71     uint32_t payload_size;
72 };
73 STATIC_ASSERT(sizeof(struct hwbcc_resp_hdr) == 12);
74 
75 #define HWBCC_MAX_RESP_PAYLOAD_SIZE 1024