Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/Memory/Memory.c

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
17pci_dt_t * dram_controller_dev = NULL;
18pci_dt_t * smbus_controller_dev = NULL;
19
20
21void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);
22void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);
23void is_Memory_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);
24
25void is_Memory_Registred_Hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6){}
26
27void Memory_start(void);
28void Memory_start(void)
29{
30
31 if (pci_config_read16(PCIADDR(0, 0x00, 0), 0x00) != 0x8086)
32return;
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
40void Memory_PCIDevice_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
41{
42pci_dt_t* current = arg1;
43if(current->class_id == PCI_CLASS_BRIDGE_HOST)
44{
45dram_controller_dev = current;
46}
47else if(is_smbus_controller(current))
48{
49smbus_controller_dev = current;
50}
51
52}
53
54void Memory_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
55{
56
57if (dram_controller_dev!=NULL) {
58scan_dram_controller(dram_controller_dev); // Rek: pci dev ram controller direct and fully informative scan ...
59}
60
61if(smbus_controller_dev)
62{
63
64scan_spd(smbus_controller_dev);
65
66}
67
68}

Archive Download this file

Revision: 2006