btnut/btnode/include/cdist/xbankdata.h File Reference


Detailed Description

This file contains functionality to store and maintain programs in banked memory.

#include <sys/types.h>
#include <hardware/ram_banks.h>
#include <support/bootloader.h>
#include <mhop/rpc.h>

Data Structures

struct  _xbank_prog_info_s
 Program information struct. More...
struct  _xbank_stack_s

Defines

#define XBANK_CMD_GET_PROGINFO   1
#define XBANK_CMD_GET_STATUS   2
#define XBANK_CMD_SET_PROGNAME   4
#define XBANK_CMD_SET_PROGTYPE   3
#define XBANK_CMD_SET_PROGVER   5
#define XBANK_ENABLE_FLASH_CB   u_char (*enable_flash_cb) (xbank_prog_info_t * info)
 Prototyp of the enable flash callback.
#define XBANK_INVALIDATE_PROG   6
#define XBANK_MAX_PROGNAME_LEN   60
#define XBANK_PROG_DATA_START   (XBANK_PROG_HEADER_START + XBANK_PROG_HEADER_LEN + CRC_LENGTH)
#define XBANK_PROG_END   ((129L * 1024)-1)
#define XBANK_PROG_HEADER_LEN   (MEM_LEN_HEADER)
#define XBANK_PROG_HEADER_START   XBANK_PROG_START
#define XBANK_PROG_INFO_LEN   sizeof(xbank_prog_info_t)
 Program info length.
#define XBANK_PROG_START   XBANK_PRSTART
#define XBANK_PROG_TYPE_DSN   REPROG_BTNODE_PROGRAM_DATA
#define XBANK_PROG_TYPE_TARGET   REPROG_TARGET_PROGRAM_DATA
#define XBANK_RECORD_HEADER_LEN   6

Typedefs

typedef _xbank_prog_info_s xbank_prog_info_t
 Program information struct.
typedef _xbank_stack_s xbank_stack_t

Functions

u_char xbank_check_program (void)
 Checks wether there is a valid program in memory.
void xbank_free_program_lock (void)
 Frees the progam access lock.
void xbank_get_prog_info (xbank_prog_info_t *prog_info)
u_char xbank_get_program_lock (void)
 Checks and sets progam access lock.
void xbank_init (void)
void xbank_init_prog_read (void)
 Prepares xbank to read a new program.
void xbank_init_prog_write (void)
 Prepares xbank to store a new program.
void xbank_invalidate_program (void)
 Deletes the current program.
void xbank_read_prog_data (u_char *buffer, u_short len)
 Read next len bytes from the current record.
u_char xbank_read_prog_record (u_long *addr, u_long *len)
 Read next program record.
void xbank_register_enable_flash_callback (XBANK_ENABLE_FLASH_CB)
 Registers the enable flash callback.
void xbank_set_prog_boot_addr (u_long boot_addr)
void xbank_set_prog_info (xbank_prog_info_t *prog_info)
void xbank_set_prog_name (char *name)
void xbank_update_prog_header (void)
u_char xbank_validate_program (void)
 Validates program.
u_char xbank_write_prog_crc (u_char *buffer)
 Write data crc to complete program in memory.
u_char xbank_write_prog_data (u_char *buffer, u_short len)
 Write data into current program record.
u_char xbank_write_prog_record (u_long addr)
 Starts a new program record.

Variables

xbank_stack_t * _xbank


Define Documentation

#define XBANK_ENABLE_FLASH_CB   u_char (*enable_flash_cb) (xbank_prog_info_t * info)

Prototyp of the enable flash callback.

The enable flash callback is called after the whole image was stored. If the callback returns 0, the flash flag will not be enabled, else it will be enabled. If the flash flag is enabled, the image will be flashed from the bootloader after resetting.


Function Documentation

u_char xbank_check_program ( void   ) 

Checks wether there is a valid program in memory.

Returns:
0 on success, 1 otherwise.

u_char xbank_get_program_lock ( void   ) 

Checks and sets progam access lock.

Returns:
0 on success, 1 otherwise.

void xbank_read_prog_data ( u_char buffer,
u_short  len 
)

Read next len bytes from the current record.

Parameters:
buffer Buffer for the data.
len Number of bytes to copy.

u_char xbank_read_prog_record ( u_long addr,
u_long len 
)

Read next program record.

Parameters:
addr Record data. Start address of the data in the record.
len Record data. Number of bytes the record contains.
Returns:
0 on success, 1 if all records have been read

void xbank_register_enable_flash_callback ( XBANK_ENABLE_FLASH_CB   ) 

Registers the enable flash callback.

If this function is not used, the flash flag will be always enabled after the whole image was stored.

See also:
XBANK_ENABLE_FLASH_CB

u_char xbank_validate_program ( void   ) 

Validates program.

Checks memory for a valid program and caches the result. The program check involves rather expensive crc computations. However, the result is cached and you have to call it only once when you store a new program. Use xbank_check_program() afterwards for fast query.

Returns:
0 if there was a valid program, 1 otherwise.

u_char xbank_write_prog_crc ( u_char buffer  ) 

Write data crc to complete program in memory.

Parameters:
buffer Buffer that holds the crc or NULL if a crc should be generated based on current program records.
Returns:
0 on success, 1 if program size exceeds maximum

u_char xbank_write_prog_data ( u_char buffer,
u_short  len 
)

Write data into current program record.

Parameters:
buffer Buffer from which data is read.
len Length of buffer
Returns:
0 on success, 1 if program size exceeds maximum

u_char xbank_write_prog_record ( u_long  addr  ) 

Starts a new program record.

Parameters:
addr The start address of the data the record will hold.
Returns:
0 on success, 1 if program size exceeds maximum


Generated on Wed Apr 29 11:12:29 2009 for BTnut System Software by doxygen 1.5.1