Xyris  0.5
ports.hpp
Go to the documentation of this file.
1 /**
2  * @file ports.hpp
3  * @author Keeton Feavel ([email protected])
4  * @brief Ports header file. Provides inline functions
5  * for getting and setting values at different ports.
6  * An I/O port is usually used as a technical term for
7  * a specific address on the x86's IO bus. This bus
8  * provides communication with devices in a fixed
9  * order and size, and was used as an alternative
10  * to memory access. (https://wiki.osdev.org/I/O_Ports)
11  * @version 0.3
12  * @date 2019-09-26
13  *
14  * @copyright Copyright Keeton Feavel (c) 2019
15  *
16  */
17 #pragma once
18 #include <stdint.h>
19 #include <Arch/i686/Arch.i686.hpp>
20 
21 /**
22  * @brief Reads a byte (8 bits) off the CPU bus at a given port address
23  *
24  * @param port Port address
25  * @return uint8_t Returned data byte
26  */
27 uint8_t readByte(uint16_t port);
28 
29 /**
30  * @brief Writes a byte (8 bits) to the CPU bus at a given port address
31  *
32  * @param port Port address
33  * @param data Byte to be written to the port
34  */
35 void writeByte(uint16_t port, uint8_t data);
36 
37 /**
38  * @brief Writes a byte (8 bits) slowly to the CPU bus at a given port address
39  *
40  * @param port Port address
41  * @param data Byte to be written to the port
42  */
43 void writeByteSlow(uint16_t port, uint8_t data);
44 
45 /**
46  * @brief Reads a word (16 bits) off the CPU bus at a given port address
47  *
48  * @param port Port address
49  * @return uint8_t Returned data word
50  */
51 uint16_t readWord(uint16_t port);
52 
53 /**
54  * @brief Writes a word (16 bits) to the CPU bus at a given port address
55  *
56  * @param port Port address
57  * @param data Word to be written to the port
58  */
59 void writeWord(uint16_t port, uint16_t data);
60 
61 /**
62  * @brief Reads a long (32 bits) off the CPU bus at a given port address
63  *
64  * @param port Port address
65  * @return uint8_t Returned data long
66  */
67 uint32_t readLong(uint16_t port);
68 
69 /**
70  * @brief Writes a long (32 bits) to the CPU bus at a given port address
71  *
72  * @param port Port address
73  * @param data Long to be written to the port
74  */
75 void writeLong(uint16_t port, uint32_t data);
writeLong
void writeLong(uint16_t port, uint32_t data)
Writes a long (32 bits) to the CPU bus at a given port address.
Definition: ports.cpp:43
readByte
uint8_t readByte(uint16_t port)
Reads a byte (8 bits) off the CPU bus at a given port address.
Definition: ports.cpp:13
writeByte
void writeByte(uint16_t port, uint8_t data)
Writes a byte (8 bits) to the CPU bus at a given port address.
Definition: ports.cpp:19
readLong
uint32_t readLong(uint16_t port)
Reads a long (32 bits) off the CPU bus at a given port address.
Definition: ports.cpp:37
readWord
uint16_t readWord(uint16_t port)
Reads a word (16 bits) off the CPU bus at a given port address.
Definition: ports.cpp:27
writeByteSlow
void writeByteSlow(uint16_t port, uint8_t data)
Writes a byte (8 bits) slowly to the CPU bus at a given port address.
Definition: ports.cpp:23
Arch.i686.hpp
i686 architecture implementation of Arch.hpp
writeWord
void writeWord(uint16_t port, uint16_t data)
Writes a word (16 bits) to the CPU bus at a given port address.
Definition: ports.cpp:33