OpenOCD
nor/driver.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /***************************************************************************
4  * Copyright (C) 2005 by Dominic Rath <Dominic.Rath@gmx.de> *
5  * Copyright (C) 2007,2008 Øyvind Harboe <oyvind.harboe@zylin.com> *
6  * Copyright (C) 2008 by Spencer Oliver <spen@spen-soft.co.uk> *
7  * Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net> *
8  * Copyright (C) 2010 by Antonio Borneo <borneo.antonio@gmail.com> *
9  ***************************************************************************/
10 
11 #ifndef OPENOCD_FLASH_NOR_DRIVER_H
12 #define OPENOCD_FLASH_NOR_DRIVER_H
13 
14 struct flash_bank;
15 
16 #define __FLASH_BANK_COMMAND(name) \
17  COMMAND_HELPER(name, struct flash_bank *bank)
18 
39 struct flash_driver {
44  const char *name;
45 
49  const char *usage;
50 
57 
84  __FLASH_BANK_COMMAND((*flash_bank_command));
85 
96  int (*erase)(struct flash_bank *bank, unsigned int first,
97  unsigned int last);
98 
116  int (*protect)(struct flash_bank *bank, int set, unsigned int first,
117  unsigned int last);
118 
130  int (*write)(struct flash_bank *bank,
131  const uint8_t *buffer, uint32_t offset, uint32_t count);
132 
144  int (*read)(struct flash_bank *bank,
145  uint8_t *buffer, uint32_t offset, uint32_t count);
146 
158  int (*verify)(struct flash_bank *bank,
159  const uint8_t *buffer, uint32_t offset, uint32_t count);
160 
168  int (*probe)(struct flash_bank *bank);
169 
179  int (*erase_check)(struct flash_bank *bank);
180 
193  int (*protect_check)(struct flash_bank *bank);
194 
204  int (*info)(struct flash_bank *bank, struct command_invocation *cmd);
205 
219  int (*auto_probe)(struct flash_bank *bank);
220 
227  void (*free_driver_priv)(struct flash_bank *bank);
228 };
229 
230 #define FLASH_BANK_COMMAND_HANDLER(name) \
231  static __FLASH_BANK_COMMAND(name)
232 
238 const struct flash_driver *flash_driver_find_by_name(const char *name);
239 
240 #endif /* OPENOCD_FLASH_NOR_DRIVER_H */
const char * name
Definition: armv4_5.c:76
uint8_t bank
Definition: esirisc.c:135
const struct flash_driver * flash_driver_find_by_name(const char *name)
Find a NOR flash driver by its name.
Definition: drivers.c:161
When run_command is called, a new instance will be created on the stack, filled with the proper value...
Definition: command.h:76
Provides details of a flash bank, available either on-chip or through a major interface.
Definition: nor/core.h:75
Provides the implementation-independent structure that defines all of the callbacks required by OpenO...
Definition: nor/driver.h:39
const struct command_registration * commands
An array of driver-specific commands to register.
Definition: nor/driver.h:56
int(* protect)(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Bank/sector protection routine (target-specific).
Definition: nor/driver.h:116
int(* auto_probe)(struct flash_bank *bank)
A more gentle flavor of flash_driver_s::probe, performing setup with less noise.
Definition: nor/driver.h:219
const char * usage
Gives a human-readable description of arguments.
Definition: nor/driver.h:49
int(* erase_check)(struct flash_bank *bank)
Check the erasure status of a flash bank.
Definition: nor/driver.h:179
int(* info)(struct flash_bank *bank, struct command_invocation *cmd)
Display human-readable information about the flash bank.
Definition: nor/driver.h:204
void(* free_driver_priv)(struct flash_bank *bank)
Deallocates private driver structures.
Definition: nor/driver.h:227
int(* write)(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Program data into the flash.
Definition: nor/driver.h:130
int(* probe)(struct flash_bank *bank)
Probe to determine what kind of flash is present.
Definition: nor/driver.h:168
int(* erase)(struct flash_bank *bank, unsigned int first, unsigned int last)
Bank/sector erase routine (target-specific).
Definition: nor/driver.h:96
__FLASH_BANK_COMMAND((*flash_bank_command))
Finish the "flash bank" command for bank.
int(* read)(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Read data from the flash.
Definition: nor/driver.h:144
int(* verify)(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Verify data in flash.
Definition: nor/driver.h:158
int(* protect_check)(struct flash_bank *bank)
Determine if the specific bank is "protected" or not.
Definition: nor/driver.h:193
const char * name
Gives a human-readable name of this flash driver, This field is used to select and initialize the dri...
Definition: nor/driver.h:44
uint8_t cmd
Definition: vdebug.c:1
uint8_t offset[4]
Definition: vdebug.c:9
uint8_t count[4]
Definition: vdebug.c:22