From 3784d947bfb4dac04558a88cb4f18a36e5afc0be Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 5 May 2006 00:42:23 +0000 Subject: [PATCH] startup debugged so it works ish with /dev/random etc --- hostside/daemons.h | 3 ++- hostside/realtime.c | 2 ++ hostside/skelproto-pic.c | 4 ++-- hostside/startup.c | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hostside/daemons.h b/hostside/daemons.h index 341f62e..dbe8c1c 100644 --- a/hostside/daemons.h +++ b/hostside/daemons.h @@ -19,7 +19,8 @@ typedef struct CommandInput CommandInput; typedef struct OutBuffer OutBuffer; typedef struct OutBufferChain OutBufferChain; typedef void OutBufferError(OutBufferChain*, const char *e1, const char *e2 - /* both e1 and e2 always non-0. say `$e1: $e2' */); + /* on error: both e1 and e2 non-0. say `$e1: $e2' + * on eof: both e1 and e2 =0. */); struct OutBufferChain { /* set by user: */ diff --git a/hostside/realtime.c b/hostside/realtime.c index e42e076..0c65026 100644 --- a/hostside/realtime.c +++ b/hostside/realtime.c @@ -16,6 +16,7 @@ static const char *device; static void comms_error(const char *ch, const char *e1, const char *e2 /* may be 0 */) { + if (!e1 && !e2) e1= "end of file"; die("communications error: %s: %s%s%s", ch, e1, e2?": ":"", e2?e2:""); } @@ -95,6 +96,7 @@ static void *serial_readable(oop_source *evts, int fd, if (!serial_buf.l) break; buf_used -= serial_buf.l; memmove(serial_buf.d, serial_buf.d + serial_buf.l, buf_used); + if (!buf_used) break; } serial_buf.l= buf_used; return OOP_CONTINUE; diff --git a/hostside/skelproto-pic.c b/hostside/skelproto-pic.c index 72440e3..ec67fb6 100644 --- a/hostside/skelproto-pic.c +++ b/hostside/skelproto-pic.c @@ -17,7 +17,7 @@ extern void enco_pic_any(PicInsn *out, int opcode, int argbits, int objnum) { int i; assert(!(as & (~0UL << argbits))); - out->l= 1 + argbits; + out->l= 1 + argbits/7; for (i= out->l - 1; i >= 0; i--, as >>= 7) @@ -63,8 +63,8 @@ void picinsn_decode(const PicInsn *pi, const PicInsnInfo *table, } } + if (objnum_r && pii) *objnum_r= val & ((1u << pii->argbits) - 1); *pii_r= pii; - if (objnum_r) *objnum_r= val & ((1u << pii->argbits) - 1); } const PicInsnInfo pic_command_infos[]= { diff --git a/hostside/startup.c b/hostside/startup.c index bc2c0bf..4685db1 100644 --- a/hostside/startup.c +++ b/hostside/startup.c @@ -16,7 +16,7 @@ static void sta_goto(StartupState new_state); static void timedout_onward(TimeoutEvent *toev) { assert(sta_state != Sta_Run); - sta_goto(sta_state + 1); + sta_goto(sta_state == Sta_Flush ? Sta_Ping : sta_state + 1); } static void timedout_ping(TimeoutEvent *toev) { -- 2.30.2