Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/iFabio/Chameleon/i386/libsaio/platform.c

Source at commit 307 created 12 years 10 months ago.
By ifabio, merge changes from trunk (929). Also merge the module changes from Azimutz branche (fix compile error) Also edited the info.plist into AHCIPortInjector.kext: http://forum.voodooprojects.org/index.php/topic,1170.0.html
1/*
2 * platform.c
3 *
4 * AsereBLN: cleanup
5 */
6
7#include "libsaio.h"
8#include "boot.h"
9#include "bootstruct.h"
10#include "pci.h"
11#include "platform.h"
12#include "cpu.h"
13#include "spd.h"
14#include "dram_controllers.h"
15
16#ifndef DEBUG_PLATFORM
17#define DEBUG_PLATFORM 0
18#endif
19
20#if DEBUG_PLATFORM
21#define DBG(x...)printf(x)
22#else
23#define DBG(x...)
24#endif
25
26PlatformInfo_t Platform;
27pci_dt_t * dram_controller_dev = NULL;
28
29//Azi: temporarily placing this here; from removed mem.c, needed by DEBUG_PLATFORM
30// check if replaceable by other or completely remove?? whatever...
31#define DC(c) (c >= 0x20 && c < 0x7f ? (char) c : '.')
32#define STEP 16
33void dumpPhysAddr(const char * title, void * a, int len)
34{
35 int i,j;
36 u_int8_t* ad = (u_int8_t*) a;
37 char buffer[80];
38 char str[16];
39
40 if(ad==NULL) return;
41
42 printf("%s addr=0x%08x len=%04d\n",title ? title : "Dump of ", a, len);
43 printf("Ofs-00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F ASCII\n");
44 i = (len/STEP)*STEP;
45 for (j=0; j < i; j+=STEP)
46 {
47 printf("%02x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
48 j,
49 ad[j], ad[j+1], ad[j+2], ad[j+3] , ad[j+4], ad[j+5], ad[j+6], ad[j+7],
50 ad[j+8], ad[j+9], ad[j+10], ad[j+11] , ad[j+12], ad[j+13], ad[j+14], ad[j+15],
51 DC(ad[j]), DC(ad[j+1]), DC(ad[j+2]), DC(ad[j+3]) , DC(ad[j+4]), DC(ad[j+5]), DC(ad[j+6]), DC(ad[j+7]),
52 DC(ad[j+8]), DC(ad[j+9]), DC(ad[j+10]), DC(ad[j+11]) , DC(ad[j+12]), DC(ad[j+13]), DC(ad[j+14]), DC(ad[j+15])
53 );
54 }
55
56 if (len%STEP==0) return;
57 sprintf(buffer,"%02x:", i);
58 for (j=0; j < STEP; j++) {
59 if (j<(len%STEP))
60 sprintf(str, " %02x", ad[i+j]);
61 else
62 strcpy(str, " " );
63 strncat(buffer, str, sizeof(buffer));
64 }
65 strncat(buffer," ", sizeof(buffer));
66 for (j=0; j < (len%STEP); j++) {
67 sprintf(str, "%c", DC(ad[i+j]));
68 strncat(buffer, str, sizeof(buffer));
69 }
70 printf("%s\n",buffer);
71}
72
73/** Return if a CPU feature specified by feature is activated (true) or not (false) */
74bool platformCPUFeature(uint32_t feature)
75{
76if (Platform.CPU.Features & feature) {
77return true;
78} else {
79return false;
80}
81}
82
83/** scan mem for memory autodection purpose */
84void scan_mem() {
85 static bool done = false;
86 if (done) return;
87
88 bool useAutodetection = true;
89 getBoolForKey(kUseMemDetect, &useAutodetection, &bootInfo->bootConfig);
90
91 if (useAutodetection) {
92if (dram_controller_dev!=NULL) {
93scan_dram_controller(dram_controller_dev); // Rek: pci dev ram controller direct and fully informative scan ...
94}
95 scan_spd(&Platform);
96 }
97 done = true;
98}
99
100/**
101 Scan platform hardware information, called by the main entry point (common_boot() )
102 _before_ bootConfig xml parsing settings are loaded
103*/
104void scan_platform(void)
105{
106memset(&Platform, 0, sizeof(Platform));
107build_pci_dt();
108scan_cpu(&Platform);
109//scan_mem(); Rek: called after pci devs init in fake_efi now ...
110}
111

Archive Download this file

Revision: 307