Skip to content

Commit 8984aa7

Browse files
committed
Smbios (Haiku): add support; enable related modules
1 parent c081268 commit 8984aa7

File tree

2 files changed

+52
-7
lines changed

2 files changed

+52
-7
lines changed

CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,29 +1124,29 @@ elseif(Haiku)
11241124
src/common/networking_linux.c
11251125
src/common/processing_linux.c
11261126
src/detection/battery/battery_haiku.c
1127-
src/detection/bios/bios_nosupport.c
1128-
src/detection/board/board_nosupport.c
1127+
src/detection/bios/bios_windows.c
1128+
src/detection/board/board_windows.c
11291129
src/detection/bootmgr/bootmgr_nosupport.c
11301130
src/detection/brightness/brightness_nosupport.c
11311131
src/detection/btrfs/btrfs_nosupport.c
1132-
src/detection/chassis/chassis_nosupport.c
1132+
src/detection/chassis/chassis_windows.c
11331133
src/detection/cpu/cpu_haiku.c
1134-
src/detection/cpucache/cpucache_nosupport.c
1134+
src/detection/cpucache/cpucache_shared.c
11351135
src/detection/cpuusage/cpuusage_nosupport.c
11361136
src/detection/cursor/cursor_nosupport.c
11371137
src/detection/bluetooth/bluetooth_nosupport.c
11381138
src/detection/bluetoothradio/bluetoothradio_nosupport.c
11391139
src/detection/disk/disk_haiku.cpp
11401140
src/detection/dns/dns_linux.c
11411141
src/detection/physicaldisk/physicaldisk_nosupport.c
1142-
src/detection/physicalmemory/physicalmemory_nosupport.c
1142+
src/detection/physicalmemory/physicalmemory_linux.c
11431143
src/detection/diskio/diskio_nosupport.c
11441144
src/detection/displayserver/displayserver_haiku.cpp
11451145
src/detection/font/font_haiku.cpp
11461146
src/detection/gpu/gpu_haiku.c
11471147
src/detection/gpu/gpu_pci.c
11481148
src/detection/gtk_qt/gtk.c
1149-
src/detection/host/host_nosupport.c
1149+
src/detection/host/host_windows.c
11501150
src/detection/icons/icons_nosupport.c
11511151
src/detection/initsystem/initsystem_linux.c
11521152
src/detection/keyboard/keyboard_nosupport.c

src/util/smbiosHelper.c

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const FFSmbiosHeader* ffSmbiosNextEntry(const FFSmbiosHeader* header)
5050
return (const FFSmbiosHeader*) (p + 1);
5151
}
5252

53-
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
53+
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__HAIKU__)
5454
#include <fcntl.h>
5555
#include <sys/stat.h>
5656
#include <sys/mman.h>
@@ -135,6 +135,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable()
135135

136136
if (buffer.chars == NULL)
137137
{
138+
#ifndef __HAIKU__
138139
#ifdef __linux__
139140
if (!ffAppendFileBuffer("/sys/firmware/dmi/tables/DMI", &buffer))
140141
#endif
@@ -216,6 +217,50 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable()
216217
munmap(p, tableLength);
217218
}
218219
}
220+
#else
221+
{
222+
uint32_t tableLength = 0;
223+
off_t tableAddress = 0;
224+
FF_AUTO_CLOSE_FD int fd = open("/dev/misc/mem", O_RDONLY);
225+
if (fd < 0)
226+
return NULL;
227+
FF_AUTO_FREE uint8_t* smBiosBase = malloc(0x10000);
228+
if (pread(fd, smBiosBase, 0x10000, 0xF0000) != 0x10000)
229+
return NULL;
230+
231+
for (off_t offset = 0; offset <= 0xffe0; offset += 0x10)
232+
{
233+
FFSmbiosEntryPoint* p = (void*)(smBiosBase + offset);
234+
if (memcmp(p, "_SM3_", sizeof(p->Smbios30.AnchorString)) == 0)
235+
{
236+
if (p->Smbios30.EntryPointLength != sizeof(p->Smbios30))
237+
return NULL;
238+
tableLength = p->Smbios30.StructureTableMaximumSize;
239+
tableAddress = (off_t) p->Smbios30.StructureTableAddress;
240+
break;
241+
}
242+
else if (memcmp(p, "_SM_", sizeof(p->Smbios20.AnchorString)) == 0)
243+
{
244+
if (p->Smbios20.EntryPointLength != sizeof(p->Smbios20))
245+
return NULL;
246+
tableLength = p->Smbios20.StructureTableLength;
247+
tableAddress = (off_t) p->Smbios20.StructureTableAddress;
248+
break;
249+
}
250+
}
251+
if (tableLength == 0)
252+
return NULL;
253+
254+
ffStrbufEnsureFixedLengthFree(&buffer, tableLength);
255+
if (pread(fd, buffer.chars, tableLength, tableAddress) == tableLength)
256+
{
257+
buffer.length = tableLength;
258+
buffer.chars[buffer.length] = '\0';
259+
}
260+
else
261+
return NULL;
262+
}
263+
#endif
219264

220265
for (
221266
const FFSmbiosHeader* header = (const FFSmbiosHeader*) buffer.chars;

0 commit comments

Comments
 (0)