Blame view

include/trusty/rpmb.h 2.9 KB
0ccdd527a   Haoran.Wang   MLK-18591-4 andro...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  /*
   * Copyright (C) 2016 The Android Open Source Project
   *
   * Permission is hereby granted, free of charge, to any person
   * obtaining a copy of this software and associated documentation
   * files (the "Software"), to deal in the Software without
   * restriction, including without limitation the rights to use, copy,
   * modify, merge, publish, distribute, sublicense, and/or sell copies
   * of the Software, and to permit persons to whom the Software is
   * furnished to do so, subject to the following conditions:
   *
   * The above copyright notice and this permission notice shall be
   * included in all copies or substantial portions of the Software.
   *
   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
   * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
   * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
   * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   * SOFTWARE.
   */
  
  #ifndef TRUSTY_RPMB_H_
  #define TRUSTY_RPMB_H_
  
  #include <trusty/sysdeps.h>
  #include <trusty/trusty_ipc.h>
  
  #define MMC_BLOCK_SIZE 512
  
  /*
   * Initialize RPMB storage proxy. Returns one of trusty_err.
   *
   * @dev:      initialized with trusty_ipc_dev_create
   * @rpmb_dev: Context of RPMB device, initialized with rpmb_storage_get_ctx
   */
  int rpmb_storage_proxy_init(struct trusty_ipc_dev *dev, void *rpmb_dev);
  /*
0ccdd527a   Haoran.Wang   MLK-18591-4 andro...
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
   * Shutdown RPMB storage proxy
   *
   * @dev: initialized with trusty_ipc_dev_create
   */
  void rpmb_storage_proxy_shutdown(struct trusty_ipc_dev *dev);
  /*
   * Execute RPMB command. Implementation is platform specific.
   * Returns one of trusty_err.
   *
   * @rpmb_dev:            Context of RPMB device, initialized with
   *                       rpmb_storage_get_ctx
   * @reliable_write_data: Buffer containing RPMB structs for reliable write
   * @reliable_write_size: Size of reliable_write_data
   * @write_data:          Buffer containing RPMB structs for write
   * @write_size:          Size of write_data
   * @read_data:           Buffer to be filled with RPMB structs read from RPMB
   *                       partition
   * @read_size:           Size of read_data
   */
  int rpmb_storage_send(void *rpmb_dev,
                        const void *reliable_write_data,
                        size_t reliable_write_size,
                        const void *write_data, size_t write_size,
                        void *read_buf, size_t read_size);
  /*
   * Return context for RPMB device. This is called when the RPMB storage proxy is
   * initialized, and subsequently used when issuing RPMB storage requests.
   * Implementation is platform specific.
   */
  void *rpmb_storage_get_ctx(void);
  
  /*
   * Put back RPMB device. This is called when the RPMB storage proxy is
   * shutdown
   */
  void rpmb_storage_put_ctx(void *dev);
  
  #endif /* TRUSTY_RPMB_H_ */