|
|
249590 |
#ifndef PE_DRIVER_IMPL_H
|
|
|
249590 |
#define PE_DRIVER_IMPL_H
|
|
|
249590 |
|
|
|
eb4c04 |
#include <stdint.h>
|
|
|
eb4c04 |
#include <stdio.h>
|
|
|
eb4c04 |
#include <sys/types.h>
|
|
|
eb4c04 |
|
|
|
eb4c04 |
#include <perk/perk.h>
|
|
|
eb4c04 |
#include <perk/perk_meta.h>
|
|
|
6851eb |
#include "perk_dprintf_impl.h"
|
|
|
456cde |
#include "argv/argv.h"
|
|
|
456cde |
|
|
|
cfa4ad |
#define PERK_OPTV_ELEMENTS 64
|
|
|
cfa4ad |
|
|
|
456cde |
extern const struct argv_option pe_default_options[];
|
|
|
eb4c04 |
|
|
|
249590 |
enum app_tags {
|
|
|
249590 |
TAG_HELP,
|
|
|
249590 |
TAG_VERSION,
|
|
|
249590 |
TAG_PRETTY,
|
|
|
cd4ace |
TAG_CATEGORY,
|
|
|
9d75af |
TAG_SECTIONS,
|
|
|
016925 |
TAG_SYMBOLS,
|
|
|
ecf121 |
TAG_STRINGS,
|
|
|
249590 |
TAG_EXPSYMS,
|
|
|
249590 |
TAG_IMPLIBS,
|
|
|
249590 |
TAG_IMPSYMS,
|
|
|
ee981e |
TAG_DSOLIBS,
|
|
|
ee981e |
TAG_DSOSYMS,
|
|
|
d38fc0 |
TAG_HDRDUMP,
|
|
|
249590 |
};
|
|
|
249590 |
|
|
|
eb4c04 |
struct pe_driver_ctx_impl {
|
|
|
df5be5 |
struct pe_common_ctx cctx;
|
|
|
df5be5 |
struct pe_driver_ctx ctx;
|
|
|
a85d3e |
struct pe_fd_ctx fdctx;
|
|
|
df5be5 |
const struct pe_unit_ctx * euctx;
|
|
|
df5be5 |
const char * eunit;
|
|
|
df5be5 |
struct pe_error_info ** errinfp;
|
|
|
df5be5 |
struct pe_error_info ** erricap;
|
|
|
df5be5 |
struct pe_error_info * erriptr[64];
|
|
|
df5be5 |
struct pe_error_info erribuf[64];
|
|
|
eb4c04 |
};
|
|
|
eb4c04 |
|
|
|
eb4c04 |
struct pe_unit_ctx_impl {
|
|
|
eb4c04 |
const char * path;
|
|
|
eb4c04 |
struct pe_raw_image map;
|
|
|
eb4c04 |
struct pe_image_meta * meta;
|
|
|
eb4c04 |
struct pe_unit_ctx uctx;
|
|
|
eb4c04 |
};
|
|
|
eb4c04 |
|
|
|
bc2468 |
|
|
|
bc2468 |
static inline struct pe_driver_ctx_impl * pe_get_driver_ictx(
|
|
|
bc2468 |
const struct pe_driver_ctx * dctx)
|
|
|
bc2468 |
{
|
|
|
bc2468 |
uintptr_t addr;
|
|
|
bc2468 |
|
|
|
bc2468 |
if (dctx) {
|
|
|
bc2468 |
addr = (uintptr_t)dctx - offsetof(struct pe_driver_ctx_impl,ctx);
|
|
|
bc2468 |
return (struct pe_driver_ctx_impl *)addr;
|
|
|
bc2468 |
}
|
|
|
bc2468 |
|
|
|
bc2468 |
return 0;
|
|
|
bc2468 |
}
|
|
|
bc2468 |
|
|
|
9a382d |
static inline void pe_driver_set_ectx(
|
|
|
9a382d |
const struct pe_driver_ctx * dctx,
|
|
|
9a382d |
const struct pe_unit_ctx * uctx,
|
|
|
9a382d |
const char * unit)
|
|
|
9a382d |
{
|
|
|
9a382d |
struct pe_driver_ctx_impl * ictx;
|
|
|
9a382d |
|
|
|
9a382d |
ictx = pe_get_driver_ictx(dctx);
|
|
|
9a382d |
ictx->euctx = uctx;
|
|
|
9a382d |
ictx->eunit = unit;
|
|
|
9a382d |
}
|
|
|
9a382d |
|
|
|
a85d3e |
static inline int pe_driver_fdin(const struct pe_driver_ctx * dctx)
|
|
|
a85d3e |
{
|
|
|
a85d3e |
struct pe_fd_ctx fdctx;
|
|
|
a85d3e |
pe_get_driver_fdctx(dctx,&fdctx);
|
|
|
a85d3e |
return fdctx.fdin;
|
|
|
a85d3e |
}
|
|
|
a85d3e |
|
|
|
a85d3e |
static inline int pe_driver_fdout(const struct pe_driver_ctx * dctx)
|
|
|
a85d3e |
{
|
|
|
a85d3e |
struct pe_fd_ctx fdctx;
|
|
|
a85d3e |
pe_get_driver_fdctx(dctx,&fdctx);
|
|
|
a85d3e |
return fdctx.fdout;
|
|
|
a85d3e |
}
|
|
|
a85d3e |
|
|
|
a85d3e |
static inline int pe_driver_fderr(const struct pe_driver_ctx * dctx)
|
|
|
a85d3e |
{
|
|
|
a85d3e |
struct pe_fd_ctx fdctx;
|
|
|
a85d3e |
pe_get_driver_fdctx(dctx,&fdctx);
|
|
|
a85d3e |
return fdctx.fderr;
|
|
|
a85d3e |
}
|
|
|
a85d3e |
|
|
|
a85d3e |
static inline int pe_driver_fdlog(const struct pe_driver_ctx * dctx)
|
|
|
a85d3e |
{
|
|
|
a85d3e |
struct pe_fd_ctx fdctx;
|
|
|
a85d3e |
pe_get_driver_fdctx(dctx,&fdctx);
|
|
|
a85d3e |
return fdctx.fdlog;
|
|
|
a85d3e |
}
|
|
|
a85d3e |
|
|
|
a85d3e |
static inline int pe_driver_fdcwd(const struct pe_driver_ctx * dctx)
|
|
|
a85d3e |
{
|
|
|
a85d3e |
struct pe_fd_ctx fdctx;
|
|
|
a85d3e |
pe_get_driver_fdctx(dctx,&fdctx);
|
|
|
a85d3e |
return fdctx.fdcwd;
|
|
|
a85d3e |
}
|
|
|
a85d3e |
|
|
|
a85d3e |
static inline int pe_driver_fddst(const struct pe_driver_ctx * dctx)
|
|
|
a85d3e |
{
|
|
|
a85d3e |
struct pe_fd_ctx fdctx;
|
|
|
a85d3e |
pe_get_driver_fdctx(dctx,&fdctx);
|
|
|
a85d3e |
return fdctx.fddst;
|
|
|
a85d3e |
}
|
|
|
a85d3e |
|
|
|
249590 |
#endif
|