diff --git a/paw/stos/Makefile b/paw/stos/Makefile index 7765b95..d793f93 100644 --- a/paw/stos/Makefile +++ b/paw/stos/Makefile @@ -10,7 +10,12 @@ include ../mk/stos.mk .PHONY: all -all: ke machine +all: target ke machine + +.PHONY: target +target: + mkdir -p target/machine/ + rsync -avr head/arch/$(ST_TARGET_ARCH)/*.h target/machine/ .PHONY: ke ke: diff --git a/paw/stos/head/arch/amd64/pio.h b/paw/stos/head/arch/amd64/pio.h new file mode 100644 index 0000000..c1e2b27 --- /dev/null +++ b/paw/stos/head/arch/amd64/pio.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2026, Chloe M. + * Provided under the BSD-3 clause. + * + * Description: Port I/O helpers + * Author: Chloe M. + */ + +#ifndef _MACHINE_PIO_H_ +#define _MACHINE_PIO_H_ 1 + +#include + +ALWAYS_INLINE static inline UCHAR +MdInb(USHORT Port) +{ + UCHAR result; + ASMV("in %%dx, %%al" : "=a" (result) : "d" (Port)); + return result; +} + +ALWAYS_INLINE static inline USHORT +MdInw(USHORT Port) +{ + USHORT Val; + ASMV("inw %w1, %w0" : "=a" (Val) : "Nd" (Port)); + return Val; +} + +ALWAYS_INLINE static inline ULONG +MdInl(USHORT Port) +{ + ULONG Val; + ASMV("inl %w1, %0" : "=a" (Val) : "Nd" (Port)); + return Val; +} + +ALWAYS_INLINE static inline VOID +MdOutb(USHORT Port, UCHAR Val) +{ + ASMV("out %%al, %%dx" : :"a" (Val), "d" (Port)); +} + +ALWAYS_INLINE static inline VOID +MdOutw(USHORT Port, USHORT Val) +{ + ASMV("outw %w0, %w1" : : "a" (Val), "Nd" (Port)); +} + +ALWAYS_INLINE static inline VOID +MdOutl(USHORT Port, ULONG Val) +{ + ASMV("outl %0, %w1" : : "a" (Val), "Nd" (Port)); +} + +#endif /* !_MACHINE_PIO_H_ */ diff --git a/paw/stos/ke/Makefile b/paw/stos/ke/Makefile index dcfa06f..e8151de 100644 --- a/paw/stos/ke/Makefile +++ b/paw/stos/ke/Makefile @@ -23,6 +23,7 @@ CFLAGS = \ -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T \ -DPRINTF_DISABLE_SUPPORT_FLOAT \ -I../head \ + -I../target \ -I$(ST_PROJECT_ROOT)/paw/spkg/head \ -I$(ST_PROJECT_ROOT)/sdk/head \ -D_BOOT_PROTO="\"$(ST_BOOT_PROTOCOL)\""