cgpt_nor.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  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. #ifndef VBOOT_REFERCENCE_CGPT_CGPT_NOR_H_
  9. #define VBOOT_REFERCENCE_CGPT_CGPT_NOR_H_
  10. // Obtain the MTD size from its sysfs node. |mtd_device| should point to
  11. // a dev node such as /dev/mtd0. This function returns 0 on success.
  12. int GetMtdSize(const char *mtd_device, uint64_t *size);
  13. // Exec |argv| in |cwd|. Return -1 on error, or exit code on success. |argv|
  14. // must be terminated with a NULL element as is required by execv().
  15. int ForkExecV(const char *cwd, const char *const argv[]);
  16. // Similar to ForkExecV but with a vararg instead of an array of pointers.
  17. int ForkExecL(const char *cwd, const char *cmd, ...);
  18. // Exec "rm" to remove |dir|.
  19. int RemoveDir(const char *dir);
  20. // Read RW_GPT from NOR flash to "rw_gpt" in a temp dir |temp_dir_template|.
  21. // |temp_dir_template| is passed to mkdtemp() so it must satisfy all
  22. // requirements by mkdtemp().
  23. int ReadNorFlash(char *temp_dir_template);
  24. // Write "rw_gpt" back to NOR flash. We write the file in two parts for safety.
  25. int WriteNorFlash(const char *dir);
  26. #endif // VBOOT_REFERCENCE_CGPT_CGPT_NOR_H_