cfenollosa_os-tutorial/15-video-ports
Carlos Fenollosa c8db77fea9 Lesson 18
2015-02-03 19:13:13 +01:00
..
boot Lesson 18 2015-02-03 19:13:13 +01:00
drivers lesson 15, video ports 2014-10-21 22:54:03 +02:00
kernel lesson 15, video ports 2014-10-21 22:54:03 +02:00
Makefile Lesson 18 2015-02-03 19:12:51 +01:00
README.md lesson 15, video ports 2014-10-21 22:54:03 +02:00

Concepts you may want to Google beforehand: I/O ports

Goal: Learn how to use the VGA card data ports

We will use C to communicate with devices via I/O registers and ports.

Open drivers/ports.c and examine the inline C assembler syntax. It has some differences, like the order of the source and destination operands, and the funny syntax to assign variables to operands.

When you understand the concepts, open kernel/kernel.c for an example of use.

In this example we will examine the I/O ports which map the screen cursor position. Specifically, we will query port 0x3d4 with value 14 to request the cursor position high byte, and the same port with 15 for the low byte.

When this port is queried, it saves the result in port 0x3d5

Don't miss the opportunity to use gdb to inspect the value of C variables, since we still can't print them on the screen. To do so, set a breakpoint for a specific line, breakpoint kernel.c:21 and use the print command to examine variables. Aren't you glad now that we invested some time in compiling the cross-compiled gdb? ;)

Finally, we will use the queried cursor position to write a character at that location.