Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/SMBiosGetters/SMBiosGetters.c

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
15void getSmbiosPatched_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
16{
17 readSMBIOSInfo(getSmbiosOriginal());
18
19execute_hook("ScanMemory", NULL, NULL, NULL, NULL, NULL, NULL);
20SMBEntryPoint *patched_smb = setupSMBIOSTable(getSmbiosOriginal());
21
22if (patched_smb != NULL)
23smbios_p = ((uint64_t)((uint32_t)patched_smb));
24else
25 {
26verbose("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
34void getProductName_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
35{
36setupSmbiosConfigFile("SMBIOS.plist");
37int len = 0;
38const char *val = 0;
39
40if (getValueForKey("SMproductname", &val, &len, &bootInfo->smbiosConfig)) {
41gPlatformName = (char *)val;
42} else {
43gPlatformName = (char *)getDefaultSMBproductName();
44}
45
46}
47
48void getboardproduct_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
49{
50setupSmbiosConfigFile("SMBIOS.plist");
51int len = 0;
52const char *val = 0;
53
54if (getValueForKey("SMboardproduct", &val, &len, &bootInfo->smbiosConfig)) {
55gboardproduct = (char *)val;
56} else {
57gboardproduct = (char *)getDefaultSMBBoardProduct();
58}
59
60}
61
62void is_SMB_Getters_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6){}
63
64void SMBiosGetters_start()
65{
66bool enable = true;
67getBoolForKey(kEnableSMBIOSGetters, &enable, &bootInfo->bootConfig) ;
68
69enable = (execute_hook("isSMBIOSRegistred", NULL, NULL, NULL, NULL, NULL, NULL) != EFI_SUCCESS);
70
71if (enable) {
72register_hook_callback("getSmbiosPatched", &getSmbiosPatched_hook);
73register_hook_callback("getProductNamePatched", &getProductName_hook);
74register_hook_callback("getboardproductPatched", &getboardproduct_hook);
75register_hook_callback("isSMBIOSRegistred", &is_SMB_Getters_Registred_Hook);
76}
77}
78

Archive Download this file

Revision: 1659