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

Clean up the usage of volatile in the lm32 firmware #267

Open
ssk1328 opened this issue Jul 4, 2016 · 0 comments
Open

Clean up the usage of volatile in the lm32 firmware #267

ssk1328 opened this issue Jul 4, 2016 · 0 comments

Comments

@ssk1328
Copy link
Contributor

ssk1328 commented Jul 4, 2016

In the current firmware, framebuffer is declared as a pointer to volatile unsigned int which is unnecessary at some places. In current firmware volatile is used in defining framebuffer pointer in hdmi_in, pattern and heartbeat files. We should clean up unnecessary usage of volatile in existing C firmware.

volatile definitions in hdmi_in0.c
volatile definitions in pattern.c
volatile definitions in heartbeat.c

volatile is a C directive used when we want out memory accesses to ordered as specified in the code sequence and not subject to possible reordering by compiler optimizations. We should declare framebuffer variable as volatile when the DMA can be writing to the framebuffer locations at the same time the CPU is accessing/writing to it. This ensures that the two reads from the same memory location are guaranteed to return the same value.

This is added as per discussion with @shenki and @mithro from irc logs here.
Reading material about memory ordering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants