ohmu
·
2026-10-15
1#include "board.h"
2
3#include "common/debug.h"
4#include "common/apple/cf_helpers.h"
5
6const char* ffDetectBoard(FFBoardResult* result) {
7 FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t service = IOServiceGetMatchingService(MACH_PORT_NULL, IOServiceMatching("IOPlatformExpertDevice"));
8 if (!service) {
9 FF_DEBUG("No IOPlatformExpertDevice found");
10 return "No IOPlatformExpertDevice found";
11 }
12
13 FF_CFTYPE_AUTO_RELEASE CFTypeRef boardId = IORegistryEntryCreateCFProperty(service, CFSTR("board-id"), kCFAllocatorDefault, kNilOptions);
14 if (boardId) {
15 ffCfStrGetString(boardId, &result->name);
16 } else {
17 io_name_t name;
18 if (IORegistryEntryGetName(service, name) == kIOReturnSuccess) {
19 ffStrbufSetS(&result->name, name);
20 }
21 }
22
23 FF_CFTYPE_AUTO_RELEASE CFStringRef version = IORegistryEntryCreateCFProperty(service, CFSTR("version"), kCFAllocatorDefault, kNilOptions);
24 if (version) {
25 ffCfStrGetString(version, &result->version);
26 }
27
28 FF_CFTYPE_AUTO_RELEASE CFTypeRef manufacturer = IORegistryEntryCreateCFProperty(service, CFSTR("manufacturer"), kCFAllocatorDefault, kNilOptions);
29 if (manufacturer) {
30 ffCfStrGetString(manufacturer, &result->vendor);
31 }
32
33 return nullptr;
34}