Chameleon

Chameleon Svn Source Tree

Root/branches/azimutz/Chazi/i386/modules/Memory/Memory.c

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
19pci_dt_t *dram_controller_dev;
20
21
22void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4);
23void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4);
24
25
26void Memory_start()
27{
28register_hook_callback("PCIDevice", &Memory_PCIDevice_hook);
29register_hook_callback("ScanMemory", &Memory_hook);
30
31}
32
33void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4)
34{
35pci_dt_t* current = arg1;
36
37if (current->class_id == PCI_CLASS_BRIDGE_HOST
38&& (current->dev.addr == PCIADDR(0, 0, 0)))
39{
40dram_controller_dev = current;
41}
42}
43
44void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4)
45{
46/* our code only works on Intel chipsets so make sure here */
47if (pci_config_read16(PCIADDR(0, 0x00, 0), 0x00) != 0x8086)
48bootInfo->memDetect = false;
49 else
50bootInfo->memDetect = true;
51/* manually */
52 getBoolForKey(kUseMemDetectKey, &bootInfo->memDetect, &bootInfo->bootConfig);
53
54 if (bootInfo->memDetect)
55{
56if (dram_controller_dev != NULL)
57{
58// Rek: pci dev ram controller direct and fully informative scan ...
59scan_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

Archive Download this file

Revision: 1044