diff --git a/xtoskrnl/CMakeLists.txt b/xtoskrnl/CMakeLists.txt index 61c28b3..bab25a1 100644 --- a/xtoskrnl/CMakeLists.txt +++ b/xtoskrnl/CMakeLists.txt @@ -36,6 +36,7 @@ list(APPEND XTOSKRNL_SOURCE ${XTOSKRNL_SOURCE_DIR}/rtl/atomic.c ${XTOSKRNL_SOURCE_DIR}/rtl/byteswap.c ${XTOSKRNL_SOURCE_DIR}/rtl/intrin.c + ${XTOSKRNL_SOURCE_DIR}/rtl/ioreg.c ${XTOSKRNL_SOURCE_DIR}/rtl/memory.c ${XTOSKRNL_SOURCE_DIR}/rtl/plist.c ${XTOSKRNL_SOURCE_DIR}/rtl/string.c diff --git a/xtoskrnl/rtl/ioreg.c b/xtoskrnl/rtl/ioreg.c new file mode 100644 index 0000000..e03e495 --- /dev/null +++ b/xtoskrnl/rtl/ioreg.c @@ -0,0 +1,124 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtoskrnl/rtl/ioreg.c + * DESCRIPTION: I/O registers related routines + * DEVELOPERS: Rafal Kupiec + */ + +#include + + +/** + * Reads a byte from a specified register address. + * + * @param Register + * Supplies a pointer to register address holding data to read. + * + * @return This routine returns UCHAR byte read from the register. + * + * @since XT 1.0 + */ +XTAPI +UCHAR +RtlReadRegisterByte(IN VOLATILE PUCHAR Register) +{ + return *Register; +} + +/** + * Reads a byte from a specified register address. + * + * @param Register + * Supplies a pointer to register address holding data to read. + * + * @return This routine returns ULONG byte read from the register. + * + * @since XT 1.0 + */ +XTAPI +ULONG +RtlReadRegisterLong(IN VOLATILE PULONG Register) +{ + return *Register; +} + +/** + * Reads a byte from a specified register address. + * + * @param Register + * Supplies a pointer to register address holding data to read. + * + * @return This routine returns USHORT byte read from the register. + * + * @since XT 1.0 + */ +XTAPI +USHORT +RtlReadRegisterShort(IN VOLATILE PUSHORT Register) +{ + return *Register; +} + +/** + * Writes a byte into a specified register address. + * + * @param Register + * Supplies a pointer to register address where data will be written. + * + * @param Value + * Supplies a new UCHAR value that will be stored into a register. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +RtlWriteRegisterByte(IN PUSHORT Register, + IN UCHAR Value) +{ + HlIoPortOutByte((USHORT)(ULONG_PTR)Register, Value); +} + +/** + * Writes a byte into a specified register address. + * + * @param Register + * Supplies a pointer to register address where data will be written. + * + * @param Value + * Supplies a new ULONG value that will be stored into a register. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +RtlWriteRegisterLong(IN PUSHORT Register, + IN ULONG Value) +{ + HlIoPortOutLong((USHORT)(ULONG_PTR)Register, Value); +} + +/** + * Writes a byte into a specified register address. + * + * @param Register + * Supplies a pointer to register address where data will be written. + * + * @param Value + * Supplies a new USHORT value that will be stored into a register. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +RtlWriteRegisterShort(IN PUSHORT Register, + IN USHORT Value) +{ + HlIoPortOutShort((USHORT)(ULONG_PTR)Register, Value); +}