diff --git a/sdk/xtdk/amd64/hlfuncs.h b/sdk/xtdk/amd64/hlfuncs.h index 2029c81..a86cd35 100644 --- a/sdk/xtdk/amd64/hlfuncs.h +++ b/sdk/xtdk/amd64/hlfuncs.h @@ -34,11 +34,29 @@ XTCDECL UCHAR HlIoPortInByte(IN USHORT Port); +XTCDECL +UCHAR +HlIoPortInShort(IN USHORT Port); + +XTCDECL +UCHAR +HlIoPortInLong(IN USHORT Port); + XTCDECL VOID HlIoPortOutByte(IN USHORT Port, IN UCHAR Data); +XTCDECL +VOID +HlIoPortOutShort(IN USHORT Port, + IN USHORT Value); + +XTCDECL +VOID +HlIoPortOutLong(IN USHORT Port, + IN UINT Value); + XTCDECL ULONG_PTR HlReadControlRegister(IN USHORT ControlRegister); diff --git a/sdk/xtdk/i686/hlfuncs.h b/sdk/xtdk/i686/hlfuncs.h index 25dd59c..b50a543 100644 --- a/sdk/xtdk/i686/hlfuncs.h +++ b/sdk/xtdk/i686/hlfuncs.h @@ -34,11 +34,29 @@ XTCDECL UCHAR HlIoPortInByte(IN USHORT Port); +XTCDECL +UCHAR +HlIoPortInShort(IN USHORT Port); + +XTCDECL +UCHAR +HlIoPortInLong(IN USHORT Port); + XTCDECL VOID HlIoPortOutByte(IN USHORT Port, IN UCHAR Data); +XTCDECL +VOID +HlIoPortOutShort(IN USHORT Port, + IN USHORT Value); + +XTCDECL +VOID +HlIoPortOutLong(IN USHORT Port, + IN UINT Value); + XTCDECL ULONG_PTR HlReadControlRegister(IN USHORT ControlRegister); diff --git a/xtoskrnl/hl/amd64/cpufunc.c b/xtoskrnl/hl/amd64/cpufunc.c index 72626f9..07f611e 100644 --- a/xtoskrnl/hl/amd64/cpufunc.c +++ b/xtoskrnl/hl/amd64/cpufunc.c @@ -83,10 +83,10 @@ HlHalt() } /** - * Reads the data from the specified I/O port. + * Reads the 8-bit data from the specified I/O port. * * @param Port - * Specifies the port number in the range of 0-0xFFFF. + * Specifies the address to read from, in the range of 0-0xFFFF. * * @return The value read from the port. * @@ -104,10 +104,52 @@ HlIoPortInByte(IN USHORT Port) } /** - * Writes the data to the specified I/O port. + * Reads the 16-bit data from the specified I/O port. * * @param Port - * Specifies the port number in the range of 0-0xFFFF. + * Specifies the address to read from, in the range of 0-0xFFFF. + * + * @return The value read from the port. + * + * @since XT 1.0 + */ +XTCDECL +UCHAR +HlIoPortInShort(IN USHORT Port) +{ + UCHAR Value; + asm volatile("inw %1, %0" + : "=a"(Value) + : "Nd"(Port)); + return Value; +} + +/** + * Reads the 32-bit data from the specified I/O port. + * + * @param Port + * Specifies the address to read from, in the range of 0-0xFFFF. + * + * @return The value read from the port. + * + * @since XT 1.0 + */ +XTCDECL +UCHAR +HlIoPortInLong(IN USHORT Port) +{ + UCHAR Value; + asm volatile("inl %1, %0" + : "=a"(Value) + : "Nd"(Port)); + return Value; +} + +/** + * Writes the 8-bit data to the specified I/O port. + * + * @param Port + * Specifies the address to write to, in the range of 0-0xFFFF. * * @param Value * Supplies the value to write. @@ -127,6 +169,54 @@ HlIoPortOutByte(IN USHORT Port, "Nd"(Port)); } +/** + * Writes the 16-bit data to the specified I/O port. + * + * @param Port + * Specifies the address to write to, in the range of 0-0xFFFF. + * + * @param Value + * Supplies the value to write. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +HlIoPortOutShort(IN USHORT Port, + IN USHORT Value) +{ + asm volatile("outw %0, %1" + : + : "a"(Value), + "Nd"(Port)); +} + +/** + * Writes the 32-bit data to the specified I/O port. + * + * @param Port + * Specifies the address to write to, in the range of 0-0xFFFF. + * + * @param Value + * Supplies the value to write. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +HlIoPortOutLong(IN USHORT Port, + IN UINT Value) +{ + asm volatile("outl %0, %1" + : + : "a"(Value), + "Nd"(Port)); +} + /** * Reads the specified CPU control register and returns its value. * diff --git a/xtoskrnl/hl/i686/cpufunc.c b/xtoskrnl/hl/i686/cpufunc.c index ebf56ea..b8317ea 100644 --- a/xtoskrnl/hl/i686/cpufunc.c +++ b/xtoskrnl/hl/i686/cpufunc.c @@ -83,10 +83,10 @@ HlHalt() } /** - * Reads the data from the specified I/O port. + * Reads the 8-bit data from the specified I/O port. * * @param Port - * Specifies the port number in the range of 0-0xFFFF. + * Specifies the address to read from, in the range of 0-0xFFFF. * * @return The value read from the port. * @@ -104,10 +104,52 @@ HlIoPortInByte(IN USHORT Port) } /** - * Writes the data to the specified I/O port. + * Reads the 16-bit data from the specified I/O port. * * @param Port - * Specifies the port number in the range of 0-0xFFFF. + * Specifies the address to read from, in the range of 0-0xFFFF. + * + * @return The value read from the port. + * + * @since XT 1.0 + */ +XTCDECL +UCHAR +HlIoPortInShort(IN USHORT Port) +{ + UCHAR Value; + asm volatile("inw %1, %0" + : "=a"(Value) + : "Nd"(Port)); + return Value; +} + +/** + * Reads the 32-bit data from the specified I/O port. + * + * @param Port + * Specifies the address to read from, in the range of 0-0xFFFF. + * + * @return The value read from the port. + * + * @since XT 1.0 + */ +XTCDECL +UCHAR +HlIoPortInLong(IN USHORT Port) +{ + UCHAR Value; + asm volatile("inl %1, %0" + : "=a"(Value) + : "Nd"(Port)); + return Value; +} + +/** + * Writes the 8-bit data to the specified I/O port. + * + * @param Port + * Specifies the address to write to, in the range of 0-0xFFFF. * * @param Value * Supplies the value to write. @@ -127,6 +169,54 @@ HlIoPortOutByte(IN USHORT Port, "Nd"(Port)); } +/** + * Writes the 16-bit data to the specified I/O port. + * + * @param Port + * Specifies the address to write to, in the range of 0-0xFFFF. + * + * @param Value + * Supplies the value to write. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +HlIoPortOutShort(IN USHORT Port, + IN USHORT Value) +{ + asm volatile("outw %0, %1" + : + : "a"(Value), + "Nd"(Port)); +} + +/** + * Writes the 32-bit data to the specified I/O port. + * + * @param Port + * Specifies the address to write to, in the range of 0-0xFFFF. + * + * @param Value + * Supplies the value to write. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +HlIoPortOutLong(IN USHORT Port, + IN UINT Value) +{ + asm volatile("outl %0, %1" + : + : "a"(Value), + "Nd"(Port)); +} + /** * Reads the specified CPU control register and returns its value. *