Chameleon

Chameleon Svn Source Tree

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

1/*
2 * DRAM Controller Module
3 * Scans the dram controller and notifies OS X of the memory modules.
4 *This was converted from boot2 code to a boot2 module.
5 *
6 */
7
8#include "libsaio.h"
9#include "pci.h"
10#include "platform.h"
11#include "dram_controllers.h"
12#include "spd.h"
13#include "mem.h"
14#include "bootstruct.h"
15#include "modules.h"
16
17#define kEnableMemory"EnableMemoryModule"
18
19pci_dt_t * dram_controller_dev = NULL;
20pci_dt_t * smbus_controller_dev = NULL;
21
22
23void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);
24void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);
25void is_Memory_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);
26
27void is_Memory_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6){}
28
29void Memory_start(void);
30void Memory_start(void)
31{
32
33bool enable = true;
34
35getBoolForKey(kEnableMemory, &enable, DEFAULT_BOOT_CONFIG);
36
37 if (pci_config_read16(PCIADDR(0, 0x00, 0), 0x00) != 0x8086)
38enable = false;
39
40enable = (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) != EFI_SUCCESS);
41
42 if (enable) {
43register_hook_callback("PCIDevice", &Memory_PCIDevice_hook);
44register_hook_callback("ScanMemory", &Memory_hook);
45register_hook_callback("isMemoryRegistred", &is_Memory_Registred_Hook);
46}
47}
48
49void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
50{
51pci_dt_t* current = arg1;
52if(current->class_id == PCI_CLASS_BRIDGE_HOST)
53{
54dram_controller_dev = current;
55}
56else if(is_smbus_controller(current))
57{
58smbus_controller_dev = current;
59}
60
61}
62
63void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
64{
65
66if (dram_controller_dev!=NULL) {
67scan_dram_controller(dram_controller_dev); // Rek: pci dev ram controller direct and fully informative scan ...
68}
69
70if(smbus_controller_dev)
71{
72#if UNUSED
73scan_spd(Platform, smbus_controller_dev);
74#else
75scan_spd(smbus_controller_dev);
76#endif
77}
78
79}

Archive Download this file

Revision: 1840