2012-07-14 10:33:15 +02:00
|
|
|
|
2012-08-07 14:00:50 +02:00
|
|
|
|
|
|
|
|
#ifndef IMAGE_H
|
|
|
|
|
#define IMAGE_H
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2012-08-07 14:53:52 +02:00
|
|
|
#include <sys/types.h>
|
2012-08-07 14:00:50 +02:00
|
|
|
|
2012-08-07 17:10:49 +02:00
|
|
|
#include "device.h"
|
|
|
|
|
|
2012-07-14 10:33:15 +02:00
|
|
|
enum image_type {
|
|
|
|
|
IMAGE_UNKNOWN = 0,
|
|
|
|
|
IMAGE_XLOADER,
|
|
|
|
|
IMAGE_2ND,
|
|
|
|
|
IMAGE_SECONDARY,
|
|
|
|
|
IMAGE_KERNEL,
|
|
|
|
|
IMAGE_INITFS,
|
|
|
|
|
IMAGE_ROOTFS,
|
2012-08-07 14:00:50 +02:00
|
|
|
IMAGE_OMAP_NAND,
|
2012-07-14 10:33:15 +02:00
|
|
|
IMAGE_MMC,
|
|
|
|
|
IMAGE_CMT_2ND,
|
|
|
|
|
IMAGE_CMT_ALGO,
|
|
|
|
|
IMAGE_CMT_MCUSW,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct image {
|
|
|
|
|
enum image_type type;
|
|
|
|
|
enum device device;
|
|
|
|
|
char * hwrevs;
|
|
|
|
|
char * version;
|
|
|
|
|
char * layout;
|
|
|
|
|
uint16_t hash;
|
|
|
|
|
uint32_t size;
|
|
|
|
|
|
|
|
|
|
int fd;
|
|
|
|
|
int shared_fd;
|
|
|
|
|
off_t offset;
|
|
|
|
|
off_t cur;
|
2012-08-07 14:53:52 +02:00
|
|
|
};
|
2012-07-14 10:33:15 +02:00
|
|
|
|
|
|
|
|
struct image_list {
|
|
|
|
|
struct image * image;
|
|
|
|
|
struct image_list * prev;
|
|
|
|
|
struct image_list * next;
|
2012-08-07 14:53:52 +02:00
|
|
|
};
|
2012-07-14 10:33:15 +02:00
|
|
|
|
|
|
|
|
struct image * image_alloc_from_file(const char * file, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout);
|
2012-08-07 14:53:52 +02:00
|
|
|
struct image * image_alloc_from_shared_fd(int fd, size_t size, size_t offset, uint16_t hash, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout);
|
2012-07-14 10:33:15 +02:00
|
|
|
void image_free(struct image * image);
|
2012-08-07 14:53:52 +02:00
|
|
|
void image_seek(struct image * image, off_t whence);
|
2012-07-14 10:33:15 +02:00
|
|
|
size_t image_read(struct image * image, void * buf, size_t count);
|
2012-08-07 14:00:50 +02:00
|
|
|
/*size_t image_write(struct image * image, void * buf, size_t count);*/
|
2012-07-14 10:33:15 +02:00
|
|
|
void image_list_add(struct image_list ** list, struct image * image);
|
|
|
|
|
void image_list_del(struct image_list * list);
|
2012-08-07 14:00:50 +02:00
|
|
|
|
|
|
|
|
uint16_t image_hash_from_data(struct image * image);
|
|
|
|
|
enum image_type image_type_from_data(struct image * image);
|
2012-08-07 17:10:49 +02:00
|
|
|
char * image_name_alloc_from_values(struct image * image);
|
2012-08-07 14:00:50 +02:00
|
|
|
enum image_type image_type_from_string(const char * type);
|
|
|
|
|
const char * image_type_to_string(enum image_type type);
|
|
|
|
|
|
|
|
|
|
#endif
|