mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-08-12 23:04:15 +00:00
.github
.vscode
Bootloader
Drivers
Kernel
.vscode
arch
core
driver
memory
panic
time
video
acpi.cpp
console.cpp
cpu.cpp
debugger.cpp
disk.cpp
dsdt.cpp
interrupts_manager.cpp
lock.cpp
pci.cpp
power.cpp
random.cpp
smbios.cpp
smbios.hpp
stack_check.cpp
symbols.cpp
syscalls.cpp
ubsan.c
ubsan.h
exec
files
include
include_std
kshell
library
network
profiling
storage
subsystem
syscalls
tasking
tests
tty
virtualization
.editorconfig
.gdbinit
.gitignore
ISSUES.md
Makefile
README.md
TODO.md
dump.sh
kernel.cpp
kernel.h
kernel_config.cpp
kernel_thread.cpp
kernel_vfs.cpp
Userspace
initrd
tools
.editorconfig
.gitignore
.gitlab-ci.yml
CODE_OF_CONDUCT.md
CONTRIBUTING.md
CREDITS.md
Doxyfile
Fennix Bootloader.code-workspace
Fennix Drivers.code-workspace
Fennix Kernel.code-workspace
Fennix Userspace.code-workspace
Fennix Website.code-workspace
Fennix.code-workspace
LICENSE.md
LICENSES.md
Makefile
README.md
SECURITY.md
STYLE_GUIDE.md
config.mk
87 lines
3.0 KiB
C++
87 lines
3.0 KiB
C++
/*
|
|
This file is part of Fennix Kernel.
|
|
|
|
Fennix Kernel is free software: you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License as
|
|
published by the Free Software Foundation, either version 3 of
|
|
the License, or (at your option) any later version.
|
|
|
|
Fennix Kernel 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 General Public License
|
|
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "smbios.hpp"
|
|
|
|
#include <debug.h>
|
|
|
|
#include "../kernel.h"
|
|
|
|
namespace SMBIOS
|
|
{
|
|
bool CheckSMBIOS()
|
|
{
|
|
if (bInfo.SMBIOSPtr != nullptr && bInfo.SMBIOSPtr < (void *)0xFFFFFFFFFFFF0000)
|
|
{
|
|
debug("SMBIOS is available (%#lx).", bInfo.SMBIOSPtr);
|
|
return true;
|
|
}
|
|
|
|
debug("SMBIOS is not available. (%#lx)", bInfo.SMBIOSPtr);
|
|
return false;
|
|
}
|
|
|
|
SMBIOSEntryPoint *GetSMBIOSEntryPoint() { return (SMBIOSEntryPoint *)bInfo.SMBIOSPtr; }
|
|
|
|
__no_sanitize("alignment") static inline int SMBIOSTableLength(SMBIOSHeader *Hdr)
|
|
{
|
|
int i;
|
|
const char *strtab = (char *)Hdr + Hdr->Length;
|
|
for (i = 1; strtab[i - 1] != '\0' || strtab[i] != '\0'; i++)
|
|
;
|
|
return Hdr->Length + i + 1;
|
|
}
|
|
|
|
__no_sanitize("alignment") void *GetSMBIOSHeader(SMBIOSType Type)
|
|
{
|
|
if (!CheckSMBIOS())
|
|
return nullptr;
|
|
|
|
SMBIOSEntryPoint *Header = (SMBIOSEntryPoint *)bInfo.SMBIOSPtr;
|
|
debug("Getting SMBIOS header for type %d", Type);
|
|
|
|
struct SMBIOSHeader *hdr = (SMBIOSHeader *)(uintptr_t)Header->TableAddress;
|
|
for (int i = 0; i <= 11; i++)
|
|
{
|
|
if (hdr < (void *)(uintptr_t)(Header->TableAddress + Header->TableLength))
|
|
if (hdr->Type == Type)
|
|
{
|
|
debug("Found SMBIOS header for type %d at %#lx", Type, hdr);
|
|
return hdr;
|
|
}
|
|
hdr = (struct SMBIOSHeader *)((uintptr_t)hdr + SMBIOSTableLength(hdr));
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
SMBIOSBIOSInformation *GetBIOSInformation() { return (SMBIOSBIOSInformation *)GetSMBIOSHeader(SMBIOSTypeBIOSInformation); }
|
|
|
|
SMBIOSSystemInformation *GetSystemInformation() { return (SMBIOSSystemInformation *)GetSMBIOSHeader(SMBIOSTypeSystemInformation); }
|
|
|
|
SMBIOSBaseBoardInformation *GetBaseBoardInformation() { return (SMBIOSBaseBoardInformation *)GetSMBIOSHeader(SMBIOSTypeBaseBoardInformation); }
|
|
|
|
SMBIOSProcessorInformation *GetProcessorInformation() { return (SMBIOSProcessorInformation *)GetSMBIOSHeader(SMBIOSTypeProcessorInformation); }
|
|
|
|
SMBIOSMemoryArray *GetMemoryArray() { return (SMBIOSMemoryArray *)GetSMBIOSHeader(SMBIOSTypePhysicalMemoryArray); }
|
|
|
|
SMBIOSMemoryDevice *GetMemoryDevice() { return (SMBIOSMemoryDevice *)GetSMBIOSHeader(SMBIOSTypeMemoryDevice); }
|
|
|
|
SMBIOSMemoryArrayMappedAddress *GetMemoryArrayMappedAddress() { return (SMBIOSMemoryArrayMappedAddress *)GetSMBIOSHeader(SMBIOSTypeMemoryArrayMappedAddress); }
|
|
|
|
SMBIOSMemoryDeviceMappedAddress *GetMemoryDeviceMappedAddress() { return (SMBIOSMemoryDeviceMappedAddress *)GetSMBIOSHeader(SMBIOSTypeMemoryDeviceMappedAddress); }
|
|
}
|