Nico Huber | 3a9939b | 2016-04-27 15:56:14 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2005-2008 coresystems GmbH |
| 5 | * (Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH) |
| 6 | * Copyright (C) 2011-2013 Stefan Tauner |
| 7 | * Copyright (C) 2016 secunet Security Networks AG |
| 8 | * (Written by Nico Huber <nico.huber@secunet.com> for secunet) |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
Nico Huber | 3a9939b | 2016-04-27 15:56:14 +0200 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #ifndef __LAYOUT_H__ |
| 22 | #define __LAYOUT_H__ 1 |
| 23 | |
| 24 | #include <stddef.h> |
| 25 | #include <stdint.h> |
Nico Huber | ae24b8b | 2019-01-20 11:33:07 +0100 | [diff] [blame] | 26 | #include <stdbool.h> |
Nico Huber | 3a9939b | 2016-04-27 15:56:14 +0200 | [diff] [blame] | 27 | |
| 28 | /* Types and macros regarding the maximum flash space size supported by generic code. */ |
| 29 | typedef uint32_t chipoff_t; /* Able to store any addressable offset within a supported flash memory. */ |
| 30 | typedef uint32_t chipsize_t; /* Able to store the number of bytes of any supported flash memory. */ |
| 31 | #define FL_MAX_CHIPOFF_BITS (24) |
| 32 | #define FL_MAX_CHIPOFF ((chipoff_t)(1ULL<<FL_MAX_CHIPOFF_BITS)-1) |
| 33 | #define PRIxCHIPOFF "06"PRIx32 |
| 34 | #define PRIuCHIPSIZE PRIu32 |
| 35 | |
Patrick Rudolph | 2d7ab69 | 2019-07-03 17:58:24 +0200 | [diff] [blame] | 36 | #define MAX_ROMLAYOUT 128 |
Nico Huber | 3a9939b | 2016-04-27 15:56:14 +0200 | [diff] [blame] | 37 | |
| 38 | struct romentry { |
Nico Huber | 4925861 | 2019-06-15 21:41:21 +0200 | [diff] [blame] | 39 | struct romentry *next; |
| 40 | |
Nico Huber | 3a9939b | 2016-04-27 15:56:14 +0200 | [diff] [blame] | 41 | chipoff_t start; |
| 42 | chipoff_t end; |
| 43 | bool included; |
Nico Huber | 70461a9 | 2019-06-15 14:56:19 +0200 | [diff] [blame] | 44 | char *name; |
Nico Huber | 3a9939b | 2016-04-27 15:56:14 +0200 | [diff] [blame] | 45 | }; |
| 46 | |
Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 47 | struct flashprog_layout; |
Nico Huber | 3a9939b | 2016-04-27 15:56:14 +0200 | [diff] [blame] | 48 | |
Nico Huber | 6e98544 | 2019-06-16 20:22:41 +0200 | [diff] [blame] | 49 | struct layout_include_args; |
Arthur Heymans | b04fef9 | 2019-02-05 17:35:05 +0100 | [diff] [blame] | 50 | |
Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 51 | struct flashprog_flashctx; |
| 52 | const struct flashprog_layout *get_default_layout(const struct flashprog_flashctx *); |
| 53 | const struct flashprog_layout *get_layout(const struct flashprog_flashctx *); |
Nico Huber | 305f417 | 2013-06-14 11:55:26 +0200 | [diff] [blame] | 54 | |
Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 55 | int layout_from_file(struct flashprog_layout **, const char *name); |
Nico Huber | d9b5771 | 2021-05-14 01:07:28 +0200 | [diff] [blame] | 56 | |
Nico Huber | ba9d9fe | 2021-05-14 01:13:33 +0200 | [diff] [blame] | 57 | int register_include_arg(struct layout_include_args **, char *arg); |
Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 58 | int process_include_args(struct flashprog_layout *, const struct layout_include_args *); |
Nico Huber | ba9d9fe | 2021-05-14 01:13:33 +0200 | [diff] [blame] | 59 | void cleanup_include_args(struct layout_include_args **); |
Nico Huber | 345f65a | 2021-05-14 01:11:08 +0200 | [diff] [blame] | 60 | |
Nico Huber | c3b02dc | 2023-08-12 01:13:45 +0200 | [diff] [blame] | 61 | const struct romentry *layout_next_included_region(const struct flashprog_layout *, chipoff_t); |
| 62 | const struct romentry *layout_next_included(const struct flashprog_layout *, const struct romentry *); |
| 63 | const struct romentry *layout_next(const struct flashprog_layout *, const struct romentry *); |
| 64 | int layout_sanity_checks(const struct flashprog_flashctx *, bool write_it); |
Nico Huber | 3a9939b | 2016-04-27 15:56:14 +0200 | [diff] [blame] | 65 | |
Edward O'Callaghan | 405e72a | 2020-12-19 11:21:49 +1100 | [diff] [blame] | 66 | #endif /* !__LAYOUT_H__ */ |