Skip to content

Commit

Permalink
Merge pull request #25 from PerryWerneck/develop
Browse files Browse the repository at this point in the history
Updating to latest version.
  • Loading branch information
PerryWerneck authored Aug 16, 2024
2 parents d8ec90b + 6e140cc commit d222948
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 13 deletions.
16 changes: 8 additions & 8 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ $(OBJRLS)/%.o: \

all: \
$(foreach TARGET, $(BUILD_TARGETS), $(BINRLS)/$(TARGET)) \
$(BINRLS)/libdmiget.static.a
$(BINRLS)/libdmiget.a

Release: \
$(foreach TARGET, $(BUILD_TARGETS), $(BINRLS)/$(TARGET))
Expand Down Expand Up @@ -229,7 +229,7 @@ $(BINRLS)/$(PYTHON_MODULE)@LIBEXT@: \
$(LIBS) \
@PYTHON_LIBS@

$(BINRLS)/libdmiget.static.a: \
$(BINRLS)/libdmiget.a: \
$(foreach SRC, $(basename $(LIBRARY_SOURCES)), $(OBJRLS)/$(SRC).o)

@$(MKDIR) $(@D)
Expand Down Expand Up @@ -304,7 +304,7 @@ install-windows-lib: \
$(DESTDIR)$(datarootdir)/$(PACKAGE_NAME)/def

install-devel: \
$(BINRLS)/libdmiget.static.a
$(BINRLS)/libdmiget.a

@$(MKDIR) \
$(DESTDIR)$(includedir)/$(PACKAGE_NAME)/smbios
Expand All @@ -315,16 +315,16 @@ install-devel: \

@mkdir -p $(DESTDIR)$(libdir)/pkgconfig
@$(INSTALL_DATA) \
dmiget.pc \
dynamic.pc \
$(DESTDIR)$(libdir)/pkgconfig/dmiget.pc

@$(INSTALL_DATA) \
dmiget.static.pc \
$(DESTDIR)$(libdir)/pkgconfig/dmiget.static.pc
static.pc \
$(DESTDIR)$(libdir)/pkgconfig/dmiget-static.pc

@$(INSTALL_DATA) \
$(BINRLS)/libdmiget.static.a \
$(DESTDIR)$(libdir)/libdmiget.static.a
$(BINRLS)/libdmiget.a \
$(DESTDIR)$(libdir)/libdmiget.a

#---[ Uninstall Targets ]----------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ dnl ---------------------------------------------------------------------------

dnl AC_CONFIG_FILES(doxygen/doxyfile)
AC_CONFIG_FILES(Makefile)
AC_CONFIG_FILES(dmiget.pc)
AC_CONFIG_FILES(dmiget.static.pc)
AC_CONFIG_FILES(dynamic.pc)
AC_CONFIG_FILES(static.pc)
AC_SUBST(BUILD_TARGETS)

dnl ---------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions dmiget.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<Unit filename="src/include/private/decoders/processor.h" />
<Unit filename="src/include/private/decoders/system.h" />
<Unit filename="src/include/private/decoders/tools.h" />
<Unit filename="src/include/private/decoders/tpm.h" />
<Unit filename="src/include/private/intl.h" />
<Unit filename="src/include/private/oemstring.h" />
<Unit filename="src/include/private/python.h" />
Expand All @@ -70,6 +71,7 @@
<Unit filename="src/libdmiget/decoders/system.cc" />
<Unit filename="src/libdmiget/decoders/table.cc" />
<Unit filename="src/libdmiget/decoders/tools.cc" />
<Unit filename="src/libdmiget/decoders/tpm.cc" />
<Unit filename="src/libdmiget/decoders/value.cc" />
<Unit filename="src/libdmiget/node/foreach.cc" />
<Unit filename="src/libdmiget/node/iterator.cc" />
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "smbios"
readme = ""
authors = [
{name = "Perry Werneck", email = "perry.werneck@gmail.com"},
]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
package_version = line.split('[')[2].split(']')[0].strip()
break;

package_version += '.4'
package_version += '.5'

extra_compile_args.append('-DPACKAGE_VERSION=\"' + package_version + '\"')

Expand Down
50 changes: 50 additions & 0 deletions src/include/private/decoders/tpm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */

/*
* Copyright (C) 2023 Perry Werneck <perry.werneck@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* @brief Declare TPM decoders.
*/

#pragma once

#include <smbios/defs.h>
#include <private/decoders.h>

namespace SMBios {

namespace Decoder {

/// @brief Decode firmware revision.
struct TPMVendorID : public Worker {
std::string as_string(const Node::Header &header, const uint8_t *ptr, const size_t offset) const override;
};

struct TPMSpecification : public Worker {
std::string as_string(const Node::Header &header, const uint8_t *ptr, const size_t offset) const override;
};

struct TPMRevision : public Worker {
std::string as_string(const Node::Header &header, const uint8_t *ptr, const size_t offset) const override;
};

}

}


13 changes: 12 additions & 1 deletion src/libdmiget/decoders/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <private/decoders/probe.h>
#include <private/decoders/chassis.h>
#include <private/decoders/baseboard.h>
#include <private/decoders/tpm.h>

#include <stdexcept>

Expand All @@ -54,6 +55,16 @@
{}
};

static const Decoder::Item TPMDevice[] = {
{ "vendor", Decoder::TPMVendorID{}, 0x04, "Vendor ID" },
{ "specversion", Decoder::TPMSpecification{}, 0x08, "Specification Version" },
{ "revision", Decoder::TPMRevision{}, 0x0a, "Firmware Revision" },
{ "description", Decoder::String{}, 0x12, "Description" },
// { "characteristics", Decoder::{}, 0x13, "Characteristics" },
{ "oem", Decoder::UInt16{}, 0x1b, "OEM-defined" },
{}
};

static const Decoder::Item BiosInformation[] = {
{ "vendor", Decoder::String{}, 0x04, "Vendor" },
{ "version", Decoder::String{}, 0x05, "Version" },
Expand Down Expand Up @@ -535,7 +546,7 @@
false,
"TPMDevice",
"TPM Device",
EmptyTable
TPMDevice
},
{
44,
Expand Down
79 changes: 79 additions & 0 deletions src/libdmiget/decoders/tpm.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */

/*
* Copyright (C) 2023 Perry Werneck <perry.werneck@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* @brief Implement TPM decoders.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif // HAVE_CONFIG_H

#include <private/decoders.h>
#include <private/decoders/tools.h>
#include <private/decoders/tpm.h>

#include <string>

using namespace std;

namespace SMBios {

std::string Decoder::TPMVendorID::as_string(const Node::Header &, const uint8_t *ptr, const size_t offset) const {
ptr += offset;
char value[4];
memcpy(value,ptr,3);
value[3] = 0;
return value;
}

std::string Decoder::TPMSpecification::as_string(const Node::Header &, const uint8_t *ptr, const size_t offset) const {
ptr += offset;
string value = std::to_string((int) ptr[0]);
value += '.';
value += std::to_string((int) ptr[1]);
return value;
}

std::string Decoder::TPMRevision::as_string(const Node::Header &, const uint8_t *ptr, const size_t) const {
string value;

switch(ptr[8]) {
case 1:
value = to_string((int) ptr[0x0C]);
value += '.';
value += to_string((int) ptr[0x0D]);
break;

case 2:
value = to_string((int) (DWORD(ptr + 0x0A) >> 16));
value += '.';
value += to_string((int) (DWORD(ptr + 0x0A) & 0xFFFF));
break;

default:
value = "Unknown";

}

return value;
}

}

2 changes: 1 addition & 1 deletion dmiget.static.pc.in → static.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version_minor=@PACKAGE_MINOR_VERSION@
Name: @PACKAGE_NAME@
Description: @PACKAGE_NAME@ static library
Version: @PACKAGE_VERSION@
Libs: -ldmiget.static
Libs: -l:libdmiget.a
Libs.private: @LIBS@
Cflags: -I@includedir@/@PACKAGE_NAME@

0 comments on commit d222948

Please sign in to comment.