blob: 61f90ed1edd4adfc724e82621aa019779c3c8da5 [file] [log] [blame]
Soby Mathewe7cf1822025-04-24 07:51:33 +01001/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4 */
5
6#ifndef DEV_H
7#define DEV_H
8
9#include <app_fw_structures.h>
10#include <arch.h>
11#include <arch_features.h>
12#include <granule.h>
13#include <sizes.h>
14#include <smc-handler.h>
15#include <smc-rmi.h>
16#include <utils_def.h>
17
18/*
19 * Represents the state of communication between an RMM device object and a
20 * device. The device object could be PDEV or VDEV.
21 */
22#define DEV_COMM_ACTIVE U(0)
23#define DEV_COMM_ERROR U(1)
24#define DEV_COMM_IDLE U(2)
25#define DEV_COMM_PENDING U(3)
26
27/* PCIe device specific details */
28struct pcie_dev {
29 /* Device identifier */
30 uint64_t bdf;
31
32 /* PCIe Segment identifier of the Root Port and endpoint. */
33 uint16_t segment_id;
34
35 /*
36 * Physical PCIe routing identifier of the Root Port to which the
37 * endpoint is connected.
38 */
39 uint16_t root_id;
40
41 /* ECAM base address of the PCIe configuration space */
42 uint64_t ecam_addr;
43
44 /* Certificate slot identifier */
45 uint64_t cert_slot_id;
46
47 /* IDE stream ID */
48 uint64_t ide_sid;
49
50 /*
51 * Base and top of requester ID range (inclusive). The value is in
52 * PCI BDF format.
53 */
54 uint64_t rid_base;
55 uint64_t rid_top;
56
57 /* Device non-coherent address range and its range */
58 struct rmi_address_range
59 ncoh_addr_range[PDEV_PARAM_NCOH_ADDR_RANGE_MAX];
60 uint64_t ncoh_num_addr_range;
61};
62
63/*
64 * PDEV object. Represents a communication channel between the RMM and a
65 * physical device, for example a PCIe device.
66 */
67struct pdev {
68 /* Pointer to this granule */
69 struct granule *g_pdev;
70
71 /* State of this PDEV. RmiPdevState */
72 unsigned long rmi_state;
73
74 /* Flags provided by the Host during PDEV creation. RmiPdevFlags */
75 unsigned long rmi_flags;
76
77 /* Number of VDEVs associated with this PDEV */
78 uint32_t num_vdevs;
79
80 /* Number and addresses of PDEV auxiliary granules */
81 struct granule *g_aux[PDEV_PARAM_AUX_GRANULES_MAX];
82 unsigned int num_aux;
83
84 /*
85 * Algorithm used to generate device digests. This value is returned to
86 * Realm as part of RDEV_GET_INFO call
87 */
88 uint8_t rmi_hash_algo;
89
90 /* Device communiction state */
91 unsigned int dev_comm_state;
92
93 /* The associated device */
94 struct pcie_dev dev;
95
96 /* DA app cfg */
97 struct app_data_cfg da_app_data;
98};
99COMPILER_ASSERT(sizeof(struct pdev) <= GRANULE_SIZE);
100
101#endif /* DEV_H */