Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2015 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef _BOOT_DEVICE_H_ |
| 17 | #define _BOOT_DEVICE_H_ |
| 18 | |
Aaron Durbin | dc9f5cd | 2015-09-08 13:34:43 -0500 | [diff] [blame] | 19 | #include <commonlib/region.h> |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 20 | |
Aaron Durbin | dcbccd6 | 2016-08-10 11:42:42 -0500 | [diff] [blame] | 21 | /* |
| 22 | * Please note that the read-only boot device may not be coherent with |
| 23 | * the read-write boot device. Thus, mixing mmap() and writeat() is |
| 24 | * most likely not to work so don't rely on such semantics. |
| 25 | */ |
| 26 | |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 27 | /* Return the region_device for the read-only boot device. */ |
| 28 | const struct region_device *boot_device_ro(void); |
| 29 | |
Aaron Durbin | dcbccd6 | 2016-08-10 11:42:42 -0500 | [diff] [blame] | 30 | /* Return the region_device for the read-write boot device. */ |
| 31 | const struct region_device *boot_device_rw(void); |
| 32 | |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 33 | /* |
| 34 | * Create a sub-region of the read-only boot device. |
| 35 | * Returns 0 on success, < 0 on error. |
| 36 | */ |
| 37 | int boot_device_ro_subregion(const struct region *sub, |
| 38 | struct region_device *subrd); |
| 39 | |
| 40 | /* |
Aaron Durbin | dcbccd6 | 2016-08-10 11:42:42 -0500 | [diff] [blame] | 41 | * Create a sub-region of the read-write boot device. |
| 42 | * Returns 0 on success, < 0 on error. |
| 43 | */ |
| 44 | int boot_device_rw_subregion(const struct region *sub, |
| 45 | struct region_device *subrd); |
| 46 | |
| 47 | /* |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 48 | * Initialize the boot device. This may be called multiple times within |
| 49 | * a stage so boot device implementations should account for this behavior. |
| 50 | **/ |
| 51 | void boot_device_init(void); |
| 52 | |
| 53 | #endif /* _BOOT_DEVICE_H_ */ |