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. |
Nico Huber | 454f613 | 2012-12-10 13:34:10 +0000 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #ifndef __LIBFLASHROM_H__ |
| 19 | #define __LIBFLASHROM_H__ 1 |
| 20 | |
Nico Huber | e7cbfae | 2018-12-10 15:21:40 +0100 | [diff] [blame^] | 21 | #include <sys/types.h> |
| 22 | #include <stddef.h> |
Nico Huber | 454f613 | 2012-12-10 13:34:10 +0000 | [diff] [blame] | 23 | #include <stdarg.h> |
| 24 | |
| 25 | int flashrom_init(int perform_selfcheck); |
| 26 | int flashrom_shutdown(void); |
| 27 | /** @ingroup flashrom-general */ |
Nico Huber | d152fb9 | 2017-06-19 12:57:10 +0200 | [diff] [blame] | 28 | enum flashrom_log_level { |
Nico Huber | 454f613 | 2012-12-10 13:34:10 +0000 | [diff] [blame] | 29 | FLASHROM_MSG_ERROR = 0, |
Nico Huber | e8e7a80 | 2017-06-19 12:38:39 +0200 | [diff] [blame] | 30 | FLASHROM_MSG_WARN = 1, |
| 31 | FLASHROM_MSG_INFO = 2, |
| 32 | FLASHROM_MSG_DEBUG = 3, |
| 33 | FLASHROM_MSG_DEBUG2 = 4, |
| 34 | FLASHROM_MSG_SPEW = 5, |
Nico Huber | 454f613 | 2012-12-10 13:34:10 +0000 | [diff] [blame] | 35 | }; |
| 36 | /** @ingroup flashrom-general */ |
| 37 | typedef int(flashrom_log_callback)(enum flashrom_log_level, const char *format, va_list); |
| 38 | void flashrom_set_log_callback(flashrom_log_callback *); |
| 39 | |
| 40 | struct flashrom_programmer; |
| 41 | int flashrom_programmer_init(struct flashrom_programmer **, const char *prog_name, const char *prog_params); |
| 42 | int flashrom_programmer_shutdown(struct flashrom_programmer *); |
| 43 | |
| 44 | struct flashrom_flashctx; |
| 45 | int flashrom_flash_probe(struct flashrom_flashctx **, const struct flashrom_programmer *, const char *chip_name); |
| 46 | size_t flashrom_flash_getsize(const struct flashrom_flashctx *); |
| 47 | int flashrom_flash_erase(struct flashrom_flashctx *); |
| 48 | void flashrom_flash_release(struct flashrom_flashctx *); |
| 49 | |
| 50 | /** @ingroup flashrom-flash */ |
| 51 | enum flashrom_flag { |
| 52 | FLASHROM_FLAG_FORCE, |
| 53 | FLASHROM_FLAG_FORCE_BOARDMISMATCH, |
| 54 | FLASHROM_FLAG_VERIFY_AFTER_WRITE, |
| 55 | FLASHROM_FLAG_VERIFY_WHOLE_CHIP, |
| 56 | }; |
| 57 | void flashrom_flag_set(struct flashrom_flashctx *, enum flashrom_flag, bool value); |
| 58 | bool flashrom_flag_get(const struct flashrom_flashctx *, enum flashrom_flag); |
| 59 | |
| 60 | int flashrom_image_read(struct flashrom_flashctx *, void *buffer, size_t buffer_len); |
Paul Kocialkowski | f701f34 | 2018-01-15 01:10:36 +0300 | [diff] [blame] | 61 | int flashrom_image_write(struct flashrom_flashctx *, void *buffer, size_t buffer_len, const void *refbuffer); |
Nico Huber | 454f613 | 2012-12-10 13:34:10 +0000 | [diff] [blame] | 62 | int flashrom_image_verify(struct flashrom_flashctx *, const void *buffer, size_t buffer_len); |
| 63 | |
| 64 | struct flashrom_layout; |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 65 | int flashrom_layout_read_from_ifd(struct flashrom_layout **, struct flashrom_flashctx *, const void *dump, size_t len); |
Arthur Heymans | c82900b | 2018-01-10 12:48:16 +0100 | [diff] [blame] | 66 | int flashrom_layout_read_fmap_from_rom(struct flashrom_layout **, |
| 67 | struct flashrom_flashctx *, off_t offset, size_t length); |
| 68 | int flashrom_layout_read_fmap_from_buffer(struct flashrom_layout **layout, |
| 69 | struct flashrom_flashctx *, const uint8_t *buf, size_t len); |
Nico Huber | 454f613 | 2012-12-10 13:34:10 +0000 | [diff] [blame] | 70 | int flashrom_layout_include_region(struct flashrom_layout *, const char *name); |
| 71 | void flashrom_layout_release(struct flashrom_layout *); |
| 72 | void flashrom_layout_set(struct flashrom_flashctx *, const struct flashrom_layout *); |
| 73 | |
Arthur Heymans | c82900b | 2018-01-10 12:48:16 +0100 | [diff] [blame] | 74 | #endif /* !__LIBFLASHROM_H__ */ |