hc
2024-03-22 f63cd4c03ea42695d5f9b0e1798edd196923aae6
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/** @file
 
  Copyright (c) 2020, Linaro Ltd. All rights reserved.<BR>
  SPDX-License-Identifier: BSD-2-Clause-Patent
 
**/
 
#ifndef OPTEE_RPMB_FVB_H_
#define OPTEE_RPMB_FVB_H_
 
/**
 Those are not currently defined in any spec, it's an internal
 contract between OP-TEE and EDK2.
 For more details check core/arch/arm/include/kernel/stmm_sp.h in OP-TEE
**/
#define SP_SVC_RPMB_READ_AARCH64        0xC4000066
#define SP_SVC_RPMB_WRITE_AARCH64       0xC4000067
 
#define SP_SVC_RPMB_READ_AARCH32        0x84000066
#define SP_SVC_RPMB_WRITE_AARCH32       0x84000067
 
#ifdef MDE_CPU_AARCH64
#define SP_SVC_RPMB_READ                SP_SVC_RPMB_READ_AARCH64
#define SP_SVC_RPMB_WRITE               SP_SVC_RPMB_WRITE_AARCH64
#endif
#ifdef MDE_CPU_ARM
#define SP_SVC_RPMB_READ                SP_SVC_RPMB_READ_AARCH32
#define SP_SVC_RPMB_WRITE               SP_SVC_RPMB_WRITE_AARCH32
#endif
 
#define FLASH_SIGNATURE            SIGNATURE_32 ('r', 'p', 'm', 'b')
#define INSTANCE_FROM_FVB_THIS(a)  CR (a, MEM_INSTANCE, FvbProtocol, \
                                      FLASH_SIGNATURE)
 
typedef struct _MEM_INSTANCE         MEM_INSTANCE;
typedef EFI_STATUS (*MEM_INITIALIZE) (MEM_INSTANCE* Instance);
 
/**
  This struct is used by the RPMB driver. Since the upper EDK2 layers
  expect byte addressable memory, we allocate a memory area of certain
  size and sync it to the hardware on reads/writes.
**/
struct _MEM_INSTANCE
{
    /// Internal signature used to discover the instance
    UINT32                              Signature;
    /// Function used to initialize the instance
    MEM_INITIALIZE                      Initialize;
    /// Set to true if initialized
    BOOLEAN                             Initialized;
    /// FVB protocol of the instance
    EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  FvbProtocol;
    /// Handle to install
    EFI_HANDLE                          Handle;
    /// Physical address of the beggining of the allocated memory
    EFI_PHYSICAL_ADDRESS                MemBaseAddress;
    /// Blocksize
    UINT16                              BlockSize;
    /// Number of allocated blocks
    UINT16                              NBlocks;
};
 
#endif