cfenollosa_os-tutorial/20-interrupts-timer
Hennik Hunsaker 7d932d43b3 Add Pandoc Support
- Add a Pandoc defaults file
- Add a Pandoc template based on the default one
- Add chapter headers to each section

### Usage

To use, install Pandoc and ConTeXt, then simply run
`pandoc -d ./pandoc.yaml` from the repo root.

### Maintenance

When new chapters get added, the `pandoc.yaml` will need to be updated
to include each new chapter's markdown file(s).

### Miscellaneous Notes

- The PDF generated complies with PDF/A 1b:2005 by default.
- The PDF also contains the source markdown files as attachments
- All links are fully functional!
- Includes a table of contents! With links to each section!

### Conclusion

Enjoy!
2023-09-05 01:46:32 -06:00
..
cpu lesson 20 finished: timer + keyboard 2015-03-20 16:42:19 +01:00
drivers lesson 21, keyboard input and shell 2015-03-20 19:20:44 +01:00
kernel lesson 20 finished: timer + keyboard 2015-03-20 16:42:19 +01:00
boot lesson 20, preliminar 2015-03-17 20:47:43 +01:00
Makefile Fixed warnings 2015-03-23 16:08:34 +01:00
README.md Add Pandoc Support 2023-09-05 01:46:32 -06:00

Interrupts: Timer

Concepts you may want to Google beforehand: CPU timer, keyboard interrupts, scancode

Goal: Implement our first IRQ handlers: the CPU timer and the keyboard

Everything is now ready to test our hardware interrupts.

Timer

The timer is easy to configure. First we'll declare an init_timer() on cpu/timer.h and implement it on cpu/timer.c. It is just a matter of computing the clock frequency and sending the bytes to the appropriate ports.

We will now fix kernel/utils.c int_to_ascii() to print the numbers in the correct order. For that, we need to implement reverse() and strlen().

Finally, go back to the kernel/kernel.c and do two things. Enable interrupts again (very important!) and then initialize the timer interrupt.

Go make run and you'll see the clock ticking!

Keyboard

The keyboard is even easier, with a drawback. The PIC does not send us the ASCII code for the pressed key, but the scancode for the key-down and the key-up events, so we will need to translate those.

Check out drivers/keyboard.c where there are two functions: the callback and the initialization which configures the interrupt callback. A new keyboard.h was created with the definitions.

keyboard.c also has a long table to translate scancodes to ASCII keys. For the time being, we will only implement a simple subset of the US keyboard. You can read more about scancodes here

I don't know about you, but I'm thrilled! We are very close to building a simple shell. In the next chapter, we will expand a little bit on keyboard input