chiark / gitweb /
not even nearly working
authorian <ian>
Mon, 30 May 2005 17:24:37 +0000 (17:24 +0000)
committerian <ian>
Mon, 30 May 2005 17:24:37 +0000 (17:24 +0000)
hostside/hostside.h
hostside/parse-proto-spec [new file with mode: 0755]

index ff495fe3a7cfae350955ad21aa3143f0d7f3b477..867a8e4556178cdecd827b51eeef6406b8accfdc 100644 (file)
@@ -54,6 +54,15 @@ void serial_transmit(const Byte *command, int length);
 void output_hex(Selector sel, const char *work,
                const Byte *command, int length);
 
+/*---------- from protocol.c ----------*/
+
+typedef struct OrdinaryPicMessage OrdinaryPicMessage;
+struct OrdinaryPicMessage {
+  const char *title;
+  unsigned opcode;
+  int operand_bits; /* 0: no operand.  >=7, insn is a 2-byte message */
+};
+     
 /*---------- from hostside.c ----------*/
 
 extern oop_source *events;
diff --git a/hostside/parse-proto-spec b/hostside/parse-proto-spec
new file mode 100755 (executable)
index 0000000..e49b905
--- /dev/null
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+while (<>) {
+    $dirn= '<' if m/^From host to PIC/ ... m/^\S/;
+    $dirn= '>' if m/^From host to PIC/ ... m/^\S/;
+    
+    $dirn=  ? '>' :
+       m/^From PIC to host/ ... m/^\S/ ? '<' : undef;
+    next unless defined $dirn;
+    next unless m/^ [(<>)] / && $1 eq $dirn;
+    die if m/\t/;
+    die unless m/^ [<>] ([01A-Z. ]+?)   +(?:\([A-Z]\))? (\S.*)$/;
+    $msg= $1; $rhs= $2;
+    next if $rhs =~ m/^\}/;
+    next if $msg =~ m/^\.\.\./;
+    $rhs =~ m/^([A-Z]+)\s/;
+    $cname= lc $1;
+    $msg =~ s/ //g;
+    if ($msg =~ m/^0[01]{7}$/) {
+       $opcode= $&;
+       $arglen= 0;
+    } else {
+       $msg =~ m/A-Z/;
+       $oplet= $&;
+       $msg =~ s/$oplet/_/g;
+       die if $msg =~ m/A-Z/;
+       die if $msg =~ m/_[01]/;
+       die unless $msg =~ m/^(1[01][01_]{6})0_{7}$/ or
+           $msg =~ m/^(0[01][01_]{6})$/;
+       $opcode= $1;
+       $arglen= $msg;
+       $arglen =~ s/[01]//g;
+       $arglen= length $arglen;
+    }
+    printf(" { %-16s, 0x%02x, %2d },",
+          "\"$cname\",", bin($opcode), $arglen)
+       or die $!;
+}