HPM SDK
HPMicro Software Development Kit
hpm_romapi.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023-2024 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef HPM_ROMAPI_H
9 #define HPM_ROMAPI_H
10 
17 #include "hpm_common.h"
18 #include "hpm_otp_drv.h"
19 #include "hpm_romapi_xpi_def.h"
20 #include "hpm_romapi_xpi_soc_def.h"
21 #include "hpm_romapi_xpi_nor_def.h"
22 #include "hpm_romapi_xpi_ram_def.h"
23 #include "hpm_sdp_drv.h"
24 
25 /* XPI0 base address */
26 #define HPM_XPI0_BASE (0xF3000000UL)
27 /* XPI0 base pointer */
28 #define HPM_XPI0 ((XPI_Type *) HPM_XPI0_BASE)
31 /***********************************************************************************************************************
32  *
33  *
34  * Definitions
35  *
36  *
37  **********************************************************************************************************************/
41 typedef union {
42  uint32_t U;
43  struct {
44  uint32_t index: 8;
45  uint32_t peripheral: 8;
46  uint32_t src: 8;
47  uint32_t tag: 8;
48  };
50 
51 /*EXiP Region Parameter */
52 typedef struct {
53  uint32_t start;
54  uint32_t len;
55  uint8_t key[16];
56  uint8_t ctr[8];
58 
59 typedef struct {
60  uint32_t region_start;
61  uint32_t region_end;
62  uint8_t aes_key[16];
63  uint8_t nonce[8];
64  uint8_t index;
65  bool enable;
66  bool valid;
67  bool lock;
69 
70 #define API_BOOT_TAG (0xEBU)
71 #define API_BOOT_SRC_OTP (0U)
72 #define API_BOOT_SRC_PRIMARY (1U)
73 #define API_BOOT_SRC_SERIAL_BOOT (2U)
74 #define API_BOOT_SRC_ISP (3U)
75 #define API_BOOT_PERIPH_AUTO (0U)
76 #define API_BOOT_PERIPH_UART (1U)
77 #define API_BOOT_PERIPH_USBHID (2U)
82 typedef struct {
84  uint32_t version;
86  void (*init)(void);
88  void (*deinit)(void);
90  uint32_t (*read_from_shadow)(uint32_t addr);
92  uint32_t (*read_from_ip)(uint32_t addr);
94  hpm_stat_t (*program)(uint32_t addr, const uint32_t *src, uint32_t num_of_words);
96  hpm_stat_t (*reload)(otp_region_t region);
98  hpm_stat_t (*lock)(uint32_t addr, otp_lock_option_t lock_option);
100  hpm_stat_t (*lock_shadow)(uint32_t addr, otp_lock_option_t lock_option);
102  hpm_stat_t (*set_configurable_region)(uint32_t start, uint32_t num_of_words);
104  hpm_stat_t (*write_shadow_register)(uint32_t addr, uint32_t data);
106 
110 typedef struct {
112  uint32_t version;
114  hpm_stat_t (*get_default_config)(xpi_config_t *xpi_config);
116  hpm_stat_t (*get_default_device_config)(xpi_device_config_t *dev_config);
118  hpm_stat_t (*init)(XPI_Type *base, xpi_config_t *xpi_config);
120  hpm_stat_t (*config_ahb_buffer)(XPI_Type *base, xpi_ahb_buffer_cfg_t *ahb_buf_cfg);
122  hpm_stat_t (*config_device)(XPI_Type *base, xpi_device_config_t *dev_cfg, xpi_channel_t channel);
124  hpm_stat_t (*update_instr_table)(XPI_Type *base, const uint32_t *inst_base, uint32_t seq_idx, uint32_t num);
126  hpm_stat_t (*transfer_blocking)(XPI_Type *base, xpi_xfer_ctx_t *xfer);
128  void (*software_reset)(XPI_Type *base);
130  bool (*is_idle)(XPI_Type *base);
132  void (*update_dllcr)(XPI_Type *base,
133  uint32_t serial_root_clk_freq,
134  uint32_t data_valid_time,
135  xpi_channel_t channel,
136  uint32_t dly_target);
138  hpm_stat_t
139  (*get_abs_apb_xfer_addr)(XPI_Type *base, xpi_xfer_channel_t channel, uint32_t in_addr, uint32_t *out_addr);
141 
145 typedef struct {
147  uint32_t version;
149  hpm_stat_t (*get_config)(XPI_Type *base, xpi_nor_config_t *nor_cfg, xpi_nor_config_option_t *cfg_option);
151  hpm_stat_t (*init)(XPI_Type *base, xpi_nor_config_t *nor_config);
153  hpm_stat_t
154  (*enable_write)(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config, uint32_t addr);
156  hpm_stat_t (*get_status)(XPI_Type *base,
157  xpi_xfer_channel_t channel,
158  const xpi_nor_config_t *nor_config,
159  uint32_t addr,
160  uint16_t *out_status);
162  hpm_stat_t
163  (*wait_busy)(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config, uint32_t addr);
165  hpm_stat_t (*erase)(XPI_Type *base,
166  xpi_xfer_channel_t channel,
167  const xpi_nor_config_t *nor_config,
168  uint32_t start,
169  uint32_t length);
171  hpm_stat_t (*erase_chip)(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config);
173  hpm_stat_t
174  (*erase_sector)(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config, uint32_t addr);
176  hpm_stat_t
177  (*erase_block)(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config, uint32_t addr);
179  hpm_stat_t (*program)(XPI_Type *base,
180  xpi_xfer_channel_t channel,
181  const xpi_nor_config_t *nor_config,
182  const uint32_t *src,
183  uint32_t dst_addr,
184  uint32_t length);
186  hpm_stat_t (*read)(XPI_Type *base,
187  xpi_xfer_channel_t channel,
188  const xpi_nor_config_t *nor_config,
189  uint32_t *dst,
190  uint32_t start,
191  uint32_t length);
193  hpm_stat_t (*page_program_nonblocking)(XPI_Type *base,
194  xpi_xfer_channel_t channel,
195  const xpi_nor_config_t *nor_config,
196  const uint32_t *src,
197  uint32_t dst_addr,
198  uint32_t length);
200  hpm_stat_t (*erase_sector_nonblocking)(XPI_Type *base,
201  xpi_xfer_channel_t channel,
202  const xpi_nor_config_t *nor_config,
203  uint32_t addr);
205  hpm_stat_t (*erase_block_nonblocking)(XPI_Type *base,
206  xpi_xfer_channel_t channel,
207  const xpi_nor_config_t *nor_config,
208  uint32_t addr);
210  hpm_stat_t
211  (*erase_chip_nonblocking)(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config);
212 
213  uint32_t reserved0[3];
214 
216  hpm_stat_t (*auto_config)(XPI_Type *base, xpi_nor_config_t *nor_cfg, xpi_nor_config_option_t *cfg_option);
217 
219  hpm_stat_t (*get_property)(XPI_Type *base, xpi_nor_config_t *nor_cfg, uint32_t property_id, uint32_t *value);
220 
222 
226 typedef struct {
227  uint32_t version;
228  hpm_stat_t (*enable)(XPI_Type *base);
229  hpm_stat_t (*disable)(XPI_Type *base);
230  hpm_stat_t (*lock_reg_access)(XPI_Type *base);
231  hpm_stat_t (*configure_region)(XPI_Type *base, const exip_region_context_t *ctx);
232 
233  bool (*remap_config)(XPI_Type *base, uint32_t start, uint32_t len, uint32_t offset);
234  bool (*remap_enabled)(XPI_Type *base);
235  void (*remap_disable)(XPI_Type *base);
236  bool (*exip_region_config)(XPI_Type *base, uint32_t index, exip_region_param_t *param);
237  void (*exip_region_disable)(XPI_Type *base, uint32_t index);
239 
243 typedef struct {
245  uint32_t version;
247  hpm_stat_t (*sdp_ip_init)(void);
249  hpm_stat_t (*sdp_ip_deinit)(void);
251  hpm_stat_t (*aes_set_key)(sdp_aes_ctx_t *aes_ctx, const uint8_t *key, sdp_aes_key_bits_t keybits, uint32_t key_idx);
253  hpm_stat_t (*aes_crypt_ecb)(sdp_aes_ctx_t *aes_ctx, sdp_aes_op_t op, uint32_t len, const uint8_t *in, uint8_t *out);
255  hpm_stat_t (*aes_crypt_cbc)(sdp_aes_ctx_t *aes_ctx,
256  sdp_aes_op_t op,
257  uint32_t length,
258  uint8_t iv[16],
259  const uint8_t *input,
260  uint8_t *output);
263  (*aes_crypt_ctr)(sdp_aes_ctx_t *aes_ctx, uint8_t *nonce_ctr, uint8_t *input, uint8_t *output, uint32_t length);
265  hpm_stat_t (*aes_ccm_gen_enc)(sdp_aes_ctx_t *aes_ctx,
266  uint32_t input_len,
267  const uint8_t *nonce,
268  uint32_t nonce_len,
269  const uint8_t *aad,
270  uint32_t aad_len,
271  const uint8_t *input,
272  uint8_t *output,
273  uint8_t *tag,
274  uint32_t tag_len);
276  hpm_stat_t (*aes_ccm_dec_verify)(sdp_aes_ctx_t *aes_ctx,
277  uint32_t input_len,
278  const uint8_t *nonce,
279  uint32_t nonce_len,
280  const uint8_t *aad,
281  uint32_t aad_len,
282  const uint8_t *input,
283  uint8_t *output,
284  const uint8_t *tag,
285  uint32_t tag_len);
287  hpm_stat_t (*memcpy)(sdp_dma_ctx_t *dma_ctx, void *dst, const void *src, uint32_t length);
289  hpm_stat_t (*memset)(sdp_dma_ctx_t *dma_ctx, void *dst, uint8_t pattern, uint32_t length);
291  hpm_stat_t (*hash_init)(sdp_hash_ctx_t *hash_ctx, sdp_hash_alg_t alg);
293  hpm_stat_t (*hash_update)(sdp_hash_ctx_t *hash_ctx, const uint8_t *data, uint32_t length);
295  hpm_stat_t (*hash_finish)(sdp_hash_ctx_t *hash_ctx, uint8_t *digest);
297  hpm_stat_t (*sm4_set_key)(sdp_sm4_ctx_t *sm4_ctx, const uint8_t *key, sdp_sm4_key_bits_t keybits, uint32_t key_idx);
299  hpm_stat_t (*sm4_crypt_ecb)(sdp_sm4_ctx_t *sm4_ctx, sdp_sm4_op_t op, uint32_t len, const uint8_t *in, uint8_t *out);
301  hpm_stat_t (*sm4_crypt_cbc)(sdp_sm4_ctx_t *sm4_ctx,
302  sdp_sm4_op_t op,
303  uint32_t length,
304  uint8_t iv[16],
305  const uint8_t *input,
306  uint8_t *output);
309  (*sm4_crypt_ctr)(sdp_sm4_ctx_t *sm4_ctx, uint8_t *nonce_ctr, uint8_t *input, uint8_t *output, uint32_t length);
311  hpm_stat_t (*sm4_ccm_gen_enc)(sdp_sm4_ctx_t *sm4_ctx,
312  uint32_t input_len,
313  const uint8_t *nonce,
314  uint32_t nonce_len,
315  const uint8_t *aad,
316  uint32_t aad_len,
317  const uint8_t *input,
318  uint8_t *output,
319  uint8_t *tag,
320  uint32_t tag_len);
322  hpm_stat_t (*sm4_ccm_dec_verify)(sdp_sm4_ctx_t *sm4_ctx,
323  uint32_t input_len,
324  const uint8_t *nonce,
325  uint32_t nonce_len,
326  const uint8_t *aad,
327  uint32_t aad_len,
328  const uint8_t *input,
329  uint8_t *output,
330  const uint8_t *tag,
331  uint32_t tag_len);
333 
337 typedef struct {
339  const uint32_t version;
341  const char *copyright;
343  hpm_stat_t (*run_bootloader)(void *arg);
345  const otp_driver_interface_t *otp_driver_if;
347  const xpi_driver_interface_t *xpi_driver_if;
349  const xpi_nor_driver_interface_t *xpi_nor_driver_if;
351  const uint32_t reserved0;
354  const uint32_t reserved1[3];
355  const exip_driver_interface_t *exip_api_if;
356  const uint32_t family_id;
358 
360 #define ROM_API_TABLE_ROOT ((const bootloader_api_table_t *)0x2001FF00U)
361 
362 
363 #ifdef __cplusplus
364 extern "C" {
365 #endif
366 
367 /***********************************************************************************************************************
368  *
369  *
370  * Enter bootloader Wrapper
371  *
372  *
373  **********************************************************************************************************************/
374 
380 static inline hpm_stat_t rom_enter_bootloader(void *ctx)
381 {
382  return ROM_API_TABLE_ROOT->run_bootloader(ctx);
383 }
384 
385 /***********************************************************************************************************************
386  *
387  *
388  * XPI NOR Driver Wrapper
389  *
390  *
391  **********************************************************************************************************************/
392 
400 ATTR_RAMFUNC
402  xpi_nor_config_t *nor_cfg,
403  xpi_nor_config_option_t *cfg_option)
404 {
405  hpm_stat_t status;
406  status = ROM_API_TABLE_ROOT->xpi_nor_driver_if->get_config(base, nor_cfg, cfg_option);
407  fencei();
408  return status;
409 }
410 
417 ATTR_RAMFUNC
418 static inline hpm_stat_t rom_xpi_nor_init(XPI_Type *base, xpi_nor_config_t *nor_config)
419 {
420  hpm_stat_t status;
421  status = ROM_API_TABLE_ROOT->xpi_nor_driver_if->init(base, nor_config);
422  fencei();
423  return status;
424 }
425 
435 ATTR_RAMFUNC
437  xpi_xfer_channel_t channel,
438  const xpi_nor_config_t *nor_config,
439  uint32_t start,
440  uint32_t length)
441 {
442  hpm_stat_t status = ROM_API_TABLE_ROOT->xpi_nor_driver_if->erase(base, channel, nor_config, start, length);
443  fencei();
444  return status;
445 }
446 
455 ATTR_RAMFUNC
457  xpi_xfer_channel_t channel,
458  const xpi_nor_config_t *nor_config,
459  uint32_t start)
460 {
461  hpm_stat_t status = ROM_API_TABLE_ROOT->xpi_nor_driver_if->erase_sector(base, channel, nor_config, start);
462  fencei();
463  return status;
464 }
465 
474 ATTR_RAMFUNC
476  xpi_xfer_channel_t channel,
477  const xpi_nor_config_t *nor_config,
478  uint32_t start)
479 {
480  return ROM_API_TABLE_ROOT->xpi_nor_driver_if->erase_sector_nonblocking(base, channel, nor_config, start);
481 }
482 
491 ATTR_RAMFUNC
493  xpi_xfer_channel_t channel,
494  const xpi_nor_config_t *nor_config,
495  uint32_t start)
496 {
497  hpm_stat_t status = ROM_API_TABLE_ROOT->xpi_nor_driver_if->erase_block(base, channel, nor_config, start);
498  fencei();
499  return status;
500 }
501 
510 ATTR_RAMFUNC
512  xpi_xfer_channel_t channel,
513  const xpi_nor_config_t *nor_config,
514  uint32_t start)
515 {
516  return ROM_API_TABLE_ROOT->xpi_nor_driver_if->erase_block_nonblocking(base, channel, nor_config, start);
517 }
518 
526 ATTR_RAMFUNC
528  xpi_xfer_channel_t channel,
529  const xpi_nor_config_t *nor_config)
530 {
531  hpm_stat_t status = ROM_API_TABLE_ROOT->xpi_nor_driver_if->erase_chip(base, channel, nor_config);
532  fencei();
533  return status;
534 }
535 
543 ATTR_RAMFUNC
545  xpi_xfer_channel_t channel,
546  const xpi_nor_config_t *nor_config)
547 {
548  hpm_stat_t status = ROM_API_TABLE_ROOT->xpi_nor_driver_if->erase_chip_nonblocking(base, channel, nor_config);
549  fencei();
550  return status;
551 }
552 
563 ATTR_RAMFUNC
565  xpi_xfer_channel_t channel,
566  const xpi_nor_config_t *nor_config,
567  const uint32_t *src,
568  uint32_t dst_addr,
569  uint32_t length)
570 {
571  hpm_stat_t status = ROM_API_TABLE_ROOT->xpi_nor_driver_if->program(base, channel, nor_config, src, dst_addr, length);
572  fencei();
573  return status;
574 }
575 
586 ATTR_RAMFUNC
588  xpi_xfer_channel_t channel,
589  const xpi_nor_config_t *nor_config,
590  const uint32_t *src,
591  uint32_t dst_addr,
592  uint32_t length)
593 {
594  return ROM_API_TABLE_ROOT->xpi_nor_driver_if
595  ->page_program_nonblocking(base, channel, nor_config, src, dst_addr, length);
596 }
597 
609  xpi_xfer_channel_t channel,
610  const xpi_nor_config_t *nor_config,
611  uint32_t *dst,
612  uint32_t start,
613  uint32_t length)
614 {
615  return ROM_API_TABLE_ROOT->xpi_nor_driver_if->read(base, channel, nor_config, dst, start, length);
616 }
617 
625 ATTR_RAMFUNC
627  xpi_nor_config_t *config,
628  xpi_nor_config_option_t *cfg_option)
629 {
630  hpm_stat_t status;
631  status = ROM_API_TABLE_ROOT->xpi_nor_driver_if->auto_config(base, config, cfg_option);
632  fencei();
633  return status;
634 }
635 
645  xpi_nor_config_t *nor_cfg,
646  uint32_t property_id,
647  uint32_t *value)
648 {
649  return ROM_API_TABLE_ROOT->xpi_nor_driver_if->get_property(base, nor_cfg, property_id, value);
650 }
651 
663  xpi_xfer_channel_t channel,
664  const xpi_nor_config_t *nor_config,
665  uint32_t addr,
666  uint16_t *out_status)
667 {
668  return ROM_API_TABLE_ROOT->xpi_nor_driver_if->get_status(base, channel, nor_config, addr, out_status);
669 }
670 
680 ATTR_RAMFUNC
681 static inline bool rom_xpi_nor_remap_config(XPI_Type *base, uint32_t start, uint32_t len, uint32_t offset)
682 {
683  return ROM_API_TABLE_ROOT->exip_api_if->remap_config(base, start, len, offset);
684 }
685 
690 ATTR_RAMFUNC
691 static inline void rom_xpi_nor_remap_disable(XPI_Type *base)
692 {
693  ROM_API_TABLE_ROOT->exip_api_if->remap_disable(base);
694  fencei();
695 }
696 
704 ATTR_RAMFUNC
705 static inline bool rom_xpi_nor_is_remap_enabled(XPI_Type *base)
706 {
707  return ROM_API_TABLE_ROOT->exip_api_if->remap_enabled(base);
708 }
709 
718 ATTR_RAMFUNC
719 static inline bool rom_xpi_nor_exip_region_config(XPI_Type *base, uint32_t index, exip_region_param_t *param)
720 {
721  bool result = ROM_API_TABLE_ROOT->exip_api_if->exip_region_config(base, index, param);
722  ROM_API_TABLE_ROOT->xpi_driver_if->software_reset(base);
723  fencei();
724  return result;
725 }
726 
732 ATTR_RAMFUNC
733 static inline void rom_xpi_nor_exip_region_disable(XPI_Type *base, uint32_t index)
734 {
735  ROM_API_TABLE_ROOT->exip_api_if->exip_region_disable(base, index);
736  fencei();
737 }
738 
743 ATTR_RAMFUNC
744 static inline void rom_xpi_nor_exip_enable(XPI_Type *base)
745 {
746  ROM_API_TABLE_ROOT->exip_api_if->enable(base);
747  fencei();
748 }
749 
754 ATTR_RAMFUNC
755 static inline void rom_xpi_nor_exip_disable(XPI_Type *base)
756 {
757  ROM_API_TABLE_ROOT->exip_api_if->disable(base);
758  fencei();
759 }
760 
761 /***********************************************************************************************************************
762  *
763  *
764  * SDP Driver Wrapper
765  *
766  *
767  **********************************************************************************************************************/
771 static inline void rom_sdp_init(void)
772 {
773  ROM_API_TABLE_ROOT->sdp_driver_if->sdp_ip_init();
774 }
775 
779 static inline void rom_sdp_deinit(void)
780 {
781  ROM_API_TABLE_ROOT->sdp_driver_if->sdp_ip_deinit();
782 }
783 
793  const uint8_t *key,
794  sdp_aes_key_bits_t key_bits,
795  uint32_t key_idx)
796 {
797  return ROM_API_TABLE_ROOT->sdp_driver_if->aes_set_key(aes_ctx, key, key_bits, key_idx);
798 }
799 
810  sdp_aes_op_t op,
811  uint32_t len,
812  const uint8_t *in,
813  uint8_t *out)
814 {
815  return ROM_API_TABLE_ROOT->sdp_driver_if->aes_crypt_ecb(aes_ctx, op, len, in, out);
816 }
817 
829  sdp_aes_op_t op,
830  uint32_t length,
831  uint8_t iv[16],
832  const uint8_t *in,
833  uint8_t *out)
834 {
835  return ROM_API_TABLE_ROOT->sdp_driver_if->aes_crypt_cbc(aes_ctx, op, length, iv, in, out);
836 }
837 
846 static inline hpm_stat_t rom_sdp_sm4_set_key(sdp_sm4_ctx_t *sm4_ctx,
847  const uint8_t *key,
848  sdp_sm4_key_bits_t key_bits,
849  uint32_t key_idx)
850 {
851  return ROM_API_TABLE_ROOT->sdp_driver_if->sm4_set_key(sm4_ctx, key, key_bits, key_idx);
852 }
853 
863 static inline hpm_stat_t rom_sdp_sm4_crypt_ecb(sdp_sm4_ctx_t *sm4_ctx,
864  sdp_sm4_op_t op,
865  uint32_t len,
866  const uint8_t *in,
867  uint8_t *out)
868 {
869  return ROM_API_TABLE_ROOT->sdp_driver_if->sm4_crypt_ecb(sm4_ctx, op, len, in, out);
870 }
871 
882 static inline hpm_stat_t rom_sdp_sm4_crypt_cbc(sdp_sm4_ctx_t *sm4_ctx,
883  sdp_sm4_op_t op,
884  uint32_t length,
885  uint8_t iv[16],
886  const uint8_t *in,
887  uint8_t *out)
888 {
889  return ROM_API_TABLE_ROOT->sdp_driver_if->sm4_crypt_cbc(sm4_ctx, op, length, iv, in, out);
890 }
891 
899 {
900  return ROM_API_TABLE_ROOT->sdp_driver_if->hash_init(hash_ctx, alg);
901 }
902 
910 static inline hpm_stat_t rom_sdp_hash_update(sdp_hash_ctx_t *hash_ctx, const uint8_t *data, uint32_t length)
911 {
912  return ROM_API_TABLE_ROOT->sdp_driver_if->hash_update(hash_ctx, data, length);
913 }
914 
921 static inline hpm_stat_t rom_sdp_hash_finish(sdp_hash_ctx_t *hash_ctx, uint8_t *digest)
922 {
923  return ROM_API_TABLE_ROOT->sdp_driver_if->hash_finish(hash_ctx, digest);
924 }
925 
934 static inline hpm_stat_t rom_sdp_memcpy(sdp_dma_ctx_t *dma_ctx, void *dst, const void *src, uint32_t length)
935 {
936  return ROM_API_TABLE_ROOT->sdp_driver_if->memcpy(dma_ctx, dst, src, length);
937 }
938 
947 static inline hpm_stat_t rom_sdp_memset(sdp_dma_ctx_t *dma_ctx, void *dst, uint8_t pattern, uint32_t length)
948 {
949  return ROM_API_TABLE_ROOT->sdp_driver_if->memset(dma_ctx, dst, pattern, length);
950 }
951 
952 #ifdef __cplusplus
953 }
954 #endif
955 
961 #endif /* HPM_ROMAPI_H */
static ATTR_RAMFUNC hpm_stat_t rom_xpi_nor_auto_config(XPI_Type *base, xpi_nor_config_t *config, xpi_nor_config_option_t *cfg_option)
Automatically configure XPI NOR based on cfg_option.
Definition: hpm_romapi.h:626
static ATTR_RAMFUNC hpm_stat_t rom_xpi_nor_init(XPI_Type *base, xpi_nor_config_t *nor_config)
Initialize XPI NOR based on nor_config.
Definition: hpm_romapi.h:418
static hpm_stat_t rom_xpi_nor_read(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config, uint32_t *dst, uint32_t start, uint32_t length)
Read data from specified FLASH address.
Definition: hpm_romapi.h:608
static ATTR_RAMFUNC hpm_stat_t rom_xpi_nor_erase_chip_nonblocking(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config)
Erase the whole FLASH in non-blocking way.
Definition: hpm_romapi.h:544
static ATTR_RAMFUNC hpm_stat_t rom_xpi_nor_erase_chip(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config)
Erase the whole FLASH in blocking way.
Definition: hpm_romapi.h:527
static ATTR_RAMFUNC hpm_stat_t rom_xpi_nor_erase_block(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config, uint32_t start)
Erase specified FLASH blcok in blocking way.
Definition: hpm_romapi.h:492
static ATTR_RAMFUNC bool rom_xpi_nor_remap_config(XPI_Type *base, uint32_t start, uint32_t len, uint32_t offset)
Configure the XPI Address Remapping Logic.
Definition: hpm_romapi.h:681
static ATTR_RAMFUNC bool rom_xpi_nor_exip_region_config(XPI_Type *base, uint32_t index, exip_region_param_t *param)
Configure Specified EXiP Region.
Definition: hpm_romapi.h:719
static ATTR_RAMFUNC void rom_xpi_nor_exip_enable(XPI_Type *base)
Enable global EXiP logic.
Definition: hpm_romapi.h:744
static ATTR_RAMFUNC hpm_stat_t rom_xpi_nor_page_program_nonblocking(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config, const uint32_t *src, uint32_t dst_addr, uint32_t length)
Page-Program data to specified FLASH address in non-blocking way.
Definition: hpm_romapi.h:587
static ATTR_RAMFUNC void rom_xpi_nor_exip_region_disable(XPI_Type *base, uint32_t index)
Disable EXiP Feature on specified EXiP Region.
Definition: hpm_romapi.h:733
static ATTR_RAMFUNC hpm_stat_t rom_xpi_nor_erase_sector_nonblocking(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config, uint32_t start)
Erase specified FLASH sector in non-blocking way.
Definition: hpm_romapi.h:475
static ATTR_RAMFUNC hpm_stat_t rom_xpi_nor_erase(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config, uint32_t start, uint32_t length)
Erase specified FLASH region.
Definition: hpm_romapi.h:436
static hpm_stat_t rom_enter_bootloader(void *ctx)
Eneter specified Boot mode.
Definition: hpm_romapi.h:380
static ATTR_RAMFUNC void rom_xpi_nor_remap_disable(XPI_Type *base)
Disable XPI Remapping logic.
Definition: hpm_romapi.h:691
static hpm_stat_t rom_xpi_nor_get_status(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config, uint32_t addr, uint16_t *out_status)
Return the status register value on XPI NOR FLASH.
Definition: hpm_romapi.h:662
static ATTR_RAMFUNC hpm_stat_t rom_xpi_nor_erase_block_nonblocking(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config, uint32_t start)
Erase specified FLASH blcok in non-blocking way.
Definition: hpm_romapi.h:511
static ATTR_RAMFUNC void rom_xpi_nor_exip_disable(XPI_Type *base)
Disable global EXiP logic.
Definition: hpm_romapi.h:755
static ATTR_RAMFUNC hpm_stat_t rom_xpi_nor_program(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config, const uint32_t *src, uint32_t dst_addr, uint32_t length)
Program data to specified FLASH address in blocking way.
Definition: hpm_romapi.h:564
static ATTR_RAMFUNC bool rom_xpi_nor_is_remap_enabled(XPI_Type *base)
Check whether XPI Remapping is enabled.
Definition: hpm_romapi.h:705
static hpm_stat_t rom_xpi_nor_get_property(XPI_Type *base, xpi_nor_config_t *nor_cfg, uint32_t property_id, uint32_t *value)
Get XPI NOR properties.
Definition: hpm_romapi.h:644
static ATTR_RAMFUNC hpm_stat_t rom_xpi_nor_get_config(XPI_Type *base, xpi_nor_config_t *nor_cfg, xpi_nor_config_option_t *cfg_option)
Get XPI NOR configuration via cfg_option.
Definition: hpm_romapi.h:401
static ATTR_RAMFUNC hpm_stat_t rom_xpi_nor_erase_sector(XPI_Type *base, xpi_xfer_channel_t channel, const xpi_nor_config_t *nor_config, uint32_t start)
Erase specified FLASH sector in blocking way.
Definition: hpm_romapi.h:456
static void init(hpm_panel_t *panel)
Definition: cc10128007.c:86
uint32_t hpm_stat_t
Definition: hpm_common.h:123
otp_region_t
OTP region definitions.
Definition: hpm_otp_drv.h:24
otp_lock_option_t
OTP lock options.
Definition: hpm_otp_drv.h:34
static hpm_stat_t rom_sdp_memset(sdp_dma_ctx_t *dma_ctx, void *dst, uint8_t pattern, uint32_t length)
SDP memset operation.
Definition: hpm_romapi.h:947
static hpm_stat_t rom_sdp_aes_crypt_cbc(sdp_aes_ctx_t *aes_ctx, sdp_aes_op_t op, uint32_t length, uint8_t iv[16], const uint8_t *in, uint8_t *out)
SDP AES CBC crypto operation(Encrypt or Decrypt)
Definition: hpm_romapi.h:828
static hpm_stat_t rom_sdp_sm4_crypt_cbc(sdp_sm4_ctx_t *sm4_ctx, sdp_sm4_op_t op, uint32_t length, uint8_t iv[16], const uint8_t *in, uint8_t *out)
SDP SM4 CBC crypto operation(Encrypt or Decrypt)
Definition: hpm_romapi.h:882
static hpm_stat_t rom_sdp_memcpy(sdp_dma_ctx_t *dma_ctx, void *dst, const void *src, uint32_t length)
SDP memcpy operation.
Definition: hpm_romapi.h:934
static hpm_stat_t rom_sdp_sm4_crypt_ecb(sdp_sm4_ctx_t *sm4_ctx, sdp_sm4_op_t op, uint32_t len, const uint8_t *in, uint8_t *out)
SDP SM4 ECB crypto operation(Encrypt or Decrypt)
Definition: hpm_romapi.h:863
static hpm_stat_t rom_sdp_sm4_set_key(sdp_sm4_ctx_t *sm4_ctx, const uint8_t *key, sdp_sm4_key_bits_t key_bits, uint32_t key_idx)
Set SM4 key to SDP.
Definition: hpm_romapi.h:846
static void rom_sdp_init(void)
Initialize SDP IP.
Definition: hpm_romapi.h:771
#define ROM_API_TABLE_ROOT
Definition: hpm_romapi.h:360
static hpm_stat_t rom_sdp_aes_set_key(sdp_aes_ctx_t *aes_ctx, const uint8_t *key, sdp_aes_key_bits_t key_bits, uint32_t key_idx)
Set AES key to SDP.
Definition: hpm_romapi.h:792
static void rom_sdp_deinit(void)
De-initialize SDP IP.
Definition: hpm_romapi.h:779
static hpm_stat_t rom_sdp_hash_finish(sdp_hash_ctx_t *hash_ctx, uint8_t *digest)
HASH finialize.
Definition: hpm_romapi.h:921
static hpm_stat_t rom_sdp_hash_update(sdp_hash_ctx_t *hash_ctx, const uint8_t *data, uint32_t length)
HASH Update.
Definition: hpm_romapi.h:910
static hpm_stat_t rom_sdp_aes_crypt_ecb(sdp_aes_ctx_t *aes_ctx, sdp_aes_op_t op, uint32_t len, const uint8_t *in, uint8_t *out)
SDP AES ECB crypto operation(Encrypt or Decrypt)
Definition: hpm_romapi.h:809
static hpm_stat_t rom_sdp_hash_init(sdp_hash_ctx_t *hash_ctx, sdp_hash_alg_t alg)
HASH initialization.
Definition: hpm_romapi.h:898
sdp_crypto_op_t
Crypto operation option.
Definition: hpm_sdp_drv.h:44
sdp_crypto_key_bits_t
SDP AES key bit options.
Definition: hpm_sdp_drv.h:29
sdp_hash_alg_t
SDP HASH algorithm definitions.
Definition: hpm_sdp_drv.h:102
xpi_xfer_channel_t
XPI Transfer Channel type definitions.
Definition: hpm_romapi_xpi_def.h:53
uint32_t XPI_Type
XPI_Type definitions for.
Definition: hpm_romapi_xpi_def.h:22
xpi_channel_t
XPI Channel definitions.
Definition: hpm_romapi_xpi_def.h:64
static hpm_stat_t read(void *ops, hpm_serial_nor_transfer_seq_t *cmd_seq)
Definition: hpm_serial_nor_host_spi.c:309
#define fencei()
execute fence.i
Definition: riscv_core.h:88
Bootloader API table.
Definition: hpm_romapi.h:243
const sdp_driver_interface_t * sdp_driver_if
Definition: hpm_romapi.h:353
EXIP driver interface.
Definition: hpm_romapi.h:226
Definition: hpm_romapi.h:59
Definition: hpm_romapi.h:52
OTP driver interface.
Definition: hpm_romapi.h:82
SDP AES context structure.
Definition: hpm_sdp_drv.h:159
SDP DMA context.
Definition: hpm_sdp_drv.h:179
SDP API interface.
Definition: hpm_romapi.h:243
uint32_t version
Definition: hpm_romapi.h:245
SDP HASH context.
Definition: hpm_sdp_drv.h:186
Definition: hpm_romapi_xpi_soc_def.h:28
XPI configuration structure.
Definition: hpm_romapi_xpi_def.h:160
XPI Device Configuration structure.
Definition: hpm_romapi_xpi_def.h:173
XPI driver interface.
Definition: hpm_romapi.h:110
XPI NOR configuration option The ROM SW can detect the FLASH configuration based on the following str...
Definition: hpm_romapi_xpi_nor_def.h:136
XPI NOR configuration structure.
Definition: hpm_romapi_xpi_nor_def.h:261
XPI NOR driver interface.
Definition: hpm_romapi.h:145
XPI Xfer context.
Definition: hpm_romapi_xpi_def.h:93
Enter Bootloader API argument.
Definition: hpm_romapi.h:41