Chameleon

Chameleon Commit Details

Date:2012-04-05 13:12:36 (12 years 15 days ago)
Author:ErmaC
Commit:1918
Parents: 1917
Message:Merge IVY Bridge stuff from Chimera Branch.
Changes:
M/branches/ErmaC/Trunk/i386/libsaio/cpu.c
M/branches/ErmaC/Trunk/i386/libsaio/platform.h
M/branches/ErmaC/Trunk/i386/libsaio/smbios_getters.c
M/branches/ErmaC/Trunk/i386/libsaio/device_inject.c
M/branches/ErmaC/Trunk/i386/libsa/zalloc.c
M/branches/ErmaC/Trunk/i386/libsaio/cpu.h
M/branches/ErmaC/Trunk/i386/util/bdmesg.c
M/branches/ErmaC/Trunk/i386/libsaio/sys.c
M/branches/ErmaC/Trunk/i386/libsaio/acpi_patcher.c
M/branches/ErmaC/Trunk/i386/libsaio/allocate.c

File differences

branches/ErmaC/Trunk/i386/libsaio/acpi_patcher.c
563563
564564
565565
566
567
566
567
568
568569
569570
570571
case CPU_MODEL_NEHALEM_EX:// Intel Xeon X75xx, Xeon X65xx, Xeon E75xx, Xeon E65xx
case CPU_MODEL_WESTMERE:// Intel Core i7, Xeon X56xx, Xeon E56xx, Xeon W36xx LGA1366 (32nm) 6 Core
case CPU_MODEL_WESTMERE_EX:// Intel Xeon E7
case CPU_MODEL_SANDY:// Intel Core i3, i5, i7 LGA1155 (32nm)
case CPU_MODEL_SANDY_XEON:// Intel Xeon E3
case CPU_MODEL_SANDYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (32nm)
case CPU_MODEL_IVYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (22nm)
case CPU_MODEL_JAKETOWN:// Intel Core i7, Xeon E5 LGA2011 (32nm)
{
maximum.Control = rdmsr64(MSR_IA32_PERF_STATUS) & 0xff; // Seems it always contains maximum multiplier value (with turbo, that's we need)...
minimum.Control = (rdmsr64(MSR_PLATFORM_INFO) >> 40) & 0xff;
branches/ErmaC/Trunk/i386/libsaio/allocate.c
5959
6060
6161
62
62
63
6364
6465
6566
6667
6768
6869
69
70
71
7072
7173
7274
{
long addr;
if (gImageLastKernelAddr == 0) {
if (gImageLastKernelAddr == 0)
{
gImageLastKernelAddr = RoundPage( bootArgs->kaddr +
bootArgs->ksize );
}
addr = gImageLastKernelAddr;
gImageLastKernelAddr += RoundPage(inSize);
if ( gImageLastKernelAddr >= (KERNEL_ADDR + KERNEL_LEN) ) {
if ( gImageLastKernelAddr >= (KERNEL_ADDR + KERNEL_LEN) )
{
stop ("AllocateKernelMemory error");
}
branches/ErmaC/Trunk/i386/libsaio/device_inject.c
3131
3232
3333
34
34
35
3536
3637
3738
......
7374
7475
7576
77
7678
79
7780
7881
7982
8083
8184
8285
83
86
8487
8588
8689
......
9194
9295
9396
94
97
98
99
95100
101
96102
97103
98104
......
104110
105111
106112
107
108
113
114
115
116
109117
110118
111119
112120
121
113122
123
114124
125
115126
127
116128
117129
118130
......
125137
126138
127139
140
128141
142
129143
144
130145
146
131147
132148
133149
......
141157
142158
143159
160
161
144162
163
145164
146165
147166
......
171190
172191
173192
193
174194
175
195
196
197
198
199
176200
177201
178202
......
184208
185209
186210
211
187212
213
188214
189215
190216
191217
192218
219
193220
221
194222
195223
196224
......
219247
220248
221249
250
222251
252
223253
254
224255
256
225257
226
258
259
260
227261
228262
229263
......
231265
232266
233267
268
234269
270
235271
272
236273
274
237275
238276
239277
......
247285
248286
249287
288
250289
290
251291
252292
253293
......
283323
284324
285325
286
326
287327
288328
289329
......
296336
297337
298338
339
299340
341
300342
301343
302344
......
321363
322364
323365
324
325
326366
327
367
368
328369
329
330
370
371
372
373
374
375
376
377
378
379
380
381
382
383
331384
332
385
386
333387
334
335
388
389
336390
337391
338392
char *efi_inject_get_devprop_string(uint32_t *len)
{
if(string) {
if(string)
{
*len = string->length;
return devprop_generate_string(string);
}
string = (struct DevPropString*)malloc(sizeof(struct DevPropString));
if(string == NULL)
{
return NULL;
}
memset(string, 0, sizeof(struct DevPropString));
string->length = 12;
string->WHAT2 = 0x01000000;
return string;
}
struct DevPropDevice *devprop_add_device(struct DevPropString *string, char *path)
{
struct DevPropDevice*device;
return NULL;
}
device = malloc(sizeof(struct DevPropDevice));
if (!device) {
return NULL;
}
if (strncmp(path, pciroot_string, strlen(pciroot_string))) {
free(device);
printf("ERROR parsing device path\n");
return NULL;
}
intx, curr = 0;
charbuff[] = "00";
for (x = 0; x < strlen(path); x++) {
if (!strncmp(&path[x], pci_device_string, strlen(pci_device_string))) {
for (x = 0; x < strlen(path); x++)
{
if (!strncmp(&path[x], pci_device_string, strlen(pci_device_string)))
{
x+=strlen(pci_device_string);
curr=x;
while(path[++x] != ',');
if(x-curr == 2)
{
sprintf(buff, "%c%c", path[curr], path[curr+1]);
}
else if(x-curr == 1)
{
sprintf(buff, "%c", path[curr]);
}
else
{
printf("ERROR parsing device path\n");
curr = x;
while(path[++x] != ')');
if(x-curr == 2)
{
sprintf(buff, "%c%c", path[curr], path[curr+1]);
}
else if(x-curr == 1)
{
sprintf(buff, "%c", path[curr]);
}
else
{
printf("ERROR parsing device path\n");
}
if(!numpaths)
{
free(device);
return NULL;
}
device->numentries = 0x00;
string->length += device->length;
if(!string->entries)
{
if((string->entries = (struct DevPropDevice**)malloc(sizeof(device)))== NULL)
return 0;
{
free(device);
return NULL;
}
}
string->entries[string->numentries++] = (struct DevPropDevice*)malloc(sizeof(device));
string->entries[string->numentries-1] = device;
{
if(!nm || !vl || !len)
{
return 0;
}
uint32_t length = ((strlen(nm) * 2) + len + (2 * sizeof(uint32_t)) + 2);
uint8_t *data = (uint8_t*)malloc(length);
{
if(!data)
{
return 0;
}
memset(data, 0, length);
uint32_t off= 0;
uint8_t *newdata = (uint8_t*)malloc((length + offset));
if(!newdata)
{
return 0;
}
if(device->data)
{
if(offset > 1)
{
memcpy(newdata, device->data, offset);
}
}
memcpy(newdata + offset, data, length);
device->length += length;
device->numentries++;
if(!device->data)
{
device->data = (uint8_t*)malloc(sizeof(uint8_t));
}
else
{
free(device->data);
}
free(data);
device->data = newdata;
char *ptr = buffer;
if(!buffer)
{
return NULL;
}
sprintf(buffer, "%08x%08x%04x%04x", dp_swap32(string->length), string->WHAT2,
dp_swap16(string->numentries), string->WHAT3);
buffer += 8;
uint8_t *dataptr = string->entries[i]->data;
for(x = 0; x < (string->entries[i]->length) - (24 + (6 * string->entries[i]->num_pci_devpaths)) ; x++)
for(x = 0; (uint32_t)x < (string->entries[i]->length) - (24 + (6 * string->entries[i]->num_pci_devpaths)) ; x++)
{
sprintf(buffer, "%02x", *dataptr++);
buffer += 2;
void devprop_free_string(struct DevPropString *string)
{
if(!string)
{
return;
}
int i;
for(i = 0; i < string->numentries; i++)
int devprop_add_network_template(struct DevPropDevice *device, uint16_t vendor_id)
{
if(!device)
return 0;
uint8_t builtin = 0x0;
if((vendor_id != 0x168c) && (builtin_set == 0))
if(device)
{
builtin_set = 1;
builtin = 0x01;
if((vendor_id != 0x168c) && (builtin_set == 0))
{
builtin_set = 1;
builtin = 0x01;
}
if(!devprop_add_value(device, "built-in", (uint8_t*)&builtin, 1))
{
return 0;
}
devices_number++;
return 1;
}
if(!devprop_add_value(device, "built-in", (uint8_t*)&builtin, 1))
else
{
return 0;
devices_number++;
return 1;
}
}
void set_eth_builtin(pci_dt_t *eth_dev)
branches/ErmaC/Trunk/i386/libsaio/sys.c
180180
181181
182182
183
183
184184
185185
186186
187187
188
188
189189
190
190
191191
192192
193193
194194
195195
196196
197
197
198198
199199
200200
......
219219
220220
221221
222
222
223223
224224
225225
......
576576
577577
578578
579
579
580580
581581
582582
......
820820
821821
822822
823
823
824824
825825
826826
......
836836
837837
838838
839
839
840840
841841
842842
......
862862
863863
864864
865
865
866866
867867
868868
FSReadFile readFile;
BVRef bvr;
unsigned long length, length2;
// Resolve the boot volume from the file spec.
if ((bvr = getBootVolumeRef(fileSpec, &filePath)) == NULL)
return -1;
*binary = (void *)kLoadAddr;
// Read file into load buffer. The data in the load buffer will be
// overwritten by the next LoadFile() call.
gFSLoadAddress = (void *) LOAD_ADDR;
readFile = bvr->fs_readfile;
if (readFile != NULL) {
// Read the first 4096 bytes (fat header)
length = readFile(bvr, (char *)filePath, *binary, 0, 0x1000);
ThinFatFile(binary, &length);
}
}
return length;
}
int read(int fdesc, char * buf, int count)
{
struct iob * io;
if ((io = iob_from_fdesc(fdesc)) == NULL)
return (-1);
for ( bvr = chain; bvr; bvr = bvr->next )
if ( bvr->part_no == multiboot_partition && bvr->biosdev == gBIOSDev )
return bvr;
/*
* Checking "Default Partition" key in system configuration - use format: hd(x,y), the volume UUID or label -
* to override the default selection.
}
free(val);
}
/*
* Scannig the volume chain backwards and trying to find
* a HFS+ volume with valid boot record signature.
&& ! gBIOSBootVolume
&& bvr->biosdev == gBIOSDev )
bvr2 = bvr;
}
}
/*
branches/ErmaC/Trunk/i386/libsaio/cpu.c
288288
289289
290290
291
292
293
294
295
296
291
292
293
294
295
296
297297
298
299
298
299
300
300301
301302
302303
int intelCPU = p->CPU.Model;
if ((p->CPU.Family == 0x06 && p->CPU.Model >= 0x0c) || (p->CPU.Family == 0x0f && p->CPU.Model >= 0x03)) {
/* Nehalem CPU model */
if (p->CPU.Family == 0x06 && (p->CPU.Model == CPU_MODEL_NEHALEM ||
p->CPU.Model == CPU_MODEL_FIELDS ||
p->CPU.Model == CPU_MODEL_DALES ||
p->CPU.Model == CPU_MODEL_DALES_32NM ||
p->CPU.Model == CPU_MODEL_WESTMERE ||
p->CPU.Model == CPU_MODEL_NEHALEM_EX ||
if (p->CPU.Family == 0x06 && (p->CPU.Model == CPU_MODEL_NEHALEM||
p->CPU.Model == CPU_MODEL_FIELDS||
p->CPU.Model == CPU_MODEL_DALES||
p->CPU.Model == CPU_MODEL_DALES_32NM||
p->CPU.Model == CPU_MODEL_WESTMERE||
p->CPU.Model == CPU_MODEL_NEHALEM_EX||
p->CPU.Model == CPU_MODEL_WESTMERE_EX ||
p->CPU.Model == CPU_MODEL_SANDY ||
p->CPU.Model == CPU_MODEL_SANDY_XEON)) {
p->CPU.Model == CPU_MODEL_SANDYBRIDGE ||
p->CPU.Model == CPU_MODEL_JAKETOWN||
p->CPU.Model == CPU_MODEL_IVYBRIDGE)) {
msr = rdmsr64(MSR_PLATFORM_INFO);
DBG("msr(%d): platform_info %08x\n", __LINE__, bitfield(msr, 31, 0));
bus_ratio_max = bitfield(msr, 14, 8);
branches/ErmaC/Trunk/i386/libsaio/platform.h
3737
3838
3939
40
41
40
41
4242
43
44
45
43
44
45
46
4647
4748
4849
#define CPU_MODEL_ATOM0x1C// Atom
#define CPU_MODEL_FIELDS0x1E// Lynnfield, Clarksfield, Jasper Forest
#define CPU_MODEL_DALES0x1F// Havendale, Auburndale
#define CPU_MODEL_DALES_32NM0x25// Clarkdale, Arrandale
#define CPU_MODEL_SANDY0x2A// Sandy Bridge
#define CPU_MODEL_DALES_32NM0x25// Clarkdale, Arrandale
#define CPU_MODEL_SANDYBRIDGE0x2A// Sandy Bridge
#define CPU_MODEL_WESTMERE0x2C// Gulftown, Westmere-EP, Westmere-WS
#define CPU_MODEL_SANDY_XEON0x2D// Sandy Bridge Xeon
#define CPU_MODEL_NEHALEM_EX0x2E// Beckton
#define CPU_MODEL_WESTMERE_EX0x2F
#define CPU_MODEL_JAKETOWN0x2D// Sandy Bridge-E, Sandy Bridge-EP
#define CPU_MODEL_NEHALEM_EX0x2E// Beckton
#define CPU_MODEL_WESTMERE_EX0x2F
#define CPU_MODEL_IVYBRIDGE0x3A// Ivy Bridge
/* CPU Features */
#define CPU_FEATURE_MMX0x00000001// MMX Instruction Set
branches/ErmaC/Trunk/i386/libsaio/cpu.h
4848
4949
5050
51
52
53
54
55
51
52
53
54
55
56
57
5658
5759
5860
#define CPUID_MODEL_ATOM28// Intel Atom (45nm)
#define CPUID_MODEL_FIELDS30// Intel Core i5, i7, Xeon X34xx LGA1156 (45nm)
#define CPUID_MODEL_DALES31// Havendale, Auburndale
#define CPUID_MODEL_DALES_32NM37// Intel Core i3, i5 LGA1156 (32nm)
#define CPUID_MODEL_SANDY42// Intel Core i3, i5, i7 LGA1155 (32nm)
#define CPUID_MODEL_WESTMERE44// Intel Core i7, Xeon X56xx, Xeon E56xx, Xeon W36xx LGA1366 (32nm) 6 Core
#define CPUID_MODEL_NEHALEM_EX46// Intel Xeon X75xx, Xeon X65xx, Xeon E75xx, Xeon E65x
#define CPUID_MODEL_WESTMERE_EX47// Intel Xeon E7
#define CPUID_MODEL_DALES_32NM37// Intel Core i3, i5 LGA1156 (32nm)
#define CPUID_MODEL_SANDYBRIDGE42// Intel Core i3, i5, i7 LGA1155 (32nm)
#define CPUID_MODEL_WESTMERE44// Intel Core i7, Xeon X56xx, Xeon E56xx, Xeon W36xx LGA1366 (32nm) 6 Core
#define CPUID_MODEL_JAKETOWN45// Intel Xeon E5 LGA2011 (22nm)
#define CPUID_MODEL_NEHALEM_EX46// Intel Xeon X75xx, Xeon X65xx, Xeon E75xx, Xeon E65x
#define CPUID_MODEL_WESTMERE_EX47// Intel Xeon E7
#define CPUID_MODEL_IVYBRIDGE58// Intel Core i5, i7 LGA1155 (22nm)
static inline uint64_t rdtsc64(void)
branches/ErmaC/Trunk/i386/libsaio/smbios_getters.c
3131
3232
3333
34
35
34
35
3636
3737
3838
......
163163
164164
165165
166
167
168
166169
167170
168171
......
170173
171174
172175
173
174
176
177
175178
176
179
180
181
182
177183
178184
179185
......
183189
184190
185191
186
187
192
193
188194
189195
190196
......
194200
195201
196202
197
198
199
200
201
202203
203204
204205
{
// set external clock to 0 for SANDY
// removes FSB info from system profiler as on real mac's.
case CPU_MODEL_SANDY_XEON:
case CPU_MODEL_SANDY:
case CPU_MODEL_SANDYBRIDGE:
case CPU_MODEL_IVYBRIDGE:
value->word = 0;
break;
default:
return true;
case CPU_MODEL_NEHALEM:// Intel Core i7, Xeon W35xx, Xeon X55xx, Xeon E55xx LGA1366 (45nm)
case CPU_MODEL_WESTMERE:// Intel Core i7, Xeon X56xx, Xeon E56xx, Xeon W36xx LGA1366 (32nm) 6 Core
case CPU_MODEL_WESTMERE_EX:// Intel Xeon E7
case CPU_MODEL_JAKETOWN:// Intel Core i7, Xeon E5 LGA2011 (32nm)
if (strstr(Platform.CPU.BrandString, "Xeon(R)"))
value->word = 0x0501;// Xeon
else
return true;
case CPU_MODEL_FIELDS:// Intel Core i5, i7, Xeon X34xx LGA1156 (45nm)
if (strstr(Platform.CPU.BrandString, "Core(TM) i5"))
value->word = 0x0601;// Core i5
if (strstr(Platform.CPU.BrandString, "Xeon(R)"))
value->word = 0x0501;// Xeon
else
value->word = 0x0701;// Core i7
if (strstr(Platform.CPU.BrandString, "Core(TM) i5"))
value->word = 0x0601;// Core i5
else
value->word = 0x0701;// Core i7
return true;
case CPU_MODEL_DALES:
value->word = 0x0701;// Core i7
return true;
case CPU_MODEL_SANDY:// Intel Core i3, i5, i7 LGA1155 (32nm)
case CPU_MODEL_SANDY_XEON:// Intel Xeon E3
case CPU_MODEL_SANDYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (32nm)
case CPU_MODEL_IVYBRIDGE:// Intel Core i3, i5, i7 LGA1155 (22nm)
case CPU_MODEL_DALES_32NM:// Intel Core i3, i5 LGA1156 (32nm)
if (strstr(Platform.CPU.BrandString, "Core(TM) i3"))
value->word = 0x0901;// Core i3
else
value->word = 0x0701;// Core i7
return true;
case CPU_MODEL_WESTMERE:// Intel Core i7, Xeon X56xx, Xeon E56xx, Xeon W36xx LGA1366 (32nm) 6 Core
case CPU_MODEL_WESTMERE_EX:// Intel Xeon E7
value->word = 0x0501;// Core i7
return true;
}
}
}
branches/ErmaC/Trunk/i386/libsa/zalloc.c
111111
112112
113113
114
114
115115
116116
117117
smallestSize = 0;
bestFit = -1;
#endif
for (i = 0; i < availableNodes; i++)
{
// find node with equal size, or if not found,
branches/ErmaC/Trunk/i386/util/bdmesg.c
3232
3333
3434
35
35
36
3637
3738
3839
const UInt8 *msglog = CFDataGetBytePtr((CFDataRef)bootLog);
if (msglog)
printf("%s\n", msglog);
CFRelease(bootLog);
return 0;
}

Archive Download the corresponding diff file

Revision: 1918