Skip to content

Commit

Permalink
Updated README for part13-interrupts
Browse files Browse the repository at this point in the history
  • Loading branch information
babbleberry committed Feb 6, 2024
1 parent 9566e13 commit e087746
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion part13-interrupts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The timers are set up using these calls:
```c
irq_init_vectors();
enable_interrupt_controller();
irq_barrier();
irq_enable();
timer_init();
```
Expand Down Expand Up @@ -77,7 +78,7 @@ In the middle we simply call a function called `handle_irq()` which is written i
void handle_irq() {
unsigned int irq = REGS_IRQ->irq0_pending_0;

while(irq) {
while(irq & (SYS_TIMER_IRQ_1 | SYS_TIMER_IRQ_3)) {
if (irq & SYS_TIMER_IRQ_1) {
irq &= ~SYS_TIMER_IRQ_1;

Expand Down Expand Up @@ -119,6 +120,8 @@ Masking is a technique used by the CPU to prevent a particular piece of code fro

The `irq_enable` and `irq_disable` functions in _utils.S_ are responsible for masking and unmasking interrupts:

They are helped by the `irq_barrier` function which ensures that the `enable_interrupt_controller()` call properly finishes before the `irq_enable()` call is made.

```c
.globl irq_enable
irq_enable:
Expand All @@ -129,6 +132,11 @@ irq_enable:
irq_disable:
msr daifset, #2
ret

.globl irq_barrier
irq_barrier:
dsb sy
ret
```

As soon as `irq_enable()` is called from `main()` in _kernel.c_, the timer handler is run when the timer interrupt fires. Well, sort of...!
Expand Down

0 comments on commit e087746

Please sign in to comment.