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 kUseMemDetect"UseMemDetect"
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
27
28void Memory_start()
29{
30register_hook_callback("PCIDevice", &Memory_PCIDevice_hook);
31register_hook_callback("ScanMemory", &Memory_hook);
32
33}
34
35void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
36{
37pci_dt_t* current = arg1;
38if(current->class_id == PCI_CLASS_BRIDGE_HOST)
39{
40dram_controller_dev = current;
41}
42else if(is_smbus_controller(current))
43{
44smbus_controller_dev = current;
45}
46
47}
48
49void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
50{
51bool useAutodetection = true;
52 getBoolForKey(kUseMemDetect, &useAutodetection, &bootInfo->bootConfig);
53
54
55 if (useAutodetection) {
56
57if (dram_controller_dev!=NULL) {
58scan_dram_controller(dram_controller_dev); // Rek: pci dev ram controller direct and fully informative scan ...
59}
60
61if(smbus_controller_dev)
62{
63scan_spd(Platform, smbus_controller_dev);
64}
65 }
66
67}

Archive Download this file

Revision: 789