Chameleon

Chameleon Svn Source Tree

Root/branches/slice/old749m/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 DEBUG_MEMORY 0
19
20#if DEBUG_MEMORY
21#define DBG(x...) verbose(x)
22#else
23#define DBG(x...)
24#endif
25
26
27pci_dt_t * dram_controller_dev = NULL;
28pci_dt_t * smbus_controller_dev = NULL;
29
30
31void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4);
32void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4);
33
34
35void Memory_start()
36{
37register_hook_callback("PCIDevice", &Memory_PCIDevice_hook);
38register_hook_callback("ScanMemory", &Memory_hook);
39
40}
41
42void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4)
43{
44pci_dt_t* current = arg1;
45if(current->class_id == PCI_CLASS_BRIDGE_HOST)
46{
47dram_controller_dev = current;
48DBG("dram_controller_dev found devID=%08x\n", current->device_id);
49}
50else if(is_smbus_controller(current))
51{
52smbus_controller_dev = current;
53DBG("smbus_controller_dev found devID=%08x\n", current->device_id);
54}
55
56}
57
58void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4)
59{
60bool useAutodetection = true;
61 getBoolForKey(kUseMemDetect, &useAutodetection, &bootInfo->bootConfig);
62
63
64 if (useAutodetection) {
65
66if (dram_controller_dev!=NULL) {
67scan_dram_controller(dram_controller_dev); // Rek: pci dev ram controller direct and fully informative scan ...
68}
69scan_memory(Platform); // unfortunately still necesary for some comp where spd cant read correct speed
70DBG("scan_memory \n");
71if(smbus_controller_dev)
72{
73scan_spd(Platform, smbus_controller_dev);
74DBG("scan_spd \n");
75}
76 }
77
78}

Archive Download this file

Revision: 1174