rm_rpc_clnt.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. /*
  2. * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. /*!
  7. * File containing client-side RPC functions for the RM service. These
  8. * functions are ported to clients that communicate to the SC.
  9. *
  10. * @addtogroup RM_SVC
  11. * @{
  12. */
  13. /* Includes */
  14. #include <stdlib.h>
  15. #include <sci/sci_types.h>
  16. #include <sci/svc/rm/sci_rm_api.h>
  17. #include <sci/sci_rpc.h>
  18. #include "sci_rm_rpc.h"
  19. /* Local Defines */
  20. /* Local Types */
  21. /* Local Functions */
  22. sc_err_t sc_rm_partition_alloc(sc_ipc_t ipc, sc_rm_pt_t *pt, sc_bool_t secure,
  23. sc_bool_t isolated, sc_bool_t restricted,
  24. sc_bool_t grant, sc_bool_t coherent)
  25. {
  26. sc_rpc_msg_t msg;
  27. uint8_t result;
  28. RPC_VER(&msg) = SC_RPC_VERSION;
  29. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  30. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_PARTITION_ALLOC;
  31. RPC_U8(&msg, 0U) = (uint8_t)secure;
  32. RPC_U8(&msg, 1U) = (uint8_t)isolated;
  33. RPC_U8(&msg, 2U) = (uint8_t)restricted;
  34. RPC_U8(&msg, 3U) = (uint8_t)grant;
  35. RPC_U8(&msg, 4U) = (uint8_t)coherent;
  36. RPC_SIZE(&msg) = 3U;
  37. sc_call_rpc(ipc, &msg, SC_FALSE);
  38. result = RPC_R8(&msg);
  39. if (pt != NULL) {
  40. *pt = RPC_U8(&msg, 0U);
  41. }
  42. return (sc_err_t)result;
  43. }
  44. sc_err_t sc_rm_set_confidential(sc_ipc_t ipc, sc_rm_pt_t pt, sc_bool_t retro)
  45. {
  46. sc_rpc_msg_t msg;
  47. uint8_t result;
  48. RPC_VER(&msg) = SC_RPC_VERSION;
  49. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  50. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_CONFIDENTIAL;
  51. RPC_U8(&msg, 0U) = (uint8_t)pt;
  52. RPC_U8(&msg, 1U) = (uint8_t)retro;
  53. RPC_SIZE(&msg) = 2U;
  54. sc_call_rpc(ipc, &msg, SC_FALSE);
  55. result = RPC_R8(&msg);
  56. return (sc_err_t)result;
  57. }
  58. sc_err_t sc_rm_partition_free(sc_ipc_t ipc, sc_rm_pt_t pt)
  59. {
  60. sc_rpc_msg_t msg;
  61. uint8_t result;
  62. RPC_VER(&msg) = SC_RPC_VERSION;
  63. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  64. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_PARTITION_FREE;
  65. RPC_U8(&msg, 0U) = (uint8_t)pt;
  66. RPC_SIZE(&msg) = 2U;
  67. sc_call_rpc(ipc, &msg, SC_FALSE);
  68. result = RPC_R8(&msg);
  69. return (sc_err_t)result;
  70. }
  71. sc_rm_did_t sc_rm_get_did(sc_ipc_t ipc)
  72. {
  73. sc_rpc_msg_t msg;
  74. uint8_t result;
  75. RPC_VER(&msg) = SC_RPC_VERSION;
  76. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  77. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_GET_DID;
  78. RPC_SIZE(&msg) = 1U;
  79. sc_call_rpc(ipc, &msg, SC_FALSE);
  80. result = RPC_R8(&msg);
  81. return (sc_rm_did_t) result;
  82. }
  83. sc_err_t sc_rm_partition_static(sc_ipc_t ipc, sc_rm_pt_t pt, sc_rm_did_t did)
  84. {
  85. sc_rpc_msg_t msg;
  86. uint8_t result;
  87. RPC_VER(&msg) = SC_RPC_VERSION;
  88. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  89. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_PARTITION_STATIC;
  90. RPC_U8(&msg, 0U) = (uint8_t)pt;
  91. RPC_U8(&msg, 1U) = (uint8_t)did;
  92. RPC_SIZE(&msg) = 2U;
  93. sc_call_rpc(ipc, &msg, SC_FALSE);
  94. result = RPC_R8(&msg);
  95. return (sc_err_t)result;
  96. }
  97. sc_err_t sc_rm_partition_lock(sc_ipc_t ipc, sc_rm_pt_t pt)
  98. {
  99. sc_rpc_msg_t msg;
  100. uint8_t result;
  101. RPC_VER(&msg) = SC_RPC_VERSION;
  102. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  103. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_PARTITION_LOCK;
  104. RPC_U8(&msg, 0U) = (uint8_t)pt;
  105. RPC_SIZE(&msg) = 2U;
  106. sc_call_rpc(ipc, &msg, SC_FALSE);
  107. result = RPC_R8(&msg);
  108. return (sc_err_t)result;
  109. }
  110. sc_err_t sc_rm_get_partition(sc_ipc_t ipc, sc_rm_pt_t *pt)
  111. {
  112. sc_rpc_msg_t msg;
  113. uint8_t result;
  114. RPC_VER(&msg) = SC_RPC_VERSION;
  115. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  116. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_GET_PARTITION;
  117. RPC_SIZE(&msg) = 1U;
  118. sc_call_rpc(ipc, &msg, SC_FALSE);
  119. result = RPC_R8(&msg);
  120. if (pt != NULL) {
  121. *pt = RPC_U8(&msg, 0U);
  122. }
  123. return (sc_err_t)result;
  124. }
  125. sc_err_t sc_rm_set_parent(sc_ipc_t ipc, sc_rm_pt_t pt, sc_rm_pt_t pt_parent)
  126. {
  127. sc_rpc_msg_t msg;
  128. uint8_t result;
  129. RPC_VER(&msg) = SC_RPC_VERSION;
  130. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  131. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_PARENT;
  132. RPC_U8(&msg, 0U) = (uint8_t)pt;
  133. RPC_U8(&msg, 1U) = (uint8_t)pt_parent;
  134. RPC_SIZE(&msg) = 2U;
  135. sc_call_rpc(ipc, &msg, SC_FALSE);
  136. result = RPC_R8(&msg);
  137. return (sc_err_t)result;
  138. }
  139. sc_err_t sc_rm_move_all(sc_ipc_t ipc, sc_rm_pt_t pt_src, sc_rm_pt_t pt_dst,
  140. sc_bool_t move_rsrc, sc_bool_t move_pads)
  141. {
  142. sc_rpc_msg_t msg;
  143. uint8_t result;
  144. RPC_VER(&msg) = SC_RPC_VERSION;
  145. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  146. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_MOVE_ALL;
  147. RPC_U8(&msg, 0U) = (uint8_t)pt_src;
  148. RPC_U8(&msg, 1U) = (uint8_t)pt_dst;
  149. RPC_U8(&msg, 2U) = (uint8_t)move_rsrc;
  150. RPC_U8(&msg, 3U) = (uint8_t)move_pads;
  151. RPC_SIZE(&msg) = 2U;
  152. sc_call_rpc(ipc, &msg, SC_FALSE);
  153. result = RPC_R8(&msg);
  154. return (sc_err_t)result;
  155. }
  156. sc_err_t sc_rm_assign_resource(sc_ipc_t ipc, sc_rm_pt_t pt, sc_rsrc_t resource)
  157. {
  158. sc_rpc_msg_t msg;
  159. uint8_t result;
  160. RPC_VER(&msg) = SC_RPC_VERSION;
  161. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  162. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_ASSIGN_RESOURCE;
  163. RPC_U16(&msg, 0U) = (uint16_t)resource;
  164. RPC_U8(&msg, 2U) = (uint8_t)pt;
  165. RPC_SIZE(&msg) = 2U;
  166. sc_call_rpc(ipc, &msg, SC_FALSE);
  167. result = RPC_R8(&msg);
  168. return (sc_err_t)result;
  169. }
  170. sc_err_t sc_rm_set_resource_movable(sc_ipc_t ipc, sc_rsrc_t resource_fst,
  171. sc_rsrc_t resource_lst, sc_bool_t movable)
  172. {
  173. sc_rpc_msg_t msg;
  174. uint8_t result;
  175. RPC_VER(&msg) = SC_RPC_VERSION;
  176. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  177. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_RESOURCE_MOVABLE;
  178. RPC_U16(&msg, 0U) = (uint16_t)resource_fst;
  179. RPC_U16(&msg, 2U) = (uint16_t)resource_lst;
  180. RPC_U8(&msg, 4U) = (uint8_t)movable;
  181. RPC_SIZE(&msg) = 3U;
  182. sc_call_rpc(ipc, &msg, SC_FALSE);
  183. result = RPC_R8(&msg);
  184. return (sc_err_t)result;
  185. }
  186. sc_err_t sc_rm_set_subsys_rsrc_movable(sc_ipc_t ipc, sc_rsrc_t resource,
  187. sc_bool_t movable)
  188. {
  189. sc_rpc_msg_t msg;
  190. uint8_t result;
  191. RPC_VER(&msg) = SC_RPC_VERSION;
  192. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  193. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_SUBSYS_RSRC_MOVABLE;
  194. RPC_U16(&msg, 0U) = (uint16_t)resource;
  195. RPC_U8(&msg, 2U) = (uint8_t)movable;
  196. RPC_SIZE(&msg) = 2U;
  197. sc_call_rpc(ipc, &msg, SC_FALSE);
  198. result = RPC_R8(&msg);
  199. return (sc_err_t)result;
  200. }
  201. sc_err_t sc_rm_set_master_attributes(sc_ipc_t ipc, sc_rsrc_t resource,
  202. sc_rm_spa_t sa, sc_rm_spa_t pa,
  203. sc_bool_t smmu_bypass)
  204. {
  205. sc_rpc_msg_t msg;
  206. uint8_t result;
  207. RPC_VER(&msg) = SC_RPC_VERSION;
  208. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  209. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_MASTER_ATTRIBUTES;
  210. RPC_U16(&msg, 0U) = (uint16_t)resource;
  211. RPC_U8(&msg, 2U) = (uint8_t)sa;
  212. RPC_U8(&msg, 3U) = (uint8_t)pa;
  213. RPC_U8(&msg, 4U) = (uint8_t)smmu_bypass;
  214. RPC_SIZE(&msg) = 3U;
  215. sc_call_rpc(ipc, &msg, SC_FALSE);
  216. result = RPC_R8(&msg);
  217. return (sc_err_t)result;
  218. }
  219. sc_err_t sc_rm_set_master_sid(sc_ipc_t ipc, sc_rsrc_t resource, sc_rm_sid_t sid)
  220. {
  221. sc_rpc_msg_t msg;
  222. uint8_t result;
  223. RPC_VER(&msg) = SC_RPC_VERSION;
  224. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  225. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_MASTER_SID;
  226. RPC_U16(&msg, 0U) = (uint16_t)resource;
  227. RPC_U16(&msg, 2U) = (uint16_t)sid;
  228. RPC_SIZE(&msg) = 2U;
  229. sc_call_rpc(ipc, &msg, SC_FALSE);
  230. result = RPC_R8(&msg);
  231. return (sc_err_t)result;
  232. }
  233. sc_err_t sc_rm_set_peripheral_permissions(sc_ipc_t ipc, sc_rsrc_t resource,
  234. sc_rm_pt_t pt, sc_rm_perm_t perm)
  235. {
  236. sc_rpc_msg_t msg;
  237. uint8_t result;
  238. RPC_VER(&msg) = SC_RPC_VERSION;
  239. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  240. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_PERIPHERAL_PERMISSIONS;
  241. RPC_U16(&msg, 0U) = (uint16_t)resource;
  242. RPC_U8(&msg, 2U) = (uint8_t)pt;
  243. RPC_U8(&msg, 3U) = (uint8_t)perm;
  244. RPC_SIZE(&msg) = 2U;
  245. sc_call_rpc(ipc, &msg, SC_FALSE);
  246. result = RPC_R8(&msg);
  247. return (sc_err_t)result;
  248. }
  249. sc_bool_t sc_rm_is_resource_owned(sc_ipc_t ipc, sc_rsrc_t resource)
  250. {
  251. sc_rpc_msg_t msg;
  252. uint8_t result;
  253. RPC_VER(&msg) = SC_RPC_VERSION;
  254. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  255. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_IS_RESOURCE_OWNED;
  256. RPC_U16(&msg, 0U) = (uint16_t)resource;
  257. RPC_SIZE(&msg) = 2U;
  258. sc_call_rpc(ipc, &msg, SC_FALSE);
  259. result = RPC_R8(&msg);
  260. return (sc_bool_t)result;
  261. }
  262. sc_bool_t sc_rm_is_resource_master(sc_ipc_t ipc, sc_rsrc_t resource)
  263. {
  264. sc_rpc_msg_t msg;
  265. uint8_t result;
  266. RPC_VER(&msg) = SC_RPC_VERSION;
  267. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  268. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_IS_RESOURCE_MASTER;
  269. RPC_U16(&msg, 0U) = (uint16_t)resource;
  270. RPC_SIZE(&msg) = 2U;
  271. sc_call_rpc(ipc, &msg, SC_FALSE);
  272. result = RPC_R8(&msg);
  273. return (sc_bool_t)result;
  274. }
  275. sc_bool_t sc_rm_is_resource_peripheral(sc_ipc_t ipc, sc_rsrc_t resource)
  276. {
  277. sc_rpc_msg_t msg;
  278. uint8_t result;
  279. RPC_VER(&msg) = SC_RPC_VERSION;
  280. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  281. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_IS_RESOURCE_PERIPHERAL;
  282. RPC_U16(&msg, 0U) = (uint16_t)resource;
  283. RPC_SIZE(&msg) = 2U;
  284. sc_call_rpc(ipc, &msg, SC_FALSE);
  285. result = RPC_R8(&msg);
  286. return (sc_bool_t)result;
  287. }
  288. sc_err_t sc_rm_get_resource_info(sc_ipc_t ipc, sc_rsrc_t resource,
  289. sc_rm_sid_t *sid)
  290. {
  291. sc_rpc_msg_t msg;
  292. uint8_t result;
  293. RPC_VER(&msg) = SC_RPC_VERSION;
  294. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  295. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_GET_RESOURCE_INFO;
  296. RPC_U16(&msg, 0U) = (uint16_t)resource;
  297. RPC_SIZE(&msg) = 2U;
  298. sc_call_rpc(ipc, &msg, SC_FALSE);
  299. if (sid != NULL) {
  300. *sid = RPC_U16(&msg, 0U);
  301. }
  302. result = RPC_R8(&msg);
  303. return (sc_err_t)result;
  304. }
  305. sc_err_t sc_rm_memreg_alloc(sc_ipc_t ipc, sc_rm_mr_t *mr,
  306. sc_faddr_t addr_start, sc_faddr_t addr_end)
  307. {
  308. sc_rpc_msg_t msg;
  309. uint8_t result;
  310. RPC_VER(&msg) = SC_RPC_VERSION;
  311. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  312. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_MEMREG_ALLOC;
  313. RPC_U32(&msg, 0U) = (uint32_t)(addr_start >> 32U);
  314. RPC_U32(&msg, 4U) = (uint32_t)addr_start;
  315. RPC_U32(&msg, 8U) = (uint32_t)(addr_end >> 32U);
  316. RPC_U32(&msg, 12U) = (uint32_t)addr_end;
  317. RPC_SIZE(&msg) = 5U;
  318. sc_call_rpc(ipc, &msg, SC_FALSE);
  319. result = RPC_R8(&msg);
  320. if (mr != NULL) {
  321. *mr = RPC_U8(&msg, 0U);
  322. }
  323. return (sc_err_t)result;
  324. }
  325. sc_err_t sc_rm_memreg_split(sc_ipc_t ipc, sc_rm_mr_t mr,
  326. sc_rm_mr_t *mr_ret, sc_faddr_t addr_start,
  327. sc_faddr_t addr_end)
  328. {
  329. sc_rpc_msg_t msg;
  330. uint8_t result;
  331. RPC_VER(&msg) = SC_RPC_VERSION;
  332. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  333. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_MEMREG_SPLIT;
  334. RPC_U32(&msg, 0U) = (uint32_t)(addr_start >> 32U);
  335. RPC_U32(&msg, 4U) = (uint32_t)addr_start;
  336. RPC_U32(&msg, 8U) = (uint32_t)(addr_end >> 32U);
  337. RPC_U32(&msg, 12U) = (uint32_t)addr_end;
  338. RPC_U8(&msg, 16U) = (uint8_t)mr;
  339. RPC_SIZE(&msg) = 6U;
  340. sc_call_rpc(ipc, &msg, SC_FALSE);
  341. result = RPC_R8(&msg);
  342. if (mr_ret != NULL) {
  343. *mr_ret = RPC_U8(&msg, 0U);
  344. }
  345. return (sc_err_t)result;
  346. }
  347. sc_err_t sc_rm_memreg_free(sc_ipc_t ipc, sc_rm_mr_t mr)
  348. {
  349. sc_rpc_msg_t msg;
  350. uint8_t result;
  351. RPC_VER(&msg) = SC_RPC_VERSION;
  352. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  353. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_MEMREG_FREE;
  354. RPC_U8(&msg, 0U) = (uint8_t)mr;
  355. RPC_SIZE(&msg) = 2U;
  356. sc_call_rpc(ipc, &msg, SC_FALSE);
  357. result = RPC_R8(&msg);
  358. return (sc_err_t)result;
  359. }
  360. sc_err_t sc_rm_find_memreg(sc_ipc_t ipc, sc_rm_mr_t *mr,
  361. sc_faddr_t addr_start, sc_faddr_t addr_end)
  362. {
  363. sc_rpc_msg_t msg;
  364. uint8_t result;
  365. RPC_VER(&msg) = SC_RPC_VERSION;
  366. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  367. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_FIND_MEMREG;
  368. RPC_U32(&msg, 0U) = (uint32_t)(addr_start >> 32U);
  369. RPC_U32(&msg, 4U) = (uint32_t)addr_start;
  370. RPC_U32(&msg, 8U) = (uint32_t)(addr_end >> 32U);
  371. RPC_U32(&msg, 12U) = (uint32_t)addr_end;
  372. RPC_SIZE(&msg) = 5U;
  373. sc_call_rpc(ipc, &msg, SC_FALSE);
  374. result = RPC_R8(&msg);
  375. if (mr != NULL) {
  376. *mr = RPC_U8(&msg, 0U);
  377. }
  378. return (sc_err_t)result;
  379. }
  380. sc_err_t sc_rm_assign_memreg(sc_ipc_t ipc, sc_rm_pt_t pt, sc_rm_mr_t mr)
  381. {
  382. sc_rpc_msg_t msg;
  383. uint8_t result;
  384. RPC_VER(&msg) = SC_RPC_VERSION;
  385. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  386. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_ASSIGN_MEMREG;
  387. RPC_U8(&msg, 0U) = (uint8_t)pt;
  388. RPC_U8(&msg, 1U) = (uint8_t)mr;
  389. RPC_SIZE(&msg) = 2U;
  390. sc_call_rpc(ipc, &msg, SC_FALSE);
  391. result = RPC_R8(&msg);
  392. return (sc_err_t)result;
  393. }
  394. sc_err_t sc_rm_set_memreg_permissions(sc_ipc_t ipc, sc_rm_mr_t mr,
  395. sc_rm_pt_t pt, sc_rm_perm_t perm)
  396. {
  397. sc_rpc_msg_t msg;
  398. uint8_t result;
  399. RPC_VER(&msg) = SC_RPC_VERSION;
  400. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  401. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_MEMREG_PERMISSIONS;
  402. RPC_U8(&msg, 0U) = (uint8_t)mr;
  403. RPC_U8(&msg, 1U) = (uint8_t)pt;
  404. RPC_U8(&msg, 2U) = (uint8_t)perm;
  405. RPC_SIZE(&msg) = 2U;
  406. sc_call_rpc(ipc, &msg, SC_FALSE);
  407. result = RPC_R8(&msg);
  408. return (sc_err_t)result;
  409. }
  410. sc_bool_t sc_rm_is_memreg_owned(sc_ipc_t ipc, sc_rm_mr_t mr)
  411. {
  412. sc_rpc_msg_t msg;
  413. uint8_t result;
  414. RPC_VER(&msg) = SC_RPC_VERSION;
  415. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  416. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_IS_MEMREG_OWNED;
  417. RPC_U8(&msg, 0U) = (uint8_t)mr;
  418. RPC_SIZE(&msg) = 2U;
  419. sc_call_rpc(ipc, &msg, SC_FALSE);
  420. result = RPC_R8(&msg);
  421. return (sc_bool_t)result;
  422. }
  423. sc_err_t sc_rm_get_memreg_info(sc_ipc_t ipc, sc_rm_mr_t mr,
  424. sc_faddr_t *addr_start, sc_faddr_t *addr_end)
  425. {
  426. sc_rpc_msg_t msg;
  427. uint8_t result;
  428. RPC_VER(&msg) = SC_RPC_VERSION;
  429. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  430. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_GET_MEMREG_INFO;
  431. RPC_U8(&msg, 0U) = (uint8_t)mr;
  432. RPC_SIZE(&msg) = 2U;
  433. sc_call_rpc(ipc, &msg, SC_FALSE);
  434. if (addr_start != NULL) {
  435. *addr_start =
  436. ((uint64_t) RPC_U32(&msg, 0U) << 32U) | RPC_U32(&msg, 4U);
  437. }
  438. if (addr_end != NULL) {
  439. *addr_end =
  440. ((uint64_t) RPC_U32(&msg, 8U) << 32U) | RPC_U32(&msg, 12U);
  441. }
  442. result = RPC_R8(&msg);
  443. return (sc_err_t)result;
  444. }
  445. sc_err_t sc_rm_assign_pad(sc_ipc_t ipc, sc_rm_pt_t pt, sc_pad_t pad)
  446. {
  447. sc_rpc_msg_t msg;
  448. uint8_t result;
  449. RPC_VER(&msg) = SC_RPC_VERSION;
  450. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  451. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_ASSIGN_PAD;
  452. RPC_U16(&msg, 0U) = (uint16_t)pad;
  453. RPC_U8(&msg, 2U) = (uint8_t)pt;
  454. RPC_SIZE(&msg) = 2U;
  455. sc_call_rpc(ipc, &msg, SC_FALSE);
  456. result = RPC_R8(&msg);
  457. return (sc_err_t)result;
  458. }
  459. sc_err_t sc_rm_set_pad_movable(sc_ipc_t ipc, sc_pad_t pad_fst,
  460. sc_pad_t pad_lst, sc_bool_t movable)
  461. {
  462. sc_rpc_msg_t msg;
  463. uint8_t result;
  464. RPC_VER(&msg) = SC_RPC_VERSION;
  465. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  466. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_PAD_MOVABLE;
  467. RPC_U16(&msg, 0U) = (uint16_t)pad_fst;
  468. RPC_U16(&msg, 2U) = (uint16_t)pad_lst;
  469. RPC_U8(&msg, 4U) = (uint8_t)movable;
  470. RPC_SIZE(&msg) = 3U;
  471. sc_call_rpc(ipc, &msg, SC_FALSE);
  472. result = RPC_R8(&msg);
  473. return (sc_err_t)result;
  474. }
  475. sc_bool_t sc_rm_is_pad_owned(sc_ipc_t ipc, sc_pad_t pad)
  476. {
  477. sc_rpc_msg_t msg;
  478. uint8_t result;
  479. RPC_VER(&msg) = SC_RPC_VERSION;
  480. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  481. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_IS_PAD_OWNED;
  482. RPC_U8(&msg, 0U) = (uint8_t)pad;
  483. RPC_SIZE(&msg) = 2U;
  484. sc_call_rpc(ipc, &msg, SC_FALSE);
  485. result = RPC_R8(&msg);
  486. return (sc_bool_t)result;
  487. }
  488. void sc_rm_dump(sc_ipc_t ipc)
  489. {
  490. sc_rpc_msg_t msg;
  491. RPC_VER(&msg) = SC_RPC_VERSION;
  492. RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM;
  493. RPC_FUNC(&msg) = (uint8_t)RM_FUNC_DUMP;
  494. RPC_SIZE(&msg) = 1U;
  495. sc_call_rpc(ipc, &msg, SC_FALSE);
  496. }
  497. /**@}*/