|
|
26e14f |
#ifndef NTUX_DRIVER_IMPL_H
|
|
|
26e14f |
#define NTUX_DRIVER_IMPL_H
|
|
|
26e14f |
|
|
|
26e14f |
#include <ntapi/ntapi.h>
|
|
|
26e14f |
#include <psxscl/psxscl.h>
|
|
|
26e14f |
#include <stdint.h>
|
|
|
26e14f |
#include <stdio.h>
|
|
|
26e14f |
|
|
|
26e14f |
#include <ntux/ntux.h>
|
|
|
fed26a |
#include "ntux_dprintf_impl.h"
|
|
|
26e14f |
#include "argv/argv.h"
|
|
|
26e14f |
|
|
|
2404cd |
#define NTUX_OPTV_ELEMENTS 64
|
|
|
2404cd |
|
|
|
7deda5 |
extern const struct argv_option ntux_default_options[];
|
|
|
7deda5 |
extern const struct argv_option ntux_spawn_options[];
|
|
|
7deda5 |
extern const struct argv_option ntux_strace_options[];
|
|
|
7deda5 |
extern const struct _ntapi_vtbl * ntux_ntapi;
|
|
|
26e14f |
|
|
|
26e14f |
#define ntapi ntux_ntapi
|
|
|
26e14f |
|
|
|
26e14f |
enum app_tags {
|
|
|
26e14f |
TAG_HELP,
|
|
|
26e14f |
TAG_VERSION,
|
|
|
6a7c02 |
TAG_CMD,
|
|
|
9682ca |
TAG_LOADER,
|
|
|
9682ca |
TAG_LOGFILE,
|
|
|
26e14f |
};
|
|
|
26e14f |
|
|
|
26e14f |
struct ntux_driver_ctx_impl {
|
|
|
26e14f |
struct ntux_common_ctx cctx;
|
|
|
26e14f |
struct ntux_driver_ctx ctx;
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
26e14f |
struct __psx_context xctx;
|
|
|
da20d8 |
const struct ntux_unit_ctx *euctx;
|
|
|
26e14f |
const char * eunit;
|
|
|
26e14f |
struct ntux_error_info ** errinfp;
|
|
|
26e14f |
struct ntux_error_info ** erricap;
|
|
|
26e14f |
struct ntux_error_info * erriptr[64];
|
|
|
26e14f |
struct ntux_error_info erribuf[64];
|
|
|
da20d8 |
char errsbuf[28];
|
|
|
da20d8 |
int errcode;
|
|
|
26e14f |
};
|
|
|
26e14f |
|
|
|
da20d8 |
|
|
|
da20d8 |
static inline struct ntux_driver_ctx_impl * ntux_get_driver_ictx(const struct ntux_driver_ctx * dctx)
|
|
|
da20d8 |
{
|
|
|
da20d8 |
uintptr_t addr;
|
|
|
da20d8 |
|
|
|
da20d8 |
if (dctx) {
|
|
|
da20d8 |
addr = (uintptr_t)dctx - offsetof(struct ntux_driver_ctx_impl,ctx);
|
|
|
da20d8 |
return (struct ntux_driver_ctx_impl *)addr;
|
|
|
da20d8 |
}
|
|
|
da20d8 |
|
|
|
da20d8 |
return 0;
|
|
|
da20d8 |
}
|
|
|
da20d8 |
|
|
|
da20d8 |
static inline void ntux_driver_set_ectx(
|
|
|
da20d8 |
const struct ntux_driver_ctx * dctx,
|
|
|
da20d8 |
const struct ntux_unit_ctx * uctx,
|
|
|
da20d8 |
const char * unit)
|
|
|
da20d8 |
{
|
|
|
da20d8 |
struct ntux_driver_ctx_impl * ictx;
|
|
|
da20d8 |
|
|
|
da20d8 |
ictx = ntux_get_driver_ictx(dctx);
|
|
|
da20d8 |
ictx->euctx = uctx;
|
|
|
da20d8 |
ictx->eunit = unit;
|
|
|
da20d8 |
}
|
|
|
da20d8 |
|
|
|
ec0005 |
static inline int ntux_driver_fdin(const struct ntux_driver_ctx * dctx)
|
|
|
ec0005 |
{
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
ec0005 |
ntux_get_driver_fdctx(dctx,&fdctx);
|
|
|
ec0005 |
return fdctx.fdin;
|
|
|
ec0005 |
}
|
|
|
ec0005 |
|
|
|
ec0005 |
static inline int ntux_driver_fdout(const struct ntux_driver_ctx * dctx)
|
|
|
ec0005 |
{
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
ec0005 |
ntux_get_driver_fdctx(dctx,&fdctx);
|
|
|
ec0005 |
return fdctx.fdout;
|
|
|
ec0005 |
}
|
|
|
ec0005 |
|
|
|
ec0005 |
static inline int ntux_driver_fderr(const struct ntux_driver_ctx * dctx)
|
|
|
ec0005 |
{
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
ec0005 |
ntux_get_driver_fdctx(dctx,&fdctx);
|
|
|
ec0005 |
return fdctx.fderr;
|
|
|
ec0005 |
}
|
|
|
ec0005 |
|
|
|
ec0005 |
static inline int ntux_driver_fdlog(const struct ntux_driver_ctx * dctx)
|
|
|
ec0005 |
{
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
ec0005 |
ntux_get_driver_fdctx(dctx,&fdctx);
|
|
|
ec0005 |
return fdctx.fdlog;
|
|
|
ec0005 |
}
|
|
|
ec0005 |
|
|
|
ec0005 |
static inline int ntux_driver_fdcwd(const struct ntux_driver_ctx * dctx)
|
|
|
ec0005 |
{
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
ec0005 |
ntux_get_driver_fdctx(dctx,&fdctx);
|
|
|
ec0005 |
return fdctx.fdcwd;
|
|
|
ec0005 |
}
|
|
|
ec0005 |
|
|
|
ec0005 |
static inline int ntux_driver_fddst(const struct ntux_driver_ctx * dctx)
|
|
|
ec0005 |
{
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
ec0005 |
ntux_get_driver_fdctx(dctx,&fdctx);
|
|
|
ec0005 |
return fdctx.fddst;
|
|
|
ec0005 |
}
|
|
|
ec0005 |
|
|
|
26e14f |
#endif
|