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

tty.c: added a nop hint to nop_putc() so that post-processing can see… #271

Merged
merged 7 commits into from
Jul 17, 2020

Conversation

BrianGraysonSiV
Copy link
Contributor

@BrianGraysonSiV BrianGraysonSiV commented Jul 8, 2020

… the characters being output to the serial port.

With this change, a "customizable non-reserved NOP hint" instruction (slli x0, a0, 0x11) is used, with the character to be output in the specified register. This allows a post-processing tool to find occurrences of that instruction, grab the character value out of the register fields, and output the character.

A simple awk script suffices to parse the output files. Here's a one-liner version:
awk '/inst=.01151013/{printf "%c",strtonum("0x"substr($(NF-4),21,2));}' myfile

… the characters being output to the serial port
src/tty.c Outdated Show resolved Hide resolved
Copy link
Contributor

@nategraff-sifive nategraff-sifive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

src/tty.c Outdated Show resolved Hide resolved
@nick-knight
Copy link

Mentioning @ericlove @aswaterman who have both implemented this trick elsewhere.

Copy link

@nick-knight nick-knight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@BrianGraysonSiV 's original description mentions

A simple awk script like the one attached suffices to parse the output files.

but I didn't see any attachments. Actually, that's probably for the best, because the formatting of the "output files", if any, depends on the machine this is run on (perhaps a simulator).

src/tty.c Show resolved Hide resolved
@nategraff-sifive nategraff-sifive merged commit 1db2ff1 into master Jul 17, 2020
@nategraff-sifive nategraff-sifive deleted the fake_serial_port branch July 17, 2020 16:43
nategraff-sifive added a commit that referenced this pull request Jul 17, 2020
Port of #271 to Freedom Metal refactor work.

Allows standard out to be extracted from an instruction trace when no
other stdio method is available.

Signed-off-by: Nathaniel Graff <nathaniel.graff@sifive.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants