mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
hw_x86_64: Provide inb and outb functions for port I/O
The port_io.h file provides the inb and outb functions to perform port I/O operations.
This commit is contained in:
parent
1b3871a3f0
commit
b75b1902f2
27
repos/base-hw/src/core/include/spec/x86/port_io.h
Normal file
27
repos/base-hw/src/core/include/spec/x86/port_io.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef _PORT_IO_H_
|
||||
#define _PORT_IO_H_
|
||||
|
||||
#include <base/stdint.h>
|
||||
|
||||
namespace Genode
|
||||
{
|
||||
/**
|
||||
* Read byte from I/O port
|
||||
*/
|
||||
inline uint8_t inb(uint16_t port)
|
||||
{
|
||||
uint8_t res;
|
||||
asm volatile ("inb %w1, %0" : "=a"(res) : "Nd"(port));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write byte to I/O port
|
||||
*/
|
||||
inline void outb(uint16_t port, uint8_t val)
|
||||
{
|
||||
asm volatile ("outb %0, %w1" : : "a"(val), "Nd"(port));
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _PORT_IO_H_ */
|
Loading…
x
Reference in New Issue
Block a user