| Nikolai Artemiev | 3e3c5bf | 2021-10-20 23:34:15 +1100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2010 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | #ifndef __WRITEPROTECT_H__ |
| 19 | #define __WRITEPROTECT_H__ 1 |
| 20 | |
| Nikolai Artemiev | b3b2d41 | 2021-10-21 01:12:39 +1100 | [diff] [blame^] | 21 | #include <stdint.h> |
| 22 | #include <stdbool.h> |
| 23 | #include <stddef.h> |
| 24 | |
| Nikolai Artemiev | 3e3c5bf | 2021-10-20 23:34:15 +1100 | [diff] [blame] | 25 | #define MAX_BP_BITS 4 |
| 26 | |
| Nikolai Artemiev | b3b2d41 | 2021-10-21 01:12:39 +1100 | [diff] [blame^] | 27 | /* |
| 28 | * Description of a chip's write protection configuration. |
| 29 | * |
| 30 | * It allows most WP code to store and manipulate a chip's configuration |
| 31 | * without knowing the exact layout of bits in the chip's status registers. |
| 32 | */ |
| 33 | struct wp_bits { |
| 34 | /* Status register protection bit (SRP) */ |
| 35 | bool srp_bit_present; |
| 36 | uint8_t srp; |
| 37 | |
| 38 | /* Status register lock bit (SRL) */ |
| 39 | bool srl_bit_present; |
| 40 | uint8_t srl; |
| 41 | |
| 42 | /* Complement bit (CMP) */ |
| 43 | bool cmp_bit_present; |
| 44 | uint8_t cmp; |
| 45 | |
| 46 | /* Sector/block protection bit (SEC) */ |
| 47 | bool sec_bit_present; |
| 48 | uint8_t sec; |
| 49 | |
| 50 | /* Top/bottom protection bit (TB) */ |
| 51 | bool tb_bit_present; |
| 52 | uint8_t tb; |
| 53 | |
| 54 | /* Block protection bits (BP) */ |
| 55 | size_t bp_bit_count; |
| 56 | uint8_t bp[MAX_BP_BITS]; |
| 57 | }; |
| 58 | |
| Nikolai Artemiev | 3e3c5bf | 2021-10-20 23:34:15 +1100 | [diff] [blame] | 59 | #endif /* !__WRITEPROTECT_H__ */ |