libflashrom
Enumerations | Functions
Write Protect

Enumerations

enum  flashrom_wp_result {
  FLASHROM_WP_OK = 0, FLASHROM_WP_ERR_CHIP_UNSUPPORTED = 1, FLASHROM_WP_ERR_OTHER = 2, FLASHROM_WP_ERR_READ_FAILED = 3,
  FLASHROM_WP_ERR_WRITE_FAILED = 4, FLASHROM_WP_ERR_VERIFY_FAILED = 5, FLASHROM_WP_ERR_RANGE_UNSUPPORTED = 6, FLASHROM_WP_ERR_MODE_UNSUPPORTED = 7,
  FLASHROM_WP_ERR_RANGE_LIST_UNAVAILABLE = 8, FLASHROM_WP_ERR_UNSUPPORTED_STATE = 9
}
 
enum  flashrom_wp_mode { FLASHROM_WP_MODE_DISABLED, FLASHROM_WP_MODE_HARDWARE, FLASHROM_WP_MODE_POWER_CYCLE, FLASHROM_WP_MODE_PERMANENT }
 

Functions

enum flashrom_wp_result flashrom_wp_cfg_new (struct flashrom_wp_cfg **cfg)
 Create a new empty WP configuration. More...
 
void flashrom_wp_cfg_release (struct flashrom_wp_cfg *cfg)
 Free a WP configuration. More...
 
void flashrom_wp_set_mode (struct flashrom_wp_cfg *cfg, enum flashrom_wp_mode mode)
 Set the protection mode for a WP configuration. More...
 
enum flashrom_wp_mode flashrom_wp_get_mode (const struct flashrom_wp_cfg *cfg)
 Get the protection mode from a WP configuration. More...
 
void flashrom_wp_set_range (struct flashrom_wp_cfg *cfg, size_t start, size_t len)
 Set the protection range for a WP configuration. More...
 
void flashrom_wp_get_range (size_t *start, size_t *len, const struct flashrom_wp_cfg *cfg)
 Get the protection range from a WP configuration. More...
 
enum flashrom_wp_result flashrom_wp_read_cfg (struct flashrom_wp_cfg *cfg, struct flashrom_flashctx *flash)
 Read the current WP configuration from a flash chip. More...
 
enum flashrom_wp_result flashrom_wp_write_cfg (struct flashrom_flashctx *flash, const struct flashrom_wp_cfg *cfg)
 Write a WP configuration to a flash chip. More...
 
enum flashrom_wp_result flashrom_wp_get_available_ranges (struct flashrom_wp_ranges **ranges, struct flashrom_flashctx *flash)
 Get a list of protection ranges supported by the flash chip. More...
 
size_t flashrom_wp_ranges_get_count (const struct flashrom_wp_ranges *ranges)
 Get a number of protection ranges in a range list. More...
 
enum flashrom_wp_result flashrom_wp_ranges_get_range (size_t *start, size_t *len, const struct flashrom_wp_ranges *ranges, unsigned int index)
 Get a protection range from a range list. More...
 
void flashrom_wp_ranges_release (struct flashrom_wp_ranges *ranges)
 Free a WP range list. More...
 

Detailed Description

Function Documentation

enum flashrom_wp_result flashrom_wp_cfg_new ( struct flashrom_wp_cfg **  cfg)

Create a new empty WP configuration.

Parameters
[out]cfgPoints to a pointer of type struct flashrom_wp_cfg that will be set if creation succeeds. *cfg has to be freed by the caller with flashrom_wp_cfg_release.
Returns
0 on success >0 on failure
void flashrom_wp_cfg_release ( struct flashrom_wp_cfg *  cfg)

Free a WP configuration.

Parameters
[in]cfgPointer to the flashrom_wp_cfg to free.
enum flashrom_wp_result flashrom_wp_get_available_ranges ( struct flashrom_wp_ranges **  ranges,
struct flashrom_flashctx *  flash 
)

Get a list of protection ranges supported by the flash chip.

Parameters
[out]rangesPoints to a pointer of type struct flashrom_wp_ranges that will be set if available ranges are found. Finding available ranges may not always be possible, even if the chip's protection range can be read or modified. *ranges must be freed using flashrom_wp_ranges_release.
[in]flashThe flash context used to access the chip.
Returns
0 on success >0 on failure
enum flashrom_wp_mode flashrom_wp_get_mode ( const struct flashrom_wp_cfg *  cfg)

Get the protection mode from a WP configuration.

Parameters
[in]cfgThe WP configuration to get the protection mode from.
Returns
The configuration's protection mode.
void flashrom_wp_get_range ( size_t *  start,
size_t *  len,
const struct flashrom_wp_cfg *  cfg 
)

Get the protection range from a WP configuration.

Parameters
[out]startPoints to a size_t to write the range start to.
[out]lenPoints to a size_t to write the range length to.
[in]cfgThe WP configuration to get the range from.
size_t flashrom_wp_ranges_get_count ( const struct flashrom_wp_ranges *  ranges)

Get a number of protection ranges in a range list.

Parameters
[in]rangesThe range list to get the count from.
Returns
Number of ranges in the list.
enum flashrom_wp_result flashrom_wp_ranges_get_range ( size_t *  start,
size_t *  len,
const struct flashrom_wp_ranges *  ranges,
unsigned int  index 
)

Get a protection range from a range list.

Parameters
[out]startPoints to a size_t to write the range's start to.
[out]lenPoints to a size_t to write the range's length to.
[in]rangesThe range list to get the range from.
[in]indexIndex of the range to get.
Returns
0 on success >0 on failure
void flashrom_wp_ranges_release ( struct flashrom_wp_ranges *  ranges)

Free a WP range list.

Parameters
[out]rangesPointer to the flashrom_wp_ranges to free.
enum flashrom_wp_result flashrom_wp_read_cfg ( struct flashrom_wp_cfg *  cfg,
struct flashrom_flashctx *  flash 
)

Read the current WP configuration from a flash chip.

Parameters
[out]cfgPointer to a struct flashrom_wp_cfg to store the chip's configuration in.
[in]flashThe flash context used to access the chip.
Returns
0 on success >0 on failure
void flashrom_wp_set_mode ( struct flashrom_wp_cfg *  cfg,
enum flashrom_wp_mode  mode 
)

Set the protection mode for a WP configuration.

Parameters
[in]modeThe protection mode to set.
[out]cfgPointer to the flashrom_wp_cfg structure to modify.
void flashrom_wp_set_range ( struct flashrom_wp_cfg *  cfg,
size_t  start,
size_t  len 
)

Set the protection range for a WP configuration.

Parameters
[out]cfgPointer to the flashrom_wp_cfg structure to modify.
[in]startThe range's start address.
[in]lenThe range's length.
enum flashrom_wp_result flashrom_wp_write_cfg ( struct flashrom_flashctx *  flash,
const struct flashrom_wp_cfg *  cfg 
)

Write a WP configuration to a flash chip.

Parameters
[in]flashThe flash context used to access the chip.
[in]cfgThe WP configuration to write to the chip.
Returns
0 on success >0 on failure