From: ian Date: Mon, 30 May 2005 17:24:37 +0000 (+0000) Subject: not even nearly working X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=74047444d8ab05f5779f43525f4e551665d6d204;p=trains.git not even nearly working --- diff --git a/hostside/hostside.h b/hostside/hostside.h index ff495fe..867a8e4 100644 --- a/hostside/hostside.h +++ b/hostside/hostside.h @@ -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 index 0000000..e49b905 --- /dev/null +++ b/hostside/parse-proto-spec @@ -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 $!; +}