sbi_platform.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2019 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Anup Patel <anup.patel@wdc.com>
  8. */
  9. #ifndef __SBI_PLATFORM_H__
  10. #define __SBI_PLATFORM_H__
  11. /**
  12. * OpenSBI 32-bit platform version with:
  13. * 1. upper 16-bits as major number
  14. * 2. lower 16-bits as minor number
  15. */
  16. #define SBI_PLATFORM_VERSION(Major, Minor) ((Major << 16) | Minor)
  17. /** Offset of opensbi_version in struct sbi_platform */
  18. #define SBI_PLATFORM_OPENSBI_VERSION_OFFSET (0x00)
  19. /** Offset of platform_version in struct sbi_platform */
  20. #define SBI_PLATFORM_VERSION_OFFSET (0x04)
  21. /** Offset of name in struct sbi_platform */
  22. #define SBI_PLATFORM_NAME_OFFSET (0x08)
  23. /** Offset of features in struct sbi_platform */
  24. #define SBI_PLATFORM_FEATURES_OFFSET (0x48)
  25. /** Offset of hart_count in struct sbi_platform */
  26. #define SBI_PLATFORM_HART_COUNT_OFFSET (0x50)
  27. /** Offset of hart_stack_size in struct sbi_platform */
  28. #define SBI_PLATFORM_HART_STACK_SIZE_OFFSET (0x54)
  29. /** Offset of platform_ops_addr in struct sbi_platform */
  30. #define SBI_PLATFORM_OPS_OFFSET (0x58)
  31. /** Offset of firmware_context in struct sbi_platform */
  32. #define SBI_PLATFORM_FIRMWARE_CONTEXT_OFFSET (0x58 + __SIZEOF_POINTER__)
  33. /** Offset of hart_index2id in struct sbi_platform */
  34. #define SBI_PLATFORM_HART_INDEX2ID_OFFSET (0x58 + (__SIZEOF_POINTER__ * 2))
  35. #define SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT (1UL << 12)
  36. #ifndef __ASSEMBLER__
  37. #include <sbi/sbi_ecall_interface.h>
  38. #include <sbi/sbi_error.h>
  39. #include <sbi/sbi_scratch.h>
  40. #include <sbi/sbi_version.h>
  41. struct sbi_domain_memregion;
  42. struct sbi_trap_info;
  43. struct sbi_trap_regs;
  44. struct sbi_hart_features;
  45. /** Possible feature flags of a platform */
  46. enum sbi_platform_features {
  47. /** Platform has fault delegation support */
  48. SBI_PLATFORM_HAS_MFAULTS_DELEGATION = (1 << 1),
  49. /** Last index of Platform features*/
  50. SBI_PLATFORM_HAS_LAST_FEATURE = SBI_PLATFORM_HAS_MFAULTS_DELEGATION,
  51. };
  52. /** Default feature set for a platform */
  53. #define SBI_PLATFORM_DEFAULT_FEATURES \
  54. (SBI_PLATFORM_HAS_MFAULTS_DELEGATION)
  55. /** Platform functions */
  56. struct sbi_platform_operations {
  57. /* Platform nascent initialization */
  58. int (*nascent_init)(void);
  59. /** Platform early initialization */
  60. int (*early_init)(bool cold_boot);
  61. /** Platform final initialization */
  62. int (*final_init)(bool cold_boot);
  63. /** Platform early exit */
  64. void (*early_exit)(void);
  65. /** Platform final exit */
  66. void (*final_exit)(void);
  67. /**
  68. * For platforms that do not implement misa, non-standard
  69. * methods are needed to determine cpu extension.
  70. */
  71. int (*misa_check_extension)(char ext);
  72. /**
  73. * For platforms that do not implement misa, non-standard
  74. * methods are needed to get MXL field of misa.
  75. */
  76. int (*misa_get_xlen)(void);
  77. /** Initialize (or populate) HART extensions for the platform */
  78. int (*extensions_init)(struct sbi_hart_features *hfeatures);
  79. /** Initialize (or populate) domains for the platform */
  80. int (*domains_init)(void);
  81. /** Initialize hw performance counters */
  82. int (*pmu_init)(void);
  83. /** Get platform specific mhpmevent value */
  84. uint64_t (*pmu_xlate_to_mhpmevent)(uint32_t event_idx, uint64_t data);
  85. /** Initialize the platform console */
  86. int (*console_init)(void);
  87. /** Initialize the platform interrupt controller for current HART */
  88. int (*irqchip_init)(bool cold_boot);
  89. /** Exit the platform interrupt controller for current HART */
  90. void (*irqchip_exit)(void);
  91. /** Initialize IPI for current HART */
  92. int (*ipi_init)(bool cold_boot);
  93. /** Exit IPI for current HART */
  94. void (*ipi_exit)(void);
  95. /** Get tlb flush limit value **/
  96. u64 (*get_tlbr_flush_limit)(void);
  97. /** Initialize platform timer for current HART */
  98. int (*timer_init)(bool cold_boot);
  99. /** Exit platform timer for current HART */
  100. void (*timer_exit)(void);
  101. /** platform specific SBI extension implementation probe function */
  102. int (*vendor_ext_check)(long extid);
  103. /** platform specific SBI extension implementation provider */
  104. int (*vendor_ext_provider)(long extid, long funcid,
  105. const struct sbi_trap_regs *regs,
  106. unsigned long *out_value,
  107. struct sbi_trap_info *out_trap);
  108. };
  109. /** Platform default per-HART stack size for exception/interrupt handling */
  110. #define SBI_PLATFORM_DEFAULT_HART_STACK_SIZE 8192
  111. /** Representation of a platform */
  112. struct sbi_platform {
  113. /**
  114. * OpenSBI version this sbi_platform is based on.
  115. * It's a 32-bit value where upper 16-bits are major number
  116. * and lower 16-bits are minor number
  117. */
  118. u32 opensbi_version;
  119. /**
  120. * OpenSBI platform version released by vendor.
  121. * It's a 32-bit value where upper 16-bits are major number
  122. * and lower 16-bits are minor number
  123. */
  124. u32 platform_version;
  125. /** Name of the platform */
  126. char name[64];
  127. /** Supported features */
  128. u64 features;
  129. /** Total number of HARTs */
  130. u32 hart_count;
  131. /** Per-HART stack size for exception/interrupt handling */
  132. u32 hart_stack_size;
  133. /** Pointer to sbi platform operations */
  134. unsigned long platform_ops_addr;
  135. /** Pointer to system firmware specific context */
  136. unsigned long firmware_context;
  137. /**
  138. * HART index to HART id table
  139. *
  140. * For used HART index <abc>:
  141. * hart_index2id[<abc>] = some HART id
  142. * For unused HART index <abc>:
  143. * hart_index2id[<abc>] = -1U
  144. *
  145. * If hart_index2id == NULL then we assume identity mapping
  146. * hart_index2id[<abc>] = <abc>
  147. *
  148. * We have only two restrictions:
  149. * 1. HART index < sbi_platform hart_count
  150. * 2. HART id < SBI_HARTMASK_MAX_BITS
  151. */
  152. const u32 *hart_index2id;
  153. };
  154. /**
  155. * Prevent modification of struct sbi_platform from affecting
  156. * SBI_PLATFORM_xxx_OFFSET
  157. */
  158. _Static_assert(
  159. offsetof(struct sbi_platform, opensbi_version)
  160. == SBI_PLATFORM_OPENSBI_VERSION_OFFSET,
  161. "struct sbi_platform definition has changed, please redefine "
  162. "SBI_PLATFORM_OPENSBI_VERSION_OFFSET");
  163. _Static_assert(
  164. offsetof(struct sbi_platform, platform_version)
  165. == SBI_PLATFORM_VERSION_OFFSET,
  166. "struct sbi_platform definition has changed, please redefine "
  167. "SBI_PLATFORM_VERSION_OFFSET");
  168. _Static_assert(
  169. offsetof(struct sbi_platform, name)
  170. == SBI_PLATFORM_NAME_OFFSET,
  171. "struct sbi_platform definition has changed, please redefine "
  172. "SBI_PLATFORM_NAME_OFFSET");
  173. _Static_assert(
  174. offsetof(struct sbi_platform, features)
  175. == SBI_PLATFORM_FEATURES_OFFSET,
  176. "struct sbi_platform definition has changed, please redefine "
  177. "SBI_PLATFORM_FEATURES_OFFSET");
  178. _Static_assert(
  179. offsetof(struct sbi_platform, hart_count)
  180. == SBI_PLATFORM_HART_COUNT_OFFSET,
  181. "struct sbi_platform definition has changed, please redefine "
  182. "SBI_PLATFORM_HART_COUNT_OFFSET");
  183. _Static_assert(
  184. offsetof(struct sbi_platform, hart_stack_size)
  185. == SBI_PLATFORM_HART_STACK_SIZE_OFFSET,
  186. "struct sbi_platform definition has changed, please redefine "
  187. "SBI_PLATFORM_HART_STACK_SIZE_OFFSET");
  188. _Static_assert(
  189. offsetof(struct sbi_platform, platform_ops_addr)
  190. == SBI_PLATFORM_OPS_OFFSET,
  191. "struct sbi_platform definition has changed, please redefine "
  192. "SBI_PLATFORM_OPS_OFFSET");
  193. _Static_assert(
  194. offsetof(struct sbi_platform, firmware_context)
  195. == SBI_PLATFORM_FIRMWARE_CONTEXT_OFFSET,
  196. "struct sbi_platform definition has changed, please redefine "
  197. "SBI_PLATFORM_FIRMWARE_CONTEXT_OFFSET");
  198. _Static_assert(
  199. offsetof(struct sbi_platform, hart_index2id)
  200. == SBI_PLATFORM_HART_INDEX2ID_OFFSET,
  201. "struct sbi_platform definition has changed, please redefine "
  202. "SBI_PLATFORM_HART_INDEX2ID_OFFSET");
  203. /** Get pointer to sbi_platform for sbi_scratch pointer */
  204. #define sbi_platform_ptr(__s) \
  205. ((const struct sbi_platform *)((__s)->platform_addr))
  206. /** Get pointer to sbi_platform for current HART */
  207. #define sbi_platform_thishart_ptr() ((const struct sbi_platform *) \
  208. (sbi_scratch_thishart_ptr()->platform_addr))
  209. /** Get pointer to platform_ops_addr from platform pointer **/
  210. #define sbi_platform_ops(__p) \
  211. ((const struct sbi_platform_operations *)(__p)->platform_ops_addr)
  212. /** Check whether the platform supports fault delegation */
  213. #define sbi_platform_has_mfaults_delegation(__p) \
  214. ((__p)->features & SBI_PLATFORM_HAS_MFAULTS_DELEGATION)
  215. /**
  216. * Get HART index for the given HART
  217. *
  218. * @param plat pointer to struct sbi_platform
  219. * @param hartid HART ID
  220. *
  221. * @return 0 <= value < hart_count for valid HART otherwise -1U
  222. */
  223. u32 sbi_platform_hart_index(const struct sbi_platform *plat, u32 hartid);
  224. /**
  225. * Get the platform features in string format
  226. *
  227. * @param plat pointer to struct sbi_platform
  228. * @param features_str pointer to a char array where the features string will be
  229. * updated
  230. * @param nfstr length of the features_str. The feature string will be truncated
  231. * if nfstr is not long enough.
  232. */
  233. void sbi_platform_get_features_str(const struct sbi_platform *plat,
  234. char *features_str, int nfstr);
  235. /**
  236. * Get name of the platform
  237. *
  238. * @param plat pointer to struct sbi_platform
  239. *
  240. * @return pointer to platform name on success and "Unknown" on failure
  241. */
  242. static inline const char *sbi_platform_name(const struct sbi_platform *plat)
  243. {
  244. if (plat)
  245. return plat->name;
  246. return "Unknown";
  247. }
  248. /**
  249. * Get the platform features
  250. *
  251. * @param plat pointer to struct sbi_platform
  252. *
  253. * @return the features value currently set for the given platform
  254. */
  255. static inline unsigned long sbi_platform_get_features(
  256. const struct sbi_platform *plat)
  257. {
  258. if (plat)
  259. return plat->features;
  260. return 0;
  261. }
  262. /**
  263. * Get platform specific tlb range flush maximum value. Any request with size
  264. * higher than this is upgraded to a full flush.
  265. *
  266. * @param plat pointer to struct sbi_platform
  267. *
  268. * @return tlb range flush limit value. Returns a default (page size) if not
  269. * defined by platform.
  270. */
  271. static inline u64 sbi_platform_tlbr_flush_limit(const struct sbi_platform *plat)
  272. {
  273. if (plat && sbi_platform_ops(plat)->get_tlbr_flush_limit)
  274. return sbi_platform_ops(plat)->get_tlbr_flush_limit();
  275. return SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT;
  276. }
  277. /**
  278. * Get total number of HARTs supported by the platform
  279. *
  280. * @param plat pointer to struct sbi_platform
  281. *
  282. * @return total number of HARTs
  283. */
  284. static inline u32 sbi_platform_hart_count(const struct sbi_platform *plat)
  285. {
  286. if (plat)
  287. return plat->hart_count;
  288. return 0;
  289. }
  290. /**
  291. * Get per-HART stack size for exception/interrupt handling
  292. *
  293. * @param plat pointer to struct sbi_platform
  294. *
  295. * @return stack size in bytes
  296. */
  297. static inline u32 sbi_platform_hart_stack_size(const struct sbi_platform *plat)
  298. {
  299. if (plat)
  300. return plat->hart_stack_size;
  301. return 0;
  302. }
  303. /**
  304. * Check whether given HART is invalid
  305. *
  306. * @param plat pointer to struct sbi_platform
  307. * @param hartid HART ID
  308. *
  309. * @return true if HART is invalid and false otherwise
  310. */
  311. static inline bool sbi_platform_hart_invalid(const struct sbi_platform *plat,
  312. u32 hartid)
  313. {
  314. if (!plat)
  315. return true;
  316. if (plat->hart_count <= sbi_platform_hart_index(plat, hartid))
  317. return true;
  318. return false;
  319. }
  320. /**
  321. * Nascent (very early) initialization for current HART
  322. *
  323. * NOTE: This function can be used to do very early initialization of
  324. * platform specific per-HART CSRs and devices.
  325. *
  326. * @param plat pointer to struct sbi_platform
  327. *
  328. * @return 0 on success and negative error code on failure
  329. */
  330. static inline int sbi_platform_nascent_init(const struct sbi_platform *plat)
  331. {
  332. if (plat && sbi_platform_ops(plat)->nascent_init)
  333. return sbi_platform_ops(plat)->nascent_init();
  334. return 0;
  335. }
  336. /**
  337. * Early initialization for current HART
  338. *
  339. * @param plat pointer to struct sbi_platform
  340. * @param cold_boot whether cold boot (true) or warm_boot (false)
  341. *
  342. * @return 0 on success and negative error code on failure
  343. */
  344. static inline int sbi_platform_early_init(const struct sbi_platform *plat,
  345. bool cold_boot)
  346. {
  347. if (plat && sbi_platform_ops(plat)->early_init)
  348. return sbi_platform_ops(plat)->early_init(cold_boot);
  349. return 0;
  350. }
  351. /**
  352. * Final initialization for current HART
  353. *
  354. * @param plat pointer to struct sbi_platform
  355. * @param cold_boot whether cold boot (true) or warm_boot (false)
  356. *
  357. * @return 0 on success and negative error code on failure
  358. */
  359. static inline int sbi_platform_final_init(const struct sbi_platform *plat,
  360. bool cold_boot)
  361. {
  362. if (plat && sbi_platform_ops(plat)->final_init)
  363. return sbi_platform_ops(plat)->final_init(cold_boot);
  364. return 0;
  365. }
  366. /**
  367. * Early exit for current HART
  368. *
  369. * @param plat pointer to struct sbi_platform
  370. */
  371. static inline void sbi_platform_early_exit(const struct sbi_platform *plat)
  372. {
  373. if (plat && sbi_platform_ops(plat)->early_exit)
  374. sbi_platform_ops(plat)->early_exit();
  375. }
  376. /**
  377. * Final exit for current HART
  378. *
  379. * @param plat pointer to struct sbi_platform
  380. */
  381. static inline void sbi_platform_final_exit(const struct sbi_platform *plat)
  382. {
  383. if (plat && sbi_platform_ops(plat)->final_exit)
  384. sbi_platform_ops(plat)->final_exit();
  385. }
  386. /**
  387. * Check CPU extension in MISA
  388. *
  389. * @param plat pointer to struct sbi_platform
  390. * @param ext shorthand letter for CPU extensions
  391. *
  392. * @return zero for not-supported and non-zero for supported
  393. */
  394. static inline int sbi_platform_misa_extension(const struct sbi_platform *plat,
  395. char ext)
  396. {
  397. if (plat && sbi_platform_ops(plat)->misa_check_extension)
  398. return sbi_platform_ops(plat)->misa_check_extension(ext);
  399. return 0;
  400. }
  401. /**
  402. * Get MXL field of MISA
  403. *
  404. * @param plat pointer to struct sbi_platform
  405. *
  406. * @return 1/2/3 on success and error code on failure
  407. */
  408. static inline int sbi_platform_misa_xlen(const struct sbi_platform *plat)
  409. {
  410. if (plat && sbi_platform_ops(plat)->misa_get_xlen)
  411. return sbi_platform_ops(plat)->misa_get_xlen();
  412. return -1;
  413. }
  414. /**
  415. * Initialize (or populate) HART extensions for the platform
  416. *
  417. * @param plat pointer to struct sbi_platform
  418. *
  419. * @return 0 on success and negative error code on failure
  420. */
  421. static inline int sbi_platform_extensions_init(
  422. const struct sbi_platform *plat,
  423. struct sbi_hart_features *hfeatures)
  424. {
  425. if (plat && sbi_platform_ops(plat)->extensions_init)
  426. return sbi_platform_ops(plat)->extensions_init(hfeatures);
  427. return 0;
  428. }
  429. /**
  430. * Initialize (or populate) domains for the platform
  431. *
  432. * @param plat pointer to struct sbi_platform
  433. *
  434. * @return 0 on success and negative error code on failure
  435. */
  436. static inline int sbi_platform_domains_init(const struct sbi_platform *plat)
  437. {
  438. if (plat && sbi_platform_ops(plat)->domains_init)
  439. return sbi_platform_ops(plat)->domains_init();
  440. return 0;
  441. }
  442. /**
  443. * Setup hw PMU events for the platform
  444. *
  445. * @param plat pointer to struct sbi_platform
  446. *
  447. * @return 0 on success and negative error code on failure
  448. */
  449. static inline int sbi_platform_pmu_init(const struct sbi_platform *plat)
  450. {
  451. if (plat && sbi_platform_ops(plat)->pmu_init)
  452. return sbi_platform_ops(plat)->pmu_init();
  453. return 0;
  454. }
  455. /**
  456. * Get the value to be written in mhpmeventx for event_idx
  457. *
  458. * @param plat pointer to struct sbi_platform
  459. * @param event_idx ID of the PMU event
  460. * @param data Additional configuration data passed from supervisor software
  461. *
  462. * @return expected value by the platform or 0 if platform doesn't know about
  463. * the event
  464. */
  465. static inline uint64_t sbi_platform_pmu_xlate_to_mhpmevent(const struct sbi_platform *plat,
  466. uint32_t event_idx, uint64_t data)
  467. {
  468. if (plat && sbi_platform_ops(plat)->pmu_xlate_to_mhpmevent)
  469. return sbi_platform_ops(plat)->pmu_xlate_to_mhpmevent(event_idx,
  470. data);
  471. return 0;
  472. }
  473. /**
  474. * Initialize the platform console
  475. *
  476. * @param plat pointer to struct sbi_platform
  477. *
  478. * @return 0 on success and negative error code on failure
  479. */
  480. static inline int sbi_platform_console_init(const struct sbi_platform *plat)
  481. {
  482. if (plat && sbi_platform_ops(plat)->console_init)
  483. return sbi_platform_ops(plat)->console_init();
  484. return 0;
  485. }
  486. /**
  487. * Initialize the platform interrupt controller for current HART
  488. *
  489. * @param plat pointer to struct sbi_platform
  490. * @param cold_boot whether cold boot (true) or warm_boot (false)
  491. *
  492. * @return 0 on success and negative error code on failure
  493. */
  494. static inline int sbi_platform_irqchip_init(const struct sbi_platform *plat,
  495. bool cold_boot)
  496. {
  497. if (plat && sbi_platform_ops(plat)->irqchip_init)
  498. return sbi_platform_ops(plat)->irqchip_init(cold_boot);
  499. return 0;
  500. }
  501. /**
  502. * Exit the platform interrupt controller for current HART
  503. *
  504. * @param plat pointer to struct sbi_platform
  505. */
  506. static inline void sbi_platform_irqchip_exit(const struct sbi_platform *plat)
  507. {
  508. if (plat && sbi_platform_ops(plat)->irqchip_exit)
  509. sbi_platform_ops(plat)->irqchip_exit();
  510. }
  511. /**
  512. * Initialize the platform IPI support for current HART
  513. *
  514. * @param plat pointer to struct sbi_platform
  515. * @param cold_boot whether cold boot (true) or warm_boot (false)
  516. *
  517. * @return 0 on success and negative error code on failure
  518. */
  519. static inline int sbi_platform_ipi_init(const struct sbi_platform *plat,
  520. bool cold_boot)
  521. {
  522. if (plat && sbi_platform_ops(plat)->ipi_init)
  523. return sbi_platform_ops(plat)->ipi_init(cold_boot);
  524. return 0;
  525. }
  526. /**
  527. * Exit the platform IPI support for current HART
  528. *
  529. * @param plat pointer to struct sbi_platform
  530. */
  531. static inline void sbi_platform_ipi_exit(const struct sbi_platform *plat)
  532. {
  533. if (plat && sbi_platform_ops(plat)->ipi_exit)
  534. sbi_platform_ops(plat)->ipi_exit();
  535. }
  536. /**
  537. * Initialize the platform timer for current HART
  538. *
  539. * @param plat pointer to struct sbi_platform
  540. * @param cold_boot whether cold boot (true) or warm_boot (false)
  541. *
  542. * @return 0 on success and negative error code on failure
  543. */
  544. static inline int sbi_platform_timer_init(const struct sbi_platform *plat,
  545. bool cold_boot)
  546. {
  547. if (plat && sbi_platform_ops(plat)->timer_init)
  548. return sbi_platform_ops(plat)->timer_init(cold_boot);
  549. return 0;
  550. }
  551. /**
  552. * Exit the platform timer for current HART
  553. *
  554. * @param plat pointer to struct sbi_platform
  555. */
  556. static inline void sbi_platform_timer_exit(const struct sbi_platform *plat)
  557. {
  558. if (plat && sbi_platform_ops(plat)->timer_exit)
  559. sbi_platform_ops(plat)->timer_exit();
  560. }
  561. /**
  562. * Check if a vendor extension is implemented or not.
  563. *
  564. * @param plat pointer to struct sbi_platform
  565. * @param extid vendor SBI extension id
  566. *
  567. * @return 0 if extid is not implemented and 1 if implemented
  568. */
  569. static inline int sbi_platform_vendor_ext_check(const struct sbi_platform *plat,
  570. long extid)
  571. {
  572. if (plat && sbi_platform_ops(plat)->vendor_ext_check)
  573. return sbi_platform_ops(plat)->vendor_ext_check(extid);
  574. return 0;
  575. }
  576. /**
  577. * Invoke platform specific vendor SBI extension implementation.
  578. *
  579. * @param plat pointer to struct sbi_platform
  580. * @param extid vendor SBI extension id
  581. * @param funcid SBI function id within the extension id
  582. * @param regs pointer to trap registers passed by the caller
  583. * @param out_value output value that can be filled by the callee
  584. * @param out_trap trap info that can be filled by the callee
  585. *
  586. * @return 0 on success and negative error code on failure
  587. */
  588. static inline int sbi_platform_vendor_ext_provider(
  589. const struct sbi_platform *plat,
  590. long extid, long funcid,
  591. const struct sbi_trap_regs *regs,
  592. unsigned long *out_value,
  593. struct sbi_trap_info *out_trap)
  594. {
  595. if (plat && sbi_platform_ops(plat)->vendor_ext_provider) {
  596. return sbi_platform_ops(plat)->vendor_ext_provider(extid,
  597. funcid, regs,
  598. out_value,
  599. out_trap);
  600. }
  601. return SBI_ENOTSUPP;
  602. }
  603. #endif
  604. #endif