Skip to content

Commit

Permalink
add screenshots and gif of hardware timer
Browse files Browse the repository at this point in the history
  • Loading branch information
acheronfail authored and phil-opp committed Oct 15, 2018
1 parent 1125cbc commit a08ba0b
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub mod interrupts;

// in src/interrupts.rs

use pic8259::ChainedPics;
use pic8259_simple::ChainedPics;
use spin;

pub const PIC_1_OFFSET: u8 = 32;
Expand Down Expand Up @@ -165,7 +165,7 @@ pub extern "C" fn _start() -> ! {

The `interrupts::enable` function of the `x86_64` crate executes the special `sti` instruction (“set interrupts”) to enable external interrupts. When we try `bootimage run` now, we see that a double fault occurs:

TODO screenshot
![QEMU printing `EXCEPTION: DOUBLE FAULT` because of hardware timer](qemu-hardware-timer-double-fault.png)

The reason for this double fault is that the hardware timer (the [Intel 8253] to be exact) is enabled by default, so we start receiving timer interrupts as soon as we enable interrupts. Since we didn't define a handler function for it yet, our double fault handler is invoked.

Expand Down Expand Up @@ -208,7 +208,7 @@ We introduce a `TIMER_INTERRUPT_ID` constant to keep things organized. Our `time

In our timer interrupt handler, we print a dot to the screen. As the timer interrupt happens periodically, we would expect to see a dot appearing on each timer tick. However, when we run it we see that only a single dot is printed:

TODO screenshot
![QEMU printing only a single dot for hardware timer](qemu-single-dot-printed.png)

### End of Interrupt

Expand All @@ -233,7 +233,7 @@ We need to be careful to use the correct interrupt vector number, otherwise we c

When we now execute `bootimage run` we see dots periodically appearing on the screen:

TODO screenshot gif
![QEMU printing consequtive dots showing the hardware timer](qemu-hardware-timer-dots.gif)

### Configuring The Timer

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub extern "C" fn _start() -> ! {

blog_os::gdt::init();
init_idt();

unsafe { PICS.lock().initialize() };
x86_64::instructions::interrupts::enable();

Expand Down

0 comments on commit a08ba0b

Please sign in to comment.