device/azalia_device.c: Add option to lock down GCAP
[coreboot.git] / src / include / boot_device.h
blob84bd16ef65efd5b308a69c4f475fc42da2250565
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef _BOOT_DEVICE_H_
4 #define _BOOT_DEVICE_H_
6 #include <commonlib/region.h>
8 /*
9 * Boot device region can be protected by 2 sources, media and controller.
10 * The following modes are identified. It depends on the flash chip and the
11 * controller if mode is actually supported.
13 * MEDIA_WP : Flash/Boot device enforces write protect
14 * CTRLR_WP : Controller device enforces write protect
15 * CTRLR_RP : Controller device enforces read protect
16 * CTRLR_RWP : Controller device enforces read-write protect
18 enum bootdev_prot_type {
19 CTRLR_WP = 1,
20 CTRLR_RP = 2,
21 CTRLR_RWP = 3,
22 MEDIA_WP = 4,
25 * Please note that the read-only boot device may not be coherent with
26 * the read-write boot device. Thus, mixing mmap() and writeat() is
27 * most likely not to work so don't rely on such semantics.
30 /* Return the region_device for the read-only boot device. This is the root
31 device for all CBFS boot devices. */
32 const struct region_device *boot_device_ro(void);
34 /* Return the region_device for the read-write boot device. */
35 const struct region_device *boot_device_rw(void);
38 * Create a sub-region of the read-only boot device.
39 * Returns 0 on success, < 0 on error.
41 int boot_device_ro_subregion(const struct region *sub,
42 struct region_device *subrd);
45 * Create a sub-region of the read-write boot device.
46 * Returns 0 on success, < 0 on error.
48 int boot_device_rw_subregion(const struct region *sub,
49 struct region_device *subrd);
52 * Write protect a sub-region of the boot device represented
53 * by the region device.
54 * Returns 0 on success, < 0 on error.
56 int boot_device_wp_region(const struct region_device *rd,
57 const enum bootdev_prot_type type);
60 * Initialize the boot device. This may be called multiple times within
61 * a stage so boot device implementations should account for this behavior.
62 **/
63 void boot_device_init(void);
66 * Restrict read/write access to the bootmedia using platform defined rules.
68 #if CONFIG(BOOTMEDIA_LOCK_NONE) || (CONFIG(BOOTMEDIA_LOCK_IN_VERSTAGE) && ENV_RAMSTAGE)
69 static inline void boot_device_security_lockdown(void) {}
70 #else
71 void boot_device_security_lockdown(void);
72 #endif
73 #endif /* _BOOT_DEVICE_H_ */