Files
0xFFFF/src/image.h
T

102 lines
3.4 KiB
C
Raw Normal View History

2012-08-08 11:44:50 +02:00
/*
0xFFFF - Open Free Fiasco Firmware Flasher
Copyright (C) 2012 Pali Rohár <pali.rohar@gmail.com>
2012-07-14 10:33:15 +02:00
2012-08-08 11:44:50 +02:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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
#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,
IMAGE_MMC,
IMAGE_CMT_2ND,
IMAGE_CMT_ALGO,
IMAGE_CMT_MCUSW,
IMAGE_1ST,
IMAGE_CERT_SW,
IMAGE_APE_ALGO,
IMAGE_COUNT,
2012-07-14 10:33:15 +02:00
};
struct image_part {
struct image_part * next;
uint32_t offset;
uint32_t size;
char * name;
};
struct image_fd {
struct image_fd * next;
int fd;
int is_shared_fd;
off_t shared_cur;
uint32_t size;
uint32_t align;
size_t offset;
char * orig_filename;
};
2012-07-14 10:33:15 +02:00
struct image {
enum image_type type;
2012-09-22 19:38:13 +02:00
struct device_list * devices;
2012-07-14 10:33:15 +02:00
char * version;
char * layout;
uint16_t hash;
uint32_t size;
struct image_part * parts;
struct image_fd * fds;
2012-09-22 23:16:56 +02:00
size_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, struct image_part * parts);
struct image * image_alloc_from_files(const char ** files, int count, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout, struct image_part * parts);
struct image * image_alloc_from_fd(int fd, const char * orig_filename, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout, struct image_part * parts);
struct image * image_alloc_from_fds(int * fds, const char ** orig_filenames, int count, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout, struct image_part * parts);
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, struct image_part * parts);
2012-07-14 10:33:15 +02:00
void image_free(struct image * image);
2012-09-22 23:16:56 +02:00
void image_seek(struct image * image, size_t whence);
2012-07-14 10:33:15 +02:00
size_t image_read(struct image * image, void * buf, size_t count);
void image_print_info(struct image * image);
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);
void image_list_unlink(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);
char * image_name_alloc_from_values(struct image * image, int part_num);
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);
2012-09-22 19:49:04 +02:00
int image_hwrev_is_valid(struct image * image, int16_t hwrev);
2012-08-07 14:00:50 +02:00
#endif