Software APIs
rram_ctrl.h
1// Copyright lowRISC contributors (OpenTitan project).
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4#ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_DRIVERS_RRAM_CTRL_H_
5#define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_DRIVERS_RRAM_CTRL_H_
6
7#include <assert.h>
8#include <limits.h>
9#include <stdbool.h>
10
13#include "sw/device/lib/base/multibits.h"
14#include "sw/device/silicon_creator/lib/error.h"
15
16#include "hw/top/rram_ctrl_regs.h" // Generated.
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/**
23 * A logical RRAM info page.
24 *
25 * Unlike flash, RRAM has only `RRAM_CTRL_PARAM_NUM_INFO_PAGES` (8) physical
26 * info pages, too few for the 20 logical pages named in `nvm_info_page_t`.
27 * The remaining pages are emulated on the data partition of the RRAM.
28 * The permissions are currently per emulated page region and not per page.
29 * This needs to be adjusted: https://github.com/lowRISC/opentitan/issues/30914.
30 */
31typedef struct rram_ctrl_info_page {
32 /**
33 * Physical page index.
34 *
35 * For a real page (`emulated` = false), this is an info-partition page
36 * index in [0, `RRAM_CTRL_PARAM_NUM_INFO_PAGES` - 1]. For an emulated page
37 * (`emulated` = true), this is a data-partition page index.
38 */
39 uint32_t page_id;
40 /**
41 * Whether this page is emulated on the data partition rather than backed by
42 * a real RRAM info page.
43 */
45 /**
46 * Number of contiguous physical pages backing this logical page.
47 *
48 * Real info pages are always 1 (there's no way to combine physical info
49 * pages). Emulated pages can span multiple contiguous data-partition pages
50 * to fit content larger than 512 bytes; callers reading/writing more than
51 * `num_pages * 512` bytes will silently spill into the next logical page's
52 * storage, since nothing enforces this bound at the read/write call site.
53 */
54 uint32_t num_pages;
55} rram_ctrl_info_page_t;
56
57/**
58 * Two data-partition page ranges, each reserved at the tail of one firmware
59 * slot (matching the linker's `_nvm_slot_reserved_bytes`, which carves the
60 * same 32KiB out of every slot): Each has its own memory-protection region,
61 * granted in full by `nvm_ctrl_init()`. Bootstrap/rescue's generic erase
62 * and program paths exclude both ranges in full.
63 */
64enum {
65 /**
66 * Number of pages the linker reserves at the tail of every slot
67 * (`_nvm_slot_reserved_bytes` in top_earlgrey_memory.ld, 32KiB).
68 */
69 kRramCtrlReservedPageCount = 0x8000 / RRAM_CTRL_PARAM_BYTES_PER_PAGE,
70
71 kRramCtrlEmulPageEndA = RRAM_CTRL_PARAM_NUM_DATA_PAGES / 2,
72 kRramCtrlEmulPageBaseA = kRramCtrlEmulPageEndA - kRramCtrlReservedPageCount,
73 kRramCtrlEmulRegionA = 8,
74
75 kRramCtrlEmulPageEndB = RRAM_CTRL_PARAM_NUM_DATA_PAGES,
76 kRramCtrlEmulPageBaseB = kRramCtrlEmulPageEndB - kRramCtrlReservedPageCount,
77 kRramCtrlEmulRegionB = 9,
78
79 /**
80 * Pages at the very tail of Region B's window reserved for OTP: read/write
81 * protected in hardware.
82 */
83 kRramCtrlOtpPageCount = RRAM_CTRL_PARAM_NUM_OTP_PAGES,
84};
85
86/**
87 * Table of RRAM information pages.
88 *
89 * Columns: Name, physical page index, whether emulated, number of contiguous
90 * physical pages backing it (see `rram_ctrl_info_page_t.num_pages`).
91 * We use an X macro to facilitate writing enums, switch statements, and unit
92 * tests using the constants here, mirroring `FLASH_CTRL_INFO_PAGES_DEFINE`.
93 *
94 * Emulated-page offsets below are manually cumulative (each is the previous
95 * entry's offset + its `num_pages`) since a page occupying more than one
96 * slot has no entries of its own for its 2nd-Nth pages.
97 */
98// clang-format off
99#define RRAM_CTRL_INFO_PAGES_DEFINE(X) \
100 /**
101 * Real, individually-protected info pages. Always 1 page each -- there's
102 * no way to combine physical info pages, so anything needing more than
103 * 512 bytes must be an emulated page instead (see below).
104 */ \
105 X(kRramCtrlInfoPageFactoryId, 0, false, 1) \
106 X(kRramCtrlInfoPageAttestationKeySeeds, 1, false, 1) \
107 X(kRramCtrlInfoPageCreatorSecret, 5, false, 1) \
108 X(kRramCtrlInfoPageOwnerSecret, 6, false, 1) \
109 X(kRramCtrlInfoPageWaferAuthSecret, 7, false, 1) \
110 /**
111 * Emulated info pages, relocated onto the data partition.
112 *
113 * All emulated pages are uniformly 4 pages (2048 bytes) each, even though
114 * several don't strictly need it. Pages that DO need the full 2048
115 * bytes:
116 * - `OwnerSlot0`/`OwnerSlot1`: back `owner_block_t`, which is 2048 bytes
117 * (`OT_ASSERT_SIZE(owner_block_t, 2048)`).
118 * - `DiceCerts`/`FactoryCerts`: share one `dice_page_t` buffer type and
119 * must be deliberately equal in size (see the `static_assert` in
120 * dice_chain.h), even though their actual content (~1.3KB and ~800
121 * bytes respectively) would technically fit in fewer.
122 * - `OwnerReserved0`: what ISFB owner configs point at
123 * (`isfb->bank=0,page=5`); needs the space for its strike region plus
124 * product expressions.
125 * - `OwnerReserved6`/`OwnerReserved7`: SKU extensions (e.g.
126 * `tpm_personalize_ext.c`'s TPM EK cert) write to them via the same
127 * `dice_page_t` buffer as `DiceCerts`/`FactoryCerts`, which is always a
128 * full `kDicePageDataSize`.
129 */ \
130 X(kRramCtrlInfoPageOwnerReserved0, kRramCtrlEmulPageBaseB + 0, true, 4) \
131 X(kRramCtrlInfoPageOwnerReserved1, kRramCtrlEmulPageBaseB + 4, true, 4) \
132 X(kRramCtrlInfoPageOwnerReserved2, kRramCtrlEmulPageBaseB + 8, true, 4) \
133 X(kRramCtrlInfoPageOwnerReserved3, kRramCtrlEmulPageBaseB + 12, true, 4) \
134 X(kRramCtrlInfoPageOwnerReserved4, kRramCtrlEmulPageBaseB + 16, true, 4) \
135 X(kRramCtrlInfoPageOwnerReserved5, kRramCtrlEmulPageBaseB + 20, true, 4) \
136 X(kRramCtrlInfoPageOwnerReserved6, kRramCtrlEmulPageBaseB + 24, true, 4) \
137 X(kRramCtrlInfoPageOwnerReserved7, kRramCtrlEmulPageBaseB + 28, true, 4) \
138 X(kRramCtrlInfoPageBootData0, kRramCtrlEmulPageBaseB + 32, true, 4) \
139 X(kRramCtrlInfoPageBootData1, kRramCtrlEmulPageBaseB + 36, true, 4) \
140 X(kRramCtrlInfoPageOwnerSlot0, kRramCtrlEmulPageBaseB + 40, true, 4) \
141 X(kRramCtrlInfoPageOwnerSlot1, kRramCtrlEmulPageBaseB + 44, true, 4) \
142 X(kRramCtrlInfoPageDiceCerts, kRramCtrlEmulPageBaseB + 48, true, 4) \
143 X(kRramCtrlInfoPageFactoryCerts, kRramCtrlEmulPageBaseB + 52, true, 4) \
144 /**
145 * In its own dedicated region (`kRramCtrlEmulRegionA`), not
146 * `kRramCtrlEmulRegionB` above; see the comment there.
147 */ \
148 X(kRramCtrlInfoPageCreatorReserved0, kRramCtrlEmulPageBaseA + 0, true, 4) \
149// clang-format on
150
151/**
152 * Total pages `RRAM_CTRL_INFO_PAGES_DEFINE` assigns within each region's
153 * window, computed by walking the table rather than hand-counted, so a
154 * future entry that doesn't fit is caught automatically instead of silently
155 * landing past the window (into the next region, or -- for Region B --
156 * into the hardware-protected OTP tail).
157 */
158#define INFO_PAGE_SUM_REGION_A_(name_, page_id_, emulated_, num_pages_) \
159 +((emulated_) && (page_id_) >= kRramCtrlEmulPageBaseA && \
160 (page_id_) < kRramCtrlEmulPageEndA \
161 ? (num_pages_) \
162 : 0)
163#define INFO_PAGE_SUM_REGION_B_(name_, page_id_, emulated_, num_pages_) \
164 +((emulated_) && (page_id_) >= kRramCtrlEmulPageBaseB && \
165 (page_id_) < kRramCtrlEmulPageEndB \
166 ? (num_pages_) \
167 : 0)
168enum {
169 kRramCtrlInfoPagesRegionATotal =
170 0 RRAM_CTRL_INFO_PAGES_DEFINE(INFO_PAGE_SUM_REGION_A_),
171 kRramCtrlInfoPagesRegionBTotal =
172 0 RRAM_CTRL_INFO_PAGES_DEFINE(INFO_PAGE_SUM_REGION_B_),
173};
174#undef INFO_PAGE_SUM_REGION_A_
175#undef INFO_PAGE_SUM_REGION_B_
176static_assert(kRramCtrlInfoPagesRegionATotal <= kRramCtrlReservedPageCount,
177 "RRAM_CTRL_INFO_PAGES_DEFINE's Region A entries overflow "
178 "kRramCtrlEmulRegionA's window");
179static_assert(kRramCtrlInfoPagesRegionBTotal <=
180 kRramCtrlReservedPageCount - kRramCtrlOtpPageCount,
181 "RRAM_CTRL_INFO_PAGES_DEFINE's Region B entries would overlap "
182 "the OTP tail");
183
184/**
185 * Helper macro for declaring an extern `rram_ctrl_info_page_t`.
186 * @param name_ Name of the enumeration constant.
187 * @param page_id_ Physical page index of the info page.
188 * @param emulated_ Whether the page is emulated on the data partition.
189 * @param num_pages_ Number of contiguous physical pages backing this page.
190 */
191#define INFO_PAGE_STRUCT_DECL_(name_, page_id_, emulated_, num_pages_) \
192 extern const rram_ctrl_info_page_t name_;
193
194/**
195 * Info pages.
196 */
197RRAM_CTRL_INFO_PAGES_DEFINE(INFO_PAGE_STRUCT_DECL_);
198
199#undef INFO_PAGE_STRUCT_DECL_
200
201/**
202 * Helper macro for declaring a `<name_>Size` compile-time constant: the
203 * total on-NVM byte size backing a logical page, i.e.
204 * `num_pages_ * RRAM_CTRL_PARAM_BYTES_PER_PAGE`. Callers should use these
205 * instead of re-deriving a page's size from `num_pages` themselves, so the
206 * page table in `RRAM_CTRL_INFO_PAGES_DEFINE` stays the only place page
207 * counts are written down.
208 * @param name_ Name of the enumeration constant.
209 * @param page_id_ Physical page index of the info page.
210 * @param emulated_ Whether the page is emulated on the data partition.
211 * @param num_pages_ Number of contiguous physical pages backing this page.
212 */
213#define INFO_PAGE_SIZE_ENUM_(name_, page_id_, emulated_, num_pages_) \
214 name_##Size = (num_pages_) * RRAM_CTRL_PARAM_BYTES_PER_PAGE,
215
216enum { RRAM_CTRL_INFO_PAGES_DEFINE(INFO_PAGE_SIZE_ENUM_) };
217
218#undef INFO_PAGE_SIZE_ENUM_
219
220/**
221 * Bitfields for `CREATOR_SW_CFG_NVM_DATA_DEFAULT_CFG` and
222 * `CREATOR_SW_CFG_NVM_INFO_BOOT_DATA_CFG` OTP items.
223 *
224 * RRAM reuses the same OTP words and bit layout as flash_ctrl (the OTP
225 * schema was not redesigned for RRAM); these are RRAM's own copies of
226 * flash_ctrl.h's `FLASH_CTRL_OTP_FIELD_*` macros so that rram_ctrl does not
227 * need to depend on the flash_ctrl driver just for these constants.
228 *
229 * Defined here to be able to use in tests.
230 */
231#define RRAM_CTRL_OTP_FIELD_SCRAMBLING \
232 (bitfield_field32_t){.mask = UINT8_MAX, .index = CHAR_BIT * 0}
233#define RRAM_CTRL_OTP_FIELD_ECC \
234 (bitfield_field32_t){.mask = UINT8_MAX, .index = CHAR_BIT * 1}
235
236/**
237 * Bitfields for `CREATOR_SW_CFG_NVM_HW_INFO_CFG_OVERRIDE` OTP item.
238 *
239 * See the note above: RRAM reuses flash_ctrl's OTP word/bit layout.
240 *
241 * Defined here to be able to use in tests.
242 */
243#define RRAM_CTRL_OTP_FIELD_HW_INFO_CFG_OVERRIDE_SCRAMBLE_DIS \
244 (bitfield_field32_t){.mask = UINT8_MAX, .index = CHAR_BIT * 0}
245#define RRAM_CTRL_OTP_FIELD_HW_INFO_CFG_OVERRIDE_ECC_DIS \
246 (bitfield_field32_t){.mask = UINT8_MAX, .index = CHAR_BIT * 1}
247
248/**
249 * The following constants represent the expected number of sec_mmio
250 * register writes performed by functions provided in this module. See
251 * `SEC_MMIO_WRITE_INCREMENT()` for more details.
252 */
253enum {
254 kRramCtrlSecMmioDataDefaultPermsSet = 1,
255 kRramCtrlSecMmioDataDefaultCfgSet = 1,
256 kRramCtrlSecMmioInfoPermsSet = 1,
257 kRramCtrlSecMmioInfoCfgSet = 1,
258 kRramCtrlSecMmioInfoCfgLock = 1,
259 kRramCtrlSecMmioInfoPageLockdown = 2,
260 kRramCtrlSecMmioExecSet = 1,
261 // 2 writes: MP_REGION_${region} and MP_REGION_CFG_${region}.
262 kRramCtrlSecMmioDataRegionProtect = 2,
263 kRramCtrlSecMmioDataRegionProtectLock = 1,
264 kRramCtrlSecMmioInit = 1,
266
267/**
268 * Kicks off the initialization of the RRAM controller.
270 * This must complete before RRAM can be accessed. The init status can be
271 * queried by calling `rram_ctrl_status_get()` and checking `init_done`.
272 *
273 * The caller is responsible for calling
274 * `SEC_MMIO_WRITE_INCREMENT(kRramCtrlSecMmioInit)` when sec_mmio is being
275 * used to check expectations.
276 */
277void rram_ctrl_init(void);
278
279/**
280 * Permanently disable the RRAM controller.
281 */
282void rram_ctrl_disable(void);
283
284/**
285 * Status bits.
286 */
287typedef struct rram_ctrl_status {
288 /**
289 * RRAM read FIFO full, software must consume data.
290 */
291 bool rd_full;
292 /**
293 * RRAM read FIFO empty.
294 */
295 bool rd_empty;
296 /**
297 * RRAM write FIFO full.
298 */
299 bool wr_full;
300 /**
301 * RRAM write FIFO empty, software must provide data.
302 */
304 /**
305 * RRAM controller undergoing init.
306 */
308} rram_ctrl_status_t;
309
310/**
311 * Query the status registers on the RRAM controller.
312 *
313 * @param[out] status The current status of the RRAM controller.
314 */
315void rram_ctrl_status_get(rram_ctrl_status_t *status);
316
317/**
318 * Error code bits.
319 */
320typedef struct rram_ctrl_error_code {
321 /**
322 * Software has supplied an undefined RRAM operation.
323 */
324 bool op_err;
325 /**
326 * RRAM access permission error. Read the ERR_ADDR register for the
327 * faulting address.
328 */
329 bool mp_err;
330 /**
331 * RRAM read error, could be an integrity error.
332 */
333 bool rd_err;
334 /**
335 * RRAM write error.
336 */
337 bool wr_err;
338} rram_ctrl_error_code_t;
339
340/**
341 * Query the error code register on the RRAM controller.
342 *
343 * @param[out] error_code The current error code of the RRAM controller.
344 */
345void rram_ctrl_error_code_get(rram_ctrl_error_code_t *error_code);
346
347/**
348 * Reads data from the data partition.
349 *
350 * @param addr Address to read from.
351 * @param word_count Number of bus words to read.
352 * @param[out] data Buffer to store the read data. Must be word aligned.
353 * @return Result of the operation.
354 */
356rom_error_t rram_ctrl_data_read(uint32_t addr, uint32_t word_count, void *data);
357
358/**
359 * Reads data from an information page.
360 *
361 * @param info_page Information page to read from.
362 * @param offset Offset from the start of the page.
363 * @param word_count Number of bus words to read.
364 * @param[out] data Buffer to store the read data. Must be word aligned.
365 * @return Result of the operation.
366 */
368rom_error_t rram_ctrl_info_read(const rram_ctrl_info_page_t *info_page,
369 uint32_t offset, uint32_t word_count,
370 void *data);
371
372/**
373 * Reads data from an information page, returning all zeros if a read error
374 * code is encountered.
375 *
376 * @param info_page Information page to read from.
377 * @param offset Offset from the start of the page.
378 * @param word_count Number of bus words to read.
379 * @param[out] data Buffer to store the read data. Must be word aligned.
380 * @return Result of the operation.
381 */
383rom_error_t rram_ctrl_info_read_zeros_on_read_error(
384 const rram_ctrl_info_page_t *info_page, uint32_t offset,
385 uint32_t word_count, void *data);
386
387/**
388 * Writes data to the data partition.
389 *
390 * RRAM supports direct overwrite; unlike flash, no erase is required before
391 * writing.
392 *
393 * @param addr Address to write to.
394 * @param word_count Number of bus words to write. Must be a multiple of 4.
395 * @param data Data to write. Must be word aligned.
396 * @return Result of the operation.
397 */
399rom_error_t rram_ctrl_data_write(uint32_t addr, uint32_t word_count,
400 const void *data);
401
402/**
403 * Writes data to an information page.
404 *
405 * @param info_page Information page to write to.
406 * @param offset Offset from the start of the page.
407 * @param word_count Number of bus words to write. Must be a multiple of 4.
408 * @param data Data to write. Must be word aligned.
409 * @return Result of the operation.
410 */
412rom_error_t rram_ctrl_info_write(const rram_ctrl_info_page_t *info_page,
413 uint32_t offset, uint32_t word_count,
414 const void *data);
415
416/**
417 * A struct for specifying access permissions.
418 *
419 * RRAM has no separate erase permission; unlike flash, write operations
420 * overwrite in place.
421 *
422 * rram_ctrl config registers use 4-bits for boolean values. Use
423 * `kMultiBitBool4True` to enable and `kMultiBitBool4False` to disable
424 * permissions.
425 */
426typedef struct rram_ctrl_perms {
427 uint32_t _pad0 : 4;
428 /**
429 * Read.
430 */
431 uint32_t read : 4;
432 /**
433 * Write.
434 */
435 uint32_t write : 4;
436 uint32_t _pad1 : 20;
437} rram_ctrl_perms_t;
438OT_ASSERT_SIZE(rram_ctrl_perms_t, 4);
439
440/**
441 * Sets default access permissions for the data partition.
442 *
443 * The caller is responsible for calling
444 * `SEC_MMIO_WRITE_INCREMENT(kRramCtrlSecMmioDataDefaultPermsSet)` when
445 * sec_mmio is being used to check expectations.
446 *
447 * @param perms New permissions.
448 */
449void rram_ctrl_data_default_perms_set(rram_ctrl_perms_t perms);
450
451/**
452 * Sets access permissions for a real (non-emulated) info page.
454 * The caller is responsible for calling
455 * `SEC_MMIO_WRITE_INCREMENT(kRramCtrlSecMmioInfoPermsSet)` when sec_mmio is
456 * being used to check expectations.
458 * @param info_page A real information page (`emulated` = false).
459 * @param perms New permissions.
460 */
461void rram_ctrl_info_perms_set(const rram_ctrl_info_page_t *info_page,
462 rram_ctrl_perms_t perms);
463
464/**
465 * A struct for RRAM configuration settings.
466 *
467 * RRAM has no high-endurance concept; unlike flash, no wear-leveling
468 * configuration is needed.
469 *
470 * rram_ctrl config registers use 4-bits for boolean values. Use
471 * `kMultiBitBool4True` to enable and `kMultiBitBool4False` to disable these
472 * settings.
473 */
474typedef struct rram_ctrl_cfg {
475 uint32_t _pad0 : 12;
476 /**
477 * Scrambling.
478 */
479 uint32_t scrambling : 4;
480 /**
481 * ECC.
482 */
483 uint32_t ecc : 4;
484 uint32_t _pad1 : 12;
485} rram_ctrl_cfg_t;
486OT_ASSERT_SIZE(rram_ctrl_cfg_t, 4);
487
488/**
489 * Sets default configuration settings for the data partition.
490 *
491 * The caller is responsible for calling
492 * `SEC_MMIO_WRITE_INCREMENT(kRramCtrlSecMmioDataDefaultCfgSet)` when
493 * sec_mmio is being used to check expectations.
494 *
495 * @param cfg New configuration settings.
496 */
497void rram_ctrl_data_default_cfg_set(rram_ctrl_cfg_t cfg);
498
499/**
500 * Reads the current default configuration settings for the data partition.
501 *
502 * @return Current configuration settings.
503 */
504rram_ctrl_cfg_t rram_ctrl_data_default_cfg_get(void);
505
506/**
507 * Reads the boot data info page configuration settings from OTP.
508 *
509 * Reuses the same `CREATOR_SW_CFG_NVM_INFO_BOOT_DATA_CFG` OTP word and bit
510 * layout as flash; the high-endurance field is ignored for RRAM.
511 *
512 * @return Current OTP configuration settings.
513 */
514rram_ctrl_cfg_t rram_ctrl_boot_data_cfg_get(void);
515
516/**
517 * A type for rram_ctrl memory protection region indices.
518 */
519typedef uint32_t rram_ctrl_region_index_t;
520
521/**
522 * Configure memory protection for a region of data-partition pages.
523 *
524 * Based on the `region` parameter, this function overwrites the
525 * `MP_REGION_${region}` and `MP_REGION_CFG_${region}` registers. Calling
526 * this function invalidates previously-configured protections for `region`.
527 *
528 * @param region The index of the region to protect.
529 * @param page_offset The index of the first page in the region.
530 * @param num_pages The number of pages in the region, i.e. the region covers
531 * the exclusive range `[page_offset, page_offset +
532 * num_pages)`. Internally compensates for the hardware's
533 * match logic, which is inclusive of `page_offset +
534 * num_pages`. Must be nonzero: the hardware has no way to
535 * express an empty region, so callers deriving this from
536 * untrusted data must reject 0 themselves.
537 * @param perms The read/write permissions for this region.
538 * @param cfg RRAM config values that are used to fill in some fields of the
539 * `MP_REGION_CFG_${region}` register.
540 * @param lock Lock the configuration for this region.
541 */
542void rram_ctrl_data_region_protect(rram_ctrl_region_index_t region,
543 uint32_t page_offset, uint32_t num_pages,
544 rram_ctrl_perms_t perms, rram_ctrl_cfg_t cfg,
545 hardened_bool_t lock);
546
547/**
548 * Sets configuration settings for a real (non-emulated) info page.
549 *
550 * The caller is responsible for calling
551 * `SEC_MMIO_WRITE_INCREMENT(kRramCtrlSecMmioInfoCfgSet)` when sec_mmio is
552 * being used to check expectations.
553 *
554 * @param info_page A real information page (`emulated` = false).
555 * @param cfg New configuration settings.
556 */
557void rram_ctrl_info_cfg_set(const rram_ctrl_info_page_t *info_page,
558 rram_ctrl_cfg_t cfg);
559
560/**
561 * Write-locks configuration settings for a real (non-emulated) info page.
562 *
563 * The caller is responsible for calling
564 * `SEC_MMIO_WRITE_INCREMENT(kRramCtrlSecMmioInfoCfgLock)` when sec_mmio is
565 * being used to check expectations.
566 *
567 * @param info_page A real information page (`emulated` = false).
568 */
569void rram_ctrl_info_cfg_lock(const rram_ctrl_info_page_t *info_page);
570
571/**
572 * Disables all access to a real (non-emulated) info page and locks its
573 * configuration until reset.
574 *
575 * Zeroes both the cfg register (clearing all permissions and configuration
576 * bits) and the regwen register (preventing further writes to cfg).
577 *
578 * The caller is responsible for calling
579 * `SEC_MMIO_WRITE_INCREMENT(kRramCtrlSecMmioInfoPageLockdown)` when sec_mmio
580 * is being used to check expectations.
581 *
582 * @param info_page A real information page (`emulated` = false).
583 */
584void rram_ctrl_info_page_lockdown(const rram_ctrl_info_page_t *info_page);
585
586/**
587 * Enable execution from RRAM.
588 *
589 * Note: an ePMP region must also be configured in order to execute code in
590 * RRAM.
591 *
592 * The caller is responsible for calling
593 * `SEC_MMIO_WRITE_INCREMENT(kRramCtrlSecMmioExecSet)` when sec_mmio is being
594 * used to check expectations.
595 *
596 * @param exec_val Value to write to the `rram_ctrl.EXEC` register.
597 * `RRAM_CTRL_PARAM_EXEC_EN` will enable execution, all other values will
598 * disable execution.
599 */
600void rram_ctrl_exec_set(uint32_t exec_val);
601
602#ifdef __cplusplus
603}
604#endif
605
606#endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_DRIVERS_RRAM_CTRL_H_