blob: bded4c854555ace73f6c6e69ccb81dee69d5b236 [file] [log] [blame]
Edward O'Callaghand3b6acf2020-09-21 17:10:21 +10001/*
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
21enum wp_mode {
22 WP_MODE_UNKNOWN = -1,
23 WP_MODE_HARDWARE, /* hardware WP pin determines status */
24 WP_MODE_POWER_CYCLE, /* WP active until power off/on cycle */
25 WP_MODE_PERMANENT, /* status register permanently locked,
26 WP permanently enabled */
27};
28
29struct wp {
30 int (*list_ranges)(const struct flashctx *flash);
31 int (*set_range)(const struct flashctx *flash,
32 unsigned int start, unsigned int len);
33 int (*enable)(const struct flashctx *flash, enum wp_mode mode);
34 int (*disable)(const struct flashctx *flash);
35 int (*wp_status)(const struct flashctx *flash);
36};
37
38extern struct wp wp_generic;
39
40enum wp_mode get_wp_mode(const char *mode_str);
41
42/*
43 * Generic write-protect stuff
44 */
45
46struct modifier_bits {
47 int sec; /* if 1, bp bits describe sectors */
48 int tb; /* value of top/bottom select bit */
49};
50
51#endif /* !__WRITEPROTECT_H__ */