| 1 | /* Copyright 2015 The ChromiumOS Authors |
| 2 | * Use of this source code is governed by a BSD-style license that can be |
| 3 | * found in the LICENSE file. |
| 4 | * |
| 5 | * This module provides some utility functions to use "flashrom" to read from |
| 6 | * and write to NOR flash. |
| 7 | */ |
| 8 | |
| 9 | #ifndef VBOOT_REFERENCE_CGPT_NOR_H_ |
| 10 | #define VBOOT_REFERENCE_CGPT_NOR_H_ |
| 11 | |
| 12 | // Obtain the MTD size from its sysfs node. |mtd_device| should point to |
| 13 | // a dev node such as /dev/mtd0. This function returns 0 on success. |
| 14 | int GetMtdSize(const char *mtd_device, uint64_t *size); |
| 15 | |
| 16 | // Exec |argv| in |cwd|. Return -1 on error, or exit code on success. |argv| |
| 17 | // must be terminated with a NULL element as is required by execv(). |
| 18 | int ForkExecV(const char *cwd, const char *const argv[]); |
| 19 | |
| 20 | // Similar to ForkExecV but with a vararg instead of an array of pointers. |
| 21 | int ForkExecL(const char *cwd, const char *cmd, ...); |
| 22 | |
| 23 | // Exec "rm" to remove |dir|. |
| 24 | int RemoveDir(const char *dir); |
| 25 | |
| 26 | // Read RW_GPT from NOR flash to "rw_gpt" in dir. |
| 27 | int ReadNorFlash(const char *dir); |
| 28 | |
| 29 | // Write "rw_gpt" back to NOR flash. We write the file in two parts for safety. |
| 30 | int WriteNorFlash(const char *dir); |
| 31 | |
| 32 | #endif /* VBOOT_REFERENCE_CGPT_NOR_H_ */ |