1 | /*␊ |
2 | * Memory Module␊ |
3 | * Scans the dram controller and(/or spd), 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 "boot.h"␊ |
10 | #include "pci.h"␊ |
11 | #include "platform.h"␊ |
12 | #include "dram_controllers.h"␊ |
13 | #include "spd.h"␊ |
14 | //#include "mem.h"␊ |
15 | #include "modules.h"␊ |
16 | ␊ |
17 | #define kUseMemDetectKey "UseMemDetect"␊ |
18 | ␊ |
19 | pci_dt_t *dram_controller_dev;␊ |
20 | ␊ |
21 | ␊ |
22 | void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4);␊ |
23 | void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4);␊ |
24 | ␊ |
25 | ␊ |
26 | void Memory_start()␊ |
27 | {␊ |
28 | ␉register_hook_callback("PCIDevice", &Memory_PCIDevice_hook);␊ |
29 | ␉register_hook_callback("ScanMemory", &Memory_hook);␊ |
30 | ␉␊ |
31 | }␊ |
32 | ␊ |
33 | void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4)␊ |
34 | {␊ |
35 | ␉pci_dt_t* current = arg1;␊ |
36 | ␉␊ |
37 | ␉if (current->class_id == PCI_CLASS_BRIDGE_HOST␊ |
38 | ␉␉&& (current->dev.addr == PCIADDR(0, 0, 0)))␊ |
39 | ␉{␊ |
40 | ␉␉dram_controller_dev = current;␊ |
41 | ␉}␊ |
42 | }␊ |
43 | ␊ |
44 | void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4)␊ |
45 | {␉␊ |
46 | ␉bool useAutodetection = true;␊ |
47 | ␉getBoolForKey(kUseMemDetectKey, &useAutodetection, &bootInfo->bootConfig);␊ |
48 | ␉␊ |
49 | ␉if (useAutodetection)␊ |
50 | ␉{␊ |
51 | ␉␉if (dram_controller_dev != NULL)␊ |
52 | ␉␉{␊ |
53 | ␉␉␉// Rek: pci dev ram controller direct and fully informative scan ...␊ |
54 | ␉␉␉scan_dram_controller(dram_controller_dev);␊ |
55 | ␉␉}␊ |
56 | ␉}␊ |
57 | ␉//Azi: gone on Kabyl's smbios update...???␊ |
58 | ␉// unfortunately still necesary for some comp where spd cant read correct speed␊ |
59 | //␉scan_memory(&Platform);␊ |
60 | ␉␊ |
61 | ␉scan_spd(&Platform); // check Mek's implementation!␊ |
62 | }␊ |
63 | |