Xyris  0.5
ports.cpp File Reference
+ Include dependency graph for ports.cpp:

Go to the source code of this file.

Functions

uint8_t readByte (uint16_t port)
 
void writeByte (uint16_t port, uint8_t data)
 
void writeByteSlow (uint16_t port, uint8_t data)
 
uint16_t readWord (uint16_t port)
 
void writeWord (uint16_t port, uint16_t data)
 
uint32_t readLong (uint16_t port)
 
void writeLong (uint16_t port, uint32_t data)
 

Detailed Description

CPU port access functions.

Author
Keeton Feavel (keeto.nosp@m.nfea.nosp@m.vel@c.nosp@m.edar.nosp@m.ville.nosp@m..edu)
Version
0.3
Date
2020-06-30

Definition in file ports.cpp.

Function Documentation

◆ readByte()

uint8_t readByte ( uint16_t  port)

Reads a byte (8 bits) off the CPU bus at a given port address.

Parameters
portPort address
Returns
uint8_t Returned data byte

Definition at line 13 of file ports.cpp.

13  {
14  uint8_t result;
15  asm volatile("inb %1, %0" : "=a" (result) : "Nd" (port));
16  return result;
17 }
+ Here is the caller graph for this function:

◆ readLong()

uint32_t readLong ( uint16_t  port)

Reads a long (32 bits) off the CPU bus at a given port address.

Parameters
portPort address
Returns
uint8_t Returned data long

Definition at line 37 of file ports.cpp.

37  {
38  uint32_t result;
39  asm volatile("inl %1, %0" : "=a" (result) : "Nd" (port));
40  return result;
41 }

◆ readWord()

uint16_t readWord ( uint16_t  port)

Reads a word (16 bits) off the CPU bus at a given port address.

Parameters
portPort address
Returns
uint8_t Returned data word

Definition at line 27 of file ports.cpp.

27  {
28  uint16_t result;
29  asm volatile("inw %1, %0" : "=a" (result) : "Nd" (port));
30  return result;
31 }

◆ writeByte()

void writeByte ( uint16_t  port,
uint8_t  data 
)

Writes a byte (8 bits) to the CPU bus at a given port address.

Parameters
portPort address
dataByte to be written to the port

Definition at line 19 of file ports.cpp.

19  {
20  asm volatile("outb %0, %1" : : "a" (data), "Nd" (port));
21 }
+ Here is the caller graph for this function:

◆ writeByteSlow()

void writeByteSlow ( uint16_t  port,
uint8_t  data 
)

Writes a byte (8 bits) slowly to the CPU bus at a given port address.

Parameters
portPort address
dataByte to be written to the port

Definition at line 23 of file ports.cpp.

23  {
24  asm volatile("outb %0, %1\njmp 1f\n1: jmp 1f\n1:" : : "a" (data), "Nd" (port));
25 }

◆ writeLong()

void writeLong ( uint16_t  port,
uint32_t  data 
)

Writes a long (32 bits) to the CPU bus at a given port address.

Parameters
portPort address
dataLong to be written to the port

Definition at line 43 of file ports.cpp.

43  {
44  asm volatile("outl %0, %1" : : "a"(data), "Nd" (port));
45 }

◆ writeWord()

void writeWord ( uint16_t  port,
uint16_t  data 
)

Writes a word (16 bits) to the CPU bus at a given port address.

Parameters
portPort address
dataWord to be written to the port

Definition at line 33 of file ports.cpp.

33  {
34  asm volatile("outw %0, %1" : : "a" (data), "Nd" (port));
35 }