aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/io
diff options
context:
space:
mode:
authorMarvin Borner2019-09-21 18:07:07 +0200
committerMarvin Borner2019-09-21 18:07:07 +0200
commitc31d465a62fbc0ec3194838db4745585471c1050 (patch)
tree10e544bc856ea1898e39d6c9304f746aa1d74670 /src/kernel/io
parentd91024fb750356bad65cce5bdef206e530b37c53 (diff)
Added ACPI based shutdown command
Diffstat (limited to 'src/kernel/io')
-rw-r--r--src/kernel/io/io.c36
-rw-r--r--src/kernel/io/io.h12
2 files changed, 32 insertions, 16 deletions
diff --git a/src/kernel/io/io.c b/src/kernel/io/io.c
index 7bddb13..74776ee 100644
--- a/src/kernel/io/io.c
+++ b/src/kernel/io/io.c
@@ -1,21 +1,31 @@
#include <stdint.h>
-unsigned char receive(unsigned short port) {
+uint8_t receive_b(uint16_t port) {
unsigned char value;
- __asm__ __volatile__ ("inb %1, %0" : "=a" (value) : "dN" (port));
+ asm volatile ("inb %1, %0" : "=a"(value) : "Nd"(port));
return value;
}
-void send(unsigned short port, unsigned char data) {
- __asm__ __volatile__ ("outb %1, %0" : : "dN" (port), "a" (data));
+uint16_t receive_w(uint16_t port) {
+ unsigned char value;
+ asm volatile("inb %1,%0" : "=a"(value) : "Nd"(port)); // TODO: Fix inw error
+ return value;
+}
+
+uint32_t receive_l(uint16_t port) {
+ unsigned char value;
+ asm volatile ("inb %1, %0" : "=a"(value) : "Nd"(port));
+ return value;
}
-void reboot() {
- uint8_t good = 0x02;
- while (good & 0x02)
- good = receive(0x64);
- send(0x64, 0xFE);
- loop:
- asm volatile ("hlt");
- goto loop;
-} \ No newline at end of file
+void send_b(uint16_t port, uint8_t data) {
+ asm volatile ("outb %0, %1"::"a" (data), "Nd"(port));
+}
+
+void send_w(uint16_t port, uint16_t data) {
+ asm volatile ("outw %0, %1"::"a" (data), "Nd"(port));
+}
+
+void send_l(uint16_t port, uint32_t data) {
+ asm volatile ("outl %0, %1"::"a" (data), "Nd"(port));
+}
diff --git a/src/kernel/io/io.h b/src/kernel/io/io.h
index e00a5f0..22776ee 100644
--- a/src/kernel/io/io.h
+++ b/src/kernel/io/io.h
@@ -3,10 +3,16 @@
#include <stdint.h>
-unsigned char receive(unsigned short port);
+uint8_t receive_b(uint16_t port);
-void send(unsigned short port, unsigned char data);
+uint16_t receive_w(uint16_t port);
-void reboot();
+uint32_t receive_l(uint16_t port);
+
+void send_b(uint16_t port, uint8_t data);
+
+void send_w(uint16_t port, uint16_t data);
+
+void send_l(uint16_t port, uint32_t data);
#endif