Anson Huang | b629413 | 2018-06-05 16:05:59 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | /*! |
| 8 | * Header file containing the public API for the System Controller (SC) |
| 9 | * Resource Management (RM) function. This includes functions for |
| 10 | * partitioning resources, pads, and memory regions. |
| 11 | * |
| 12 | * @addtogroup RM_SVC (SVC) Resource Management Service |
| 13 | * |
| 14 | * Module for the Resource Management (RM) service. |
| 15 | * |
| 16 | * @includedoc rm/details.dox |
| 17 | * |
| 18 | * @{ |
| 19 | */ |
| 20 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 21 | #ifndef SCI_RM_API_H |
| 22 | #define SCI_RM_API_H |
Anson Huang | b629413 | 2018-06-05 16:05:59 +0800 | [diff] [blame] | 23 | |
| 24 | /* Includes */ |
| 25 | |
| 26 | #include <sci/sci_types.h> |
| 27 | |
| 28 | /* Defines */ |
| 29 | |
| 30 | /*! |
| 31 | * @name Defines for type widths |
| 32 | */ |
| 33 | /*@{*/ |
| 34 | #define SC_RM_PARTITION_W 5 /* Width of sc_rm_pt_t */ |
| 35 | #define SC_RM_MEMREG_W 6 /* Width of sc_rm_mr_t */ |
| 36 | #define SC_RM_DID_W 4 /* Width of sc_rm_did_t */ |
| 37 | #define SC_RM_SID_W 6 /* Width of sc_rm_sid_t */ |
| 38 | #define SC_RM_SPA_W 2 /* Width of sc_rm_spa_t */ |
| 39 | #define SC_RM_PERM_W 3 /* Width of sc_rm_perm_t */ |
| 40 | /*@}*/ |
| 41 | |
| 42 | /*! |
| 43 | * @name Defines for ALL parameters |
| 44 | */ |
| 45 | /*@{*/ |
| 46 | #define SC_RM_PT_ALL ((sc_rm_pt_t) UINT8_MAX) /* All partitions */ |
| 47 | #define SC_RM_MR_ALL ((sc_rm_mr_t) UINT8_MAX) /* All memory regions */ |
| 48 | /*@}*/ |
| 49 | |
| 50 | /*! |
| 51 | * @name Defines for sc_rm_spa_t |
| 52 | */ |
| 53 | /*@{*/ |
| 54 | #define SC_RM_SPA_PASSTHRU 0U /* Pass through (attribute driven by master) */ |
| 55 | #define SC_RM_SPA_PASSSID 1U /* Pass through and output on SID */ |
| 56 | #define SC_RM_SPA_ASSERT 2U /* Assert (force to be secure/privileged) */ |
| 57 | #define SC_RM_SPA_NEGATE 3U /* Negate (force to be non-secure/user) */ |
| 58 | /*@}*/ |
| 59 | |
| 60 | /*! |
| 61 | * @name Defines for sc_rm_perm_t |
| 62 | */ |
| 63 | /*@{*/ |
| 64 | #define SC_RM_PERM_NONE 0U /* No access */ |
| 65 | #define SC_RM_PERM_SEC_R 1U /* Secure RO */ |
| 66 | #define SC_RM_PERM_SECPRIV_RW 2U /* Secure privilege R/W */ |
| 67 | #define SC_RM_PERM_SEC_RW 3U /* Secure R/W */ |
| 68 | #define SC_RM_PERM_NSPRIV_R 4U /* Secure R/W, non-secure privilege RO */ |
| 69 | #define SC_RM_PERM_NS_R 5U /* Secure R/W, non-secure RO */ |
| 70 | #define SC_RM_PERM_NSPRIV_RW 6U /* Secure R/W, non-secure privilege R/W */ |
| 71 | #define SC_RM_PERM_FULL 7U /* Full access */ |
| 72 | /*@}*/ |
| 73 | |
| 74 | /* Types */ |
| 75 | |
| 76 | /*! |
| 77 | * This type is used to declare a resource partition. |
| 78 | */ |
| 79 | typedef uint8_t sc_rm_pt_t; |
| 80 | |
| 81 | /*! |
| 82 | * This type is used to declare a memory region. |
| 83 | */ |
| 84 | typedef uint8_t sc_rm_mr_t; |
| 85 | |
| 86 | /*! |
| 87 | * This type is used to declare a resource domain ID used by the |
| 88 | * isolation HW. |
| 89 | */ |
| 90 | typedef uint8_t sc_rm_did_t; |
| 91 | |
| 92 | /*! |
| 93 | * This type is used to declare an SMMU StreamID. |
| 94 | */ |
| 95 | typedef uint16_t sc_rm_sid_t; |
| 96 | |
| 97 | /*! |
| 98 | * This type is a used to declare master transaction attributes. |
| 99 | */ |
| 100 | typedef uint8_t sc_rm_spa_t; |
| 101 | |
| 102 | /*! |
| 103 | * This type is used to declare a resource/memory region access permission. |
| 104 | * Refer to the XRDC2 Block Guide for more information. |
| 105 | */ |
| 106 | typedef uint8_t sc_rm_perm_t; |
| 107 | |
| 108 | /* Functions */ |
| 109 | |
| 110 | /*! |
| 111 | * @name Partition Functions |
| 112 | * @{ |
| 113 | */ |
| 114 | |
| 115 | /*! |
| 116 | * This function requests that the SC create a new resource partition. |
| 117 | * |
| 118 | * @param[in] ipc IPC handle |
| 119 | * @param[out] pt return handle for partition; used for subsequent function |
| 120 | * calls associated with this partition |
| 121 | * @param[in] secure boolean indicating if this partition should be secure; only |
| 122 | * valid if caller is secure |
| 123 | * @param[in] isolated boolean indicating if this partition should be HW isolated |
| 124 | * via XRDC; set SC_TRUE if new DID is desired |
| 125 | * @param[in] restricted boolean indicating if this partition should be restricted; set |
| 126 | * SC_TRUE if masters in this partition cannot create new partitions |
| 127 | * @param[in] grant boolean indicating if this partition should always grant |
| 128 | * access and control to the parent |
| 129 | * @param[in] coherent boolean indicating if this partition is coherent; |
| 130 | * set SC_TRUE if only this partition will contain both AP clusters |
| 131 | * and they will be coherent via the CCI |
| 132 | * |
| 133 | * @return Returns an error code (SC_ERR_NONE = success). |
| 134 | * |
| 135 | * Return errors: |
| 136 | * - SC_ERR_NOACCESS if caller's partition is restricted, |
| 137 | * - SC_ERR_PARM if caller's partition is not secure but a new secure partition is requested, |
| 138 | * - SC_ERR_LOCKED if caller's partition is locked, |
| 139 | * - SC_ERR_UNAVAILABLE if partition table is full (no more allocation space) |
| 140 | * |
| 141 | * Marking as non-secure prevents subsequent functions from configuring masters in this |
| 142 | * partition to assert the secure signal. If restricted then the new partition is limited |
| 143 | * in what functions it can call, especially those associated with managing partitions. |
| 144 | * |
| 145 | * The grant option is usually used to isolate a bus master's traffic to specific |
| 146 | * memory without isolating the peripheral interface of the master or the API |
| 147 | * controls of that master. |
| 148 | */ |
| 149 | sc_err_t sc_rm_partition_alloc(sc_ipc_t ipc, sc_rm_pt_t *pt, sc_bool_t secure, |
| 150 | sc_bool_t isolated, sc_bool_t restricted, |
| 151 | sc_bool_t grant, sc_bool_t coherent); |
| 152 | |
| 153 | /*! |
| 154 | * This function makes a partition confidential. |
| 155 | * |
| 156 | * @param[in] ipc IPC handle |
| 157 | * @param[in] pt handle of partition that is granting |
| 158 | * @param[in] retro retroactive |
| 159 | * |
| 160 | * @return Returns an error code (SC_ERR_NONE = success). |
| 161 | * |
| 162 | * Return errors: |
| 163 | * - SC_PARM if \a pt out of range, |
| 164 | * - SC_ERR_NOACCESS if caller's not allowed to change \a pt |
| 165 | * - SC_ERR_LOCKED if partition \a pt is locked |
| 166 | * |
| 167 | * Call to make a partition confidential. Confidential means only this |
| 168 | * partition should be able to grant access permissions to this partition. |
| 169 | * |
| 170 | * If retroactive, then all resources owned by other partitions will have |
| 171 | * access rights for this partition removed, even if locked. |
| 172 | */ |
| 173 | sc_err_t sc_rm_set_confidential(sc_ipc_t ipc, sc_rm_pt_t pt, sc_bool_t retro); |
| 174 | |
| 175 | /*! |
| 176 | * This function frees a partition and assigns all resources to the caller. |
| 177 | * |
| 178 | * @param[in] ipc IPC handle |
| 179 | * @param[in] pt handle of partition to free |
| 180 | * |
| 181 | * @return Returns an error code (SC_ERR_NONE = success). |
| 182 | * |
| 183 | * Return errors: |
| 184 | * - SC_ERR_NOACCESS if caller's partition is restricted, |
| 185 | * - SC_PARM if \a pt out of range or invalid, |
| 186 | * - SC_ERR_NOACCESS if \a pt is the SC partition, |
| 187 | * - SC_ERR_NOACCESS if caller's partition is not the parent of \a pt, |
| 188 | * - SC_ERR_LOCKED if \a pt or caller's partition is locked |
| 189 | * |
| 190 | * All resources, memory regions, and pads are assigned to the caller/parent. |
| 191 | * The partition watchdog is disabled (even if locked). DID is freed. |
| 192 | */ |
| 193 | sc_err_t sc_rm_partition_free(sc_ipc_t ipc, sc_rm_pt_t pt); |
| 194 | |
| 195 | /*! |
| 196 | * This function returns the DID of a partition. |
| 197 | * |
| 198 | * @param[in] ipc IPC handle |
| 199 | * |
| 200 | * @return Returns the domain ID (DID) of the caller's partition. |
| 201 | * |
| 202 | * The DID is a SoC-specific internal ID used by the HW resource |
| 203 | * protection mechanism. It is only required by clients when using the |
| 204 | * SEMA42 module as the DID is sometimes connected to the master ID. |
| 205 | */ |
| 206 | sc_rm_did_t sc_rm_get_did(sc_ipc_t ipc); |
| 207 | |
| 208 | /*! |
| 209 | * This function forces a partition to use a specific static DID. |
| 210 | * |
| 211 | * @param[in] ipc IPC handle |
| 212 | * @param[in] pt handle of partition to assign \a did |
| 213 | * @param[in] did static DID to assign |
| 214 | * |
| 215 | * @return Returns an error code (SC_ERR_NONE = success). |
| 216 | * |
| 217 | * Return errors: |
| 218 | * - SC_ERR_NOACCESS if caller's partition is restricted, |
| 219 | * - SC_PARM if \a pt or \a did out of range, |
| 220 | * - SC_ERR_NOACCESS if caller's partition is not the parent of \a pt, |
| 221 | * - SC_ERR_LOCKED if \a pt is locked |
| 222 | * |
| 223 | * Assumes no assigned resources or memory regions yet! The number of static |
| 224 | * DID is fixed by the SC at boot. |
| 225 | */ |
| 226 | sc_err_t sc_rm_partition_static(sc_ipc_t ipc, sc_rm_pt_t pt, sc_rm_did_t did); |
| 227 | |
| 228 | /*! |
| 229 | * This function locks a partition. |
| 230 | * |
| 231 | * @param[in] ipc IPC handle |
| 232 | * @param[in] pt handle of partition to lock |
| 233 | * |
| 234 | * @return Returns an error code (SC_ERR_NONE = success). |
| 235 | * |
| 236 | * Return errors: |
| 237 | * - SC_PARM if \a pt out of range, |
| 238 | * - SC_ERR_NOACCESS if caller's partition is not the parent of \a pt |
| 239 | * |
| 240 | * If a partition is locked it cannot be freed, have resources/pads assigned |
| 241 | * to/from it, memory regions created/assigned, DID changed, or parent changed. |
| 242 | */ |
| 243 | sc_err_t sc_rm_partition_lock(sc_ipc_t ipc, sc_rm_pt_t pt); |
| 244 | |
| 245 | /*! |
| 246 | * This function gets the partition handle of the caller. |
| 247 | * |
| 248 | * @param[in] ipc IPC handle |
| 249 | * @param[out] pt return handle for caller's partition |
| 250 | * |
| 251 | * @return Returns an error code (SC_ERR_NONE = success). |
| 252 | */ |
| 253 | sc_err_t sc_rm_get_partition(sc_ipc_t ipc, sc_rm_pt_t *pt); |
| 254 | |
| 255 | /*! |
| 256 | * This function sets a new parent for a partition. |
| 257 | * |
| 258 | * @param[in] ipc IPC handle |
| 259 | * @param[in] pt handle of partition for which parent is to be |
| 260 | * changed |
| 261 | * @param[in] pt_parent handle of partition to set as parent |
| 262 | * |
| 263 | * @return Returns an error code (SC_ERR_NONE = success). |
| 264 | * |
| 265 | * Return errors: |
| 266 | * - SC_ERR_NOACCESS if caller's partition is restricted, |
| 267 | * - SC_PARM if arguments out of range or invalid, |
| 268 | * - SC_ERR_NOACCESS if caller's partition is not the parent of \a pt, |
| 269 | * - SC_ERR_LOCKED if either partition is locked |
| 270 | */ |
| 271 | sc_err_t sc_rm_set_parent(sc_ipc_t ipc, sc_rm_pt_t pt, sc_rm_pt_t pt_parent); |
| 272 | |
| 273 | /*! |
| 274 | * This function moves all movable resources/pads owned by a source partition |
| 275 | * to a destination partition. It can be used to more quickly set up a new |
| 276 | * partition if a majority of the caller's resources are to be moved to a |
| 277 | * new partition. |
| 278 | * |
| 279 | * @param[in] ipc IPC handle |
| 280 | * @param[in] pt_src handle of partition from which resources should |
| 281 | * be moved from |
| 282 | * @param[in] pt_dst handle of partition to which resources should be |
| 283 | * moved to |
| 284 | * @param[in] move_rsrc boolean to indicate if resources should be moved |
| 285 | * @param[in] move_pads boolean to indicate if pads should be moved |
| 286 | * |
| 287 | * @return Returns an error code (SC_ERR_NONE = success). |
| 288 | * |
| 289 | * By default, all resources are movable. This can be changed using the |
| 290 | * sc_rm_set_resource_movable() function. Note all masters defaulted to SMMU |
| 291 | * bypass. |
| 292 | * |
| 293 | * Return errors: |
| 294 | * - SC_ERR_NOACCESS if caller's partition is restricted, |
| 295 | * - SC_PARM if arguments out of range or invalid, |
| 296 | * - SC_ERR_NOACCESS if caller's partition is not \a pt_src or the |
| 297 | * parent of \a pt_src, |
| 298 | * - SC_ERR_LOCKED if either partition is locked |
| 299 | */ |
| 300 | sc_err_t sc_rm_move_all(sc_ipc_t ipc, sc_rm_pt_t pt_src, sc_rm_pt_t pt_dst, |
| 301 | sc_bool_t move_rsrc, sc_bool_t move_pads); |
| 302 | |
| 303 | /* @} */ |
| 304 | |
| 305 | /*! |
| 306 | * @name Resource Functions |
| 307 | * @{ |
| 308 | */ |
| 309 | |
| 310 | /*! |
| 311 | * This function assigns ownership of a resource to a partition. |
| 312 | * |
| 313 | * @param[in] ipc IPC handle |
| 314 | * @param[in] pt handle of partition to which resource should be |
| 315 | * assigned |
| 316 | * @param[in] resource resource to assign |
| 317 | * |
| 318 | * @return Returns an error code (SC_ERR_NONE = success). |
| 319 | * |
| 320 | * This action resets the resource's master and peripheral attributes. |
| 321 | * Privilege attribute will be PASSTHRU, security attribute will be |
| 322 | * ASSERT if the partition si secure and NEGATE if it is not, and |
| 323 | * masters will defaulted to SMMU bypass. Access permissions will reset |
| 324 | * to SEC_RW for the owning partition only for secure partitions, FULL for |
| 325 | * non-secure. DEfault is no access by other partitions. |
| 326 | * |
| 327 | * Return errors: |
| 328 | * - SC_ERR_NOACCESS if caller's partition is restricted, |
| 329 | * - SC_PARM if arguments out of range or invalid, |
| 330 | * - SC_ERR_NOACCESS if caller's partition is not the resource owner or parent |
| 331 | * of the owner, |
| 332 | * - SC_ERR_LOCKED if the owning partition or \a pt is locked |
| 333 | */ |
| 334 | sc_err_t sc_rm_assign_resource(sc_ipc_t ipc, sc_rm_pt_t pt, sc_rsrc_t resource); |
| 335 | |
| 336 | /*! |
| 337 | * This function flags resources as movable or not. |
| 338 | * |
| 339 | * @param[in] ipc IPC handle |
| 340 | * @param[in] resource_fst first resource for which flag should be set |
| 341 | * @param[in] resource_lst last resource for which flag should be set |
| 342 | * @param[in] movable movable flag (SC_TRUE is movable) |
| 343 | * |
| 344 | * @return Returns an error code (SC_ERR_NONE = success). |
| 345 | * |
| 346 | * Return errors: |
| 347 | * - SC_PARM if resources are out of range, |
| 348 | * - SC_ERR_NOACCESS if caller's partition is not a parent of a resource owner, |
| 349 | * - SC_ERR_LOCKED if the owning partition is locked |
| 350 | * |
| 351 | * This function is used to determine the set of resources that will be |
| 352 | * moved using the sc_rm_move_all() function. All resources are movable |
| 353 | * by default so this function is normally used to prevent a set of |
| 354 | * resources from moving. |
| 355 | */ |
| 356 | sc_err_t sc_rm_set_resource_movable(sc_ipc_t ipc, sc_rsrc_t resource_fst, |
| 357 | sc_rsrc_t resource_lst, sc_bool_t movable); |
| 358 | |
| 359 | /*! |
| 360 | * This function flags all of a subsystem's resources as movable |
| 361 | * or not. |
| 362 | * |
| 363 | * @param[in] ipc IPC handle |
| 364 | * @param[in] resource resource to use to identify subsystem |
| 365 | * @param[in] movable movable flag (SC_TRUE is movable) |
| 366 | * |
| 367 | * @return Returns an error code (SC_ERR_NONE = success). |
| 368 | * |
| 369 | * Return errors: |
| 370 | * - SC_ERR_PARM if a function argument is out of range |
| 371 | * |
| 372 | * Note \a resource is used to find the associated subsystem. Only |
| 373 | * resources owned by the caller are set. |
| 374 | */ |
| 375 | sc_err_t sc_rm_set_subsys_rsrc_movable(sc_ipc_t ipc, sc_rsrc_t resource, |
| 376 | sc_bool_t movable); |
| 377 | |
| 378 | /*! |
| 379 | * This function sets attributes for a resource which is a bus master (i.e. |
| 380 | * capable of DMA). |
| 381 | * |
| 382 | * @param[in] ipc IPC handle |
| 383 | * @param[in] resource master resource for which attributes should apply |
| 384 | * @param[in] sa security attribute |
| 385 | * @param[in] pa privilege attribute |
| 386 | * @param[in] smmu_bypass SMMU bypass mode |
| 387 | * |
| 388 | * @return Returns an error code (SC_ERR_NONE = success). |
| 389 | * |
| 390 | * Return errors: |
| 391 | * - SC_ERR_NOACCESS if caller's partition is restricted, |
| 392 | * - SC_PARM if arguments out of range or invalid, |
| 393 | * - SC_ERR_NOACCESS if caller's partition is not a parent of the resource owner, |
| 394 | * - SC_ERR_LOCKED if the owning partition is locked |
| 395 | * |
| 396 | * This function configures how the HW isolation will see bus transactions |
| 397 | * from the specified master. Note the security attribute will only be |
| 398 | * changed if the caller's partition is secure. |
| 399 | */ |
| 400 | sc_err_t sc_rm_set_master_attributes(sc_ipc_t ipc, sc_rsrc_t resource, |
| 401 | sc_rm_spa_t sa, sc_rm_spa_t pa, |
| 402 | sc_bool_t smmu_bypass); |
| 403 | |
| 404 | /*! |
| 405 | * This function sets the StreamID for a resource which is a bus master (i.e. |
| 406 | * capable of DMA). |
| 407 | * |
| 408 | * @param[in] ipc IPC handle |
| 409 | * @param[in] resource master resource for which attributes should apply |
| 410 | * @param[in] sid StreamID |
| 411 | * |
| 412 | * @return Returns an error code (SC_ERR_NONE = success). |
| 413 | * |
| 414 | * Return errors: |
| 415 | * - SC_ERR_NOACCESS if caller's partition is restricted, |
| 416 | * - SC_PARM if arguments out of range or invalid, |
| 417 | * - SC_ERR_NOACCESS if caller's partition is not the resource owner or parent |
| 418 | * of the owner, |
| 419 | * - SC_ERR_LOCKED if the owning partition is locked |
| 420 | * |
| 421 | * This function configures the SID attribute associated with all bus transactions |
| 422 | * from this master. Note 0 is not a valid SID as it is reserved to indicate |
| 423 | * bypass. |
| 424 | */ |
| 425 | sc_err_t sc_rm_set_master_sid(sc_ipc_t ipc, sc_rsrc_t resource, |
| 426 | sc_rm_sid_t sid); |
| 427 | |
| 428 | /*! |
| 429 | * This function sets access permissions for a peripheral resource. |
| 430 | * |
| 431 | * @param[in] ipc IPC handle |
| 432 | * @param[in] resource peripheral resource for which permissions should apply |
| 433 | * @param[in] pt handle of partition \a perm should by applied for |
| 434 | * @param[in] perm permissions to apply to \a resource for \a pt |
| 435 | * |
| 436 | * @return Returns an error code (SC_ERR_NONE = success). |
| 437 | * |
| 438 | * Return errors: |
| 439 | * - SC_PARM if arguments out of range or invalid, |
| 440 | * - SC_ERR_NOACCESS if caller's partition is not the resource owner or parent |
| 441 | * of the owner, |
| 442 | * - SC_ERR_LOCKED if the owning partition is locked |
| 443 | * - SC_ERR_LOCKED if the \a pt is confidential and the caller isn't \a pt |
| 444 | * |
| 445 | * This function configures how the HW isolation will restrict access to a |
| 446 | * peripheral based on the attributes of a transaction from bus master. |
| 447 | */ |
| 448 | sc_err_t sc_rm_set_peripheral_permissions(sc_ipc_t ipc, sc_rsrc_t resource, |
| 449 | sc_rm_pt_t pt, sc_rm_perm_t perm); |
| 450 | |
| 451 | /*! |
| 452 | * This function gets ownership status of a resource. |
| 453 | * |
| 454 | * @param[in] ipc IPC handle |
| 455 | * @param[in] resource resource to check |
| 456 | * |
| 457 | * @return Returns a boolean (SC_TRUE if caller's partition owns the resource). |
| 458 | * |
| 459 | * If \a resource is out of range then SC_FALSE is returned. |
| 460 | */ |
| 461 | sc_bool_t sc_rm_is_resource_owned(sc_ipc_t ipc, sc_rsrc_t resource); |
| 462 | |
| 463 | /*! |
| 464 | * This function is used to test if a resource is a bus master. |
| 465 | * |
| 466 | * @param[in] ipc IPC handle |
| 467 | * @param[in] resource resource to check |
| 468 | * |
| 469 | * @return Returns a boolean (SC_TRUE if the resource is a bus master). |
| 470 | * |
| 471 | * If \a resource is out of range then SC_FALSE is returned. |
| 472 | */ |
| 473 | sc_bool_t sc_rm_is_resource_master(sc_ipc_t ipc, sc_rsrc_t resource); |
| 474 | |
| 475 | /*! |
| 476 | * This function is used to test if a resource is a peripheral. |
| 477 | * |
| 478 | * @param[in] ipc IPC handle |
| 479 | * @param[in] resource resource to check |
| 480 | * |
| 481 | * @return Returns a boolean (SC_TRUE if the resource is a peripheral). |
| 482 | * |
| 483 | * If \a resource is out of range then SC_FALSE is returned. |
| 484 | */ |
| 485 | sc_bool_t sc_rm_is_resource_peripheral(sc_ipc_t ipc, sc_rsrc_t resource); |
| 486 | |
| 487 | /*! |
| 488 | * This function is used to obtain info about a resource. |
| 489 | * |
| 490 | * @param[in] ipc IPC handle |
| 491 | * @param[in] resource resource to inquire about |
| 492 | * @param[out] sid pointer to return StreamID |
| 493 | * |
| 494 | * @return Returns an error code (SC_ERR_NONE = success). |
| 495 | * |
| 496 | * Return errors: |
| 497 | * - SC_PARM if \a resource is out of range |
| 498 | */ |
| 499 | sc_err_t sc_rm_get_resource_info(sc_ipc_t ipc, sc_rsrc_t resource, |
| 500 | sc_rm_sid_t *sid); |
| 501 | |
| 502 | /* @} */ |
| 503 | |
| 504 | /*! |
| 505 | * @name Memory Region Functions |
| 506 | * @{ |
| 507 | */ |
| 508 | |
| 509 | /*! |
| 510 | * This function requests that the SC create a new memory region. |
| 511 | * |
| 512 | * @param[in] ipc IPC handle |
| 513 | * @param[out] mr return handle for region; used for |
| 514 | * subsequent function calls |
| 515 | * associated with this region |
| 516 | * @param[in] addr_start start address of region (physical) |
| 517 | * @param[in] addr_end end address of region (physical) |
| 518 | * |
| 519 | * @return Returns an error code (SC_ERR_NONE = success). |
| 520 | * |
| 521 | * Return errors: |
| 522 | * - SC_ERR_PARM if the new memory region is misaligned, |
| 523 | * - SC_ERR_LOCKED if caller's partition is locked, |
| 524 | * - SC_ERR_PARM if the new memory region spans multiple existing regions, |
| 525 | * - SC_ERR_NOACCESS if caller's partition does not own the memory containing |
| 526 | * the new region, |
| 527 | * - SC_ERR_UNAVAILABLE if memory region table is full (no more allocation |
| 528 | * space) |
| 529 | * |
| 530 | * The area covered by the memory region must currently be owned by the caller. |
| 531 | * By default, the new region will have access permission set to allow the |
| 532 | * caller to access. |
| 533 | */ |
| 534 | sc_err_t sc_rm_memreg_alloc(sc_ipc_t ipc, sc_rm_mr_t *mr, |
| 535 | sc_faddr_t addr_start, sc_faddr_t addr_end); |
| 536 | |
| 537 | /*! |
| 538 | * This function requests that the SC split a memory region. |
| 539 | * |
| 540 | * @param[in] ipc IPC handle |
| 541 | * @param[in] mr handle of memory region to split |
| 542 | * @param[out] mr_ret return handle for new region; used for |
| 543 | * subsequent function calls |
| 544 | * associated with this region |
| 545 | * @param[in] addr_start start address of region (physical) |
| 546 | * @param[in] addr_end end address of region (physical) |
| 547 | * |
| 548 | * @return Returns an error code (SC_ERR_NONE = success). |
| 549 | * |
| 550 | * Return errors: |
| 551 | * - SC_ERR_PARM if the new memory region is not start/end part of mr, |
| 552 | * - SC_ERR_LOCKED if caller's partition is locked, |
| 553 | * - SC_ERR_PARM if the new memory region spans multiple existing regions, |
| 554 | * - SC_ERR_NOACCESS if caller's partition does not own the memory containing |
| 555 | * the new region, |
| 556 | * - SC_ERR_UNAVAILABLE if memory region table is full (no more allocation |
| 557 | * space) |
| 558 | * |
| 559 | * Note the new region must start or end on the split region. |
| 560 | */ |
| 561 | sc_err_t sc_rm_memreg_split(sc_ipc_t ipc, sc_rm_mr_t mr, |
| 562 | sc_rm_mr_t *mr_ret, sc_faddr_t addr_start, |
| 563 | sc_faddr_t addr_end); |
| 564 | |
| 565 | /*! |
| 566 | * This function frees a memory region. |
| 567 | * |
| 568 | * @param[in] ipc IPC handle |
| 569 | * @param[in] mr handle of memory region to free |
| 570 | * |
| 571 | * @return Returns an error code (SC_ERR_NONE = success). |
| 572 | * |
| 573 | * Return errors: |
| 574 | * - SC_PARM if \a mr out of range or invalid, |
| 575 | * - SC_ERR_NOACCESS if caller's partition is not a parent of \a mr, |
| 576 | * - SC_ERR_LOCKED if the owning partition of \a mr is locked |
| 577 | */ |
| 578 | sc_err_t sc_rm_memreg_free(sc_ipc_t ipc, sc_rm_mr_t mr); |
| 579 | |
| 580 | /*! |
| 581 | * Internal SC function to find a memory region. |
| 582 | * |
| 583 | * @see sc_rm_find_memreg(). |
| 584 | */ |
| 585 | /*! |
| 586 | * This function finds a memory region. |
| 587 | * |
| 588 | * @param[in] ipc IPC handle |
| 589 | * @param[out] mr return handle for region; used for |
| 590 | * subsequent function calls |
| 591 | * associated with this region |
| 592 | * @param[in] addr_start start address of region to search for |
| 593 | * @param[in] addr_end end address of region to search for |
| 594 | * |
| 595 | * @return Returns an error code (SC_ERR_NONE = success). |
| 596 | * |
| 597 | * Return errors: |
| 598 | * - SC_ERR_NOTFOUND if region not found, |
| 599 | * |
| 600 | * Searches only for regions owned by the caller. Finds first |
| 601 | * region containing the range specified. |
| 602 | */ |
| 603 | sc_err_t sc_rm_find_memreg(sc_ipc_t ipc, sc_rm_mr_t *mr, |
| 604 | sc_faddr_t addr_start, sc_faddr_t addr_end); |
| 605 | |
| 606 | /*! |
| 607 | * This function assigns ownership of a memory region. |
| 608 | * |
| 609 | * @param[in] ipc IPC handle |
| 610 | * @param[in] pt handle of partition to which memory region |
| 611 | * should be assigned |
| 612 | * @param[in] mr handle of memory region to assign |
| 613 | * |
| 614 | * @return Returns an error code (SC_ERR_NONE = success). |
| 615 | * |
| 616 | * Return errors: |
| 617 | * - SC_PARM if arguments out of range or invalid, |
| 618 | * - SC_ERR_NOACCESS if caller's partition is not the \a mr owner or parent |
| 619 | * of the owner, |
| 620 | * - SC_ERR_LOCKED if the owning partition or \a pt is locked |
| 621 | */ |
| 622 | sc_err_t sc_rm_assign_memreg(sc_ipc_t ipc, sc_rm_pt_t pt, sc_rm_mr_t mr); |
| 623 | |
| 624 | /*! |
| 625 | * This function sets access permissions for a memory region. |
| 626 | * |
| 627 | * @param[in] ipc IPC handle |
| 628 | * @param[in] mr handle of memory region for which permissions |
| 629 | * should apply |
| 630 | * @param[in] pt handle of partition \a perm should by |
| 631 | * applied for |
| 632 | * @param[in] perm permissions to apply to \a mr for \a pt |
| 633 | * |
| 634 | * @return Returns an error code (SC_ERR_NONE = success). |
| 635 | * |
| 636 | * Return errors: |
| 637 | * - SC_PARM if arguments out of range or invalid, |
| 638 | * - SC_ERR_NOACCESS if caller's partition is not the region owner or parent |
| 639 | * of the owner, |
| 640 | * - SC_ERR_LOCKED if the owning partition is locked |
| 641 | * - SC_ERR_LOCKED if the \a pt is confidential and the caller isn't \a pt |
| 642 | * |
| 643 | * This function configures how the HW isolation will restrict access to a |
| 644 | * memory region based on the attributes of a transaction from bus master. |
| 645 | */ |
| 646 | sc_err_t sc_rm_set_memreg_permissions(sc_ipc_t ipc, sc_rm_mr_t mr, |
| 647 | sc_rm_pt_t pt, sc_rm_perm_t perm); |
| 648 | |
| 649 | /*! |
| 650 | * This function gets ownership status of a memory region. |
| 651 | * |
| 652 | * @param[in] ipc IPC handle |
| 653 | * @param[in] mr handle of memory region to check |
| 654 | * |
| 655 | * @return Returns a boolean (SC_TRUE if caller's partition owns the |
| 656 | * memory region). |
| 657 | * |
| 658 | * If \a mr is out of range then SC_FALSE is returned. |
| 659 | */ |
| 660 | sc_bool_t sc_rm_is_memreg_owned(sc_ipc_t ipc, sc_rm_mr_t mr); |
| 661 | |
| 662 | /*! |
| 663 | * This function is used to obtain info about a memory region. |
| 664 | * |
| 665 | * @param[in] ipc IPC handle |
| 666 | * @param[in] mr handle of memory region to inquire about |
| 667 | * @param[out] addr_start pointer to return start address |
| 668 | * @param[out] addr_end pointer to return end address |
| 669 | * |
| 670 | * @return Returns an error code (SC_ERR_NONE = success). |
| 671 | * |
| 672 | * Return errors: |
| 673 | * - SC_PARM if \a mr is out of range |
| 674 | */ |
| 675 | sc_err_t sc_rm_get_memreg_info(sc_ipc_t ipc, sc_rm_mr_t mr, |
| 676 | sc_faddr_t *addr_start, sc_faddr_t *addr_end); |
| 677 | |
| 678 | /* @} */ |
| 679 | |
| 680 | /*! |
| 681 | * @name Pad Functions |
| 682 | * @{ |
| 683 | */ |
| 684 | |
| 685 | /*! |
| 686 | * This function assigns ownership of a pad to a partition. |
| 687 | * |
| 688 | * @param[in] ipc IPC handle |
| 689 | * @param[in] pt handle of partition to which pad should |
| 690 | * be assigned |
| 691 | * @param[in] pad pad to assign |
| 692 | * |
| 693 | * @return Returns an error code (SC_ERR_NONE = success). |
| 694 | * |
| 695 | * Return errors: |
| 696 | * - SC_ERR_NOACCESS if caller's partition is restricted, |
| 697 | * - SC_PARM if arguments out of range or invalid, |
| 698 | * - SC_ERR_NOACCESS if caller's partition is not the pad owner or parent |
| 699 | * of the owner, |
| 700 | * - SC_ERR_LOCKED if the owning partition or \a pt is locked |
| 701 | */ |
| 702 | sc_err_t sc_rm_assign_pad(sc_ipc_t ipc, sc_rm_pt_t pt, sc_pad_t pad); |
| 703 | |
| 704 | /*! |
| 705 | * This function flags pads as movable or not. |
| 706 | * |
| 707 | * @param[in] ipc IPC handle |
| 708 | * @param[in] pad_fst first pad for which flag should be set |
| 709 | * @param[in] pad_lst last pad for which flag should be set |
| 710 | * @param[in] movable movable flag (SC_TRUE is movable) |
| 711 | * |
| 712 | * @return Returns an error code (SC_ERR_NONE = success). |
| 713 | * |
| 714 | * Return errors: |
| 715 | * - SC_PARM if pads are out of range, |
| 716 | * - SC_ERR_NOACCESS if caller's partition is not a parent of a pad owner, |
| 717 | * - SC_ERR_LOCKED if the owning partition is locked |
| 718 | * |
| 719 | * This function is used to determine the set of pads that will be |
| 720 | * moved using the sc_rm_move_all() function. All pads are movable |
| 721 | * by default so this function is normally used to prevent a set of |
| 722 | * pads from moving. |
| 723 | */ |
| 724 | sc_err_t sc_rm_set_pad_movable(sc_ipc_t ipc, sc_pad_t pad_fst, |
| 725 | sc_pad_t pad_lst, sc_bool_t movable); |
| 726 | |
| 727 | /*! |
| 728 | * This function gets ownership status of a pad. |
| 729 | * |
| 730 | * @param[in] ipc IPC handle |
| 731 | * @param[in] pad pad to check |
| 732 | * |
| 733 | * @return Returns a boolean (SC_TRUE if caller's partition owns the pad). |
| 734 | * |
| 735 | * If \a pad is out of range then SC_FALSE is returned. |
| 736 | */ |
| 737 | sc_bool_t sc_rm_is_pad_owned(sc_ipc_t ipc, sc_pad_t pad); |
| 738 | |
| 739 | /* @} */ |
| 740 | |
| 741 | /*! |
| 742 | * @name Debug Functions |
| 743 | * @{ |
| 744 | */ |
| 745 | |
| 746 | /*! |
| 747 | * This function dumps the RM state for debug. |
| 748 | * |
| 749 | * @param[in] ipc IPC handle |
| 750 | */ |
| 751 | void sc_rm_dump(sc_ipc_t ipc); |
| 752 | |
| 753 | /* @} */ |
| 754 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 755 | #endif /* SCI_RM_API_H */ |
Anson Huang | b629413 | 2018-06-05 16:05:59 +0800 | [diff] [blame] | 756 | |
| 757 | /**@}*/ |