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 "mem.h" - reminder␊ |
9 | //#include "libsaio.h"␊ |
10 | #include "boot.h"␊ |
11 | #include "pci.h"␊ |
12 | #include "platform.h"␊ |
13 | #include "spd.h"␊ |
14 | #include "dram_controllers.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 | ␉/* our code only works on Intel chipsets so make sure here */␊ |
47 | ␉if (pci_config_read16(PCIADDR(0, 0x00, 0), 0x00) != 0x8086)␊ |
48 | ␉␉bootInfo->memDetect = false;␊ |
49 | else␊ |
50 | ␉␉bootInfo->memDetect = true;␊ |
51 | ␉/* manually */␊ |
52 | getBoolForKey(kUseMemDetectKey, &bootInfo->memDetect, &bootInfo->bootConfig);␊ |
53 | ␊ |
54 | if (bootInfo->memDetect)␊ |
55 | ␉{␊ |
56 | ␉␉if (dram_controller_dev != NULL)␊ |
57 | ␉␉{␊ |
58 | ␉␉␉// Rek: pci dev ram controller direct and fully informative scan ...␊ |
59 | ␉␉␉scan_dram_controller(dram_controller_dev);␊ |
60 | ␉␉}␊ |
61 | ␉␉␊ |
62 | ␉␉//Azi: gone on Kabyl's smbios update - reminder␊ |
63 | ␉␉// unfortunately still necesary for some comp where spd cant read correct speed␊ |
64 | ␉␉//␉scan_memory(&Platform);␊ |
65 | ␉␉␊ |
66 | scan_spd(&Platform); // check Mek's implementation!␊ |
67 | }␊ |
68 | }␊ |
69 | |