Root/
Source at commit 555 created 13 years 7 months ago. By meklort, Removed recursion, already taken care of in the pci setup function. | |
---|---|
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 "boot.h"␊ |
14 | #include "bootstruct.h"␊ |
15 | #include "modules.h"␊ |
16 | ␊ |
17 | pci_dt_t * dram_controller_dev = NULL;␊ |
18 | pci_dt_t * smbus_controller_dev = NULL;␊ |
19 | ␊ |
20 | ␊ |
21 | void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4);␊ |
22 | void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4);␊ |
23 | ␊ |
24 | ␊ |
25 | void Memory_start()␊ |
26 | {␊ |
27 | ␉register_hook_callback("PCIDevice", &Memory_PCIDevice_hook);␊ |
28 | ␉register_hook_callback("ScanMemory", &Memory_hook);␊ |
29 | ␉␊ |
30 | }␊ |
31 | ␊ |
32 | void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4)␊ |
33 | {␊ |
34 | ␉pci_dt_t* current = arg1;␊ |
35 | ␉if(current->class_id == PCI_CLASS_BRIDGE_HOST)␊ |
36 | ␉{␊ |
37 | ␉␉dram_controller_dev = current;␊ |
38 | ␉}␊ |
39 | ␉else if(is_smbus_controller(current))␊ |
40 | ␉{␊ |
41 | ␉␉smbus_controller_dev = current;␊ |
42 | ␉}␊ |
43 | ␊ |
44 | }␊ |
45 | ␊ |
46 | void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4)␊ |
47 | {␊ |
48 | ␉bool useAutodetection = true;␊ |
49 | getBoolForKey(kUseMemDetect, &useAutodetection, &bootInfo->bootConfig);␊ |
50 | ␉␊ |
51 | ␉␊ |
52 | if (useAutodetection) {␊ |
53 | ␉␉␊ |
54 | ␉␉if (dram_controller_dev!=NULL) {␊ |
55 | ␉␉␉scan_dram_controller(dram_controller_dev); // Rek: pci dev ram controller direct and fully informative scan ...␊ |
56 | ␉␉}␊ |
57 | ␉␉scan_memory(Platform); // unfortunately still necesary for some comp where spd cant read correct speed␊ |
58 | ␉␉␊ |
59 | ␉␉if(smbus_controller_dev)␊ |
60 | ␉␉{␊ |
61 | ␉␉␉scan_spd(Platform, smbus_controller_dev);␊ |
62 | ␉␉}␊ |
63 | }␊ |
64 | ␉␊ |
65 | } |