Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Duncan Laurie | d8c4f2b | 2014-04-22 10:46:06 -0700 | [diff] [blame] | 4 | * Copyright (C) 2014 Google Inc. |
Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 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 | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 14 | */ |
| 15 | |
Duncan Laurie | d8c4f2b | 2014-04-22 10:46:06 -0700 | [diff] [blame] | 16 | #ifndef _COMMON_NVM_H_ |
| 17 | #define _COMMON_NVM_H_ |
Aaron Durbin | 9a7d7bc | 2013-09-07 00:41:48 -0500 | [diff] [blame] | 18 | |
| 19 | #include <stddef.h> |
| 20 | |
| 21 | /* Determine if area is erased. returns 1 if erased. 0 otherwise. */ |
| 22 | int nvm_is_erased(const void *start, size_t size); |
| 23 | |
| 24 | /* Erase region according to start and size. Returns < 0 on error else 0. */ |
| 25 | int nvm_erase(void *start, size_t size); |
| 26 | |
| 27 | /* Write data to NVM. Returns 0 on success < 0 on error. */ |
| 28 | int nvm_write(void *start, const void *data, size_t size); |
| 29 | |
Duncan Laurie | a32b6b9 | 2015-01-15 15:49:07 -0800 | [diff] [blame] | 30 | /* Determine if flash device is write protected */ |
| 31 | int nvm_is_write_protected(void); |
| 32 | |
| 33 | /* Apply protection to a range of flash */ |
| 34 | int nvm_protect(void *start, size_t size); |
| 35 | |
Alexandru Gagniuc | 9220641 | 2016-03-03 10:58:30 -0800 | [diff] [blame] | 36 | /* Map MMIO address to actual address in flash */ |
| 37 | uint32_t nvm_mmio_to_flash_offset(void *p); |
| 38 | |
Duncan Laurie | d8c4f2b | 2014-04-22 10:46:06 -0700 | [diff] [blame] | 39 | #endif /* _COMMON_NVM_H_ */ |