summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-12-21 17:28:02 -0500
committerIan Moffett <ian@osmora.org>2025-12-21 17:28:02 -0500
commit75bb6f4169a7df336888d5bb6b81bc79c4c831a2 (patch)
tree1f8668b91a8a21c653f196e2d3a3fb68521a0d11
parent1e2bf71bb692cc6f622f4c57181d0dd87eb66f7c (diff)
mos/x86_64: Add port I/O helpers + arch target dir
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--.gitignore1
-rw-r--r--mos/sys/Makefile7
-rw-r--r--mos/sys/arch/x86_64/Makefile7
-rw-r--r--mos/sys/arch/x86_64/bus/mainbus/pio.S45
-rw-r--r--mos/sys/inc/arch/x86_64/pio.h21
-rw-r--r--mos/sys/kern/Makefile5
6 files changed, 83 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 8d51278..d3110e7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,5 +12,6 @@
/cc
/Makefile
/mos/boot
+/mos/sys/target
/var/autom4te.cache
/var/configure
diff --git a/mos/sys/Makefile b/mos/sys/Makefile
index 47f70b7..aaa7f15 100644
--- a/mos/sys/Makefile
+++ b/mos/sys/Makefile
@@ -10,7 +10,7 @@ SYS_CFLAGS =
ARCH =
.PHONY: all
-all: kern arch
+all: target kern arch
.PHONY: kern
kern:
@@ -19,3 +19,8 @@ kern:
.PHONY: arch
arch:
cd arch/$(ARCH); make CC=$(CC) LD=$(LD) SYS_CFLAGS="$(SYS_CFLAGS)"
+
+.PHONY: target
+target:
+ mkdir -p target/inc/md/
+ rsync -avr inc/arch/$(ARCH)/* target/inc/md/
diff --git a/mos/sys/arch/x86_64/Makefile b/mos/sys/arch/x86_64/Makefile
index e7d352e..c28b067 100644
--- a/mos/sys/arch/x86_64/Makefile
+++ b/mos/sys/arch/x86_64/Makefile
@@ -11,6 +11,11 @@ CC =
LD =
SYS_CFLAGS =
+CFLAGS = \
+ -I ../../target/inc/ \
+ -I../../../../usr/sdk/inc/ \
+ $(SYS_CFLAGS)
+
LDFLAGS = -Tadmin/mos.lds
MOS_OUT = ../../sys.mos
@@ -19,4 +24,4 @@ all: $(ASMOFILES)
$(LD) $(LDFLAGS) $(MISC_OFILES) -o $(MOS_OUT)
%.S.o: %.S
- $(CC) $(SYS_CFLAGS) -c $< -o $@
+ $(CC) $(CFLAGS) -c $< -o $@
diff --git a/mos/sys/arch/x86_64/bus/mainbus/pio.S b/mos/sys/arch/x86_64/bus/mainbus/pio.S
new file mode 100644
index 0000000..2bc3a9a
--- /dev/null
+++ b/mos/sys/arch/x86_64/bus/mainbus/pio.S
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2025, Ian Moffett.
+ * Provided under the BSD-3 clause.
+ */
+ .text
+ .globl md_outb
+md_outb:
+ mov %rdi, %rdx
+ mov %rsi, %rax
+ outb %al, %dx
+ retq
+
+ .globl md_outw
+md_outw:
+ mov %rdi, %rdx
+ mov %rsi, %rax
+ outw %ax, %dx
+ retq
+
+ .globl md_outl
+md_outl:
+ mov %rdi, %rdx
+ mov %rsi, %rax
+ outl %eax, %dx
+
+ .globl md_inb
+md_inb:
+ mov %rdi, %rdx
+ xor %rax, %rax
+ inb %dx, %al
+ retq
+
+ .globl md_inw
+md_inw:
+ mov %rdi, %rdx
+ xor %rax, %rax
+ inw %dx, %ax
+ retq
+
+ .globl md_inl
+md_inl:
+ mov %rdi, %rdx
+ xor %rax, %rax
+ inl %dx, %eax
+ retq
diff --git a/mos/sys/inc/arch/x86_64/pio.h b/mos/sys/inc/arch/x86_64/pio.h
new file mode 100644
index 0000000..5520307
--- /dev/null
+++ b/mos/sys/inc/arch/x86_64/pio.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025, Ian Moffett.
+ * Provided under the BSD-3 clause.
+ */
+
+#ifndef _MACHINE_PIO_H_
+#define _MACHINE_PIO_H_ 1
+
+#include <sdk/types.h>
+
+/* PIO write helpers */
+void md_outb(USHORT port, UBYTE data);
+void md_outw(USHORT port, USHORT data);
+void md_outl(USHORT port, ULONG data);
+
+/* PIO read helpers */
+UBYTE md_inb(USHORT port);
+USHORT md_inw(USHORT port);
+ULONG md_inl(USHORT port);
+
+#endif /* !_MACHINE_PIO_H_ */
diff --git a/mos/sys/kern/Makefile b/mos/sys/kern/Makefile
index 1ee87c2..5abbf16 100644
--- a/mos/sys/kern/Makefile
+++ b/mos/sys/kern/Makefile
@@ -7,7 +7,10 @@ CFILES = $(shell find . -name "*.c")
OFILES = $(CFILES:.c=.o)
SYS_CFLAGS =
-CFLAGS = $(SYS_CFLAGS) -I../../../usr/sdk/inc/
+CFLAGS = \
+ $(SYS_CFLAGS) \
+ -I../../../usr/sdk/inc/ \
+ -I../target/inc/
.PHONY: all
all: $(OFILES)