diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index f36bb9eb..249f3f73 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -10,7 +10,7 @@ jobs: with: fetch-depth: 1 - name: apt - run: sudo apt update && sudo apt install libusb-1.0-0-dev libsqlite3-dev ninja-build + run: sudo apt update && sudo apt install libusb-1.0-0-dev libsqlite3-dev ninja-build protobuf-compiler - name: make run: make @@ -21,7 +21,7 @@ jobs: with: fetch-depth: 1 - name: brew - run: brew install sqlite pkg-config libusb ninja + run: brew install sqlite pkg-config libusb ninja protobuf - name: make run: make @@ -37,7 +37,7 @@ jobs: fetch-depth: 1 - name: pacman run: | - pacman -S --noconfirm --needed make ninja mingw-w64-i686-libusb mingw-w64-i686-sqlite3 mingw-w64-i686-zlib mingw-w64-cross-gcc zip + pacman -S --noconfirm --needed make ninja mingw-w64-i686-libusb mingw-w64-i686-sqlite3 mingw-w64-i686-zlib mingw-w64-cross-gcc zip protobuf mingw-w64-i686-protobuf - name: build run: | make CXX=/opt/bin/i686-w64-mingw32-g++.exe AR="/opt/bin/i686-w64-mingw32-ar.exe rcs" diff --git a/Makefile b/Makefile index 073fee8e..b53d6d3e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PACKAGES = zlib sqlite3 libusb-1.0 +PACKAGES = zlib sqlite3 libusb-1.0 protobuf export CFLAGS = --std=c++14 -ffunction-sections -fdata-sections export LDFLAGS = diff --git a/arch/brother/brother.proto b/arch/brother/brother.proto new file mode 100644 index 00000000..f9d07f6a --- /dev/null +++ b/arch/brother/brother.proto @@ -0,0 +1,10 @@ +syntax = "proto2"; + +message Brother { + optional double clock_rate_us = 1 [default = 3.83]; + optional double post_index_gap_ms = 2 [default = 1.0]; + optional double sector_spacing_ms = 3 [default = 16.2]; + optional double post_header_spacing_ms = 4 [default = 0.69]; + optional string sector_skew = 5 [default = "05a3816b4927"]; +} + diff --git a/arch/ibm/ibm.proto b/arch/ibm/ibm.proto new file mode 100644 index 00000000..848042ed --- /dev/null +++ b/arch/ibm/ibm.proto @@ -0,0 +1,24 @@ +syntax = "proto2"; + +message IBM { + enum FmMfm { + USE_MFM = 0; + USE_FM = 1; + } + + optional double track_length_ms = 1; + optional int32 sector_size_bytes = 2; + optional bool emit_iam = 3; + optional int32 start_sector_id = 4; + optional double clock_rate_khz = 5; + optional FmMfm use_fm = 6 [default = USE_MFM]; + optional int32 idam_byte = 7; + optional int32 dam_byte = 8; + optional int32 gap0 = 9; + optional int32 gap1 = 10; + optional int32 gap2 = 11; + optional int32 gap3 = 12; + optional string sector_skew = 13; + optional bool swap_sizes = 14; +} + diff --git a/lib/config.proto b/lib/config.proto index f12f1d72..b70c21be 100644 --- a/lib/config.proto +++ b/lib/config.proto @@ -1,6 +1,31 @@ syntax = "proto2"; +import "arch/brother/brother.proto"; +import "arch/ibm/ibm.proto"; +import "lib/decoders/decoder.proto"; +import "lib/imagereader/img.proto"; + +message DiskEncoding { + optional int32 cylinder = 1; + optional int32 head = 2; + oneof format { + IBM ibm = 3; + Brother brother = 4; + } +} + +message FileEncoding { + optional string filename = 1; + oneof format { + Img img = 2; + } +} + message Config { optional string thing = 1; + + repeated DiskEncoding disk = 2; + optional FileEncoding file = 3; + optional Decoder decoder = 4; } diff --git a/lib/decoders/decoder.proto b/lib/decoders/decoder.proto new file mode 100644 index 00000000..0652be86 --- /dev/null +++ b/lib/decoders/decoder.proto @@ -0,0 +1,9 @@ +syntax = "proto2"; + +message Decoder { + optional double pulse_debounce_threshold = 1 [default = 0.30]; + optional double bit_error_threshold = 2 [default = 0.40]; + optional double clock_interval_bias = 3 [default = -0.02]; + optional double minimum_clock_us = 4 [default = 0.75]; +} + diff --git a/lib/imagereader/img.proto b/lib/imagereader/img.proto new file mode 100644 index 00000000..7d85059e --- /dev/null +++ b/lib/imagereader/img.proto @@ -0,0 +1,17 @@ +syntax = "proto2"; + +message Img { + message Format { + optional int32 track = 1; + optional int32 side = 2; + + optional int64 file_offset = 3; + optional int32 sector_size = 4; + } + + optional int32 tracks = 1; + optional int32 heads = 2; + optional int32 sectors = 3; + repeated Format format = 4; +} + diff --git a/mkninja.sh b/mkninja.sh index 6122e926..acdd01c9 100644 --- a/mkninja.sh +++ b/mkninja.sh @@ -177,6 +177,7 @@ runtest() { buildprogram $OBJDIR/$prog \ lib$prog.a \ libbackend.a \ + libproto.a \ libagg.a \ libfmt.a @@ -192,10 +193,15 @@ buildlibrary libfmt.a \ dep/fmt/format.cc \ dep/fmt/posix.cc \ -buildproto libconfig.a \ - lib/config.proto +buildproto libproto.a \ + arch/brother/brother.proto \ + arch/ibm/ibm.proto \ + lib/config.proto \ + lib/decoders/decoder.proto \ + lib/imagereader/img.proto \ buildlibrary libbackend.a \ + -I$OBJDIR/proto \ lib/imagereader/diskcopyimagereader.cc \ lib/imagereader/imagereader.cc \ lib/imagereader/imgimagereader.cc \ @@ -260,6 +266,7 @@ buildlibrary libbackend.a \ lib/csvreader.cc \ buildlibrary libfrontend.a \ + -I$OBJDIR/proto \ src/fe-analysedriveresponse.cc \ src/fe-analyselayout.cc \ src/fe-cwftoflux.cc \ @@ -305,6 +312,7 @@ buildlibrary libfrontend.a \ buildprogram fluxengine \ libfrontend.a \ libbackend.a \ + libproto.a \ libfmt.a \ libagg.a \ @@ -338,6 +346,7 @@ runtest fmmfm-test tests/fmmfm.cc runtest greaseweazle-test tests/greaseweazle.cc runtest kryoflux-test tests/kryoflux.cc runtest ldbs-test tests/ldbs.cc +runtest proto-test -I$OBJDIR/proto tests/proto.cc # vim: sw=4 ts=4 et diff --git a/tests/proto.cc b/tests/proto.cc new file mode 100644 index 00000000..98f0fa93 --- /dev/null +++ b/tests/proto.cc @@ -0,0 +1,18 @@ +#include "globals.h" +#include "bytes.h" +#include "lib/config.pb.h" +#include + +static void test_proto(void) +{ + Config config; + config.set_thing("fnord"); +} + +int main(int argc, const char* argv[]) +{ + test_proto(); + return 0; +} + +