From 0645685b0e8d93b9ed81318a5ff00143926c4ed5 Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 5 May 2006 00:25:03 +0000 Subject: [PATCH] realtime compiles and links now --- hostside/.cvsignore | 3 ++- hostside/Makefile | 6 +++--- hostside/commands.c | 7 ------- hostside/daemons.h | 4 +++- hostside/eventhelp.c | 29 +++++++++++++++++++++++++++++ hostside/multiplex.c | 4 ++++ hostside/obc.c | 18 +++++++++++------- hostside/realtime.c | 4 ++++ hostside/startup.c | 14 ++++++++++++++ 9 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 hostside/multiplex.c diff --git a/hostside/.cvsignore b/hostside/.cvsignore index e285fdd..7536abf 100644 --- a/hostside/.cvsignore +++ b/hostside/.cvsignore @@ -1,5 +1,6 @@ -hostside +realtime hostside-old +hostside safety t layoutinfo.h diff --git a/hostside/Makefile b/hostside/Makefile index 0ac0a63..9239920 100644 --- a/hostside/Makefile +++ b/hostside/Makefile @@ -14,9 +14,9 @@ all: $(TARGETS) hostside-old: serialio.o nmra.o main.o encode.o utils.o $(LINK) -realtime: realtime.o startup.o cdumgr.o \ - cmdinput.o \ - utils.o serialio.o auproto-pic.o \ +realtime: realtime.o startup.o cdumgr.o \ + cmdinput.o obc.o eventhelp.o \ + utils.o serialio.o parseutils.o auproto-pic.o \ __oop-read-copy.o -loop $(LINK) diff --git a/hostside/commands.c b/hostside/commands.c index 26ee20d..2dccc25 100644 --- a/hostside/commands.c +++ b/hostside/commands.c @@ -184,10 +184,3 @@ static void cmd_pic(ParseState *ps, const CmdInfo *ci) { serial_transmit(&pi); ouack(ci); } - -const CmdInfo toplevel_cmds[]= { - { "pic", cmd_pic }, - { "nmra", cmd_nmra, }, - { "noop", cmd_noop }, - { 0 } -}; diff --git a/hostside/daemons.h b/hostside/daemons.h index 205b66a..341f62e 100644 --- a/hostside/daemons.h +++ b/hostside/daemons.h @@ -38,6 +38,8 @@ void ovprintf(OutBufferChain *ch, const char *fmt, va_list al) void oprintf(OutBufferChain *ch, const char *msg, ...) __attribute__((format(printf,2,3))); void owrite(OutBufferChain *ch, const char *data, int l); +void voerror(OutBufferChain *ch, const char *fmt, va_list al) + __attribute__((format(printf,2,0))); /*---------- from cmdinput.c ----------*/ @@ -71,7 +73,7 @@ struct TimeoutEvent { /* Undefined Idle Running set by */ * and then callback member is read and the function called */ -void toev_init(TimeoutEvent*); /* B -> I */ +void toev_init(TimeoutEvent*); /* U -> I */ void toev_start(TimeoutEvent*); /* IR -> R; reads duration */ /* if duration is -1 then is same as toev_stop */ void toev_stop(TimeoutEvent*); /* IR -> I */ diff --git a/hostside/eventhelp.c b/hostside/eventhelp.c index 8b3dd05..4471240 100644 --- a/hostside/eventhelp.c +++ b/hostside/eventhelp.c @@ -3,7 +3,36 @@ * helpers for event handling */ +#include +#include + #include "daemons.h" oop_source *events; +static void *toev_callback(oop_source *source, struct timeval tv, void *t_v) { + TimeoutEvent *toev= t_v; + toev->running= 0; + toev->callback(toev); + return OOP_CONTINUE; +} + +void toev_init(TimeoutEvent *toev) { toev->running= 0; } + +void toev_start(TimeoutEvent *toev) { + toev_stop(toev); + if (toev->duration==-1) return; + toev->running= 1; + mgettimeofday(&toev->abs); + assert(toev->duration < INT_MAX/1000); + toev->abs.tv_usec += toev->duration * 1000; + toev->abs.tv_sec += toev->abs.tv_usec / 1000000; + toev->abs.tv_usec %= 1000000; + events->on_time(events, toev->abs, toev_callback, toev); +} + +void toev_stop(TimeoutEvent *toev) { + if (!toev->running) return; + toev->running= 0; + events->cancel_time(events, toev->abs, toev_callback, toev); +} diff --git a/hostside/multiplex.c b/hostside/multiplex.c new file mode 100644 index 0000000..1d30794 --- /dev/null +++ b/hostside/multiplex.c @@ -0,0 +1,4 @@ +void vbadcmd(ParseState *ps, const char *fmt, va_list al) { + voerror(&ps->ci->out,fmt,al); +} + diff --git a/hostside/obc.c b/hostside/obc.c index 63547a0..7154d83 100644 --- a/hostside/obc.c +++ b/hostside/obc.c @@ -1,4 +1,7 @@ -/**/ +/* + * daemons + * output buffer chains + */ #include #include @@ -15,12 +18,6 @@ struct OutBuffer { int l; }; -void vbadcmd(ParseState *ps, const char *fmt, va_list al) { - oprintf(&ps->ci->out,"error "); - ovprintf(&ps->ci->out,fmt,al); - owrite(&ps->ci->out,"\n",1); -} - static void *writeable(oop_source *evts, int fd, oop_event evt, void *ch_v) { OutBufferChain *ch= ch_v; @@ -62,6 +59,7 @@ static void addlink(OutBufferChain *ch, OutBuffer *ob) { } void obc_init(OutBufferChain *ch) { + int r; ch->done_of_head= 0; r= oop_fd_nonblock(ch->fd, 1); if (r) diee("nonblock(OutBufferChain->fd,1)"); @@ -83,6 +81,12 @@ void oprintf(OutBufferChain *ch, const char *msg, ...) { va_end(al); } +void voerror(OutBufferChain *ch, const char *fmt, va_list al) { + oprintf(ch,"error "); + ovprintf(ch,fmt,al); + owrite(ch,"\n",1); +} + void owrite(OutBufferChain *ch, const char *data, int l) { OutBuffer *ob; ob= mmalloc(sizeof(*ob)); diff --git a/hostside/realtime.c b/hostside/realtime.c index 7d2b7cd..e42e076 100644 --- a/hostside/realtime.c +++ b/hostside/realtime.c @@ -52,6 +52,10 @@ void oupicio(const char *dirn, const PicInsnInfo *pii, int objnum) { oprintf(UPO, "picio %s %s %u\n", dirn, pii->name, objnum); } +void vbadcmd(ParseState *ps, const char *fmt, va_list al) { + voerror(UPO,fmt,al); +} + static void obc_error(OutBufferChain *ch, const char *e1, const char *e2) { comms_error(ch->desc, e1, e2); } diff --git a/hostside/startup.c b/hostside/startup.c index f9fd986..bc2c0bf 100644 --- a/hostside/startup.c +++ b/hostside/startup.c @@ -177,6 +177,11 @@ void on_pic_wtimeout(const PicInsnInfo *pii, const PicInsn *pi, int objnum) { oprintf(UPO, "warning watchdog \"PIC watchdog timer triggered\"\n"); } +void on_pic_hello(const PicInsnInfo *pii, const PicInsn *pi, int objnum) + { abort(); } +void on_pic_aaargh(const PicInsnInfo *pii, const PicInsn *pi, int objnum) + { abort(); } + /*---------- fixme move these to where they want to go ----------*/ void on_pic_nmradone(const PicInsnInfo *pii, const PicInsn *pi, int objnum) { @@ -195,3 +200,12 @@ void on_pic_detect1(const PicInsnInfo *pii, const PicInsn *pi, int objnum) { void abandon_run(void) { /* fixme do something here */ } + +const CmdInfo toplevel_cmds[]= { +#if 0 + { "pic", cmd_pic }, + { "nmra", cmd_nmra, }, + { "noop", cmd_noop }, +#endif + { 0 } +}; -- 2.30.2