diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | mos/sys/Makefile | 7 | ||||
| -rw-r--r-- | mos/sys/arch/x86_64/Makefile | 7 | ||||
| -rw-r--r-- | mos/sys/arch/x86_64/bus/mainbus/pio.S | 45 | ||||
| -rw-r--r-- | mos/sys/inc/arch/x86_64/pio.h | 21 | ||||
| -rw-r--r-- | mos/sys/kern/Makefile | 5 |
6 files changed, 83 insertions, 3 deletions
@@ -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) |
