Blame include/slibtool/slibtool.h

9ca8c4
#ifndef SOFORT_H
9ca8c4
#define SOFORT_H
9ca8c4
9ca8c4
#include <stdint.h>
9ca8c4
#include <stdio.h>
9ca8c4
9ca8c4
#include "slibtool_api.h"
9ca8c4
9ca8c4
#ifdef __cplusplus
9ca8c4
extern "C" {
9ca8c4
#endif
9ca8c4
9ca8c4
/* pre-alpha */
9ca8c4
#ifndef SLBT_APP
9ca8c4
#ifndef SLBT_PRE_ALPHA
9ca8c4
#error  libslibtool: pre-alpha: ABI is not final!
9ca8c4
#error  to use the library, please pass -DSLBT_PRE_ALPHA to the compiler.
9ca8c4
#endif
9ca8c4
#endif
9ca8c4
9ca8c4
/* status codes */
9ca8c4
#define SLBT_OK				0x00
9ca8c4
#define SLBT_USAGE			0x01
9ca8c4
#define SLBT_BAD_OPT			0x02
9ca8c4
#define SLBT_BAD_OPT_VAL		0x03
9ca8c4
#define SLBT_IO_ERROR			0xA0
9ca8c4
#define SLBT_MAP_ERROR			0xA1
9ca8c4
9ca8c4
/* driver flags */
9ca8c4
#define SLBT_DRIVER_VERBOSITY_NONE	0x0000
9ca8c4
#define SLBT_DRIVER_VERBOSITY_ERRORS	0x0001
9ca8c4
#define SLBT_DRIVER_VERBOSITY_STATUS	0x0002
9ca8c4
#define SLBT_DRIVER_VERBOSITY_USAGE	0x0004
9ca8c4
#define SLBT_DRIVER_CLONE_VECTOR	0x0008
9ca8c4
9ca8c4
#define SLBT_DRIVER_VERSION		0x0010
9ca8c4
#define SLBT_DRIVER_DRY_RUN		0x0020
9ca8c4
9ca8c4
/* unit action flags */
9ca8c4
9ca8c4
struct slbt_input {
9ca8c4
	void *	addr;
9ca8c4
	size_t	size;
9ca8c4
};
9ca8c4
9ca8c4
struct slbt_common_ctx {
9ca8c4
	uint64_t			drvflags;
9ca8c4
	uint64_t			actflags;
9ca8c4
	uint64_t			fmtflags;
9ca8c4
};
9ca8c4
9ca8c4
struct slbt_driver_ctx {
9ca8c4
	const char **			units;
9ca8c4
	const char *			program;
9ca8c4
	const char *			module;
9ca8c4
	const struct slbt_common_ctx *	cctx;
9ca8c4
	void *				any;
9ca8c4
	int				status;
9ca8c4
	int				nerrors;
9ca8c4
};
9ca8c4
9ca8c4
struct slbt_unit_ctx {
9ca8c4
	const char * const *		path;
9ca8c4
	const struct slbt_input *	map;
9ca8c4
	const struct slbt_common_ctx *	cctx;
9ca8c4
	void *				any;
9ca8c4
	int				status;
9ca8c4
	int				nerrors;
9ca8c4
};
9ca8c4
9ca8c4
/* driver api */
9ca8c4
slbt_api int  slbt_get_driver_ctx	(char ** argv, char ** envp, uint32_t flags, struct slbt_driver_ctx **);
9ca8c4
slbt_api int  slbt_create_driver_ctx	(const struct slbt_common_ctx *, struct slbt_driver_ctx **);
9ca8c4
slbt_api void slbt_free_driver_ctx	(struct slbt_driver_ctx *);
9ca8c4
9ca8c4
slbt_api int  slbt_get_unit_ctx		(const struct slbt_driver_ctx *, const char * path, struct slbt_unit_ctx **);
9ca8c4
slbt_api void slbt_free_unit_ctx	(struct slbt_unit_ctx *);
9ca8c4
9ca8c4
slbt_api int  slbt_map_input		(int fd, const char * path, int prot, struct slbt_input *);
9ca8c4
slbt_api int  slbt_unmap_input		(struct slbt_input *);
9ca8c4
9ca8c4
/* utility api */
9ca8c4
9ca8c4
#ifdef __cplusplus
9ca8c4
}
9ca8c4
#endif
9ca8c4
9ca8c4
#endif