• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2015 The Chromium OS Authors. All rights reserved.
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_REFERCENCE_CGPT_CGPT_NOR_H_
10 #define VBOOT_REFERCENCE_CGPT_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 a temp dir |temp_dir_template|.
27 // |temp_dir_template| is passed to mkdtemp() so it must satisfy all
28 // requirements by mkdtemp().
29 int ReadNorFlash(char *temp_dir_template);
30 
31 // Write "rw_gpt" back to NOR flash. We write the file in two parts for safety.
32 int WriteNorFlash(const char *dir);
33 
34 #endif  // VBOOT_REFERCENCE_CGPT_CGPT_NOR_H_
35