Nico Huber | 454f613 | 2012-12-10 13:34:10 +0000 | [diff] [blame] | 1 | /* |
| 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. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #ifndef __LIBFLASHROM_H__ |
| 23 | #define __LIBFLASHROM_H__ 1 |
| 24 | |
| 25 | #include <stdarg.h> |
| 26 | |
| 27 | int flashrom_init(int perform_selfcheck); |
| 28 | int flashrom_shutdown(void); |
| 29 | /** @ingroup flashrom-general */ |
| 30 | enum flashrom_log_level { /* This has to match enum msglevel. */ |
| 31 | FLASHROM_MSG_ERROR = 0, |
| 32 | FLASHROM_MSG_INFO = 1, |
| 33 | FLASHROM_MSG_DEBUG = 2, |
| 34 | FLASHROM_MSG_DEBUG2 = 3, |
| 35 | FLASHROM_MSG_SPEW = 4, |
| 36 | }; |
| 37 | /** @ingroup flashrom-general */ |
| 38 | typedef int(flashrom_log_callback)(enum flashrom_log_level, const char *format, va_list); |
| 39 | void flashrom_set_log_callback(flashrom_log_callback *); |
| 40 | |
| 41 | struct flashrom_programmer; |
| 42 | int flashrom_programmer_init(struct flashrom_programmer **, const char *prog_name, const char *prog_params); |
| 43 | int flashrom_programmer_shutdown(struct flashrom_programmer *); |
| 44 | |
| 45 | struct flashrom_flashctx; |
| 46 | int flashrom_flash_probe(struct flashrom_flashctx **, const struct flashrom_programmer *, const char *chip_name); |
| 47 | size_t flashrom_flash_getsize(const struct flashrom_flashctx *); |
| 48 | int flashrom_flash_erase(struct flashrom_flashctx *); |
| 49 | void flashrom_flash_release(struct flashrom_flashctx *); |
| 50 | |
| 51 | /** @ingroup flashrom-flash */ |
| 52 | enum flashrom_flag { |
| 53 | FLASHROM_FLAG_FORCE, |
| 54 | FLASHROM_FLAG_FORCE_BOARDMISMATCH, |
| 55 | FLASHROM_FLAG_VERIFY_AFTER_WRITE, |
| 56 | FLASHROM_FLAG_VERIFY_WHOLE_CHIP, |
| 57 | }; |
| 58 | void flashrom_flag_set(struct flashrom_flashctx *, enum flashrom_flag, bool value); |
| 59 | bool flashrom_flag_get(const struct flashrom_flashctx *, enum flashrom_flag); |
| 60 | |
| 61 | int flashrom_image_read(struct flashrom_flashctx *, void *buffer, size_t buffer_len); |
Nico Huber | 1b172f2 | 2017-06-19 12:35:24 +0200 | [diff] [blame^] | 62 | int flashrom_image_write(struct flashrom_flashctx *, void *buffer, size_t buffer_len); |
Nico Huber | 454f613 | 2012-12-10 13:34:10 +0000 | [diff] [blame] | 63 | int flashrom_image_verify(struct flashrom_flashctx *, const void *buffer, size_t buffer_len); |
| 64 | |
| 65 | struct flashrom_layout; |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 66 | int flashrom_layout_read_from_ifd(struct flashrom_layout **, struct flashrom_flashctx *, const void *dump, size_t len); |
Nico Huber | 454f613 | 2012-12-10 13:34:10 +0000 | [diff] [blame] | 67 | int flashrom_layout_include_region(struct flashrom_layout *, const char *name); |
| 68 | void flashrom_layout_release(struct flashrom_layout *); |
| 69 | void flashrom_layout_set(struct flashrom_flashctx *, const struct flashrom_layout *); |
| 70 | |
| 71 | #endif /* !__LIBFLASHROM_H__ */ |