libflashrom
Functions
Layout handling

Functions

int flashrom_layout_new (struct flashrom_layout **layout)
 Create a new, empty layout. More...
 
int flashrom_layout_read_from_ifd (struct flashrom_layout **layout, struct flashrom_flashctx *flashctx, const void *dump, size_t len)
 Read a layout from the Intel ICH descriptor in the flash. More...
 
int flashrom_layout_read_fmap_from_rom (struct flashrom_layout **layout, struct flashrom_flashctx *flashctx, size_t offset, size_t length)
 Read a layout by searching the flash chip for fmap. More...
 
int flashrom_layout_read_fmap_from_buffer (struct flashrom_layout **layout, struct flashrom_flashctx *flashctx, const uint8_t *buffer, size_t len)
 Read a layout by searching a buffer for fmap. More...
 
int flashrom_layout_add_region (struct flashrom_layout *layout, size_t start, size_t end, const char *name)
 Add a region to an existing layout. More...
 
int flashrom_layout_include_region (struct flashrom_layout *layout, const char *name)
 Mark given region as included. More...
 
int flashrom_layout_get_region_range (struct flashrom_layout *layout, const char *name, unsigned int *start, unsigned int *len)
 Get given region's offset and length. More...
 
void flashrom_layout_release (struct flashrom_layout *layout)
 Free a layout. More...
 
void flashrom_layout_set (struct flashrom_flashctx *flashctx, const struct flashrom_layout *layout)
 Set the active layout for a flash context. More...
 

Detailed Description

Function Documentation

int flashrom_layout_add_region ( struct flashrom_layout *  layout,
size_t  start,
size_t  end,
const char *  name 
)

Add a region to an existing layout.

Parameters
layoutThe existing layout.
startStart address of the region.
endEnd address (inclusive) of the region.
nameName of the region.
Returns
0 on success, 1 if out of memory.
int flashrom_layout_get_region_range ( struct flashrom_layout *  layout,
const char *  name,
unsigned int *  start,
unsigned int *  len 
)

Get given region's offset and length.

Parameters
[in]layoutThe existing layout.
[in]nameThe name of the region.
[out]startThe start address to be written.
[out]lenThe length of the region to be written.
Returns
0 on success, 1 if the given name can't be found.
int flashrom_layout_include_region ( struct flashrom_layout *  layout,
const char *  name 
)

Mark given region as included.

Parameters
layoutThe layout to alter.
nameThe name of the region to include.
Returns
0 on success, 1 if the given name can't be found.
int flashrom_layout_new ( struct flashrom_layout **  layout)

Create a new, empty layout.

Parameters
layoutPointer to returned layout reference.
Returns
0 on success, 1 if out of memory.
int flashrom_layout_read_fmap_from_buffer ( struct flashrom_layout **  layout,
struct flashrom_flashctx *  flashctx,
const uint8_t *  buffer,
size_t  len 
)

Read a layout by searching a buffer for fmap.

Parameters
[out]layoutPoints to a struct flashrom_layout pointer that gets set if the fmap is read and parsed successfully.
[in]flashctxFlash context
[in]bufferBuffer to search in
[in]lenSize of buffer to search
Returns
0 on success, 3 if fmap parsing isn't implemented for the host, 2 if the fmap couldn't be read, 1 on any other error.
int flashrom_layout_read_fmap_from_rom ( struct flashrom_layout **  layout,
struct flashrom_flashctx *  flashctx,
size_t  offset,
size_t  length 
)

Read a layout by searching the flash chip for fmap.

Parameters
[out]layoutPoints to a struct flashrom_layout pointer that gets set if the fmap is read and parsed successfully.
[in]flashctxFlash context
[in]offsetOffset to begin searching for fmap.
[in]lengthLength of address space to search.
Returns
0 on success, 3 if fmap parsing isn't implemented for the host, 2 if the fmap couldn't be read, 1 on any other error.
int flashrom_layout_read_from_ifd ( struct flashrom_layout **  layout,
struct flashrom_flashctx *  flashctx,
const void *  dump,
size_t  len 
)

Read a layout from the Intel ICH descriptor in the flash.

Optionally verify that the layout matches the one in the given descriptor dump.

Parameters
[out]layoutPoints to a struct flashrom_layout pointer that gets set if the descriptor is read and parsed successfully.
[in]flashctxFlash context to read the descriptor from flash.
[in]dumpThe descriptor dump to compare to or NULL.
[in]lenThe length of the descriptor dump.
Returns
0 on success, 6 if descriptor parsing isn't implemented for the host, 5 if the descriptors don't match, 4 if the descriptor dump couldn't be parsed, 3 if the descriptor on flash couldn't be parsed, 2 if the descriptor on flash couldn't be read, 1 on any other error.
void flashrom_layout_release ( struct flashrom_layout *  layout)

Free a layout.

Parameters
layoutLayout to free.
void flashrom_layout_set ( struct flashrom_flashctx *  flashctx,
const struct flashrom_layout *  layout 
)

Set the active layout for a flash context.

Note: The caller must not release the layout as long as it is used through the given flash context.

Parameters
flashctxFlash context whose layout will be set.
layoutLayout to bet set.