chiark / gitweb /
startup debugged so it works ish with /dev/random etc
authorian <ian>
Fri, 5 May 2006 00:42:23 +0000 (00:42 +0000)
committerian <ian>
Fri, 5 May 2006 00:42:23 +0000 (00:42 +0000)
hostside/daemons.h
hostside/realtime.c
hostside/skelproto-pic.c
hostside/startup.c

index 341f62e713ad0add6c298306f69b9850fcb17716..dbe8c1c573b9140445b4712f48121193d43464e4 100644 (file)
@@ -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: */
index e42e0763ab603491d0a8a6d8538336a4998cb722..0c650260e19e919b6be1b64913ff1b00578a9fc2 100644 (file)
@@ -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;
index 72440e36ad80dfedf4cd73cd45cd6645ae99d2f2..ec67fb6f5cb3dc37d3996fbf1fadb47a5d46aa77 100644 (file)
@@ -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[]= {
index bc2c0bf092a43a345069a111f6a9ef0e368baa50..4685db187ca0bf8384417860706d913c43c6521e 100644 (file)
@@ -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) {