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