blob: 074a2ce406edc55d79a8500df93604ae18098a4e [file] [log] [blame]
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -05001/*
2 * This file is part of the coreboot project.
3 *
Duncan Lauried8c4f2b2014-04-22 10:46:06 -07004 * Copyright (C) 2014 Google Inc.
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -05005 *
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 Durbin9a7d7bc2013-09-07 00:41:48 -050014 */
15
Duncan Lauried8c4f2b2014-04-22 10:46:06 -070016#ifndef _COMMON_NVM_H_
17#define _COMMON_NVM_H_
Aaron Durbin9a7d7bc2013-09-07 00:41:48 -050018
19#include <stddef.h>
20
21/* Determine if area is erased. returns 1 if erased. 0 otherwise. */
22int nvm_is_erased(const void *start, size_t size);
23
24/* Erase region according to start and size. Returns < 0 on error else 0. */
25int nvm_erase(void *start, size_t size);
26
27/* Write data to NVM. Returns 0 on success < 0 on error. */
28int nvm_write(void *start, const void *data, size_t size);
29
Duncan Lauriea32b6b92015-01-15 15:49:07 -080030/* Determine if flash device is write protected */
31int nvm_is_write_protected(void);
32
33/* Apply protection to a range of flash */
34int nvm_protect(void *start, size_t size);
35
Alexandru Gagniuc92206412016-03-03 10:58:30 -080036/* Map MMIO address to actual address in flash */
37uint32_t nvm_mmio_to_flash_offset(void *p);
38
Duncan Lauried8c4f2b2014-04-22 10:46:06 -070039#endif /* _COMMON_NVM_H_ */