8000 Add pine64 star64 platform by canarysnort01 · Pull Request #167 · seL4/util_libs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add pine64 star64 platform #167

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

canarysnort01
Copy link

This adds a timer and serial driver to libplatsupport.
Co-developed with @Ivan-Velickovic.

Purpose: Ready to merge.
Context: Needed to allow sel4test to run on star64.
Testing performed: Tested with WIP sel4test for the star64 platform on pinetab-v hardware.

@Ivan-Velickovic
Copy link
Contributor

It should be noted that due to there being no current documentation on the JH7110 timer, details such as the register map are taken from the JH7110 timer Linux kernel patch which can be found here: https://patchwork.kernel.org/project/linux-riscv/patch/20230627055313.252519-3-xingyu.wu@starfivetech.com/.

@axel-h
Copy link
Member
axel-h commented Aug 22, 2023

It looks good, could you squash the commits?

* Stores the number of times the continuous counter timer has elapsed and started over.
* This allows us to count to a higher number than allowed by the hardware.
*/
uint32_t value_h;
Copy link
Member

Choose a reason for hiding this comment

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

Should this be declared volatile also, as it could be access concurrently, and we also want to prevent the compiler from doing some optimization that would move the accesses around.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused, these drivers aren't multithreaded right? How could there be concurrent access?

Copy link
Member

Choose a reason for hiding this comment

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

Driver ware not multi-threaded, but they have an ISR that could interrupt us any time and update this value. Using volatile might not prevent the race completely, but could makes the windows even smaller.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite understand why volatile will help here, this is internal state that is just like a normal C variable?


/* Include unhandled interrupt in value_h */
if (timer->regs->intclr == 1) {
value_h += 1;
Copy link
Member
@axel-h axel-h Jan 5, 2024

Choose a reason for hiding this comment

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

Should we read timer->regs->value again now, as the interrupt may have arrived after we read it before?

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't that what line 68 is doing? I'm confused


/* the timer value counts down from the load value */
uint64_t value_l = (uint64_t)(STARFIVE_TIMER_MAX_TICKS - timer->regs->value);
uint64_t value_h = (uint64_t)timer->value_h;
Copy link
Member
@axel-h axel-h Jan 5, 2024

Choose a reason for hiding this comment

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

Do we have to take into account concurrency around timer->value_h here (in case the ISR updates it while we are here) ? So better read high, lo, and high again. If high it differs, read low again.

Copy link
Contributor

Choose a reason for hiding this comment

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

The time is always going to be changing because you have to consume time to read the register so would reading the registers again actually help?

canarysnort01 and others added 5 commits March 25, 2025 17:34
This adds a timer and serial driver to libplatsupport.

Co-developed-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
Signed-off-by: Jimmy Brush <code@jimmah.com>
The interrupt is enabled on init. Nothing needs to be done in the IRQ
handler as the next read will acknowledge the interrupt to the device.

Signed-off-by: Jimmy Brush <code@jimmah.com>
Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
@Ivan-Velickovic
685C Copy link
Contributor

I've tried to address all the comments now, hopefully we can merge this.

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

Successfully merging this pull request may close these issues.

3 participants
0