openc166 0.2.5__tar.gz → 0.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. {openc166-0.2.5 → openc166-0.2.7}/CMakeLists.txt +1 -1
  2. {openc166-0.2.5 → openc166-0.2.7}/PKG-INFO +3 -2
  3. {openc166-0.2.5 → openc166-0.2.7}/README.md +2 -1
  4. openc166-0.2.7/boards/5wy19.json +31 -0
  5. openc166-0.2.7/boards/c166.json +12 -0
  6. openc166-0.2.7/boards/c167.json +12 -0
  7. openc166-0.2.7/boards/c167cr.json +12 -0
  8. openc166-0.2.7/boards/c167cs.json +12 -0
  9. openc166-0.2.7/docs/boards.md +192 -0
  10. {openc166-0.2.5 → openc166-0.2.7}/docs/ghidra.md +1 -1
  11. {openc166-0.2.5 → openc166-0.2.7}/docs/simulator.md +17 -13
  12. {openc166-0.2.5 → openc166-0.2.7}/include/openc166/openc166.h +11 -3
  13. {openc166-0.2.5 → openc166-0.2.7}/python/openc166/_native.py +2 -0
  14. {openc166-0.2.5 → openc166-0.2.7}/python/openc166/ghidra.py +2 -3
  15. {openc166-0.2.5 → openc166-0.2.7}/python/openc166/sim.py +11 -5
  16. {openc166-0.2.5 → openc166-0.2.7}/src/CMakeLists.txt +8 -1
  17. {openc166-0.2.5 → openc166-0.2.7}/src/capi_sim.cpp +30 -2
  18. openc166-0.2.7/src/json.cpp +341 -0
  19. openc166-0.2.7/src/json.hpp +74 -0
  20. openc166-0.2.7/src/sim/board_config.cpp +338 -0
  21. openc166-0.2.7/src/sim/board_config.hpp +60 -0
  22. openc166-0.2.7/src/sim/boards.cpp +291 -0
  23. openc166-0.2.7/src/sim/boards.hpp +141 -0
  24. {openc166-0.2.5 → openc166-0.2.7}/src/sim/machine.cpp +31 -3
  25. {openc166-0.2.5 → openc166-0.2.7}/src/sim/machine.hpp +10 -1
  26. {openc166-0.2.5 → openc166-0.2.7}/tests/CMakeLists.txt +3 -1
  27. openc166-0.2.7/tests/unit/test_boards.cpp +196 -0
  28. openc166-0.2.7/tests/unit/test_json.cpp +36 -0
  29. openc166-0.2.5/src/sim/boards.cpp +0 -75
  30. openc166-0.2.5/src/sim/boards.hpp +0 -81
  31. {openc166-0.2.5 → openc166-0.2.7}/.gitattributes +0 -0
  32. {openc166-0.2.5 → openc166-0.2.7}/.github/workflows/ci.yml +0 -0
  33. {openc166-0.2.5 → openc166-0.2.7}/.github/workflows/wheels.yml +0 -0
  34. {openc166-0.2.5 → openc166-0.2.7}/.gitignore +0 -0
  35. {openc166-0.2.5 → openc166-0.2.7}/LICENSE +0 -0
  36. {openc166-0.2.5 → openc166-0.2.7}/cli/CMakeLists.txt +0 -0
  37. {openc166-0.2.5 → openc166-0.2.7}/cli/main.cpp +0 -0
  38. {openc166-0.2.5 → openc166-0.2.7}/cmake/embed_files.cmake +0 -0
  39. {openc166-0.2.5 → openc166-0.2.7}/docs/compatibility.md +0 -0
  40. {openc166-0.2.5 → openc166-0.2.7}/docs/debug-info.md +0 -0
  41. {openc166-0.2.5 → openc166-0.2.7}/docs/debugger-design.md +0 -0
  42. {openc166-0.2.5 → openc166-0.2.7}/docs/mpl.md +0 -0
  43. {openc166-0.2.5 → openc166-0.2.7}/docs/phase1-feasibility.md +0 -0
  44. {openc166-0.2.5 → openc166-0.2.7}/docs/releasing.md +0 -0
  45. {openc166-0.2.5 → openc166-0.2.7}/docs/tasking.md +0 -0
  46. {openc166-0.2.5 → openc166-0.2.7}/editors/vscode/README.md +0 -0
  47. {openc166-0.2.5 → openc166-0.2.7}/editors/vscode/extension.js +0 -0
  48. {openc166-0.2.5 → openc166-0.2.7}/editors/vscode/package.json +0 -0
  49. {openc166-0.2.5 → openc166-0.2.7}/examples/mtos/README.md +0 -0
  50. {openc166-0.2.5 → openc166-0.2.7}/examples/mtos/bsl_shim.a66 +0 -0
  51. {openc166-0.2.5 → openc166-0.2.7}/examples/mtos/driver_patch.a66 +0 -0
  52. {openc166-0.2.5 → openc166-0.2.7}/examples/mtos/kline_hello.a66 +0 -0
  53. {openc166-0.2.5 → openc166-0.2.7}/examples/mtos/loader.a66 +0 -0
  54. {openc166-0.2.5 → openc166-0.2.7}/examples/mtos/marker.a66 +0 -0
  55. {openc166-0.2.5 → openc166-0.2.7}/examples/mtos/memory_dump.a66 +0 -0
  56. {openc166-0.2.5 → openc166-0.2.7}/examples/mtos/stage2_hello.a66 +0 -0
  57. {openc166-0.2.5 → openc166-0.2.7}/examples/payload.a66 +0 -0
  58. {openc166-0.2.5 → openc166-0.2.7}/examples/sections.a66 +0 -0
  59. {openc166-0.2.5 → openc166-0.2.7}/inc/REG167.INC +0 -0
  60. {openc166-0.2.5 → openc166-0.2.7}/pyproject.toml +0 -0
  61. {openc166-0.2.5 → openc166-0.2.7}/python/openc166/__init__.py +0 -0
  62. {openc166-0.2.5 → openc166-0.2.7}/python/openc166/bridge.py +0 -0
  63. {openc166-0.2.5 → openc166-0.2.7}/python/openc166/dap.py +0 -0
  64. {openc166-0.2.5 → openc166-0.2.7}/python/openc166/py.typed +0 -0
  65. {openc166-0.2.5 → openc166-0.2.7}/python/tests/test_bridge.py +0 -0
  66. {openc166-0.2.5 → openc166-0.2.7}/python/tests/test_dap.py +0 -0
  67. {openc166-0.2.5 → openc166-0.2.7}/python/tests/test_elf.py +0 -0
  68. {openc166-0.2.5 → openc166-0.2.7}/python/tests/test_ghidra.py +0 -0
  69. {openc166-0.2.5 → openc166-0.2.7}/python/tests/test_openc166.py +0 -0
  70. {openc166-0.2.5 → openc166-0.2.7}/python/tests/test_sim.py +0 -0
  71. {openc166-0.2.5 → openc166-0.2.7}/python/tests/test_stock_5wy19.py +0 -0
  72. {openc166-0.2.5 → openc166-0.2.7}/src/assembler.cpp +0 -0
  73. {openc166-0.2.5 → openc166-0.2.7}/src/assembler.hpp +0 -0
  74. {openc166-0.2.5 → openc166-0.2.7}/src/bundled.cpp +0 -0
  75. {openc166-0.2.5 → openc166-0.2.7}/src/bundled.hpp +0 -0
  76. {openc166-0.2.5 → openc166-0.2.7}/src/capi.cpp +0 -0
  77. {openc166-0.2.5 → openc166-0.2.7}/src/capi.map +0 -0
  78. {openc166-0.2.5 → openc166-0.2.7}/src/debuginfo.cpp +0 -0
  79. {openc166-0.2.5 → openc166-0.2.7}/src/diag.hpp +0 -0
  80. {openc166-0.2.5 → openc166-0.2.7}/src/disasm.cpp +0 -0
  81. {openc166-0.2.5 → openc166-0.2.7}/src/disasm.hpp +0 -0
  82. {openc166-0.2.5 → openc166-0.2.7}/src/disasm_module.cpp +0 -0
  83. {openc166-0.2.5 → openc166-0.2.7}/src/elf.cpp +0 -0
  84. {openc166-0.2.5 → openc166-0.2.7}/src/encode.cpp +0 -0
  85. {openc166-0.2.5 → openc166-0.2.7}/src/encode.hpp +0 -0
  86. {openc166-0.2.5 → openc166-0.2.7}/src/expr.cpp +0 -0
  87. {openc166-0.2.5 → openc166-0.2.7}/src/expr.hpp +0 -0
  88. {openc166-0.2.5 → openc166-0.2.7}/src/isa/c166.tbl +0 -0
  89. {openc166-0.2.5 → openc166-0.2.7}/src/isa/isa.cpp +0 -0
  90. {openc166-0.2.5 → openc166-0.2.7}/src/isa/isa.hpp +0 -0
  91. {openc166-0.2.5 → openc166-0.2.7}/src/isa/isa_types.hpp +0 -0
  92. {openc166-0.2.5 → openc166-0.2.7}/src/lexer.cpp +0 -0
  93. {openc166-0.2.5 → openc166-0.2.7}/src/lexer.hpp +0 -0
  94. {openc166-0.2.5 → openc166-0.2.7}/src/m166.cpp +0 -0
  95. {openc166-0.2.5 → openc166-0.2.7}/src/m166.hpp +0 -0
  96. {openc166-0.2.5 → openc166-0.2.7}/src/mpl.cpp +0 -0
  97. {openc166-0.2.5 → openc166-0.2.7}/src/mpl.hpp +0 -0
  98. {openc166-0.2.5 → openc166-0.2.7}/src/operand.cpp +0 -0
  99. {openc166-0.2.5 → openc166-0.2.7}/src/operand.hpp +0 -0
  100. {openc166-0.2.5 → openc166-0.2.7}/src/output.cpp +0 -0
  101. {openc166-0.2.5 → openc166-0.2.7}/src/predef.cpp +0 -0
  102. {openc166-0.2.5 → openc166-0.2.7}/src/predef.hpp +0 -0
  103. {openc166-0.2.5 → openc166-0.2.7}/src/sim/cpu.cpp +0 -0
  104. {openc166-0.2.5 → openc166-0.2.7}/src/sim/debug.cpp +0 -0
  105. {openc166-0.2.5 → openc166-0.2.7}/src/sim/debug.hpp +0 -0
  106. {openc166-0.2.5 → openc166-0.2.7}/src/sim/peripherals.cpp +0 -0
  107. {openc166-0.2.5 → openc166-0.2.7}/src/sim/peripherals.hpp +0 -0
  108. {openc166-0.2.5 → openc166-0.2.7}/src/value.hpp +0 -0
  109. {openc166-0.2.5 → openc166-0.2.7}/tests/acceptance/minimon.py +0 -0
  110. {openc166-0.2.5 → openc166-0.2.7}/tests/capi/test_capi.c +0 -0
  111. {openc166-0.2.5 → openc166-0.2.7}/tests/check_binary.cmake +0 -0
  112. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/alignment.a66 +0 -0
  113. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/bit_section_errors.a66 +0 -0
  114. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/bit_sections.a66 +0 -0
  115. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/bits.a66 +0 -0
  116. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/branches.a66 +0 -0
  117. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/cond.a66 +0 -0
  118. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/cond_errors.a66 +0 -0
  119. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/controls.a66 +0 -0
  120. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/defs.a66 +0 -0
  121. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/directives.a66 +0 -0
  122. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/dpp.a66 +0 -0
  123. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/expressions.a66 +0 -0
  124. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/group_errors.a66 +0 -0
  125. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/groups.a66 +0 -0
  126. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/inc/code.inc +0 -0
  127. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/inc/comments.inc +0 -0
  128. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/inc/count.inc +0 -0
  129. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/inc/crlf.inc +0 -0
  130. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/inc/ignored.inc +0 -0
  131. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/inc/lit.inc +0 -0
  132. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/inc/mpl.inc +0 -0
  133. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/inc/nested.inc +0 -0
  134. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/inc/noeol.inc +0 -0
  135. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/inc/regs.inc +0 -0
  136. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/inc/sub/deep.inc +0 -0
  137. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/inc/sub/level3.inc +0 -0
  138. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/include.a66 +0 -0
  139. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/label_errors.a66 +0 -0
  140. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/labels.a66 +0 -0
  141. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/bits/1main.a66 +0 -0
  142. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/bits/2lib.a66 +0 -0
  143. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/bits/3more.a66 +0 -0
  144. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/calls/1main.a66 +0 -0
  145. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/calls/2lib.a66 +0 -0
  146. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/combine/1first.a66 +0 -0
  147. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/combine/2second.a66 +0 -0
  148. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/combine/3third.a66 +0 -0
  149. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/fixups/1use.a66 +0 -0
  150. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/fixups/2def.a66 +0 -0
  151. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/groups/1main.a66 +0 -0
  152. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/groups/2lib.a66 +0 -0
  153. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/mixed/1seg.a66 +0 -0
  154. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/mixed/2flat.a66 +0 -0
  155. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/mixed/3seg.a66 +0 -0
  156. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/regbanks/1main.a66 +0 -0
  157. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/regbanks/2lib.a66 +0 -0
  158. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/sections/1first.a66 +0 -0
  159. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/sections/2second.a66 +0 -0
  160. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/sections/3third.a66 +0 -0
  161. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/segmented/1main.a66 +0 -0
  162. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/segmented/2lib.a66 +0 -0
  163. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/unresolved/1main.a66 +0 -0
  164. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/unresolved/2one.a66 +0 -0
  165. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/unresolved/3two.a66 +0 -0
  166. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/values/1use.a66 +0 -0
  167. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/link/values/2def.a66 +0 -0
  168. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/listing.a66 +0 -0
  169. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/lit.a66 +0 -0
  170. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/lit_errors.a66 +0 -0
  171. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/locate.a66 +0 -0
  172. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/macro_args.a66 +0 -0
  173. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/macro_errors.a66 +0 -0
  174. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/macros.a66 +0 -0
  175. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/mpl.a66 +0 -0
  176. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/mpl_err_exit.a66 +0 -0
  177. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/mpl_err_expr.a66 +0 -0
  178. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/mpl_err_fi.a66 +0 -0
  179. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/mpl_err_meta.a66 +0 -0
  180. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/mpl_err_paren.a66 +0 -0
  181. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/mpl_err_pattern.a66 +0 -0
  182. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/mpl_err_syntax.a66 +0 -0
  183. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/mpl_err_undefined.a66 +0 -0
  184. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/operands.a66 +0 -0
  185. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/primary.a66 +0 -0
  186. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/redefine.a66 +0 -0
  187. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/regbank_errors.a66 +0 -0
  188. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/regbanks.a66 +0 -0
  189. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/reloc.a66 +0 -0
  190. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/section_errors.a66 +0 -0
  191. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/section_length.a66 +0 -0
  192. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/segmented.a66 +0 -0
  193. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/type_operator_errors.a66 +0 -0
  194. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/cases/type_operators.a66 +0 -0
  195. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/gen_sweep.py +0 -0
  196. {openc166-0.2.5 → openc166-0.2.7}/tests/diff/keil_diff.py +0 -0
  197. {openc166-0.2.5 → openc166-0.2.7}/tests/expected/driver_patch.hex +0 -0
  198. {openc166-0.2.5 → openc166-0.2.7}/tests/expected/driver_patch.s28 +0 -0
  199. {openc166-0.2.5 → openc166-0.2.7}/tests/expected/payload.srec +0 -0
  200. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/helpers.hpp +0 -0
  201. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/main.cpp +0 -0
  202. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_assembler.cpp +0 -0
  203. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_bits.cpp +0 -0
  204. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_branches.cpp +0 -0
  205. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_cond.cpp +0 -0
  206. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_debug.cpp +0 -0
  207. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_defs.cpp +0 -0
  208. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_dpp.cpp +0 -0
  209. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_encode.cpp +0 -0
  210. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_expr.cpp +0 -0
  211. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_groups.cpp +0 -0
  212. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_include.cpp +0 -0
  213. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_lexer.cpp +0 -0
  214. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_link.cpp +0 -0
  215. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_listing.cpp +0 -0
  216. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_lit.cpp +0 -0
  217. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_macros.cpp +0 -0
  218. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_mpl.cpp +0 -0
  219. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_output.cpp +0 -0
  220. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_peripherals.cpp +0 -0
  221. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_regbanks.cpp +0 -0
  222. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_sections.cpp +0 -0
  223. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_sim.cpp +0 -0
  224. {openc166-0.2.5 → openc166-0.2.7}/tests/unit/test_tasking.cpp +0 -0
  225. {openc166-0.2.5 → openc166-0.2.7}/third_party/doctest/LICENSE.txt +0 -0
  226. {openc166-0.2.5 → openc166-0.2.7}/third_party/doctest/doctest.h +0 -0
  227. {openc166-0.2.5 → openc166-0.2.7}/tools/CMakeLists.txt +0 -0
  228. {openc166-0.2.5 → openc166-0.2.7}/tools/ghidra/ExportOpenc166Symbols.py +0 -0
  229. {openc166-0.2.5 → openc166-0.2.7}/tools/isagen.cpp +0 -0
@@ -1,6 +1,6 @@
1
1
  cmake_minimum_required(VERSION 3.20)
2
2
  project(openc166
3
- VERSION 0.2.5
3
+ VERSION 0.2.7
4
4
  DESCRIPTION "Keil A166-compatible assembler for the Infineon C166/C167 family"
5
5
  LANGUAGES CXX)
6
6
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openc166
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: Keil A166-compatible assembler for the Infineon C166/C167 microcontrollers
5
5
  Keywords: c166,c167,st10,assembler,keil,a166,infineon,ecu
6
6
  License-Expression: MIT
@@ -281,7 +281,8 @@ byte for byte), `openc166-sim run` runs firmware headless and lists the
281
281
  registers it touched that are not modelled yet, and `openc166 -g` writes
282
282
  debug information ([format](docs/debug-info.md)). `openc166 -o prog.elf`
283
283
  writes an ELF file with DWARF line and symbol information for Ghidra,
284
- readelf, objdump and other tools. See
284
+ readelf, objdump and other tools. The hardware around the CPU is a
285
+ [board file](docs/boards.md) in JSON. See
285
286
  [docs/simulator.md](docs/simulator.md) for what is modelled and what is
286
287
  next.
287
288
 
@@ -258,7 +258,8 @@ byte for byte), `openc166-sim run` runs firmware headless and lists the
258
258
  registers it touched that are not modelled yet, and `openc166 -g` writes
259
259
  debug information ([format](docs/debug-info.md)). `openc166 -o prog.elf`
260
260
  writes an ELF file with DWARF line and symbol information for Ghidra,
261
- readelf, objdump and other tools. See
261
+ readelf, objdump and other tools. The hardware around the CPU is a
262
+ [board file](docs/boards.md) in JSON. See
262
263
  [docs/simulator.md](docs/simulator.md) for what is modelled and what is
263
264
  next.
264
265
 
@@ -0,0 +1,31 @@
1
+ // Siemens 5WY19 engine ECU (SIMK43 family, Hyundai/Kia).
2
+ // What is known and how: docs/simulator.md, "Findings on the 5WY19".
3
+ {
4
+ "format": "openc166-board",
5
+ "version": 1,
6
+ "name": "Siemens 5WY19",
7
+ "description": "C167CS-LM, AM29F400BB flash, external RAM, 74HC574 output latch",
8
+ "chip": "c167cs",
9
+ // An 8 MHz crystal and PLL factor 3: the boot block computes ASC0 reload
10
+ // values from 24000000 (016E3600H at 089A7CH), and its 1 ms tick is 187
11
+ // counts of T1 at fCPU / 128.
12
+ "clock_hz": "24MHz",
13
+ "chip_selects": {
14
+ // Only A0..A18 reach the flash, so it appears at 0 and at 80000H.
15
+ "cs0": { "device": "flash", "name": "flash", "model": "am29f400bb", "image": "$IMAGE", "mask": "0x7FFFF" },
16
+ // The startup code maps CS2 at 90000H just long enough to test RAM there
17
+ // and reports an error unless RAM answers. The chip size is not known.
18
+ "cs2": { "device": "ram", "name": "ram", "size": "64K" },
19
+ // The 4 KB window at 0A000H that the startup code writes a shadow byte to.
20
+ "cs3": { "device": "latch", "name": "latch" }
21
+ },
22
+ "inputs": {
23
+ // The boot block's download loop resets the CPU while A/D channel 1
24
+ // (presumably the supply) reads below 0C4H.
25
+ "adc": { "1": "0x2A0" }
26
+ },
27
+ "options": {
28
+ // K-line: the boot block checks the echo of every byte it sends.
29
+ "serial_echo": true
30
+ }
31
+ }
@@ -0,0 +1,12 @@
1
+ // A bare 80C166: the image as ROM on CS0 from address 0, mirrored every image
2
+ // size, and nothing else on the bus.
3
+ {
4
+ "format": "openc166-board",
5
+ "version": 1,
6
+ "name": "80C166",
7
+ "chip": "c166",
8
+ "clock_hz": "25MHz",
9
+ "chip_selects": {
10
+ "cs0": { "device": "rom", "name": "rom", "image": "$IMAGE" }
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ // A bare C167: the image as ROM on CS0 from address 0, mirrored every image
2
+ // size, and nothing else on the bus.
3
+ {
4
+ "format": "openc166-board",
5
+ "version": 1,
6
+ "name": "C167",
7
+ "chip": "c167",
8
+ "clock_hz": "25MHz",
9
+ "chip_selects": {
10
+ "cs0": { "device": "rom", "name": "rom", "image": "$IMAGE" }
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ // A bare C167CR: the image as ROM on CS0 from address 0, mirrored every image
2
+ // size, and nothing else on the bus.
3
+ {
4
+ "format": "openc166-board",
5
+ "version": 1,
6
+ "name": "C167CR",
7
+ "chip": "c167cr",
8
+ "clock_hz": "25MHz",
9
+ "chip_selects": {
10
+ "cs0": { "device": "rom", "name": "rom", "image": "$IMAGE" }
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ // A bare C167CS: the image as ROM on CS0 from address 0, mirrored every image
2
+ // size, and nothing else on the bus.
3
+ {
4
+ "format": "openc166-board",
5
+ "version": 1,
6
+ "name": "C167CS",
7
+ "chip": "c167cs",
8
+ "clock_hz": "25MHz",
9
+ "chip_selects": {
10
+ "cs0": { "device": "rom", "name": "rom", "image": "$IMAGE" }
11
+ }
12
+ }
@@ -0,0 +1,192 @@
1
+ # Board files
2
+
3
+ A board file tells the simulator what hardware the firmware runs on: which
4
+ chip, which devices sit on the chip selects, how the chip is configured at
5
+ reset, and what the inputs read before a script changes them. Board files are
6
+ JSON. Comments (`//` and `/* */`) are allowed; trailing commas and duplicate
7
+ members are errors.
8
+
9
+ Everywhere a board is taken (`--board` in `openc166-sim run`/`serve`,
10
+ `python -m openc166.ghidra` and the Ghidra launcher, `board=` in
11
+ `Simulator(...)`, `"board"` in a DAP launch configuration), you can give:
12
+
13
+ - the name of a built-in board: `c166`, `c167`, `c167cr`, `c167cs`, `5wy19`
14
+ (their files are in [boards/](../boards));
15
+ - the path of a `.json` file (anything containing a `/`, or `./my.json`);
16
+ - the JSON text itself (it starts with `{`).
17
+
18
+ Mistakes are reported with the place:
19
+
20
+ ```
21
+ my-ecu.json: line 14, column 20: unknown member "colck_hz" (expected format, version, name, ...)
22
+ ```
23
+
24
+ The firmware image you load is the board's `$IMAGE`. Things that depend on
25
+ the firmware rather than the board, such as `--boot-mode` or a script that
26
+ plays a crank signal, stay outside the board file.
27
+
28
+ ## An example
29
+
30
+ The 5WY19 file, shortened:
31
+
32
+ ```jsonc
33
+ {
34
+ "format": "openc166-board",
35
+ "version": 1,
36
+ "name": "Siemens 5WY19",
37
+ "chip": "c167cs",
38
+ "clock_hz": "24MHz",
39
+ "chip_selects": {
40
+ // Only A0..A18 reach the flash, so it appears at 0 and at 80000H.
41
+ "cs0": { "device": "flash", "model": "am29f400bb", "image": "$IMAGE", "mask": "0x7FFFF" },
42
+ "cs2": { "device": "ram", "size": "64K" },
43
+ "cs3": { "device": "latch" }
44
+ },
45
+ "inputs": { "adc": { "1": "0x2A0" } },
46
+ "options": { "serial_echo": true }
47
+ }
48
+ ```
49
+
50
+ ## Numbers
51
+
52
+ A number is a JSON number or a string: `"0x7FFFF"`, `"7FFFFH"`, sizes with
53
+ `K` or `M` (`"64K"` is 65536, `"1M"` 1048576), frequencies with `Hz`, `kHz`
54
+ or `MHz` (`"24MHz"`). Underscores are ignored (`"0x7_FFFF"`).
55
+
56
+ ## Top level
57
+
58
+ | Member | |
59
+ |---|---|
60
+ | `format` | `"openc166-board"` (optional) |
61
+ | `version` | `1` (optional) |
62
+ | `name` | shown by the debugger and in errors |
63
+ | `description` | free text |
64
+ | `chip` | **required**: `c166`, `c167`, `c167cr` or `c167cs` |
65
+ | `clock_hz` | fCPU; default 25 MHz. Every peripheral times itself from it |
66
+ | `reset` | register values the chip latches at reset |
67
+ | `chip_selects` | the external devices, `cs0` .. `cs4` |
68
+ | `inputs` | default input values |
69
+ | `ssc` | the SSC's default reply |
70
+ | `options` | simulator options the board needs |
71
+
72
+ Any other member is an error, so a misspelt name does not go unnoticed.
73
+
74
+ ## Chips
75
+
76
+ | Chip | Core | IRAM | On the chip besides the C167 peripherals |
77
+ |---|---|---|---|
78
+ | `c166` | C166 | 0FA00H, 1 KB | — |
79
+ | `c167` | C167 | 0F600H, 2 KB | — |
80
+ | `c167cr` | C167 | 0F600H, 2 KB | XRAM 0E000H (2 KB) and CAN at 0EF00H, on with SYSCON.XPEN |
81
+ | `c167cs` | C167 | 0F200H, 3 KB | XRAM1 0E000H (2 KB), XRAM2 0C000H (6 KB), CAN1 0EF00H, CAN2 0EE00H, each on with its XPERCON bit; XPERCON resets to 0401H |
82
+
83
+ Every chip has the C167 interrupt table and the modelled peripherals
84
+ (ASC0, CAPCOM, SSC, A/D converter, watchdog; see
85
+ [simulator.md](simulator.md)). The CAN modules are logged storage.
86
+
87
+ ## Reset configuration
88
+
89
+ `reset` sets what the chip reads from the bus at reset (the data bus
90
+ configuration pins) and the XPERCON reset value:
91
+
92
+ | Member | Default |
93
+ |---|---|
94
+ | `syscon` | 0000H |
95
+ | `buscon0` | 0000H |
96
+ | `rp0h` | 0FFH |
97
+ | `xpercon` | the chip's |
98
+
99
+ ## Chip selects
100
+
101
+ `chip_selects` maps `cs0` .. `cs4` to devices; `null` or a missing entry
102
+ leaves the chip select empty (accesses to it are reported as unmodelled).
103
+ CS0 is active from reset; the others answer where the firmware's
104
+ ADDRSELx/BUSCONx put them. Each device has a `device` type and an optional
105
+ `name`, which the debugger shows (`CS0:flash`).
106
+
107
+ The address a device sees is masked with `mask`, which is the size rounded
108
+ up to a power of two less one unless given. A smaller mask than the address
109
+ range makes the device appear several times (mirrors).
110
+
111
+ ### rom
112
+
113
+ Read-only memory. Writes are reported as unmodelled.
114
+
115
+ | Member | |
116
+ |---|---|
117
+ | `image` | `"$IMAGE"` or a file name, relative to the board file |
118
+ | `offset` | bytes to skip at the start of the image |
119
+ | `size` | default: the image's size |
120
+ | `fill` | the byte after the end of the image; default 0FFH |
121
+ | `mask` | see above |
122
+
123
+ `image` or `size` is required.
124
+
125
+ ### ram
126
+
127
+ Read-write memory: the same members as `rom`; `size` is required unless
128
+ there is an `image` to start from. Without an image the RAM holds 0FFH (or
129
+ `fill`).
130
+
131
+ ### flash
132
+
133
+ An AMD-style flash chip with its command set:
134
+
135
+ - the unlock cycles (AAH at 555H, 55H at 2AAH as word addresses on a 16-bit
136
+ bus, 0AAAH/555H as byte addresses on an 8-bit one), reset (0F0H);
137
+ - autoselect (90H): manufacturer, device ID, sector protection (never);
138
+ - program (A0H): bits only go from 1 to 0;
139
+ - sector erase (80H, 30H) with the 50 µs window for more sectors, and chip
140
+ erase (80H, 10H);
141
+ - status polling while the chip works: DQ7 (the complement of the data
142
+ bit while programming, 0 while erasing), DQ6 toggling, DQ3 (the erase has
143
+ started), DQ2 toggling in the sectors being erased.
144
+
145
+ The operations take virtual time, and their state and the array are part of
146
+ snapshots, so reverse execution steps back over a flash write. A write
147
+ outside a command is reported as unmodelled. Not modelled: erase suspend
148
+ (an erase is finished at once instead), sector protection, DQ5 (time
149
+ limit exceeded).
150
+
151
+ | Member | |
152
+ |---|---|
153
+ | `model` | **required**: `am29f400bb` or `am29f400bt` (512 KB, bottom or top boot block) |
154
+ | `image`, `offset`, `fill`, `mask` | as for `rom`; the size is the chip's |
155
+ | `bus_width` | 16 (default) or 8 |
156
+ | `program_us` | time to program a word; default 12 |
157
+ | `sector_erase_ms` | per sector; default 1000 |
158
+ | `chip_erase_ms` | default 8000 |
159
+
160
+ ### latch
161
+
162
+ An output register (such as a 74HC574): it keeps the last byte written,
163
+ which the debugger shows; reads return 0FFH, as from a write-only latch. The 5WY19's latch is the shadow byte the startup code writes
164
+ at 0A000H.
165
+
166
+ ### stub
167
+
168
+ Logged storage of `size` bytes (default 4 KB): accesses work as RAM and are
169
+ reported as unmodelled, so a run
170
+ shows what the firmware expects there.
171
+
172
+ ## Inputs and options
173
+
174
+ ```jsonc
175
+ "inputs": { "adc": { "1": "0x2A0", "4": 512 } }, // A/D channel: 10-bit value
176
+ "ssc": { "default_reply": "0xFFFF" }, // what an SSC transfer reads back
177
+ "options": {
178
+ "serial_echo": true, // ASC0 hears its own output, as on a K-line
179
+ "watchdog_frozen": false // the watchdog never times out
180
+ }
181
+ ```
182
+
183
+ Scripts and command-line options (`--adc`, `--freeze-watchdog`) still
184
+ change these after the board is built.
185
+
186
+ ## Writing a board for another ECU
187
+
188
+ Start from the chip's file in [boards/](../boards), copy it next to the
189
+ image, and add what the schematic or the firmware shows. `openc166-sim run
190
+ image.bin --board ./my-ecu.json` lists the SFRs and addresses the firmware
191
+ touches that nothing models, with the PC of the first access, which is
192
+ usually the quickest way to find the next device to describe.
@@ -31,7 +31,7 @@ Open the firmware program in the Debugger tool. In the launch menu choose
31
31
  | Option | Meaning |
32
32
  |---|---|
33
33
  | Image | the flash or ROM image: by default the program's own file |
34
- | Board | `5wy19`, `c167cs`, `c167` or `c166` |
34
+ | Board | a built-in board (`5wy19`, `c167cs`, `c167cr`, `c167`, `c166`) or the path of a [board file](boards.md) |
35
35
  | Symbols | optional: an export from `tools/ghidra/ExportOpenc166Symbols.py`, for frame names |
36
36
  | A/D inputs | `CH=VALUE` pairs; the 5WY19 resets itself unless channel 1 reads above 0C4H |
37
37
  | Boot mode | 5WY19: erase the application signature so the boot block runs |
@@ -68,7 +68,7 @@ also works.
68
68
  | 3 | CPU core, bus, snapshots | Done except the hardware oracle (below). The stock reset path passes all its self-tests: error word 0000H. |
69
69
  | 4 | Bootloader boots | Done, see "K-line and gkflasher" below. ASC0, CAPCOM and the ADC are modelled; gkflasher identifies the simulated ECU through `openc166-sim serve` (with the application; in boot mode the boot block refuses its memory read at gkflasher's security level, as a real ECU in boot mode would). |
70
70
  | 5 | Debug core and DAP | Done: breakpoints, watchpoints, stepping, reverse execution, DAP, Ghidra symbols. Keil-syntax conditions are not done (conditions are Python). |
71
- | 6 | Flash model and CAN | Not started; the flash is a read-only image and the CAN controllers are logged storage. |
71
+ | 6 | Flash model and CAN | Flash done: the 5WY19's Am29F400BB answers the AMD command set (program, erase, autoselect, status polling) on the virtual clock. CAN not started: the controllers are logged storage. |
72
72
  | 7 | Application runs | Mostly done. With the CAPCOM unit and the SSC stub the stock application runs its scheduler, services the watchdog and answers KWP2000 on the K-line; `gkflasher --id` identifies it through `openc166-sim serve`. GPT1/GPT2, PWM, CAN and the ports are still logged storage. |
73
73
  | 8 | Hardware snapshot | Not started. |
74
74
 
@@ -148,19 +148,22 @@ application, which:
148
148
 
149
149
  ## Boards
150
150
 
151
- `board=` takes:
151
+ A board file in JSON says which chip, which devices on which chip
152
+ selects, the reset configuration and the default inputs;
153
+ [boards.md](boards.md) describes the format. `board=` and `--board` take a
154
+ built-in board or the path of a file:
152
155
 
153
156
  - `5wy19`: C167CS-LM at 24 MHz (the firmware's baud-rate code divides
154
- 24000000; the design doc said 25); flash on CS0 seen at 0 and 80000H; RAM in
155
- the CS2 window; the 74HC574 latch in the CS3 window at 0A000H; XRAM1
156
- (0E000H, 2 KB) and XRAM2 (0C000H, 6 KB) and CAN1/CAN2 (0EF00H/0EE00H,
157
- logged storage) through XPERCON.
158
- - `c167cs`: the same CPU with the image as ROM on CS0.
159
- - `c167`, `c166`: a plain core with the image as ROM on CS0 (2 KB IRAM).
157
+ 24000000; the design doc said 25); an Am29F400BB flash on CS0, seen at 0
158
+ and 80000H, with its command set; RAM in the CS2 window; the 74HC574
159
+ latch in the CS3 window at 0A000H; XRAM1 (0E000H, 2 KB) and XRAM2
160
+ (0C000H, 6 KB) and CAN1/CAN2 (0EF00H/0EE00H, logged storage) through
161
+ XPERCON.
162
+ - `c167cs`, `c167cr`, `c167`, `c166`: the bare chip with the image as ROM
163
+ on CS0.
160
164
 
161
- Board definitions are C++ (`src/sim/boards.cpp`). Devices written in
162
- Python go on a chip select with `Simulator.attach()`; they are not part of
163
- snapshots, so reverse execution does not replay them.
165
+ Devices written in Python go on a chip select with `Simulator.attach()`;
166
+ they are not part of snapshots, so reverse execution does not replay them.
164
167
 
165
168
  ### Findings on the 5WY19
166
169
 
@@ -224,8 +227,9 @@ snapshots, so reverse execution does not replay them.
224
227
  and port P6 for the chip selects) or 0000H.
225
228
  - **A/D converter**: single, continuous and scan conversions of 10-bit
226
229
  values set from scripts (`set_adc`), 250 cycles each.
227
- - Not yet: GPT1/GPT2, PWM, CAN (logged storage), ports (logged storage),
228
- the flash command set.
230
+ - **Flash** on a chip select: the AMD command set, see
231
+ [boards.md](boards.md#flash).
232
+ - Not yet: GPT1/GPT2, PWM, CAN (logged storage), ports (logged storage).
229
233
 
230
234
  Host input to ASC0 is logged with its arrival cycle, so reverse execution
231
235
  replays it exactly. Loading a snapshot by hand, or sending new input after
@@ -351,10 +351,18 @@ OC166_API void oc166_free(void *p);
351
351
 
352
352
  typedef struct oc166_sim oc166_sim;
353
353
 
354
- /* A machine for 'board' ("5wy19", "c167cs", "c167" or "c166") with 'image'
355
- * as its flash or ROM (from address 0), with a debugger attached. Returns
356
- * NULL for an unknown board or if out of memory. */
354
+ /* A machine for 'board' with a debugger attached. 'board' is a built-in
355
+ * board ("5wy19", "c167cs", "c167cr", "c167", "c166"), the path of a board
356
+ * file (.json, see docs/boards.md) or a board file's JSON text; 'image' is
357
+ * what "$IMAGE" in it stands for (the flash or ROM contents). Returns NULL
358
+ * if the board cannot be built; oc166_sim_last_error() says why. */
357
359
  OC166_API oc166_sim *oc166_sim_new(const char *board, const uint8_t *image, size_t size);
360
+
361
+ /* Why the last oc166_sim_new() on this thread failed, or "". */
362
+ OC166_API const char *oc166_sim_last_error(void);
363
+
364
+ /* The built-in boards, separated by commas. */
365
+ OC166_API const char *oc166_sim_builtin_boards(void);
358
366
  OC166_API void oc166_sim_free(oc166_sim *s);
359
367
 
360
368
  /* Resets the machine: 0 power-on, 1 software (SRST), 2 watchdog, 3 hardware. */
@@ -189,6 +189,8 @@ _declare("oc166_sfr_address", _i64, _str)
189
189
  _declare("oc166_bit_address", _i64, _str, ctypes.POINTER(_int))
190
190
  _declare("oc166_sfr_name", _str, _u32)
191
191
  _declare("oc166_sim_new", _p, _str, _u8p, _size)
192
+ _declare("oc166_sim_last_error", _str)
193
+ _declare("oc166_sim_builtin_boards", _str)
192
194
  _declare("oc166_sim_free", None, _p)
193
195
  _declare("oc166_sim_reset", None, _p, _int)
194
196
  for _name in ("oc166_sim_step", "oc166_sim_reverse_step", "oc166_sim_reverse_continue"):
@@ -667,9 +667,8 @@ LAUNCHER = r"""#!/usr/bin/env bash
667
667
  #@menu-group openc166
668
668
  #@icon icon.debugger
669
669
  #@depends Debugger-rmi-trace
670
- #@enum Board:str 5wy19 c167cs c167 c166
671
670
  #@arg :file "Image" "Flash or ROM image (or an openc166 source, .a66)"
672
- #@env OPT_BOARD:Board="5wy19" "Board" "The simulated board"
671
+ #@env OPT_BOARD:str="5wy19" "Board" "A built-in board (5wy19, c167cs, c167cr, c167, c166) or the path of a board file (.json)"
673
672
  #@env OPT_PYTHON:file="{python}" "Python" "A Python with the openc166 package"
674
673
  #@env OPT_SYMBOLS:file="" "Symbols" "Optional: symbols exported with tools/ghidra/ExportOpenc166Symbols.py"
675
674
  #@env OPT_ADC:str="1=0x2A0" "A/D inputs" "Space-separated CH=VALUE pairs (the 5WY19 boot block wants channel 1 above 0C4H)"
@@ -729,7 +728,7 @@ def main(argv: Optional[List[str]] = None) -> int:
729
728
  p.add_argument("--install-launcher", metavar="GHIDRA_DIR",
730
729
  help="install the 'openc166 simulator' launcher into this Ghidra's user extensions and exit")
731
730
  p.add_argument("--extensions-dir", help="with --install-launcher: write the extension here instead")
732
- p.add_argument("--board", default="c167", choices=simmod.Simulator.BOARDS)
731
+ p.add_argument("--board", default="c167", help=simmod.BOARD_HELP)
733
732
  g = p.add_mutually_exclusive_group()
734
733
  g.add_argument("--connect", help="Ghidra's Trace RMI address host:port (default: $GHIDRA_TRACE_RMI_ADDR)")
735
734
  g.add_argument("--listen", help="wait for Ghidra to connect at [host:]port")
@@ -387,13 +387,16 @@ _WATCH_KINDS = {"read": 1, "write": 2, "rw": 3, "access": 3, "change": 4}
387
387
  class Simulator:
388
388
  """A simulated board with a debugger attached."""
389
389
 
390
- BOARDS = ("5wy19", "c167cs", "c167", "c166")
390
+ #: The built-in boards. A board can also be the path of a board file
391
+ #: (.json, see docs/boards.md) or a board file's JSON text.
392
+ BOARDS = tuple(_lib.oc166_sim_builtin_boards().decode("ascii").split(","))
391
393
 
392
394
  def __init__(self, image: bytes, board: str = "c167", symbols: Optional[Symbols] = None):
393
395
  buf = (ctypes.c_uint8 * max(len(image), 1)).from_buffer_copy(bytes(image) or b"\0")
394
- h = _lib.oc166_sim_new(board.lower().encode("ascii"), buf, len(image))
396
+ spec = os.fspath(board)
397
+ h = _lib.oc166_sim_new(spec.encode("utf-8"), buf, len(image))
395
398
  if not h:
396
- raise SimulatorError("cannot create board {!r} (known: {})".format(board, ", ".join(self.BOARDS)))
399
+ raise SimulatorError(_lib.oc166_sim_last_error().decode("utf-8", "replace") or "cannot create the board")
397
400
  self._h = h
398
401
  self.board = board
399
402
  self.symbols = symbols or Symbols()
@@ -863,6 +866,9 @@ def _int(text: str) -> int:
863
866
  return _addr(text) if not text.isdigit() else int(text)
864
867
 
865
868
 
869
+ BOARD_HELP = "a built-in board ({}) or a board file (.json)".format(", ".join(Simulator.BOARDS))
870
+
871
+
866
872
  def main(argv: Optional[List[str]] = None) -> int:
867
873
  """openc166-sim: disassemble images and run firmware headless."""
868
874
  import argparse
@@ -881,7 +887,7 @@ def main(argv: Optional[List[str]] = None) -> int:
881
887
 
882
888
  r = sub.add_parser("run", help="run firmware and report what it touched that is not modelled")
883
889
  r.add_argument("image")
884
- r.add_argument("--board", default="c167", choices=Simulator.BOARDS)
890
+ r.add_argument("--board", default="c167", help=BOARD_HELP)
885
891
  r.add_argument("--instructions", type=_int, default=1_000_000)
886
892
  r.add_argument("--break", dest="breaks", action="append", default=[], help="stop at an address or symbol")
887
893
  r.add_argument("--symbols", help="Ghidra export (JSON or CSV)")
@@ -890,7 +896,7 @@ def main(argv: Optional[List[str]] = None) -> int:
890
896
 
891
897
  sv = sub.add_parser("serve", help="serve the ECU's serial port (ASC0) over TCP for host tools")
892
898
  sv.add_argument("image")
893
- sv.add_argument("--board", default="5wy19", choices=Simulator.BOARDS)
899
+ sv.add_argument("--board", default="5wy19", help=BOARD_HELP)
894
900
  sv.add_argument("--port", type=int, default=5555)
895
901
  sv.add_argument("--host", default="127.0.0.1")
896
902
  sv.add_argument("--raw", action="store_true", help="plain TCP (socket://) instead of RFC 2217")
@@ -21,7 +21,12 @@ add_custom_command(
21
21
  VERBATIM)
22
22
 
23
23
  # Build the files in inc/ (assembler include files) into the library.
24
- set(_bundled ${PROJECT_SOURCE_DIR}/inc/REG167.INC)
24
+ set(_bundled ${PROJECT_SOURCE_DIR}/inc/REG167.INC
25
+ ${PROJECT_SOURCE_DIR}/boards/c166.json
26
+ ${PROJECT_SOURCE_DIR}/boards/c167.json
27
+ ${PROJECT_SOURCE_DIR}/boards/c167cr.json
28
+ ${PROJECT_SOURCE_DIR}/boards/c167cs.json
29
+ ${PROJECT_SOURCE_DIR}/boards/5wy19.json)
25
30
  set(_bundled_inc ${OPENC166_GENERATED_DIR}/openc166/bundled_files.inc)
26
31
  string(REPLACE ";" "|" _bundled_arg "${_bundled}")
27
32
  add_custom_command(
@@ -45,12 +50,14 @@ add_library(openc166_core STATIC
45
50
  disasm_module.cpp
46
51
  encode.cpp
47
52
  expr.cpp
53
+ json.cpp
48
54
  lexer.cpp
49
55
  m166.cpp
50
56
  mpl.cpp
51
57
  operand.cpp
52
58
  output.cpp
53
59
  predef.cpp
60
+ sim/board_config.cpp
54
61
  sim/boards.cpp
55
62
  sim/cpu.cpp
56
63
  sim/debug.cpp
@@ -4,6 +4,7 @@
4
4
  #include "openc166/openc166.h"
5
5
 
6
6
  #include "disasm.hpp"
7
+ #include "sim/board_config.hpp"
7
8
  #include "sim/boards.hpp"
8
9
  #include "sim/debug.hpp"
9
10
  #include "sim/peripherals.hpp"
@@ -146,14 +147,41 @@ const char* oc166_sfr_name(uint32_t address) {
146
147
  }
147
148
  }
148
149
 
150
+ namespace {
151
+ thread_local std::string sim_error;
152
+ }
153
+
154
+ const char* oc166_sim_last_error(void) { return sim_error.c_str(); }
155
+
156
+ const char* oc166_sim_builtin_boards(void) {
157
+ static const std::string names = [] {
158
+ std::string s;
159
+ for (const auto& b : builtin_boards()) s += (s.empty() ? "" : ",") + b;
160
+ return s;
161
+ }();
162
+ return names.c_str();
163
+ }
164
+
149
165
  oc166_sim* oc166_sim_new(const char* board, const uint8_t* image, size_t size) {
150
166
  try {
151
- if (!board || (!image && size)) return nullptr;
167
+ sim_error.clear();
168
+ if (!board || (!image && size)) {
169
+ sim_error = "no board given";
170
+ return nullptr;
171
+ }
152
172
  auto s = std::make_unique<oc166_sim>();
153
173
  std::vector<std::uint8_t> img(image, image + size);
154
- s->machine = std::make_unique<Machine>(board_by_name(board, std::move(img)));
174
+ BoardConfig cfg = load_board(board, std::move(img));
175
+ s->machine = std::make_unique<Machine>(std::move(cfg.board));
176
+ apply_board(*s->machine, cfg);
155
177
  s->debugger = std::make_unique<Debugger>(*s->machine);
156
178
  return s.release();
179
+ } catch (const std::exception& e) {
180
+ try {
181
+ sim_error = e.what();
182
+ } catch (...) {
183
+ }
184
+ return nullptr;
157
185
  } catch (...) {
158
186
  return nullptr;
159
187
  }