summaryrefslogtreecommitdiff
path: root/kernel/src/arch/i686/asm.c
diff options
context:
space:
mode:
authorTyler Murphy <=>2023-07-17 19:34:52 -0400
committerTyler Murphy <=>2023-07-17 19:34:52 -0400
commit7a912d1b668ab86ffe088eca3ac7e6f78a04a0c5 (patch)
tree4e86ff20e73171285156631db043e12aaf63bf04 /kernel/src/arch/i686/asm.c
parentpaging (diff)
downloadfinix-7a912d1b668ab86ffe088eca3ac7e6f78a04a0c5.tar.gz
finix-7a912d1b668ab86ffe088eca3ac7e6f78a04a0c5.tar.bz2
finix-7a912d1b668ab86ffe088eca3ac7e6f78a04a0c5.zip
refactoring
Diffstat (limited to 'kernel/src/arch/i686/asm.c')
-rw-r--r--kernel/src/arch/i686/asm.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/kernel/src/arch/i686/asm.c b/kernel/src/arch/i686/asm.c
new file mode 100644
index 0000000..8ed00d0
--- /dev/null
+++ b/kernel/src/arch/i686/asm.c
@@ -0,0 +1,51 @@
+#include <arch/i686/asm.h>
+
+uint8_t inb(uint16_t port) {
+ uint8_t ret;
+ __asm__ volatile ("inb %1, %0" : "=a"(ret) : "Nd"(port));
+ return ret;
+}
+
+void outb(uint16_t port, uint8_t val) {
+ __asm__ volatile ("outb %0, %1" : : "a"(val), "Nd"(port));
+}
+
+uint16_t inw(uint16_t port) {
+ uint16_t ret;
+ __asm__ volatile ("inw %1, %0" : "=a"(ret) : "Nd"(port));
+ return ret;
+}
+
+void outw(uint16_t port, uint16_t val) {
+ __asm__ volatile ("outw %0, %1" : : "a"(val), "Nd"(port));
+}
+
+uint32_t inl(uint16_t port) {
+ uint32_t ret;
+ __asm__ volatile ("inl %1, %0" : "=a"(ret) : "Nd"(port));
+ return ret;
+}
+
+void outl(uint16_t port, uint32_t val) {
+ __asm__ volatile ("outl %0, %1" : : "a"(val), "Nd"(port));
+}
+
+void io_wait(void) {
+ outb(0x80, 0);
+}
+
+void int_enable(void) {
+ __asm__ volatile ("sti");
+}
+
+void int_disable(void) {
+ __asm__ volatile ("cli");
+}
+
+void int_wait(void) {
+ __asm__ volatile ("sti; hlt");
+}
+
+void halt(void) {
+ __asm__ volatile ("cli; hlt");
+}