
#ifndef _BL_IMAGE_DB_H_
#define _BL_IMAGE_DB_H_

#include <aimage.h>

#define IMAGEDB_SOURCE_TYPE_UNUSED   0
#define IMAGEDB_SOURCE_TYPE_MEM      1
#define IMAGEDB_SOURCE_TYPE_NAND     2

#define DEVNAME_LEN_MAX             32

typedef struct
{
    int source_type;                    /* */
    aimage_v1_header_t cached;          /* */
    aimage_v1_header_t *mem_image;      /* pointer to validated image (if memory mapped... NULL if not) */
    char devname[DEVNAME_LEN_MAX];      /* e.g. "/dev/mtdblock2" */
    char *mtdparts;                     /* */
}
imagedb_entry_t;

extern void image_db_init (void);
extern int image_db_entry_add (aimage_v1_header_t *image, int source_type, char *devname, char *mtdparts);
extern imagedb_entry_t *image_db_find (unsigned int type);
extern imagedb_entry_t *image_db_find_bootable (void);
extern imagedb_entry_t *image_db_find_unused (void);
extern unsigned int image_db_get_release_id (void);
extern void image_db_show_selected (void);
extern int image_db_scan_flash_nor (void);
extern int image_db_scan_flash_nand (void);

#endif

