mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Add section about port I/O
This commit is contained in:
@@ -45,7 +45,13 @@ The chips implementing a serial interface are called [UARTs]. There are [lots of
|
||||
[16550 UART]: https://en.wikipedia.org/wiki/16550_UART
|
||||
|
||||
### Port I/O
|
||||
TODO
|
||||
There are two different approaches for communicating between the CPU and peripheral hardware on x86, **memory-mapped I/O** and **port-mapped I/O**. We already used memory-mapped I/O for accessing the [VGA text buffer] through the memory address `0xb8000`. This address is not mapped to RAM, but to some memory on the GPU.
|
||||
|
||||
[VGA text buffer]: ./second-edition/posts/03-vga-text-buffer/index.md
|
||||
|
||||
In contrast, port-mapped I/O uses a separate I/O bus for communication. Each connected peripheral has one or more port numbers. To communicate with such an I/O port there are special CPU instructions called `in` and `out`, which take a port number and a data byte (there are also variations of these commands that allow sending an `u16` or `u32`).
|
||||
|
||||
The UART uses port-mapped I/O. Fortunately there are already several crates that provide abstractions for I/O ports, so we don't need to invoke the `in` and `out` assembly commands manually.
|
||||
|
||||
### Implementation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user