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 "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, void* arg5, void* arg6);␊ |
22 | void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);␊ |
23 | void is_Memory_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);␊ |
24 | ␊ |
25 | void is_Memory_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6){}␊ |
26 | ␊ |
27 | void Memory_start(void);␊ |
28 | void Memory_start(void)␊ |
29 | {␉␊ |
30 | ␊ |
31 | if (pci_config_read16(PCIADDR(0, 0x00, 0), 0x00) != 0x8086) ␊ |
32 | ␉␉return;␉␊ |
33 | ␊ |
34 | register_hook_callback("PCIDevice", &Memory_PCIDevice_hook);␊ |
35 | register_hook_callback("ScanMemory", &Memory_hook);␊ |
36 | register_hook_callback("isMemoryRegistred", &is_Memory_Registred_Hook);␊ |
37 | ␉␊ |
38 | }␊ |
39 | ␊ |
40 | void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)␊ |
41 | {␊ |
42 | ␉pci_dt_t* current = arg1;␊ |
43 | ␉if(current->class_id == PCI_CLASS_BRIDGE_HOST)␊ |
44 | ␉{␊ |
45 | ␉␉dram_controller_dev = current;␊ |
46 | ␉}␊ |
47 | ␉else if(is_smbus_controller(current))␊ |
48 | ␉{␊ |
49 | ␉␉smbus_controller_dev = current;␊ |
50 | ␉}␊ |
51 | ␊ |
52 | }␊ |
53 | ␊ |
54 | void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)␊ |
55 | {␉␊ |
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 | ␊ |
64 | ␉␉scan_spd(smbus_controller_dev);␊ |
65 | ␊ |
66 | ␉}␊ |
67 | ␉␊ |
68 | } |