OpenOCD
flash/nor/driver.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Dominic Rath <Dominic.Rath@gmx.de> *
3  * Copyright (C) 2007,2008 Øyvind Harboe <oyvind.harboe@zylin.com> *
4  * Copyright (C) 2008 by Spencer Oliver <spen@spen-soft.co.uk> *
5  * Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net> *
6  * Copyright (C) 2010 by Antonio Borneo <borneo.antonio@gmail.com> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
20  ***************************************************************************/
21 
22 #ifndef OPENOCD_FLASH_NOR_DRIVER_H
23 #define OPENOCD_FLASH_NOR_DRIVER_H
24 
25 struct flash_bank;
26 
27 #define __FLASH_BANK_COMMAND(name) \
28  COMMAND_HELPER(name, struct flash_bank *bank)
29 
50 struct flash_driver {
55  const char *name;
56 
60  const char *usage;
61 
68 
95  __FLASH_BANK_COMMAND((*flash_bank_command));
96 
107  int (*erase)(struct flash_bank *bank, unsigned int first,
108  unsigned int last);
109 
127  int (*protect)(struct flash_bank *bank, int set, unsigned int first,
128  unsigned int last);
129 
141  int (*write)(struct flash_bank *bank,
142  const uint8_t *buffer, uint32_t offset, uint32_t count);
143 
155  int (*read)(struct flash_bank *bank,
156  uint8_t *buffer, uint32_t offset, uint32_t count);
157 
169  int (*verify)(struct flash_bank *bank,
170  const uint8_t *buffer, uint32_t offset, uint32_t count);
171 
179  int (*probe)(struct flash_bank *bank);
180 
190  int (*erase_check)(struct flash_bank *bank);
191 
204  int (*protect_check)(struct flash_bank *bank);
205 
216  int (*info)(struct flash_bank *bank, char *buf, int buf_size);
217 
231  int (*auto_probe)(struct flash_bank *bank);
232 
239  void (*free_driver_priv)(struct flash_bank *bank);
240 };
241 
242 #define FLASH_BANK_COMMAND_HANDLER(name) \
243  static __FLASH_BANK_COMMAND(name)
244 
250 const struct flash_driver *flash_driver_find_by_name(const char *name);
251 
252 #endif /* OPENOCD_FLASH_NOR_DRIVER_H */
void(* free_driver_priv)(struct flash_bank *bank)
Deallocates private driver structures.
int(* erase)(struct flash_bank *bank, unsigned int first, unsigned int last)
Bank/sector erase routine (target-specific).
static int count
Definition: log.c:62
Provides the implementation-independent structure that defines all of the callbacks required by OpenO...
int(* probe)(struct flash_bank *bank)
Probe to determine what kind of flash is present.
int(* info)(struct flash_bank *bank, char *buf, int buf_size)
Display human-readable information about the flash bank into the given buffer.
int(* verify)(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Verify data in flash.
const struct flash_driver * flash_driver_find_by_name(const char *name)
Find a NOR flash driver by its name.
Definition: drivers.c:166
const struct command_registration * commands
An array of driver-specific commands to register.
uint32_t offset
Definition: arm_cti.c:179
int(* erase_check)(struct flash_bank *bank)
Check the erasure status of a flash bank.
const char * name
Gives a human-readable name of this flash driver, This field is used to select and initialize the dri...
int(* auto_probe)(struct flash_bank *bank)
A more gentle flavor of flash_driver_s::probe, performing setup with less noise.
const char * usage
Gives a human-readable description of arguments.
uint8_t bank
Definition: esirisc.c:146
int(* protect_check)(struct flash_bank *bank)
Determine if the specific bank is "protected" or not.
int(* write)(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Program data into the flash.
int(* read)(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Read data from the flash.
int(* protect)(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Bank/sector protection routine (target-specific).
Provides details of a flash bank, available either on-chip or through a major interface.
Definition: nor/core.h:88
__FLASH_BANK_COMMAND((*flash_bank_command))
Finish the "flash bank" command for bank.