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 "boot.h"
15#include "bootstruct.h"
16#include "modules.h"
17
18#define kEnableMemory"EnableMemoryModule"
19
20pci_dt_t * dram_controller_dev = NULL;
21pci_dt_t * smbus_controller_dev = NULL;
22
23
24void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);
25void Memory_PCIDevice_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()
30{
31
32bool enable = true;
33
34getBoolForKey(kEnableMemory, &enable, &bootInfo->bootConfig);
35
36 if (pci_config_read16(PCIADDR(0, 0x00, 0), 0x00) != 0x8086)
37enable = false;
38
39enable = (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) != EFI_SUCCESS);
40
41 if (enable) {
42register_hook_callback("PCIDevice", &Memory_PCIDevice_hook);
43register_hook_callback("ScanMemory", &Memory_hook);
44register_hook_callback("isMemoryRegistred", &is_Memory_Registred_Hook);
45}
46}
47
48void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
49{
50pci_dt_t* current = arg1;
51if(current->class_id == PCI_CLASS_BRIDGE_HOST)
52{
53dram_controller_dev = current;
54}
55else if(is_smbus_controller(current))
56{
57smbus_controller_dev = current;
58}
59
60}
61
62void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
63{
64
65if (dram_controller_dev!=NULL) {
66scan_dram_controller(dram_controller_dev); // Rek: pci dev ram controller direct and fully informative scan ...
67}
68
69if(smbus_controller_dev)
70{
71#if UNUSED
72scan_spd(Platform, smbus_controller_dev);
73#else
74scan_spd(smbus_controller_dev);
75#endif
76}
77
78}

Archive Download this file

Revision: 1119