1 | /*␊ |
2 | * Copyright 2011 cparm <armelcadetpetit@gmail.com>. All rights reserved.␊ |
3 | */␊ |
4 | #include "boot.h"␊ |
5 | #include "bootstruct.h"␊ |
6 | #include "libsaio.h"␊ |
7 | #include "modules.h"␊ |
8 | #include "Platform.h"␊ |
9 | #include "efi.h"␊ |
10 | #include "mysmbios.h"␊ |
11 | ␊ |
12 | #define kEnableSMBIOSGetters␉␉␉"EnableSMBIOSGetters"␊ |
13 | ␊ |
14 | ␊ |
15 | void getSmbiosPatched_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)␊ |
16 | {␉␊ |
17 | readSMBIOSInfo(getSmbiosOriginal());␊ |
18 | ␊ |
19 | ␉execute_hook("ScanMemory", NULL, NULL, NULL, NULL, NULL, NULL);␊ |
20 | ␉SMBEntryPoint *patched_smb = setupSMBIOSTable(getSmbiosOriginal());␊ |
21 | ␉␊ |
22 | ␉if (patched_smb != NULL)␊ |
23 | ␉␉smbios_p = ((uint64_t)((uint32_t)patched_smb));␊ |
24 | ␉else␊ |
25 | {␊ |
26 | ␉␉verbose("Error: Could not get patched SMBIOS, fallback to original SMBIOS !!\n");␊ |
27 | ␊ |
28 | struct SMBEntryPoint *smbios_o = getSmbiosOriginal();␉␊ |
29 | smbios_p = ((uint64_t)((uint32_t)smbios_o)); ␊ |
30 | } ␊ |
31 | ␊ |
32 | }␊ |
33 | ␊ |
34 | void getProductName_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)␊ |
35 | {␉␊ |
36 | ␉setupSmbiosConfigFile("SMBIOS.plist");␊ |
37 | ␉int len = 0;␊ |
38 | ␉const char *val = 0;␊ |
39 | ␉␊ |
40 | ␉if (getValueForKey("SMproductname", &val, &len, &bootInfo->smbiosConfig)) {␊ |
41 | ␉␉gPlatformName = (char *)val;␊ |
42 | ␉} else {␊ |
43 | ␉␉gPlatformName = getDefaultSMBproductName();␊ |
44 | ␉}␉␊ |
45 | ␉␉␊ |
46 | }␊ |
47 | ␊ |
48 | void getboardproduct_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)␊ |
49 | {␉␊ |
50 | ␉setupSmbiosConfigFile("SMBIOS.plist");␊ |
51 | ␉int len = 0;␊ |
52 | ␉const char *val = 0;␊ |
53 | ␉␊ |
54 | ␉if (getValueForKey("SMboardproduct", &val, &len, &bootInfo->smbiosConfig)) {␊ |
55 | ␉␉gboardproduct = (char *)val;␊ |
56 | ␉} else {␊ |
57 | ␉␉gboardproduct = getDefaultSMBBoardProduct();␊ |
58 | ␉}␉␊ |
59 | ␉␊ |
60 | }␊ |
61 | ␊ |
62 | void is_SMB_Getters_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6){}␊ |
63 | ␊ |
64 | void SMBiosGetters_start()␊ |
65 | {␉␊ |
66 | ␉bool enable = true;␊ |
67 | ␉getBoolForKey(kEnableSMBIOSGetters, &enable, &bootInfo->bootConfig) ;␊ |
68 | ␉␊ |
69 | ␉enable = (execute_hook("isSMBIOSRegistred", NULL, NULL, NULL, NULL, NULL, NULL) != EFI_SUCCESS);␊ |
70 | ␊ |
71 | ␉if (enable) {␊ |
72 | ␉␉register_hook_callback("getSmbiosPatched", &getSmbiosPatched_hook);␉␉␊ |
73 | ␉␉register_hook_callback("getProductNamePatched", &getProductName_hook);␊ |
74 | ␉␉register_hook_callback("getboardproductPatched", &getboardproduct_hook);␊ |
75 | ␉␉register_hook_callback("isSMBIOSRegistred", &is_SMB_Getters_Registred_Hook);␊ |
76 | ␉}␊ |
77 | }␊ |
78 | |