Kernel: Add IO functions inl, outl, and ins{b,w,l} to read into buffer
This commit is contained in:
parent
80f9428337
commit
34f9912a1d
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
namespace IO
|
namespace IO
|
||||||
{
|
{
|
||||||
|
@ -29,6 +30,33 @@ namespace IO
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void outl(uint16_t port, uint32_t val)
|
||||||
|
{
|
||||||
|
asm volatile("outl %0, %1" : : "a"(val), "Nd"(port));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t inl(uint16_t port)
|
||||||
|
{
|
||||||
|
uint32_t ret;
|
||||||
|
asm volatile("inl %1, %0" : "=a"(ret) : "Nd"(port));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void insb(uint16_t port, uint8_t* buffer, size_t count)
|
||||||
|
{
|
||||||
|
asm volatile("rep insb" : "+D"(buffer), "+c"(count), "=m"(*buffer) : "Nd"(port) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void insw(uint16_t port, uint16_t* buffer, size_t count)
|
||||||
|
{
|
||||||
|
asm volatile("rep insw" : "+D"(buffer), "+c"(count), "=m"(*buffer) : "Nd"(port) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void insl(uint16_t port, uint32_t* buffer, size_t count)
|
||||||
|
{
|
||||||
|
asm volatile("rep insl" : "+D"(buffer), "+c"(count), "=m"(*buffer) : "Nd"(port) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
static inline void io_wait()
|
static inline void io_wait()
|
||||||
{
|
{
|
||||||
outb(0x80, 0);
|
outb(0x80, 0);
|
||||||
|
|
Loading…
Reference in New Issue