blob: 04907b2afd1893948eea44ee6862619bec9418be [file] [log] [blame]
Nico Huber454f6132012-12-10 13:34:10 +00001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2012 secunet Security Networks AG
5 * (Written by Nico Huber <nico.huber@secunet.com> for secunet)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Nico Huber454f6132012-12-10 13:34:10 +000016 */
17
18#ifndef __LIBFLASHROM_H__
19#define __LIBFLASHROM_H__ 1
20
21#include <stdarg.h>
22
23int flashrom_init(int perform_selfcheck);
24int flashrom_shutdown(void);
25/** @ingroup flashrom-general */
Nico Huberd152fb92017-06-19 12:57:10 +020026enum flashrom_log_level {
Nico Huber454f6132012-12-10 13:34:10 +000027 FLASHROM_MSG_ERROR = 0,
Nico Hubere8e7a802017-06-19 12:38:39 +020028 FLASHROM_MSG_WARN = 1,
29 FLASHROM_MSG_INFO = 2,
30 FLASHROM_MSG_DEBUG = 3,
31 FLASHROM_MSG_DEBUG2 = 4,
32 FLASHROM_MSG_SPEW = 5,
Nico Huber454f6132012-12-10 13:34:10 +000033};
34/** @ingroup flashrom-general */
35typedef int(flashrom_log_callback)(enum flashrom_log_level, const char *format, va_list);
36void flashrom_set_log_callback(flashrom_log_callback *);
37
38struct flashrom_programmer;
39int flashrom_programmer_init(struct flashrom_programmer **, const char *prog_name, const char *prog_params);
40int flashrom_programmer_shutdown(struct flashrom_programmer *);
41
42struct flashrom_flashctx;
43int flashrom_flash_probe(struct flashrom_flashctx **, const struct flashrom_programmer *, const char *chip_name);
44size_t flashrom_flash_getsize(const struct flashrom_flashctx *);
45int flashrom_flash_erase(struct flashrom_flashctx *);
46void flashrom_flash_release(struct flashrom_flashctx *);
47
48/** @ingroup flashrom-flash */
49enum flashrom_flag {
50 FLASHROM_FLAG_FORCE,
51 FLASHROM_FLAG_FORCE_BOARDMISMATCH,
52 FLASHROM_FLAG_VERIFY_AFTER_WRITE,
53 FLASHROM_FLAG_VERIFY_WHOLE_CHIP,
54};
55void flashrom_flag_set(struct flashrom_flashctx *, enum flashrom_flag, bool value);
56bool flashrom_flag_get(const struct flashrom_flashctx *, enum flashrom_flag);
57
58int flashrom_image_read(struct flashrom_flashctx *, void *buffer, size_t buffer_len);
Paul Kocialkowskif701f342018-01-15 01:10:36 +030059int flashrom_image_write(struct flashrom_flashctx *, void *buffer, size_t buffer_len, const void *refbuffer);
Nico Huber454f6132012-12-10 13:34:10 +000060int flashrom_image_verify(struct flashrom_flashctx *, const void *buffer, size_t buffer_len);
61
62struct flashrom_layout;
Nico Huber305f4172013-06-14 11:55:26 +020063int flashrom_layout_read_from_ifd(struct flashrom_layout **, struct flashrom_flashctx *, const void *dump, size_t len);
Nico Huber454f6132012-12-10 13:34:10 +000064int flashrom_layout_include_region(struct flashrom_layout *, const char *name);
65void flashrom_layout_release(struct flashrom_layout *);
66void flashrom_layout_set(struct flashrom_flashctx *, const struct flashrom_layout *);
67
Paul Kocialkowskif701f342018-01-15 01:10:36 +030068#endif /* !__LIBFLASHROM_H__ */