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

[Lesson04] Raspberry Pi 4 interrupts not working after first call to timer_tick() #255

Closed
archaro opened this issue Jul 31, 2022 · 1 comment

Comments

@archaro
Copy link

archaro commented Jul 31, 2022

I followed the advice given in issue #237 and was able to get my project behaving properly on a pi4, with the timer ticking nicely.

However, I've run into an odd problem with the scheduler. Using most of the code from Lesson04 I have built a primitive scheduler in my project, and things are now behaving strangely. Here is some output with helpful debugging printf()s:

Current Exception Level is: 1
Enabling interrupt 97
EnableRegister: ff84110c
About to call enable_irq()...
Calling switch_to()...
1234512345123451234512In handle_irq()...
In timer_tick()....
About to call enable_irq()...
Calling switch_to()...
abcdeabcdeabcdeabcdeabcdeabcd[...]

As you can see, everything is just peachy until timer_tick() is called by the interrupt handler. Thereafter, it seems that even though interrupts are re-enabled, the interrupt handler never gets called again. My handle_irq() function is using the fix described by @maxstreitberger in issue #237, and my timer_tick() function and enable_irq() assembler function are identical to those in Lesson04.

I'm very confused!

@archaro
Copy link
Author

archaro commented Jul 31, 2022

Ah, the wisdom of the rubber duck.

In handle_interrupt(), I had:

  switch (irq) {
    case (SYSTEM_TIMER_IRQ_1):
      handle_timer_irq();
      put32(GICC_EOIR, irq_ack_reg);
      break;

and what I actually needed was:

  switch (irq) {
    case (SYSTEM_TIMER_IRQ_1):
      put32(GICC_EOIR, irq_ack_reg);
      handle_timer_irq();
      break;

Order matters!

@archaro archaro closed this as completed Jul 31, 2022
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

No branches or pull requests

1 participant