Chameleon

Chameleon Commit Details

Date:2011-10-28 14:05:05 (12 years 5 months ago)
Author:armel cadet-petit
Commit:1667
Parents: 1666
Message:added a mechanism to strip the MADT(APIC) table in acpicodec
Changes:
M/branches/cparm/i386/modules/ACPICodec/acpi_codec.h
M/branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
M/branches/cparm/i386/modules/ACPICodec/acpicode.c
M/branches/cparm/i386/modules/ACPICodec/acpi_codec.c
M/branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c
M/branches/cparm/CHANGES
M/branches/cparm/i386/modules/ACPICodec/acpicode.h

File differences

branches/cparm/CHANGES
1
2
13
24
35
- Small security fix
- Added a mechanism to strip the madt table
- Ported the serial number randomizer to smbiosgetters,
Warning: smbiosgetters (and also the Gui module) still don't work when built with Xcode4.
branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
537537
538538
539539
540
540
541541
542542
543543
......
568568
569569
570570
571
571
572572
573573
574
574
575575
576576
577577
......
597597
598598
599599
600
600
601601
602602
603603
......
618618
619619
620620
621
621
622622
623623
624624
......
759759
760760
761761
762
762
763763
764
764
765765
766766
767767
char tmp[2];
bzero(tmp,sizeof(tmp));
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn1]);
strcpy (str, tmp);
strlcpy (str, tmp, sizeof(tmp)+1);
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn2]);
strcat (str, tmp);
if (rand_week < 10) {
sprintf(tmp,"0%d",rand_week);
strcpy (str, tmp);
strlcpy (str, tmp, sizeof(tmp)+1);
} else if (rand_week < 100) { // avoid overflow in case random return a number >= 100
sprintf(tmp,"%d",rand_week);
strcpy (str, tmp);
strlcpy (str, tmp, sizeof(tmp)+1);
}
DBG ("fake_week: %s\n",str);
if (rand_year < 10) {
sprintf(tmp,"%d",rand_year);
strcpy (str, tmp);
strlcpy (str, tmp, sizeof(tmp)+1);
}
DBG ("fake_year: %s\n",str);
rand_country = random(random_country_obj);
random_free(random_country_obj);
strcpy (str, sm_country_list[rand_country].code);
strlcpy (str, sm_country_list[rand_country].code,strlen(sm_country_list[rand_country].code)+1);
DBG ("fake_country: %s (%s)\n",str,sm_country_list[rand_country].info);
getBoolForKey(kSMBIOSRandomSerial, &randomSerial, &bootInfo->bootConfig) ;
if ( randomSerial ) // useless
strcat (fake_serial,sm_get_random_country());
strlcpy (fake_serial,sm_get_random_country(), strlen(sm_get_random_country())+1);
else
strcpy (fake_serial,sm_search_str(sm_chosen, "SMserialProductCountry"));
strlcpy (fake_serial,sm_search_str(sm_chosen, "SMserialProductCountry"), strlen(sm_search_str(sm_chosen, "SMserialProductCountry"))+1);
if ( randomSerial ) // useless
strcat (fake_serial,sm_get_random_year());
branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c
311311
312312
313313
314
314
315315
316316
317317
......
342342
343343
344344
345
345
346346
347347
348
348
349349
350350
351351
......
371371
372372
373373
374
374
375375
376376
377377
......
392392
393393
394394
395
395
396396
397397
398398
......
533533
534534
535535
536
536
537537
538
538
539539
540540
541541
char tmp[2];
bzero(tmp,sizeof(tmp));
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn1]);
strcpy (str, tmp);
strlcpy (str, tmp, sizeof(tmp)+1);
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn2]);
strcat (str, tmp);
if (rand_week < 10) {
sprintf(tmp,"0%d",rand_week);
strcpy (str, tmp);
strlcpy (str, tmp, sizeof(tmp)+1);
} else if (rand_week < 100) { // avoid overflow in case random return a number >= 100
sprintf(tmp,"%d",rand_week);
strcpy (str, tmp);
strlcpy (str, tmp, sizeof(tmp)+1);
}
DBG ("fake_week: %s\n",str);
if (rand_year < 10) {
sprintf(tmp,"%d",rand_year);
strcpy (str, tmp);
strlcpy (str, tmp, sizeof(tmp)+1);
}
DBG ("fake_year: %s\n",str);
rand_country = random(random_country_obj);
random_free(random_country_obj);
strcpy (str, sm_country_list[rand_country].code);
strlcpy (str, sm_country_list[rand_country].code,strlen(sm_country_list[rand_country].code)+1);
DBG ("fake_country: %s (%s)\n",str,sm_country_list[rand_country].info);
getBoolForKey(kSMBIOSRandomSerial, &randomSerial, &bootInfo->bootConfig) ;
if ( randomSerial ) // useless
strcat (fake_serial,sm_get_random_country());
strlcpy (fake_serial,sm_get_random_country(), strlen(sm_get_random_country())+1);
else
strcpy (fake_serial,sm_search_str(sm_chosen, "SMserialProductCountry"));
strlcpy (fake_serial,sm_search_str(sm_chosen, "SMserialProductCountry"), strlen(sm_search_str(sm_chosen, "SMserialProductCountry"))+1);
if ( randomSerial ) // useless
strcat (fake_serial,sm_get_random_year());
branches/cparm/i386/modules/ACPICodec/acpi_codec.h
2222
2323
2424
25
26
2527
2628
2729
#define KIntelFADT"IntelFADTSpec"/* acpi_codec.c */
#define kSTRIPAPIC "StripAPICTable" /* acpi_codec.c */
#define kRestartFix"RestartFix" /* acpi_codec.c */
#define KResetType"ResetType"/* acpi_codec.c */
#define PCI_RESET_TYPE0// (default)
branches/cparm/i386/modules/ACPICodec/acpicode.c
8888
8989
9090
91
9192
92
93
9394
9495
9596
return (1);
}
//-----------------------------------------------------------------------------
U32 ProcessMadt(ACPI_TABLE_MADT * madt, MADT_INFO * madt_info)
U32 ProcessMadtInfo(ACPI_TABLE_MADT * madt, MADT_INFO * madt_info)
{
void *current;
void *end;
branches/cparm/i386/modules/ACPICodec/acpi_codec.c
140140
141141
142142
143
143
144
145
144146
145147
146148
......
150152
151153
152154
153
155
154156
155157
156158
......
195197
196198
197199
198
200
199201
200202
201203
204
205
202206
203
204
205207
206208
207209
......
27092711
27102712
27112713
2712
2714
2715
27132716
2714
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
27153001
27163002
27173003
2718
2719
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
27203054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
27213083
27223084
27233085
......
27323094
27333095
27343096
2735
2736
2737
2738
2739
27403097
27413098
27423099
......
27483105
27493106
27503107
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
3108
27633109
27643110
27653111
27663112
2767
3113
27683114
27693115
27703116
......
38384184
38394185
38404186
3841
4187
38424188
38434189
38444190
......
38704216
38714217
38724218
3873
38744219
38754220
38764221
......
38984243
38994244
39004245
3901
4246
39024247
39034248
39044249
......
39154260
39164261
39174262
3918
39194263
39204264
39214265
......
39684312
39694313
39704314
3971
3972
3973
3974
4315
39754316
39764317
39774318
......
40754416
40764417
40774418
4078
4419
40794420
40804421
40814422
......
48815222
48825223
48835224
4884
4885
5225
48865226
48875227
48885228
......
49135253
49145254
49155255
4916
4917
5256
49185257
49195258
49205259
......
52635602
52645603
52655604
5266
5267
5268
5269
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
52705642
52715643
52725644
#define MSR_RAPL_POWER_UNIT 0x606
#define MSR_PKG_RAPL_POWER_LIMIT 0x610
static U32 turbo_enabled = 0;
static U32 BuildSsdt(ACPI_TABLE_MADT * madt, ACPI_TABLE_DSDT *dsdt, void * buffer, U32 bufferSize, bool enable_cstates, bool enable_pstates, bool enable_tstates);
static U32 ProcessMadt(ACPI_TABLE_MADT * madt, MADT_INFO * madt_info, void * buffer, U32 bufferSize, U32 NB_CPU);
static U32 buildMADT(U32 * new_table_list, ACPI_TABLE_DSDT *dsdt, MADT_INFO * madt_info);
static U32 BuildSsdt(MADT_INFO * madt_info, ACPI_TABLE_DSDT *dsdt, void * buffer, U32 bufferSize, bool enable_cstates, bool enable_pstates, bool enable_tstates);
static bool is_sandybridge(void);
static bool is_jaketown(void);
static U32 encode_pstate(U32 ratio);
#endif
static U32 BuildCstateInfo(CPU_DETAILS * cpu, U32 pmbase);
static U32 BuildPstateInfo(CPU_DETAILS * cpu);
static U32 ProcessSsdt(U32 * new_table_list, ACPI_TABLE_DSDT *dsdt, bool enable_cstates, bool enable_pstates, bool enable_tstates );
static U32 ProcessSsdt(U32 * new_table_list, ACPI_TABLE_DSDT *dsdt, MADT_INFO * madt_info, bool enable_cstates, bool enable_pstates, bool enable_tstates );
static void * buildCpuScope (void * current, U32 cpu_namespace, PROCESSOR_NUMBER_TO_NAMESEG * aslCpuNamePath);
static void * buildPDC(void * current);
static void * buildOSC(void * current);
#define MAX_SSDT_TABLE 15 // 15 additional SSDT tables
#define MAX_ACPI_TABLE MAX_NON_SSDT_TABLE + MAX_SSDT_TABLE
// Security space for SSDT & FACP generation,
// Security space for SSDT , FACP & MADT table generation,
// the size can be increased
// note: the table will not placed in the reserved space if the 'normal' space is not full
#if OLD_SSDT
#define RESERVED_AERA 4
#else
#define RESERVED_AERA 3
#else
#define RESERVED_AERA 2
#endif
#define ACPI_TABLE_LIST_FULL MAX_ACPI_TABLE + RESERVED_AERA + 1
}
#endif
static U32 ProcessSsdt(U32 * new_table_list, ACPI_TABLE_DSDT *dsdt, bool enable_cstates, bool enable_pstates, bool enable_tstates )
//-----------------------------------------------------------------------------
U32 ProcessMadt(ACPI_TABLE_MADT * madt, MADT_INFO * madt_info, void * buffer, U32 bufferSize, U32 nb_cpu)
{
DBG("Processing SSDT\n");
void *current;
void *currentOut;
void *end;
void * endOut;
U32 LOCAL_APIC_NMI_CNT = 0, LOCAL_SAPIC_CNT = 0, INT_SRC_CNT = 0, Length = 0;
// Quick sanity check for a valid MADT
if (madt == 0ul || !nb_cpu)
return (0);
// Confirm a valid MADT buffer was provided
if (!buffer)
{
printf("Error: Invalid Buffer Address for MADT\n");
return(0);
}
// Confirm a valid MADT buffer length was provided
if (!bufferSize)
{
printf("Error: Invalid Buffer Length for MADT\n");
return(0);
}
madt_info->lapic_count = 0;
memcpy(buffer, madt, sizeof(ACPI_TABLE_MADT));
// Search MADT for Sub-tables with needed data
current = madt + 1;
currentOut = buffer + sizeof(ACPI_TABLE_MADT) ;
end = (U8 *) madt + madt->Header.Length;
endOut = (U8 *)buffer + bufferSize;
// Check to confirm no MADT buffer overflow
if ( (U8 *)currentOut > (U8 *)endOut )
{
printf("Error: MADT Buffer Length exceeded available space \n");
return(0);
}
Length += sizeof(ACPI_TABLE_MADT);
while (current < end)
{
ACPI_SUBTABLE_HEADER *subtable = current;
ACPI_SUBTABLE_HEADER *subtableOut = currentOut;
switch (subtable->Type)
{
case ACPI_MADT_TYPE_LOCAL_APIC:
{
// Process sub-tables with Type as 0: Processor Local APIC
ACPI_MADT_LOCAL_APIC *lapic = current;
current = lapic + 1;
if (!(lapic->LapicFlags & ACPI_MADT_ENABLED))
continue;
if (madt_info->lapic_count >= nb_cpu)
continue;
// copy subtable
{
memcpy(currentOut, lapic, lapic->Header.Length);
currentOut = currentOut + lapic->Header.Length;
// Check to confirm no MADT buffer overflow
if ( (U8 *)currentOut > (U8 *)endOut )
{
printf("Error: MADT Buffer Length exceeded available space \n");
return(0);
}
}
{
LAPIC_INFO *lapic_info = &madt_info->lapic[madt_info->lapic_count];
lapic_info->processorId = lapic->ProcessorId;
lapic_info->apicId = lapic->Id;
lapic_info->madt_type = ACPI_MADT_TYPE_LOCAL_APIC;
}
madt_info->lapic_count++;
Length += lapic->Header.Length;
// Sanity check to verify compile time limit for max logical CPU is not exceeded
if (madt_info->lapic_count > MAX_LOGICAL_CPU)
return (0);
break;
}
case ACPI_MADT_TYPE_X2APIC:
{
// Process sub-tables with Type as 9: Processor X2APIC
ACPI_MADT_X2APIC *x2apic = current;
current = x2apic + 1;
if (!(x2apic->x2apicFlags & ACPI_MADT_ENABLED))
continue;
if (madt_info->lapic_count >= nb_cpu)
continue;
// copy subtable
{
memcpy(currentOut, x2apic, x2apic->Header.Length);
currentOut = currentOut + x2apic->Header.Length;
// Check to confirm no MADT buffer overflow
if ( (U8 *)currentOut > (U8 *)endOut )
{
printf("Error: MADT Buffer Length exceeded available space \n");
return(0);
}
}
{
LAPIC_INFO *lapic_info = &madt_info->lapic[madt_info->lapic_count];
lapic_info->uid = x2apic->UID;
lapic_info->apicId = x2apic->x2apicId;
lapic_info->madt_type = ACPI_MADT_TYPE_X2APIC;
}
madt_info->lapic_count++;
Length += x2apic->Header.Length;
// Sanity check to verify compile time limit for max logical CPU is not exceeded
if (madt_info->lapic_count > MAX_LOGICAL_CPU)
return (0);
break;
}
case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
{
// Process sub-tables with Type as 4: Local APIC NMI
ACPI_MADT_LOCAL_APIC_NMI *nmi = current;
current = nmi + 1;
if (LOCAL_APIC_NMI_CNT >= nb_cpu)
continue;
memcpy(currentOut, nmi, nmi->Header.Length);
currentOut = currentOut + nmi->Header.Length;
// Check to confirm no MADT buffer overflow
if ( (U8 *)currentOut > (U8 *)endOut )
{
printf("Error: MADT Buffer Length exceeded available space \n");
return(0);
}
LOCAL_APIC_NMI_CNT++;
Length += nmi->Header.Length;
// Sanity check to verify compile time limit for max logical CPU is not exceeded
if (LOCAL_APIC_NMI_CNT > MAX_LOGICAL_CPU)
return (0);
break;
}
case ACPI_MADT_TYPE_LOCAL_SAPIC:
{
// Process sub-tables with Type as 7: Local Sapic
ACPI_MADT_LOCAL_SAPIC *sapic = current;
current = sapic + 1;
if (LOCAL_SAPIC_CNT >= nb_cpu)
continue;
memcpy(currentOut, sapic, sapic->Header.Length);
currentOut = currentOut + sapic->Header.Length;
// Check to confirm no MADT buffer overflow
if ( (U8 *)currentOut > (U8 *)endOut )
{
printf("Error: MADT Buffer Length exceeded available space \n");
return(0);
}
LOCAL_SAPIC_CNT++;
Length += sapic->Header.Length;
// Sanity check to verify compile time limit for max logical CPU is not exceeded
if (LOCAL_SAPIC_CNT > MAX_LOGICAL_CPU)
return (0);
break;
}
case ACPI_MADT_TYPE_INTERRUPT_SOURCE:
{
// Process sub-tables with Type as 8: Platform Interrupt Source
ACPI_MADT_INTERRUPT_SOURCE *intsrc = current;
current = intsrc + 1;
if (INT_SRC_CNT >= nb_cpu)
continue;
memcpy(currentOut, intsrc, intsrc->Header.Length);
currentOut = currentOut + intsrc->Header.Length;
// Check to confirm no MADT buffer overflow
if ( (U8 *)currentOut > (U8 *)endOut )
{
printf("Error: MADT Buffer Length exceeded available space \n");
return(0);
}
INT_SRC_CNT++;
Length += intsrc->Header.Length;
// Sanity check to verify compile time limit for max logical CPU is not exceeded
if (INT_SRC_CNT > MAX_LOGICAL_CPU)
return (0);
break;
}
default:
{
// Process all other sub-tables
current = (U8 *) subtable + subtable->Length;
currentOut = (U8 *) subtableOut + subtable->Length;
memcpy(subtableOut, subtable, subtable->Length);
// Check to confirm no MADT buffer overflow
if ( (U8 *)currentOut > (U8 *)endOut )
{
printf("Error: MADT Buffer Length exceeded available space \n");
return(0);
}
Length += subtable->Length;
break;
}
} // switch
} // while
{
ACPI_TABLE_MADT * new_madt = (ACPI_TABLE_MADT * )buffer;
// Update the Lenght of the new MADT table
new_madt->Header.Length = Length;
// Update the checksum of the new MADT table
SetChecksum(&new_madt->Header);
}
return (1);
}
static U32 buildMADT(U32 * new_table_list, ACPI_TABLE_DSDT *dsdt, MADT_INFO * madt_info)
{
DBG("Build MADT\n");
ACPI_TABLE_MADT * madt_file = (void*)0ul;
ACPI_TABLE_MADT * MadtPointer = (void*)0ul;
U8 new_table_index = 0;
bool oem_apic=false;
bool oem_apic=false;
U8 new_table_index = 0;
// Check that we have a valid cpu_map (if it's not already done, it will try to generate it)
if (generate_cpu_map_from_acpi(dsdt) != 0)
{
return(0);
}
{
bool tmpval;
oem_apic=getBoolForKey(kOEMAPIC, &tmpval, &bootInfo->bootConfig)&&tmpval;
}
if (oem_apic == true)
{
return(0);
}
if ((madt_file = (ACPI_TABLE_MADT *)get_new_table_in_list(new_table_list, NAMESEG("APIC"), &new_table_index)) != (void *)0ul)
{
MadtPointer = (ACPI_TABLE_MADT *)madt_file;
new_table_list[new_table_index] = 0ul; // This way, the non-patched table will not be added in our new rsdt/xsdt table list // note: for now we don't patch this table
}
else
{
MadtPointer = (acpi_tables.MadtPointer64 != (void*)0ul) ? (ACPI_TABLE_MADT *)acpi_tables.MadtPointer64 : (ACPI_TABLE_MADT *)acpi_tables.MadtPointer;
new_table_index = get_0ul_index_in_list(new_table_list, true);
// Check to confirm space is available
if (new_table_index == ACPI_TABLE_LIST_FULL)
{
printf("Error: not enought reserved space in the new acpi list for the MADT table,\n ");
printf(" please increase the RESERVED_AERA\n");
return(0);
}
}
// Create buffer for MADT
U8 memory_for_madt[2 * 1024];
// Build the new MADT
if ( (ProcessMadt(MadtPointer, madt_info, memory_for_madt, sizeof(memory_for_madt), cpu_map_count))== 0)
{
printf("Error: Failed to build MADT table\n");
return (0);
}
// insert MADT in the new_table_list
{
// Create pointer to MADT just built in the stack buffer
ACPI_TABLE_MADT * old_madt = (ACPI_TABLE_MADT *)memory_for_madt;
// Reserved kernel memory for the madt table
ACPI_TABLE_MADT *new_madt = (ACPI_TABLE_MADT *)AllocateKernelMemory(old_madt->Header.Length);
if (!new_madt)
{
printf("Unable to allocate kernel memory for MADT ");
return (0);
}
// Move the old stack buffer to kernel memory
memcpy(new_madt, old_madt, old_madt->Header.Length);
// Add the new madt into an empty space of the new_table_list
new_table_list[new_table_index] = (U32)new_madt;
}
verbose ("MADT table successfully patched\n");
return(1);
}
static U32 ProcessSsdt(U32 * new_table_list, ACPI_TABLE_DSDT *dsdt, MADT_INFO * madt_info, bool enable_cstates, bool enable_pstates, bool enable_tstates )
{
DBG("Processing SSDT\n");
if (Platform->CPU.Vendor != 0x756E6547) {
verbose ("Not an Intel platform: SSDT will not be generated !!!\n");
return(0);
verbose ("DSDT not found: SSDT will not be generated !!!\n");
return (0);
}
{
bool tmpval;
oem_apic=getBoolForKey(kOEMAPIC, &tmpval, &bootInfo->bootConfig)&&tmpval;
}
// Get an empty space in the new_talbe_list (true = allow reserved space)
U8 empty = get_0ul_index_in_list(new_table_list, true);
printf(" please increase the RESERVED_AERA\n");
return(0);
}
if ((madt_file = (ACPI_TABLE_MADT *)get_new_table_in_list(new_table_list, NAMESEG("APIC"), &new_table_index)) != (void *)0ul)
{
if (oem_apic == false)
{
MadtPointer = (ACPI_TABLE_MADT *)madt_file;
//new_table_list[new_table_index] = 0ul; // This way, the non-patched table will not be added in our new rsdt/xsdt table list // note: for now we don't patch this table
}
} else
MadtPointer = (acpi_tables.MadtPointer64 != (void*)0ul) ? (ACPI_TABLE_MADT *)acpi_tables.MadtPointer64 : (ACPI_TABLE_MADT *)acpi_tables.MadtPointer;
// Create buffer for SSDT
U8 memory_for_ssdt[20 * 1024];
// Build the SSDT
if ( (BuildSsdt(MadtPointer, dsdt, memory_for_ssdt, sizeof(memory_for_ssdt), enable_cstates, enable_pstates, enable_tstates)) == 0)
if ( (BuildSsdt(madt_info, dsdt, memory_for_ssdt, sizeof(memory_for_ssdt), enable_cstates, enable_pstates, enable_tstates)) == 0)
{
printf("Error: Failed to build SSDT table\n");
return (0);
#endif
//-----------------------------------------------------------------------------
static U32 BuildSsdt(ACPI_TABLE_MADT * madt, ACPI_TABLE_DSDT *dsdt, void * buffer, U32 bufferSize, bool enable_cstates, bool enable_pstates, bool enable_tstates)
static U32 BuildSsdt(MADT_INFO * madt_info, ACPI_TABLE_DSDT *dsdt, void * buffer, U32 bufferSize, bool enable_cstates, bool enable_pstates, bool enable_tstates)
{
// Build SSDT
{
U32 pstates_enabled = 0;
U32 cstates_enabled = 0;
CPU_DETAILS cpu;
MADT_INFO madt_info;
U8 ACPI_COORD_TYPE = ACPI_COORD_TYPE_SW_ANY; // default
ACPI_TABLE_SSDT *SsdtPointer = (void*)0ul;
return(0);
}
if (madt == (void*) 0ul)
if (madt_info == (void*) 0ul)
{
return(0);
}
}
collect_cpu_info(&cpu);
ProcessMadt(madt, &madt_info);
if (enable_cstates && pmbase)
{
// (3) For each logical processor CPUn
// We will use the dsdt datas in place of madt,for the cpu(s) detection.
// Most users use the dsdt table to change the numbers of cpu(s) that the OS and the bootloader should use,
// (MADT patch to sync the nb of cpu(s) with DSDT is still in progress,
// in an ideal world we should sync the dsdt and madt tables with the with the cpu options found into the boot.plist in first,
// then the number of core cpu detected by cpu.c, then the dsdt )
// 'Cause most users use the dsdt table to change the numbers of cpu(s) that the OS and the bootloader should use,
// Note also that due to chameleon limit we use the same package per each cpu(s) for all objects and methods
// (package detection for each cpu(s) is still in progress)
{
// (3.4.4) Create PSD with hardware coordination
{
DBG("Building _PSD Method\n");
U32 domain = madt_info.lapic[lapic_index].pkg_index;
U32 domain = madt_info->lapic[lapic_index].pkg_index;
// In this (bad?) implementation we use the nb of cpu found in the dsdt
U32 cpusInDomain = cpu_map_count;
ACPI_TABLE_FADT *fadt_file = (void *)0ul; // a Pointer to the (non-patched) fadt file
ACPI_TABLE_FADT *FacpPointer = (void *)0ul; // a Pointer to the non-patched FACP table, it can be a file or the FACP table found in the RSDT/XSDT
ACPI_TABLE_RSDP *rsdp_mod = (void *)0ul, *rsdp_conv= (void *)0ul;
U32 rsdplength;
bool update_acpi=false, gen_xsdt=false;
oem_dsdt=getBoolForKey(kOEMDSDT, &tmpval, &bootInfo->bootConfig)&&tmpval;
oem_fadt=getBoolForKey(kOEMFADT, &tmpval, &bootInfo->bootConfig)&&tmpval;
gen_csta=getBoolForKey(kGenerateCStates, &tmpval, &bootInfo->bootConfig)&&tmpval;
gen_psta=getBoolForKey(kGeneratePStates, &tmpval, &bootInfo->bootConfig)&&tmpval;
#if !OLD_SSDT
}
}
#else
if (gen_ssdt || gen_csta || gen_psta || gen_tsta)
{
ProcessSsdt(new_table_list, DsdtPtr, gen_csta, gen_psta, gen_tsta );
}
{
MADT_INFO madt_info;
bool strip_madt = true;
getBoolForKey(kSTRIPAPIC, &strip_madt, &bootInfo->bootConfig);
if ((strip_madt == false) || (!buildMADT(new_table_list, DsdtPtr, &madt_info )))
{
ACPI_TABLE_MADT * madt_file = (void*)0ul;
ACPI_TABLE_MADT * MadtPointer = (void*)0ul;
bool oem_apic=false;
{
bool tmpval;
oem_apic=getBoolForKey(kOEMAPIC, &tmpval, &bootInfo->bootConfig)&&tmpval;
}
if ((madt_file = (ACPI_TABLE_MADT *)get_new_table_in_list(new_table_list, NAMESEG("APIC"), &new_table_index)) != (void *)0ul)
{
if (oem_apic == false)
{
MadtPointer = (ACPI_TABLE_MADT *)madt_file;
}
} else
MadtPointer = (acpi_tables.MadtPointer64 != (void*)0ul) ? (ACPI_TABLE_MADT *)acpi_tables.MadtPointer64 : (ACPI_TABLE_MADT *)acpi_tables.MadtPointer;
ProcessMadtInfo(MadtPointer, &madt_info);
}
if (gen_ssdt || gen_csta || gen_psta || gen_tsta)
{
ProcessSsdt(new_table_list, DsdtPtr, &madt_info, gen_csta, gen_psta, gen_tsta );
}
}
#endif
if ((rsdp_mod != (void *)0ul) && (rsdp_mod->Length >= ACPI_RSDP_REV0_SIZE) )
branches/cparm/i386/modules/ACPICodec/acpicode.h
3939
4040
4141
42
42
4343
4444
4545
U32 update_rsdp_with_rsdt(ACPI_TABLE_RSDP *rsdp, ACPI_TABLE_RSDT *rsdt);
void SetChecksum(struct acpi_table_header *header);
U32 ProcessMadt(ACPI_TABLE_MADT * madt, MADT_INFO * madt_info);
U32 ProcessMadtInfo(ACPI_TABLE_MADT * madt, MADT_INFO * madt_info);
void MoveRsdtInsertSsdt(ACPI_TABLE_RSDP * RsdPointer, ACPI_TABLE_RSDT * OldRsdtPointer, ACPI_TABLE_RSDT * NewRsdtPointer, ACPI_TABLE_SSDT * SsdtPointer);
void InsertSsdt(ACPI_TABLE_RSDT * RsdtPointer, ACPI_TABLE_SSDT * SsdtPointer);
void InsertSsdt64(ACPI_TABLE_XSDT * XsdtPointer, ACPI_TABLE_SSDT * SsdtPointer);

Archive Download the corresponding diff file

Revision: 1667