Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/SMBiosPatcher/SMBiosPatcher.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 "smbios_patcher.h"
10#include "efi.h"
11
12#ifndef DEBUG_SMBIOS
13#define DEBUG_SMBIOS 0
14#endif
15
16#if DEBUG_SMBIOS==2
17#define DBG(x...)printf(x)
18#elif DEBUG_SMBIOS==1
19#define DBG(x...) msglog(x)
20#else
21#define DBG(x...)
22#endif
23
24void getSmbiosPatched_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
25{
26struct SMBEntryPoint *smbios_o = (struct SMBEntryPoint *)arg1;
27struct SMBEntryPoint *patched_smb = NULL;
28
29execute_hook("ScanMemory", NULL, NULL, NULL, NULL, NULL, NULL);
30
31patched_smb = getSmbiosPatched(smbios_o);
32
33if (patched_smb)
34smbios_p = (EFI_PTR32)patched_smb;
35else
36verbose("Error: Could not get patched SMBIOS, fallback to original SMBIOS !!\n");
37}
38
39void smbios_helper_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
40{
41struct SMBEntryPoint *orig = (struct SMBEntryPoint *)arg1;
42getSmbiosTableStructure(orig); // generate tables entry list for fast table finding
43
44if (is_module_loaded("Memory"))
45scan_memory(Platform);
46}
47
48void getProductName_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("SMproductname", &val, &len, &bootInfo->smbiosConfig)) {
55gPlatformName = (char *)val;
56} else {
57const char *productName = sm_get_defstr("SMproductname", 0);
58gPlatformName = (char *)productName;
59}
60DBG("SMBIOS Product name: %s\n",productName);
61
62
63}
64
65void SMBiosPatcher_start()
66{
67register_hook_callback("getSmbiosPatched", &getSmbiosPatched_hook);
68register_hook_callback("smbios_helper", &smbios_helper_hook);
69register_hook_callback("getProductNamePatched", &getProductName_hook);
70}
71

Archive Download this file

Revision: 789