24 #include <sys/ioctl.h>
29 #include <sys/types.h>
38 #define dbg(fmt, ...) if (g_libeasynmc_debug) { \
39 fprintf(stderr, "libeasynmc: " fmt, ##__VA_ARGS__); \
42 #define err(fmt, ...) if (g_libeasynmc_errors) { \
43 fprintf(stderr, "libeasynmc: " fmt, ##__VA_ARGS__); \
46 static int stdio_handle_section(
struct easynmc_handle *h,
char* name, FILE *rfd, GElf_Shdr shdr)
50 if (strcmp(name,
".easynmc_stdin")==0)
52 else if (strcmp(name,
".easynmc_stdout")==0)
55 if (shdr.sh_size == 0)
62 int rq = (type) ? IOCTL_NMC3_ATTACH_STDOUT : IOCTL_NMC3_ATTACH_STDIN;
63 uint32_t addr = shdr.sh_addr << 2;
64 dbg(
"Attaching %s io buffer size %d words\n", name, h->
imem32[shdr.sh_addr + 1]);
66 int ret = ioctl(h->
iofd, rq, &addr);
72 rq = (type) ? IOCTL_NMC3_REFORMAT_STDOUT : IOCTL_NMC3_REFORMAT_STDIN;
75 ret = ioctl(h->
iofd, rq, &rfmt);
86 .handle_section = stdio_handle_section
90 static int arg_handle_section(
struct easynmc_handle *h,
char*
name, FILE *rfd, GElf_Shdr shdr)
92 if (strcmp(name,
".easynmc_args")!=0)
95 if (shdr.sh_size == 0)
107 .handle_section = arg_handle_section