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 | ␊ |
26 | PlatformInfo_t Platform;␊ |
27 | pci_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␊ |
33 | void 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) */␊ |
74 | bool platformCPUFeature(uint32_t feature)␊ |
75 | {␊ |
76 | ␉if (Platform.CPU.Features & feature) {␊ |
77 | ␉␉return true;␊ |
78 | ␉} else {␊ |
79 | ␉␉return false;␊ |
80 | ␉}␊ |
81 | }␊ |
82 | ␊ |
83 | /** scan mem for memory autodection purpose */␊ |
84 | void 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) {␊ |
92 | ␉␉if (dram_controller_dev!=NULL) {␊ |
93 | ␉␉␉scan_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 | */␊ |
104 | void scan_platform(void)␊ |
105 | {␊ |
106 | ␉memset(&Platform, 0, sizeof(Platform));␊ |
107 | ␉build_pci_dt();␊ |
108 | ␉scan_cpu(&Platform);␊ |
109 | ␉//scan_mem(); Rek: called after pci devs init in fake_efi now ...␊ |
110 | }␊ |
111 | |