Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First steps in adding Silicon Labs CIP-51 to the 8051 language files #7320

Closed
wants to merge 21 commits into from

Conversation

gtackett
Copy link
Contributor

@gtackett gtackett commented Dec 26, 2024

  • Added a variant called CIP-51 to 8051.ldefs, and for this variant specifically:
    • Added a commented-out compiler entry for Keil Cx51 compilers, to be un-commented out once cx51.cspec is complete
    • Pending possible removal of Archimedes C compiler entry, commented it out, Archimedes having been acquired over 20 years ago by Keil. (See 8051 language files trivia #5878)
  • In 8051_main.sinc added internal flash address space and expanded SFR address space, both conditionalized on CIP51,
  • Began work on cx51.cspec towards implementing Keil's Cx51 calling convention.

…h addrress space and extend SFR address space to two byte.

Conditionalized definition of SFR space so that CIP51 gets 2 bytes (Intel MCS51 uses 1 byte) and add IFLASH address space to CIP51.
Retains for now the 8051 "default" compiler, adding a "stub" (that is, commented-out) compiler definition for Keil Cx51 and commenting out (preparatory to eventually deleting) the line for the Archimedes compiler that Keil bought out and obsoleted.
@ryanmkurtz ryanmkurtz self-assigned this Jan 5, 2025
@ryanmkurtz ryanmkurtz added Status: Prioritize This is currently being prioritized Feature: Processor/8051 labels Jan 5, 2025
For CIP-51 follow convention of lower-case filenames
While I was at it, normalized indentation of "manualindexfile" items.
Abide by lowercase filename convention. Make the slafile name match the name of this variant. Make this version 1.0 of the cip-51 language.
Removed SFRs not in CIP-51, renamed several holdovers from 8051, added comment annotations to SFRs on Page 0 and on All Pages.
Still need to compare to what I have at home
@ryanmkurtz ryanmkurtz assigned emteere and unassigned ryanmkurtz Jan 16, 2025
@ryanmkurtz ryanmkurtz added Status: Triage Information is being gathered Status: Internal This is being tracked internally by the Ghidra team and removed Status: Prioritize This is currently being prioritized Status: Triage Information is being gathered labels Jan 16, 2025
@jobermayr
Copy link
Contributor

First certification.manifest must be updated:

+data/languages/cip-51.pspec||GHIDRA||||END|
+data/languages/keil-cx51.cspec||GHIDRA||||END|

Then it leads to a runtime error:
Validation error: Missing sleigh file:
.../Ghidra/Processors/8051/data/languages/cip-51.slaspec
which should be fixed with:

diff --git a/Ghidra/Processors/8051/data/languages/cip-51.slaspec b/Ghidra/Processors/8051/data/languages/cip-51.slaspec
new file mode 100644
index 0000000000..522a9f419d
--- /dev/null
+++ b/Ghidra/Processors/8051/data/languages/cip-51.slaspec
@@ -0,0 +1,3 @@
+@define CIP51  ""
+
+@include "8051_main.sinc"

But this leads to a build error:

Compiling ./data/languages/cip-51.slaspec:
unknown variable: GROUP1 at 8051_main.sinc:660(662): :ACALL  Addr11 is  $(GROUP1) & aaddrfill=1 & aoplo=1 & Addr11   { ret:2 = inst_next; push16(ret); call Addr11; }
Errors during preprocessing, halting compilation

Per github comment by @jobermayr, added cip-51.pspec and keil-cx51.cspec
Add CIP51 to conditional that determines definition of GROUP1, GROUP2, GROUP3
Need to add cip-51.slaspec as well
@jobermayr pointed out this missing file in original PR
@gtackett
Copy link
Contributor Author

First certification.manifest must be updated:

+data/languages/cip-51.pspec||GHIDRA||||END|
+data/languages/keil-cx51.cspec||GHIDRA||||END|

Then it leads to a runtime error: Validation error: Missing sleigh file: .../Ghidra/Processors/8051/data/languages/cip-51.slaspec which should be fixed with:

diff --git a/Ghidra/Processors/8051/data/languages/cip-51.slaspec b/Ghidra/Processors/8051/data/languages/cip-51.slaspec
new file mode 100644
index 0000000000..522a9f419d
--- /dev/null
+++ b/Ghidra/Processors/8051/data/languages/cip-51.slaspec
@@ -0,0 +1,3 @@
+@define CIP51  ""
+
+@include "8051_main.sinc"

But this leads to a build error:

Compiling ./data/languages/cip-51.slaspec:
unknown variable: GROUP1 at 8051_main.sinc:660(662): :ACALL  Addr11 is  $(GROUP1) & aaddrfill=1 & aoplo=1 & Addr11   { ret:2 = inst_next; push16(ret); call Addr11; }
Errors during preprocessing, halting compilation

Made changes via github.com that I believe should resolve these. Also added cip-51.slaspec tp certification.manifest.
However, I don't have a way to test with these changes while at work, and when I get home today, my time is probably spoken for.

I appreciate your input, @jobermayr

@jobermayr
Copy link
Contributor

New build error:

Compiling ./data/languages/cip-51.slaspec:
8051_main.sinc:517: unknown start, end, next2, operand, epsilon, or varnode 'ACC' in varnode reference
Unrecoverable error(s), halting compilation
java.lang.NullPointerException: Cannot invoke "ghidra.pcodeCPort.slghsymbol.SpecificSymbol.getVarnode()" because "ss" is null
        at ghidra.sleigh.grammar.SleighCompiler.varnode(SleighCompiler.java:9439)
        at ghidra.sleigh.grammar.SleighCompiler.export(SleighCompiler.java:7842)
        at ghidra.sleigh.grammar.SleighCompiler.statement(SleighCompiler.java:6153)
        at ghidra.sleigh.grammar.SleighCompiler.statements(SleighCompiler.java:5896)
        at ghidra.sleigh.grammar.SleighCompiler.code_block(SleighCompiler.java:5843)
        at ghidra.sleigh.grammar.SleighCompiler.semantic(SleighCompiler.java:5753)
        at ghidra.sleigh.grammar.SleighCompiler.ctorsemantic(SleighCompiler.java:3609)
        at ghidra.sleigh.grammar.SleighCompiler.constructor(SleighCompiler.java:3519)
        at ghidra.sleigh.grammar.SleighCompiler.constructorlike(SleighCompiler.java:3070)
        at ghidra.sleigh.grammar.SleighCompiler.root(SleighCompiler.java:486)
        at ghidra.pcodeCPort.slgh_compile.SleighCompile.run_compilation(SleighCompile.java:1854)
        at ghidra.pcodeCPort.slgh_compile.SleighCompileLauncher.runMain(SleighCompileLauncher.java:217)
        at ghidra.pcodeCPort.slgh_compile.SleighCompile.main(SleighCompile.java:1910)

@gtackett gtackett closed this Feb 5, 2025
@gtackett
Copy link
Contributor Author

gtackett commented Feb 5, 2025

I believe these changes have already been merged

@jobermayr
Copy link
Contributor

I believe these changes have already been merged

No: https://github.com/NationalSecurityAgency/ghidra/commits/master/Ghidra/Processors/8051

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Processor/8051 Status: Internal This is being tracked internally by the Ghidra team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants