diff --git a/drivers/input/i8042prt/CMakeLists.txt b/drivers/input/i8042prt/CMakeLists.txt index 2e8c6ee9ab0..808367f0690 100644 --- a/drivers/input/i8042prt/CMakeLists.txt +++ b/drivers/input/i8042prt/CMakeLists.txt @@ -1,4 +1,7 @@ +include_directories( + ${REACTOS_SOURCE_DIR}/sdk/lib/dmilib) + list(APPEND SOURCE createclose.c hwhacks.c @@ -18,6 +21,7 @@ add_library(i8042prt SHARED i8042prt.rc) set_module_type(i8042prt kernelmodedriver) +target_link_libraries(i8042prt dmilib) add_importlibs(i8042prt ntoskrnl hal) add_pch(i8042prt i8042prt.h SOURCE) add_cd_file(TARGET i8042prt DESTINATION reactos/system32/drivers NO_CAB FOR all) diff --git a/drivers/input/i8042prt/hwhacks.c b/drivers/input/i8042prt/hwhacks.c index 885f0a25a54..d6d81f20aae 100644 --- a/drivers/input/i8042prt/hwhacks.c +++ b/drivers/input/i8042prt/hwhacks.c @@ -12,7 +12,7 @@ #include #include #include -#include "dmi.h" +#include #define NDEBUG #include @@ -21,25 +21,6 @@ const GUID MSSmBios_RawSMBiosTables_GUID = SMBIOS_DATA_GUID; PVOID i8042SMBiosTables; ULONG i8042HwFlags; -enum _ID_STRINGS -{ - ID_NONE = 0, - BIOS_VENDOR, - BIOS_VERSION, - BIOS_DATE, - SYS_VENDOR, - SYS_PRODUCT, - SYS_VERSION, - SYS_SERIAL, - BOARD_VENDOR, - BOARD_NAME, - BOARD_VERSION, - BOARD_SERIAL, - BOARD_ASSET_TAG, - - ID_STRINGS_MAX, -}; - typedef struct _MATCHENTRY { ULONG Type; @@ -75,110 +56,16 @@ const HARDWARE_TABLE i8042HardwareTable[] = -static -PCHAR -GetDmiString( - _In_ PDMI_HEADER Header, - _In_ ULONG FieldOffset) -{ - ULONG StringIndex; - PCHAR String; - - StringIndex = ((PUCHAR)Header)[FieldOffset]; - if (StringIndex == 0) - { - return NULL; - } - - String = (PCHAR)Header + Header->Length; - - while (--StringIndex != 0) - { - while (*String != 0) - String++; - - String++; - } - - return String; -} - - static VOID i8042ParseSMBiosTables( _In_reads_bytes_(TableSize) PVOID SMBiosTables, _In_ ULONG TableSize) { - PMSSmBios_RawSMBiosTables BiosTablesHeader = SMBiosTables; - PDMI_HEADER Header; - ULONG Remaining, i, j; - PCHAR Data; + ULONG i, j; PCHAR Strings[ID_STRINGS_MAX] = { 0 }; - Header = (PDMI_HEADER)(&BiosTablesHeader->SMBiosData); - Remaining = BiosTablesHeader->Size; - - while (Remaining >= sizeof(*Header)) - { - - if (Header->Type == DMI_ENTRY_END_OF_TABLE) - break; - - switch (Header->Type) - { - case DMI_ENTRY_BIOS: - if (Remaining < DMI_BIOS_SIZE) - return; - Strings[BIOS_VENDOR] = GetDmiString(Header, DMI_BIOS_VENDOR); - Strings[BIOS_VERSION] = GetDmiString(Header, DMI_BIOS_VERSION); - Strings[BIOS_DATE] = GetDmiString(Header, DMI_BIOS_DATE); - break; - - case DMI_ENTRY_SYSTEM: - if (Remaining < DMI_SYS_SIZE) - return; - Strings[SYS_VENDOR] = GetDmiString(Header, DMI_SYS_VENDOR); - Strings[SYS_PRODUCT] = GetDmiString(Header, DMI_SYS_PRODUCT); - Strings[SYS_VERSION] = GetDmiString(Header, DMI_SYS_VERSION); - Strings[SYS_SERIAL] = GetDmiString(Header, DMI_SYS_SERIAL); - break; - - case DMI_ENTRY_BASEBOARD: - if (Remaining < DMI_BOARD_SIZE) - return; - Strings[BOARD_VENDOR] = GetDmiString(Header, DMI_BOARD_VENDOR); - Strings[BOARD_NAME] = GetDmiString(Header, DMI_BOARD_NAME); - Strings[BOARD_VERSION] = GetDmiString(Header, DMI_BOARD_VERSION); - Strings[BOARD_SERIAL] = GetDmiString(Header, DMI_BOARD_SERIAL); - Strings[BOARD_ASSET_TAG] = GetDmiString(Header, DMI_BOARD_ASSET_TAG); - break; - - case DMI_ENTRY_CHASSIS: - case DMI_ENTRY_ONBOARD_DEVICE: - case DMI_ENTRY_OEMSTRINGS: - // DMI_ENTRY_IPMI_DEV? - // DMI_ENTRY_ONBOARD_DEV_EXT? - break; - } - - Remaining -= Header->Length; - Data = (PCHAR)Header + Header->Length; - - /* Now loop until we find 2 zeroes */ - while ((Remaining >= 2) && ((Data[0] != 0) || (Data[1] != 0))) - { - Data++; - Remaining--; - } - - if (Remaining < 2) - break; - - /* Go to the next header */ - Remaining -= 2; - Header = (PDMI_HEADER)((PUCHAR)Data + 2); - } + ParseSMBiosTables(SMBiosTables, TableSize, Strings); #if 0 // DBG DbgPrint("i8042prt: Dumping DMI data:\n"); diff --git a/sdk/lib/CMakeLists.txt b/sdk/lib/CMakeLists.txt index 700a332f300..99c68493aa2 100644 --- a/sdk/lib/CMakeLists.txt +++ b/sdk/lib/CMakeLists.txt @@ -18,6 +18,7 @@ if(MSVC) endif() add_subdirectory(delayimp) +add_subdirectory(dmilib) #add_subdirectory(dnslib) Nothing links to this lib. add_subdirectory(drivers) add_subdirectory(dxguid) diff --git a/sdk/lib/dmilib/CMakeLists.txt b/sdk/lib/dmilib/CMakeLists.txt new file mode 100644 index 00000000000..a3ad96ca00f --- /dev/null +++ b/sdk/lib/dmilib/CMakeLists.txt @@ -0,0 +1,8 @@ + +list(APPEND SOURCE + dmilib.c + precomp.h) + +add_library(dmilib ${SOURCE}) +add_pch(dmilib precomp.h SOURCE) +add_dependencies(dmilib psdk) diff --git a/drivers/input/i8042prt/dmi.h b/sdk/lib/dmilib/dmi.h similarity index 91% rename from drivers/input/i8042prt/dmi.h rename to sdk/lib/dmilib/dmi.h index ba562e50a33..855b69703ea 100644 --- a/drivers/input/i8042prt/dmi.h +++ b/sdk/lib/dmilib/dmi.h @@ -1,3 +1,10 @@ +/* + * PROJECT: ReactOS DMI/SMBIOS Library + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dmi.h + * PURPOSE: SMBIOS table parsing functions + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org) + */ #pragma once diff --git a/sdk/lib/dmilib/dmilib.c b/sdk/lib/dmilib/dmilib.c new file mode 100644 index 00000000000..7571fcaf71b --- /dev/null +++ b/sdk/lib/dmilib/dmilib.c @@ -0,0 +1,113 @@ +/* + * PROJECT: ReactOS DMI/SMBIOS Library + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dmilib.c + * PURPOSE: SMBIOS table parsing functions + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org) + * REFERENCES: http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf + */ + +#include "precomp.h" + +static +PCHAR +GetDmiString( + _In_ PDMI_HEADER Header, + _In_ ULONG FieldOffset) +{ + ULONG StringIndex; + PCHAR String; + + StringIndex = ((PUCHAR)Header)[FieldOffset]; + if (StringIndex == 0) + { + return NULL; + } + + String = (PCHAR)Header + Header->Length; + + while (--StringIndex != 0) + { + while (*String != 0) + String++; + + String++; + } + + return String; +} + +VOID +ParseSMBiosTables( + _In_reads_bytes_(TableSize) PVOID SMBiosTables, + _In_ ULONG TableSize, + _Inout_updates_(ID_STRINGS_MAX) PCHAR * Strings) +{ + PMSSmBios_RawSMBiosTables BiosTablesHeader = SMBiosTables; + PDMI_HEADER Header; + ULONG Remaining; + PCHAR Data; + + Header = (PDMI_HEADER)(&BiosTablesHeader->SMBiosData); + Remaining = BiosTablesHeader->Size; + + while (Remaining >= sizeof(*Header)) + { + if (Header->Type == DMI_ENTRY_END_OF_TABLE) + break; + + switch (Header->Type) + { + case DMI_ENTRY_BIOS: + if (Remaining < DMI_BIOS_SIZE) + return; + Strings[BIOS_VENDOR] = GetDmiString(Header, DMI_BIOS_VENDOR); + Strings[BIOS_VERSION] = GetDmiString(Header, DMI_BIOS_VERSION); + Strings[BIOS_DATE] = GetDmiString(Header, DMI_BIOS_DATE); + break; + + case DMI_ENTRY_SYSTEM: + if (Remaining < DMI_SYS_SIZE) + return; + Strings[SYS_VENDOR] = GetDmiString(Header, DMI_SYS_VENDOR); + Strings[SYS_PRODUCT] = GetDmiString(Header, DMI_SYS_PRODUCT); + Strings[SYS_VERSION] = GetDmiString(Header, DMI_SYS_VERSION); + Strings[SYS_SERIAL] = GetDmiString(Header, DMI_SYS_SERIAL); + break; + + case DMI_ENTRY_BASEBOARD: + if (Remaining < DMI_BOARD_SIZE) + return; + Strings[BOARD_VENDOR] = GetDmiString(Header, DMI_BOARD_VENDOR); + Strings[BOARD_NAME] = GetDmiString(Header, DMI_BOARD_NAME); + Strings[BOARD_VERSION] = GetDmiString(Header, DMI_BOARD_VERSION); + Strings[BOARD_SERIAL] = GetDmiString(Header, DMI_BOARD_SERIAL); + Strings[BOARD_ASSET_TAG] = GetDmiString(Header, DMI_BOARD_ASSET_TAG); + break; + + case DMI_ENTRY_CHASSIS: + case DMI_ENTRY_ONBOARD_DEVICE: + case DMI_ENTRY_OEMSTRINGS: + // DMI_ENTRY_IPMI_DEV? + // DMI_ENTRY_ONBOARD_DEV_EXT? + break; + } + + Remaining -= Header->Length; + Data = (PCHAR)Header + Header->Length; + + /* Now loop until we find 2 zeroes */ + while ((Remaining >= 2) && ((Data[0] != 0) || (Data[1] != 0))) + { + Data++; + Remaining--; + } + + if (Remaining < 2) + break; + + /* Go to the next header */ + Remaining -= 2; + Header = (PDMI_HEADER)((PUCHAR)Data + 2); + } +} diff --git a/sdk/lib/dmilib/dmilib.h b/sdk/lib/dmilib/dmilib.h new file mode 100644 index 00000000000..22f2331725d --- /dev/null +++ b/sdk/lib/dmilib/dmilib.h @@ -0,0 +1,34 @@ +/* + * PROJECT: ReactOS DMI/SMBIOS Library + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dmilib.h + * PURPOSE: SMBIOS table parsing functions + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org) + */ + +#pragma once + +enum _ID_STRINGS +{ + ID_NONE = 0, + BIOS_VENDOR, + BIOS_VERSION, + BIOS_DATE, + SYS_VENDOR, + SYS_PRODUCT, + SYS_VERSION, + SYS_SERIAL, + BOARD_VENDOR, + BOARD_NAME, + BOARD_VERSION, + BOARD_SERIAL, + BOARD_ASSET_TAG, + + ID_STRINGS_MAX, +}; + +VOID +ParseSMBiosTables( + _In_reads_bytes_(TableSize) PVOID SMBiosTables, + _In_ ULONG TableSize, + _Inout_updates_(ID_STRINGS_MAX) PCHAR * Strings); diff --git a/sdk/lib/dmilib/precomp.h b/sdk/lib/dmilib/precomp.h new file mode 100644 index 00000000000..550611e4fcb --- /dev/null +++ b/sdk/lib/dmilib/precomp.h @@ -0,0 +1,9 @@ +#ifndef _DMILIB_PCH_ +#define _DMILIB_PCH_ + +#include +#include +#include "dmi.h" +#include "dmilib.h" + +#endif /* _DMILIB_PCH_ */