You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Carlos Fenollosa c8db77fea9
Lesson 18
9 years ago
..
boot Lesson 18 9 years ago
drivers lesson 15, video ports 10 years ago
kernel lesson 15, video ports 10 years ago
Makefile Lesson 18 9 years ago
README.md lesson 15, video ports 10 years ago

README.md

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.