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