Chameleon

Chameleon Commit Details

Date:2012-02-09 17:08:37 (8 years 8 months ago)
Author:armel cadet-petit
Commit:1815
Parents: 1814
Message:starting to work on xcode4 compatibility
Changes:
M/branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
M/branches/cparm/i386/libsaio/platform.c
M/branches/cparm/i386/libsaio/platform.h
M/branches/cparm/i386/modules/ACPICodec/acpi_codec.c
M/branches/cparm/i386/libsaio/saio_internal.h

File differences

branches/cparm/i386/libsaio/platform.c
2424
2525
2626
27
27
2828
29
29
3030
3131
3232
33
33
3434
35
35
3636
3737
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
3873
3974
4075
PlatformInfo_t *Platform;
/** Return if a CPU feature specified by feature is activated (true) or not (false) */
inline bool platformCPUFeature(uint32_t feature)
bool platformCPUFeature(uint32_t feature)
{
return (Platform->CPU.Features & feature);
return (Platform->CPU.Features & feature) ? true : false;
}
/** Return if a CPU Extended feature specified by feature is activated (true) or not (false) */
inline bool platformCPUExtFeature(uint32_t feature)
bool platformCPUExtFeature(uint32_t feature)
{
return (Platform->CPU.ExtFeatures & feature);
return (Platform->CPU.ExtFeatures & feature) ? true : false;
}
bool platformIsIntel(void)
{
return (Platform->CPU.Vendor == 0x756E6547) ? true : false;
}
uint32_t getCPUnCores(void)
{
return Platform->CPU.NoCores;
}
uint32_t getCPUnThreads(void)
{
return Platform->CPU.NoThreads;
}
uint8_t getCPUModel(void)
{
return Platform->CPU.Model;
}
uint8_t getCPUFamily(void)
{
return Platform->CPU.Family;
}
bool platformIsServer(void)
{
return (Platform->CPU.isServer) ? true : false;
}
bool platformIsMobile(void)
{
return (Platform->CPU.isMobile) ? true : false;
}
/**
Scan platform hardware information, called by the main entry point (common_boot() )
_before_ bootConfig xml parsing settings are loaded
branches/cparm/i386/libsaio/platform.h
1111
1212
1313
14
15
16
17
1814
1915
2016
2117
2218
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
4019
4120
4221
#include "cpuid.h"
#include "cpu_data.h"
extern bool platformCPUExtFeature(uint32_t);
extern bool platformCPUFeature(uint32_t);
extern void scan_platform(void);
#define bitmask(h,l)((_Bit(h)|(_Bit(h)-1)) & ~(_Bit(l)-1))
#define bitfield(x,h,l)(((x) & bitmask(h,l)) >> l)
#define quad(hi,lo) (((uint64_t)(hi)) << 32 | (lo))
/* CPUID index into cpuid_raw */
/*
#define CPUID_00
#define CPUID_11
#define CPUID_22
#define CPUID_33
#define CPUID_44
#define CPUID_55
#define CPUID_66
#define CPUID_807
#define CPUID_818
#define CPUID_B09
#define CPUID_B110
#define CPUID_MAX11
*/
/* Additional models supported by Chameleon (NOT SUPPORTED BY THE APPLE'S ORIGINAL KERNEL) */
#define CPUID_MODEL_BANIAS 0x09
#define CPUID_MODEL_DOTHAN 0x0D
branches/cparm/i386/libsaio/saio_internal.h
164164
165165
166166
167
168
169
170
171
172
173
174
175
176
177
167178
168179
169
170180
171181
172182
extern BVRef nbpScanBootVolumes(int biosdev, int *count);
#endif
/* platform.h */
extern bool platformCPUExtFeature(uint32_t);
extern bool platformCPUFeature(uint32_t);
extern void scan_platform(void);
extern bool platformIsIntel(void);
extern uint8_t getCPUModel(void);
extern uint8_t getCPUFamily(void);
extern uint32_t getCPUnCores(void);
extern uint32_t getCPUnThread(void);
extern bool platformIsMobile(void);
extern bool platformIsServer(void);
/* stringTable.c */
extern char * newStringFromList(char **list, int *size);
extern int stringLength(const char *table, int compress);
branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
635635
636636
637637
638
638
639639
640640
641
642
641
642
643643
644644
645645
646646
647647
648
648
649649
650650
651651
......
655655
656656
657657
658
658
659659
660660
661661
662
662
663663
664664
665665
......
10121012
10131013
10141014
1015
1015
10161016
10171017
10181018
1019
1019
10201020
10211021
10221022
const SMStrEntryPair*sm_defaults;
const SMStrEntryPair*sm_chosen;
if (Platform->CPU.isServer == true)
if (platformIsServer() == true)
{
sm_defaults=sm_xserve_defaults;
} else if (Platform->CPU.isMobile == true) {
if (Platform->CPU.NoCores > 1) {
} else if (platformIsMobile() == true) {
if (getCPUnCores() > 1) {
sm_defaults=sm_macbookpro_defaults;
} else {
sm_defaults=sm_macbook_defaults;
}
} else {
switch (Platform->CPU.NoCores)
switch (getCPUnCores())
{
case 1:
sm_defaults=sm_macmini_defaults;
break;
default:
{
switch (Platform->CPU.Family)
switch (getCPUFamily())
{
case 0x06:
{
switch (Platform->CPU.Model)
switch (getCPUModel())
{
case CPUID_MODEL_FIELDS: // Intel Core i5, i7 LGA1156 (45nm)
case CPUID_MODEL_DALES: // Intel Core i5, i7 LGA1156 (45nm) ???
{
SMBOemProcessorBusSpeed *p = (SMBOemProcessorBusSpeed *)structPtr->new;
switch (Platform->CPU.Family)
switch (getCPUFamily())
{
case 0x06:
{
switch (Platform->CPU.Model)
switch (getCPUModel())
{
case 0x19:// Intel Core i5 650 @3.20 Ghz
case CPUID_MODEL_FIELDS:// Intel Core i5, i7 LGA1156 (45nm)
branches/cparm/i386/modules/ACPICodec/acpi_codec.c
765765
766766
767767
768
768
769769
770770
771771
772772
773
773
774774
775775
776776
......
10361036
10371037
10381038
1039
1039
10401040
10411041
10421042
1043
1043
10441044
10451045
10461046
......
10521052
10531053
10541054
1055
1055
10561056
10571057
10581058
......
24262426
24272427
24282428
2429
2429
2430
24302431
2431
24322432
2433
2433
24342434
24352435
24362436
......
24912491
24922492
24932493
2494
2494
2495
24952496
24962497
2497
2498
24982499
24992500
25002501
......
39783979
39793980
39803981
3981
3982
39823983
39833984
39843985
......
41244125
41254126
41264127
4127
4128
41284129
41294130
41304131
static bool is_sandybridge(void)
{
return Platform->CPU.Model == CPUID_MODEL_SANDYBRIDGE;
return getCPUModel() == CPUID_MODEL_SANDYBRIDGE;
}
static bool is_jaketown(void)
{
return Platform->CPU.Model == CPUID_MODEL_JAKETOWN;
return getCPUModel() == CPUID_MODEL_JAKETOWN;
}
static U32 get_bclk(void)
#endif
switch (Platform->CPU.Family)
switch (getCPUFamily())
{
case 0x06:
{
switch (Platform->CPU.Model)
switch (getCPUModel())
{
case CPUID_MODEL_DOTHAN:
case CPUID_MODEL_YONAH: // Yonah
cpu->core_c1_supported = ((Platform->CPU.sub_Cstates >> 4) & 0xf) ? 1 : 0;
cpu->core_c4_supported = ((Platform->CPU.sub_Cstates >> 16) & 0xf) ? 1 : 0;
if (Platform->CPU.Model == CPUID_MODEL_ATOM)
if (getCPUModel() == CPUID_MODEL_ATOM)
{
cpu->core_c2_supported = cpu->core_c3_supported = ((Platform->CPU.sub_Cstates >> 8) & 0xf) ? 1 : 0;
cpu->core_c6_supported = ((Platform->CPU.sub_Cstates >> 12) & 0xf) ? 1 : 0;
}
// Create buffer for MADT
U8 memory_for_madt[2 * 1024];
//U8 memory_for_madt[2 * 1024]; // seems to bug with xcode4, need to found out what is going on (not enough memory in the stack ?)
U8 *memory_for_madt = (U8*)AllocateKernelMemory(2 * 1024);
// Build the new MADT
if ( (ProcessMadt(MadtPointer, madt_info, memory_for_madt, sizeof(memory_for_madt), cpu_map_count))== 0)
if ( (ProcessMadt(MadtPointer, madt_info, memory_for_madt, 2 * 1024, cpu_map_count))== 0)
{
printf("Error: Failed to build MADT table\n");
return (0);
}
// Create buffer for SSDT
U8 memory_for_ssdt[20 * 1024];
//U8 memory_for_ssdt[20 * 1024];// seems to bug with xcode4, need to found out what is going on (not enough memory in the stack ?)
U8 *memory_for_ssdt =(U8*)AllocateKernelMemory(20 * 1024);
// Build the SSDT
if ( (BuildSsdt(madt_info, dsdt, memory_for_ssdt, sizeof(memory_for_ssdt), enable_cstates, enable_pstates, enable_tstates)) == 0)
if ( (BuildSsdt(madt_info, dsdt, memory_for_ssdt, 20 * 1024 /*sizeof(memory_for_ssdt)*/, enable_cstates, enable_pstates, enable_tstates)) == 0)
{
printf("Error: Failed to build SSDT table\n");
return (0);
const char * value;
// Restart Fix
if (Platform->CPU.Vendor == 0x756E6547) /* Intel */
if (platformIsIntel()) /* Intel */
{
fix_restart = true;
getBoolForKey(kRestartFix, &fix_restart, &bootInfo->bootConfig);
bool val = false;
getBoolForKey("PreferInternalProfileDetect", &val, &bootInfo->bootConfig); // if true Give prior to the profile resolved trought the CPU model
val = Platform->CPU.isServer ;
val = platformIsServer() ;
if (fadt_mod->PreferredProfile <= MaxSupportedPMProfile && !val)
{

Archive Download the corresponding diff file

Revision: 1815