forked from len0rd/rockbox
This is a new flash installer framework for the X1000 targets. A bunch of this code is *UNTESTED* but there is an external test harness which allows the library to be built and tested on a PC. Once tests are written and the bugs are ironed out this framework will replace the existing installer code. New features: - Update tarballs are MD5-checksummed to guarantee integrity. - The flash map is no longer fixed -- updates are self describing and carry a map file which specifies the areas to update. - Can take full or partial backups with checksums computed on the fly. - Supports an additional verification mode which reads back data after writing to ensure the flash contents were not silently corrupted. Change-Id: I29a89190c7ff566019f6a844ad0571f01fb7192f
64 lines
2.3 KiB
C
64 lines
2.3 KiB
C
/***************************************************************************
|
|
* __________ __ ___.
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
* \/ \/ \/ \/ \/
|
|
* $Id$
|
|
*
|
|
* Copyright (C) 2021 Aidan MacDonald
|
|
*
|
|
* 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 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
****************************************************************************/
|
|
|
|
#ifndef _XF_STREAM_H_
|
|
#define _XF_STREAM_H_
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <sys/types.h> /* ssize_t */
|
|
#include "microtar.h"
|
|
|
|
struct xf_stream;
|
|
|
|
struct xf_stream_ops {
|
|
off_t(*xget_size)(struct xf_stream* s);
|
|
ssize_t(*xread)(struct xf_stream* s, void* buf, size_t len);
|
|
ssize_t(*xwrite)(struct xf_stream* s, const void* buf, size_t len);
|
|
int(*xclose)(struct xf_stream* s);
|
|
};
|
|
|
|
struct xf_stream {
|
|
intptr_t data;
|
|
const struct xf_stream_ops* ops;
|
|
};
|
|
|
|
inline size_t xf_stream_get_size(struct xf_stream* s)
|
|
{ return s->ops->xget_size(s); }
|
|
|
|
inline ssize_t xf_stream_read(struct xf_stream* s, void* buf, size_t len)
|
|
{ return s->ops->xread(s, buf, len); }
|
|
|
|
inline ssize_t xf_stream_write(struct xf_stream* s, const void* buf, size_t len)
|
|
{ return s->ops->xwrite(s, buf, len); }
|
|
|
|
inline int xf_stream_close(struct xf_stream* s)
|
|
{ return s->ops->xclose(s); }
|
|
|
|
int xf_open_file(const char* file, int flags, struct xf_stream* s);
|
|
int xf_open_tar(mtar_t* mtar, const char* file, struct xf_stream* s);
|
|
int xf_create_tar(mtar_t* mtar, const char* file, size_t size, struct xf_stream* s);
|
|
|
|
/* Utility function needed for a few things */
|
|
int xf_stream_read_lines(struct xf_stream* s, char* buf, size_t bufsz,
|
|
int(*callback)(int n, char* buf, void* arg), void* arg);
|
|
|
|
#endif /* _XF_STREAM_H_ */
|