Chameleon

Chameleon Commit Details

Date:2012-07-23 12:09:46 (2 years 4 months ago)
Author:armel cadet-petit
Commit:2031
Parents: 2030
Message:Ported acpicodec, warning cpuid index order have changed
Changes:
A/trunk/i386/modules/Sata/include/include/acpi_codec.h
A/trunk/i386/modules/Sata/include/include
A/trunk/i386/modules/Sata/include/include/datatype.h
A/trunk/i386/modules/Sata/include/include/acpi.h
A/trunk/i386/modules/Sata/include/include/ppmsetup.h
A/trunk/i386/modules/Sata/include/acpicode.c
A/trunk/i386/modules/Sata/include/include/acpidecode.h
A/trunk/i386/modules/Sata/include/acpi_codec.c
A/trunk/i386/modules/Sata/include/ACPICodec.c
A/trunk/i386/modules/Sata/include/acpidecode.c
A/trunk/i386/modules/Sata/include/include/ppm.h
A/trunk/i386/modules/Sata/include/include/acpi_tools.h
A/trunk/i386/modules/Sata/include/Cconfig
A/trunk/i386/modules/Sata/include/Readme.txt
A/trunk/i386/modules/Sata/include/Makefile
A/trunk/i386/modules/Sata/include/acpi_tools.c
A/trunk/i386/modules/Sata/include/include/intel_acpi.h
A/trunk/i386/modules/Sata/include/include/acpicode.h
M/trunk/i386/modules/Cconfig
M/trunk/i386/modules/Makefile
M/trunk/i386/libsaio/cpu.c
M/trunk/i386/libsaio/platform.h

File differences

trunk/i386/libsaio/cpu.c
238238
239239
240240
241
242
243
244
245
246
241247
242248
243249
do_cpuid(0x00000003, p->CPU.CPUID[CPUID_3]);
do_cpuid2(0x00000004, 0, p->CPU.CPUID[CPUID_4]);
do_cpuid(0x80000000, p->CPU.CPUID[CPUID_80]);
if (p->CPU.CPUID[CPUID_0][0] >= 0x5) {
do_cpuid(5, p->CPU.CPUID[CPUID_5]);
}
if (p->CPU.CPUID[CPUID_0][0] >= 6) {
do_cpuid(6, p->CPU.CPUID[CPUID_6]);
}
if ((p->CPU.CPUID[CPUID_80][0] & 0x0000000f) >= 8) {
do_cpuid(0x80000008, p->CPU.CPUID[CPUID_88]);
do_cpuid(0x80000001, p->CPU.CPUID[CPUID_81]);
trunk/i386/libsaio/platform.h
2323
2424
2525
26
27
28
29
30
26
27
28
29
30
31
3132
3233
3334
#define CPUID_22
#define CPUID_33
#define CPUID_44
#define CPUID_65
#define CPUID_806
#define CPUID_817
#define CPUID_888
#define CPUID_MAX9
#define CPUID_55
#define CPUID_66
#define CPUID_807
#define CPUID_818
#define CPUID_889
#define CPUID_MAX10
#define CPU_MODEL_DOTHAN0x0D// Dothan
#define CPU_MODEL_YONAH0x0E// Sossaman, Yonah
trunk/i386/modules/Cconfig
99
1010
1111
12
1213
source "i386/modules/HelloWorld/Cconfig"
source "i386/modules/Sata/Cconfig"
source "i386/modules/Keylayout/Cconfig"
source "i386/modules/ACPIcodec/Cconfig"
endmenu
trunk/i386/modules/Sata/include/acpidecode.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "acpi.h"
#include "acpidecode.h"
#define DEBUG_ACPI_DECODE 0
#if DEBUG_ACPI_DECODE==1
#include "libsaio.h"
#define DBG(x...) printf(x)
#else
#define DBG(x...)
#endif
static U8 *parse_acpi_dataobject(const struct acpi_namespace *ns, U8 * current, U8 * end);
static U8 *parse_acpi_package(const struct acpi_namespace *ns, U8 * current, U8 * end);
static U8 *parse_acpi_termarg(const struct acpi_namespace *ns, U8 * current, U8 * end);
static U8 *parse_acpi_termarglist(const struct acpi_namespace *ns, U8 * current, U8 * end);
static U8 *parse_acpi_objectlist(const struct acpi_namespace *ns, U8 * current, U8 * end);
U8* UIDPointer = (U8*)0;
void *decodeTableHeader(void *current, ACPI_TABLE_HEADER ** tableHeader)
{
*tableHeader = current;
current = *tableHeader + 1;
return current;
}
void dprint_nameseg(U32 i)
{
DBG("%c%c%c%c",
(int)(i & 0x000000ff),
(int)((i & 0x0000ff00) >> 8),
(int)((i & 0x00ff0000) >> 16),
(int)(i >> 24));
}
#if DEBUG_ACPI_DECODE
static void dprint_namespace(const struct acpi_namespace *ns)
{
U32 i;
DBG( "\\");
for (i = 0; i < ns->depth; i++) {
if (i != 0)
DBG( ".");
dprint_nameseg(ns->nameseg[i]);
}
}
#endif
static void parsePackageLength(U8 * current, U32 * length, U32 * lengthEncoding)
{
U32 i;
U8 len0 = *current;
U8 numBytes = len0 >> 6;
U32 total = 0;
for (i = numBytes; i > 0; i--) {
total <<= 8;
total |= current[i];
}
total <<= 4;
total |= len0 & 0x3f;
*length = total;
*lengthEncoding = numBytes + 1;
DBG("Package length=0x%02x\n", *length);
}
#if UNUSED
static bool ns_match(struct acpi_namespace *ns1, struct acpi_namespace *ns2)
{
U32 i;
if (ns1->depth != ns2->depth)
return false;
for (i = 0; i < ns1->depth; i++)
if (ns1->nameseg[i] != ns2->nameseg[i])
return false;
return true;
}
U32 acpi_ns_found;
#endif
static U8 *parse_acpi_namestring(const struct acpi_namespace *ns_context, struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
struct acpi_namespace dummy_ns;
(void)end;
if (!ns)
ns = &dummy_ns;
*ns = *ns_context;
if (*current == AML_ROOT_PREFIX) {
ns->depth = 0;
current++;
} else
while (*current == AML_PARENT_PREFIX) {
if (ns->depth == 0) {
DBG( "Attempt to use parent prefix with no namespace left\n");
return temp;
}
current++;
ns->depth--;
}
switch (*current) {
case AML_DUAL_NAME_PREFIX:
if (ns->depth + 2 > ACPI_NAMESPACE_MAX_DEPTH) {
DBG( "Namespace got too deep\n");
return temp;
}
current++;
ns->nameseg[ns->depth++] = *(U32 *) current;
current += 4;
ns->nameseg[ns->depth++] = *(U32 *) current;
current += 4;
break;
case AML_MULTI_NAME_PREFIX:
{
U8 nameseg_count;
current++;
nameseg_count = *current++;
if (ns->depth + nameseg_count > ACPI_NAMESPACE_MAX_DEPTH) {
DBG( "Namespace got too deep\n");
return temp;
}
while (nameseg_count--) {
ns->nameseg[ns->depth++] = *(U32 *) current;
current += 4;
}
break;
}
case AML_NULL_NAME:
current++;
break;
default:
if (*current != '_' && (*current < 'A' || *current > 'Z')) {
DBG( "Invalid nameseg lead character: 0x%02x\n", *current);
return temp;
}
if (ns->depth + 1 > ACPI_NAMESPACE_MAX_DEPTH) {
DBG( "Namespace got too deep\n");
return temp;
}
ns->nameseg[ns->depth++] = *(U32 *) current;
current += 4;
break;
}
#if DEBUG_ACPI_DECODE
DBG( "Found NameString: ");
dprint_namespace(ns);
DBG("\n");
#endif
if (ns->nameseg[1] == NAMESEG("PCI0") && ns->nameseg[2] == NAMESEG("_UID")) {
UIDPointer = current;
}
#if UNUSED
if (!acpi_ns_found) {
U32 index;
for (index = 0; index < acpi_processor_count; index++)
if (ns_match(ns, &acpi_processors[index].ns)) {
acpi_ns_found = 1;
break;
}
}
#endif
return current;
}
static U8 *parse_acpi_buffer(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U32 pkglen = 0, lengthEncoding = 0;
(void)ns;
(void)end;
if (*current != AML_BUFFER_OP)
return current;
current++;
parsePackageLength(current, &pkglen, &lengthEncoding);
current += pkglen;
return current;
}
static U8 *parse_acpi_computationaldata(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
current = parse_acpi_buffer(ns, current, end);
if (current != temp)
return current;
switch (*current) {
case AML_BYTE_OP:
DBG("Found ByteOp\n");
current += 1 + 1;
break;
case AML_WORD_OP:
DBG( "Found WordOp\n");
current += 1 + 2;
break;
case AML_DWORD_OP:
DBG("Found DwordOp\n");
current += 1 + 4;
break;
case AML_QWORD_OP:
DBG( "Found QwordOp\n");
current += 1 + 8;
break;
case AML_STRING_OP:
DBG( "Found StringOp: \"");
current++;
while (*current)
#if DEBUG_ACPI_DECODE
if (*current < ' ' || *current > 0x7e)
printf( "\\x%02x", *current++);
else
printf( "%c", *current++);
#else
current++;
#endif
current++; /* Skip the \0 */
DBG( "\"\n");
break;
case AML_ZERO_OP:
DBG( "Found ZeroOp\n");
current += 1;
break;
case AML_ONE_OP:
DBG( "Found OneOp\n");
current += 1;
break;
case AML_ONES_OP:
DBG( "Found OneOp\n");
current += 1;
break;
case AML_EXT_OP_PREFIX:
if (*(current + 1) == AML_REVISION_OP)
current += 2;
default:
break;
}
return current;
}
static U8 *parse_acpi_argobj(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
(void)ns;
(void)end;
switch (*current) {
case AML_ARG0_OP:
DBG( "Found Arg0Op\n");
current++;
break;
case AML_ARG1_OP:
DBG( "Found Arg1Op\n");
current++;
break;
case AML_ARG2_OP:
DBG( "Found Arg2Op\n");
current++;
break;
case AML_ARG3_OP:
DBG( "Found Arg3Op\n");
current++;
break;
case AML_ARG4_OP:
DBG( "Found Arg4Op\n");
current++;
break;
case AML_ARG5_OP:
DBG( "Found Arg5Op\n");
current++;
break;
case AML_ARG6_OP:
DBG( "Found Arg6Op\n");
current++;
break;
default:
break;
}
return current;
}
static U8 *parse_acpi_localobj(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
(void)ns;
(void)end;
switch (*current) {
case AML_LOCAL0_OP:
DBG( "Found Local0Op\n");
current++;
break;
case AML_LOCAL1_OP:
DBG( "Found Local1Op\n");
current++;
break;
case AML_LOCAL2_OP:
DBG( "Found Local2Op\n");
current++;
break;
case AML_LOCAL3_OP:
DBG("Found Local3Op\n");
current++;
break;
case AML_LOCAL4_OP:
DBG( "Found Local4Op\n");
current++;
break;
case AML_LOCAL5_OP:
DBG( "Found Local5Op\n");
current++;
break;
case AML_LOCAL6_OP:
DBG( "Found Local6Op\n");
current++;
break;
case AML_LOCAL7_OP:
DBG( "Found Local7Op\n");
current++;
break;
default:
break;
}
return current;
}
static U8 *parse_acpi_debugobj(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
(void)ns;
(void)end;
if ((*current == AML_EXT_OP_PREFIX) && (*(current + 1) == AML_DEBUG_OP)) {
current += 2;
DBG( "Found DebugOp\n");
}
return current;
}
static U8 *parse_acpi_datarefobject(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
DBG( "Beginning datarefobject: 0x%02x at memory location %p\n", *current, current);
current = parse_acpi_dataobject(ns, current, end);
if (current != temp)
return current;
return current;
}
static U8 *parse_acpi_simplename(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
current = parse_acpi_namestring(ns, NULL, current, end);
if (current != temp)
return current;
current = parse_acpi_argobj(ns, current, end);
if (current != temp)
return current;
current = parse_acpi_localobj(ns, current, end);
if (current != temp)
return current;
return current;
}
static U8 *parse_acpi_supername(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
current = parse_acpi_simplename(ns, current, end);
if (current != temp)
return current;
current = parse_acpi_debugobj(ns, current, end);
if (current != temp)
return current;
return current;
}
static U8 *parse_acpi_target(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
current = parse_acpi_supername(ns, current, end);
if (current != temp)
return current;
if (*current == AML_NULL_NAME)
current++;
return current;
}
static U8 *parse_acpi_method(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *new_end = current;
U8 *temp;
U32 pkglen = 0;
U32 lengthEncoding = 0;
struct acpi_namespace new_ns;
(void)end;
parsePackageLength(current, &pkglen, &lengthEncoding);
current += lengthEncoding;
new_end += pkglen;
temp = current;
current = parse_acpi_namestring(ns, &new_ns, current, new_end);
if (current == temp)
return new_end;
#if DEBUG_ACPI_DECODE
DBG( "Found Method: ");
dprint_namespace(&new_ns);
DBG( "\n");
#endif
// U8 methodFlags
current++;
parse_acpi_termlist(&new_ns, current, new_end);
#if DEBUG_ACPI_DECODE
DBG( "End of Method: ");
dprint_namespace(&new_ns);
DBG( "\n");
#endif
return new_end;
}
U32 acpi_processor_count;
struct acpi_processor acpi_processors[CPU_MAP_LIMIT];
static void add_processor(const struct acpi_namespace *ns, U8 id, U32 pmbase)
{
if (acpi_processor_count == CPU_MAP_LIMIT) {
DBG( "No more room for ACPI processor structures\n");
return;
}
acpi_processors[acpi_processor_count].ns = *ns;
acpi_processors[acpi_processor_count].id = id;
acpi_processors[acpi_processor_count].pmbase = pmbase;
acpi_processor_count++;
}
static U8 *parse_acpi_processor(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *new_end = current;
U8 *temp;
U32 pkglen = 0;
U32 lengthEncoding = 0;
struct acpi_namespace new_ns;
U8 id;
U32 pmbase;
(void)end;
parsePackageLength(current, &pkglen, &lengthEncoding);
current += lengthEncoding;
new_end += pkglen;
temp = current;
current = parse_acpi_namestring(ns, &new_ns, current, new_end);
if (current == temp)
return new_end;
id = *current++;
pmbase = *(U32 *) current;
current += 4;
(void)current; // Silent a warning reported by the clang static analizer .
#if DEBUG_ACPI_DECODE
DBG( "Found CPU object: ");
dprint_namespace(&new_ns);
DBG( " id = 0x%x pmbase = 0x%x\n", id, pmbase);
#endif
add_processor(&new_ns, id, pmbase);
return new_end;
}
static U8 *parse_acpi_namedobj(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
DBG( "Beginning namedobj: 0x%02x at memory location %p\n", *current, current);
switch (*current) {
case AML_EXT_OP_PREFIX:
{
if (*(current + 1) == AML_MUTEX_OP) {
struct acpi_namespace new_ns;
current += 2;
current = parse_acpi_namestring(ns, &new_ns, current, end);
#if DEBUG_ACPI_DECODE
DBG( "Mutex: ");
dprint_namespace(&new_ns);
DBG( "\n");
#endif
current++; /* SyncFlags */
} else if (*(current + 1) == AML_OPREGION_OP) {
struct acpi_namespace new_ns;
current += 2;
DBG( "OpRegion at memory location %p\n", current);
current = parse_acpi_namestring(ns, &new_ns, current, end);
#if DEBUG_ACPI_DECODE
DBG( "OpRegion name: ");
dprint_namespace(&new_ns);
DBG( "\n");
#endif
current++;
current = parse_acpi_termarg(ns, current, end);
current = parse_acpi_termarg(ns, current, end);
#if DEBUG_ACPI_DECODE
DBG( "End OpRegion: ");
dprint_namespace(&new_ns);
DBG( "\n");
#endif
} else if (*(current + 1) == AML_FIELD_OP) {
U32 pkglen = 0;
U32 lengthEncoding = 0;
current += 2;
DBG( "FieldOp at memory location %p\n", current);
parsePackageLength(current, &pkglen, &lengthEncoding);
current += pkglen;
} else if (*(current + 1) == AML_DEVICE_OP) {
U8 *new_end;
U32 pkglen = 0;
U32 lengthEncoding = 0;
struct acpi_namespace new_ns;
current += 2;
new_end = current;
DBG( "DeviceOp at memory location %p\n", current);
parsePackageLength(current, &pkglen, &lengthEncoding);
current += lengthEncoding;
new_end += pkglen;
current = parse_acpi_namestring(ns, &new_ns, current, new_end);
#if DEBUG_ACPI_DECODE
DBG( "DeviceOp name: ");
dprint_namespace(&new_ns);
DBG( "\n");
#endif
parse_acpi_objectlist(&new_ns, current, new_end);
current = new_end;
} else if (*(current + 1) == AML_PROCESSOR_OP) {
current += 2;
current = parse_acpi_processor(ns, current, end);
} else if (*(current + 1) == AML_INDEXFIELD_OP) {
U8 *new_end;
U32 pkglen = 0;
U32 lengthEncoding = 0;
struct acpi_namespace new_ns;
current += 2;
new_end = current;
DBG( "IndexFieldOp at memory location %p\n", current);
parsePackageLength(current, &pkglen, &lengthEncoding);
current += lengthEncoding;
new_end += pkglen;
current = parse_acpi_namestring(ns, &new_ns, current, new_end);
#if DEBUG_ACPI_DECODE
DBG( "IndexFieldOp name: ");
dprint_namespace(&new_ns);
DBG( "\n");
#endif
parse_acpi_objectlist(&new_ns, current, new_end);
current = new_end;
}
break;
}
case AML_METHOD_OP:
{
current++;
current = parse_acpi_method(ns, current, end);
break;
}
default:
break;
}
return current;
}
static U8 *parse_acpi_type1opcode(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
DBG( "Beginning type1opcode: 0x%02x at memory location %p\n", *current, current);
switch (*current) {
case AML_IF_OP:
{
U8 *new_end;
U32 pkgLen = 0;
U32 lengthEncoding = 0;
DBG( "Found IfOp\n");
current++;
parsePackageLength(current, &pkgLen, &lengthEncoding);
new_end = current + pkgLen;
current += lengthEncoding;
current = parse_acpi_termarg(ns, current, new_end);
parse_acpi_termlist(ns, current, new_end);
current = new_end;
break;
}
case AML_ELSE_OP:
{
U8 *new_end;
U32 pkgLen = 0;
U32 lengthEncoding = 0;
DBG( "Found ElseOp\n");
current++;
parsePackageLength(current, &pkgLen, &lengthEncoding);
new_end = current + pkgLen;
current += lengthEncoding;
parse_acpi_termlist(ns, current, new_end);
current = new_end;
break;
}
case AML_RETURN_OP:
{
DBG( "Found ReturnOp\n");
current++;
current = parse_acpi_termarg(ns, current, end);
break;
}
default:
break;
}
return current;
}
static U8 *parse_acpi_type2opcode(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
DBG( "Beginning type2opcode: 0x%02x at memory location %p\n", *current, current);
current = parse_acpi_package(ns, current, end);
if (current != temp)
return current;
switch (*current) {
case AML_LNOT_OP:
current++;
DBG( "Found logical not operator\n");
current = parse_acpi_termarg(ns, current, end);
break;
case AML_LAND_OP:
case AML_LOR_OP:
case AML_LEQUAL_OP:
case AML_LGREATER_OP:
case AML_LLESS_OP:
DBG( "Found logical binary operator: %c\n", "&|!=><"[*current - AML_LAND_OP]);
current++;
current = parse_acpi_termarg(ns, current, end);
current = parse_acpi_termarg(ns, current, end);
break;
case AML_EXT_OP_PREFIX:
{
if (*(current + 1) == AML_COND_REF_OF_OP) {
DBG( "Found CondRefOf\n");
current += 2;
current = parse_acpi_supername(ns, current, end);
current = parse_acpi_target(ns, current, end);
}
break;
}
case AML_STORE_OP:
{
DBG( "Found StoreOp\n");
current++;
current = parse_acpi_termarg(ns, current, end);
current = parse_acpi_supername(ns, current, end);
break;
}
default:
{
current = parse_acpi_namestring(ns, NULL, current, end);
if (current == temp)
break;
current = parse_acpi_termarglist(ns, current, end);
}
}
return current;
}
static U8 *parse_acpi_package(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
(void)ns;
(void)end;
if (*current == AML_PACKAGE_OP) {
U32 pkglen = 0;
U32 lengthEncoding = 0;
DBG( "Found PackageOp\n");
current++;
parsePackageLength(current, &pkglen, &lengthEncoding);
current += pkglen;
}
return current;
}
static U8 *parse_acpi_dataobject(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
current = parse_acpi_computationaldata(ns, current, end);
if (current != temp)
return current;
current = parse_acpi_package(ns, current, end);
if (current != temp)
return current;
return current;
}
static U8 *parse_acpi_termarg(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
U8 *temp = current;
DBG( "Beginning termarg: 0x%02x at memory location %p\n", *current, current);
current = parse_acpi_type2opcode(ns, current, end);
if (current != temp)
return current;
current = parse_acpi_dataobject(ns, current, end);
if (current != temp)
return current;
current = parse_acpi_argobj(ns, current, end);
if (current != temp)
return current;
current = parse_acpi_localobj(ns, current, end);
if (current != temp)
return current;
return current;
}
static U8 *parse_acpi_namespacemodifierobj(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
DBG( "Beginning namespacemodifierobj: 0x%02x at memory location %p\n", *current, current);
switch (*current) {
case AML_SCOPE_OP:
{
U8 *new_end;
struct acpi_namespace new_ns;
U32 scopeLen = 0;
U32 lengthEncoding = 0;
current++;
parsePackageLength(current, &scopeLen, &lengthEncoding);
new_end = current + scopeLen;
current = parse_acpi_namestring(ns, &new_ns, current + lengthEncoding, new_end);
#if DEBUG_ACPI_DECODE
DBG( "Found Scope: ");
dprint_namespace(&new_ns);
DBG( "\n");
#endif
parse_acpi_termlist(&new_ns, current, new_end);
#if DEBUG_ACPI_DECODE
DBG( "End Scope: ");
dprint_namespace(&new_ns);
DBG( "\n");
#endif
current = new_end;
break;
}
case AML_NAME_OP:
current++;
current = parse_acpi_namestring(ns, NULL, current, end);
current = parse_acpi_datarefobject(ns, current, end);
break;
case AML_ALIAS_OP:
current++;
current = parse_acpi_namestring(ns, NULL, current, end);
current = parse_acpi_namestring(ns, NULL, current, end);
break;
default:
break;
}
return current;
}
static U8 *parse_acpi_objectlist(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
DBG( "Beginning objectlist: 0x%02x at memory location %p end=%p\n", *current, current, end);
while (current < end) {
U8 *temp = current;
DBG( "New iteration of objectlist: 0x%02x at memory location %p end=%p\n", *current, current, end);
current = parse_acpi_namespacemodifierobj(ns, current, end);
if (current != temp)
continue;
current = parse_acpi_namedobj(ns, current, end);
if (current != temp)
continue;
if (current == temp) {
DBG( "Unhandled object in object list: 0x%02x at memory location %p\n", *current, current);
#if DEBUG_ACPI_DECODE
DBG( "namespace: ");
dprint_namespace(ns);
DBG( "\n");
#endif
break;
}
}
DBG( "Ending objectlist: 0x%02x at memory location %p\n", *current, current);
return current;
}
static U8 *parse_acpi_termarglist(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
DBG( "Beginning termarglist: 0x%02x at memory location %p\n", *current, current);
while (current < end) {
U8 *temp = current;
current = parse_acpi_termarg(ns, current, end);
if (current == temp) {
DBG( "Unhandled item in term arg list: 0x%02x at memory location %p\n", *current, current);
#if DEBUG_ACPI_DECODE
DBG( "namespace: ");
dprint_namespace(ns);
DBG( "\n");
#endif
break;
}
}
return current;
}
void parse_acpi_termlist(const struct acpi_namespace *ns, U8 * current, U8 * end)
{
while (current < end) {
U8 *temp = current;
DBG( "Beginning new term in term list: 0x%02x at memory location %p\n", *current, current);
current = parse_acpi_namespacemodifierobj(ns, current, end);
if (current != temp)
continue;
current = parse_acpi_namedobj(ns, current, end);
if (current != temp)
continue;
current = parse_acpi_type1opcode(ns, current, end);
if (current != temp)
continue;
current = parse_acpi_type2opcode(ns, current, end);
if (current != temp)
continue;
switch (*current) {
default:
{
DBG( "Unhandled item in term list: 0x%02x at memory location %p\n", *current, current);
#if DEBUG_ACPI_DECODE
DBG( "namespace: ");
dprint_namespace(ns);
DBG( "\n");
#endif
return;
}
}
}
}
trunk/i386/modules/Sata/include/include/acpi_codec.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
73
74
75
76
77
/*
* Copyright 2008 mackerintel
*/
/*
* Copyright (c) 2011 cparm <armelcadetpetit@gmail.com>. All rights reserved.
*
*/
#ifndef __LIBSAIO_ACPI_CODEC_H
#define __LIBSAIO_ACPI_CODEC_H
#include "libsaio.h"
#include "efi.h"
#define OEMOPT_TEMPLATE"oemXXXX"
#define OEMOPT_SIZEsizeof(OEMOPT_TEMPLATE)
#define kOEMDSDT"oemDSDT"/* acpi_codec.c */
#define kOEMFADT"oemFADT"/* acpi_codec.c */
#define kOEMAPIC"oemAPIC"/* acpi_codec.c */
#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)
#define KEYBOARD_RESET_TYPE1
#define kGeneratePStates"GeneratePStates"/* acpi_codec.c */
#define kGenerateCStates"GenerateCStates"/* acpi_codec.c */
#define kGenerateTStates"GenerateTStates"/* acpi_codec.c */
#define kMaxRatio"MaxBusRatio"/* acpi_codec.c */
#define kMinRatio"MinBusRatio"/* acpi_codec.c */
#definekSpeedstep"EnableSpeedStep"/* acpi_codec.c */
#define kEnableC2State "EnableC2State" /* acpi_codec.c */
#define kEnableC3State "EnableC3State" /* acpi_codec.c */
#define kEnableC4State"EnableC4State"/* acpi_codec.c */
#define kEnableC6State "EnableC6State" /* acpi_codec.c */
#define kEnableC7State "EnableC7State" /* acpi_codec.c */
#define KEnableMwait"EnableMwait" /* acpi_codec.c */
#define KForceSSDT"ForceGenSSDT" /* acpi_codec.c */
#define KAcpiCoordType"PstateCoordination" /* acpi_codec.c */
#define kCoreTurbo"EnableTurbo"/* acpi_codec.c */
#define kUpdateACPI"UpdateACPI" /* acpi_codec.c */
//#define kUnsafeACPI"UnsafeACPI"/* acpi_codec.c */ // DEPRECATED, replaced by nacpi=0x2000
#define kOnlySignedAml"LoadSignedAmlOnly" /* acpi_codec.c */
#if UNUSED
#define kGenerateFACS"GenerateFACS"/* acpi_codec.c */
#define kOEMFACS"oemFACS"/* acpi_codec.c */
#endif
extern int AcpiSetup(void);
struct p_state
{
union
{
uint16_t Control;
struct
{
uint8_t VID;// Voltage ID
uint8_t FID;// Frequency ID
};
};
uint8_tCID;// Compare ID
uint32_tFrequency;
};
#endif /* !__LIBSAIO_ACPI_CODEC_H */
trunk/i386/modules/Sata/include/include/datatype.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef DATATYPE_H
#define DATATYPE_H
#include "libsa.h"
typedef uint8_t U8;
typedef uint16_t U16;
typedef uint32_t U32;
typedef uint64_t U64;
#if 0
typedef uint32_t bool;
#ifndef false
#define true 1
#endif
#ifndef false
#define false 0
#endif
#ifndef NULL
#define NULL ((void *) 0)
#endif
#endif
#endif /* DATATYPE_H */
trunk/i386/modules/Sata/include/include/acpi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef __LIBSAIO_ACPI_H
#define __LIBSAIO_ACPI_H
#include "acpi_tools.h"
#define ACPI_RANGE_START (0x0E0000)
#define ACPI_RANGE_END (0x0FFFFF)
#define Unspecified 0
#define Desktop 1
#define Mobile 2
#define Workstation 3
#define EnterpriseServer 4
#define SOHOServer 5
#define AppliancePC 6
#define PerformanceServer 7
#define MaxSupportedPMProfile PerformanceServer // currently max profile supported
#define PMProfileError MaxSupportedPMProfile + 1
#define kAcpiMethod"Acpi2Method"// 2 (= method 2) for some machines that may hang on acpi 2 (aka acpi 64 bit) detection (replace the old kUnsafeACPI "UnsafeACPI")
#endif /* !__LIBSAIO_ACPI_H */
trunk/i386/modules/Sata/include/include/acpi_tools.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef acpi_tools_h
#define acpi_tools_h
#include "datatype.h"
#include "intel_acpi.h"
#include "ppm.h"
U32 get_num_tables(ACPI_TABLE_RSDT * rsdt);
U32 get_num_tables64(ACPI_TABLE_XSDT * xsdt);
U32 FindAcpiTables(ACPI_TABLES * acpi_tables);
U8 GetChecksum(void *mem_addr, U32 mem_size);
#endif // acpi_tools_h
trunk/i386/modules/Sata/include/include/ppm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ppm_h
#define ppm_h
#include "datatype.h"
#define PROFILE_ALL
//#define PROFILE_NEHALEM_EP_DP
//#define PROFILE_WESTMERE_EP_UP_DP
//#define PROFILE_NEHALEM_EX_MP
//#define PROFILE_WESTMERE_EX_MP
//#define PROFILE_SANDYBRIDGE_UP
#if defined(PROFILE_ALL) || defined(PROFILE_WESTMERE_EX_MP)
#define MAX_CPU_SOCKETS 8 // max count of cpu packages (any range of APIC IDs is ok)
#define MAX_LOGICAL_CPU 256 // max count of cpu found in MADT
#define MAX_CORES 32 // Based on full range of Core APID ID values (max of 5 bits for core APIC ID mask)
#elif defined(PROFILE_NEHALEM_EX_MP)
#define MAX_CPU_SOCKETS 8 // max count of cpu packages (any range of APIC IDs is ok)
#define MAX_LOGICAL_CPU 128 // max count of cpu found in MADT
#define MAX_CORES 16 // Based on full range of Core APID ID values (max of 4 bits for core APIC ID mask)
#elif defined(PROFILE_WESTMERE_EP_UP_DP)
#define MAX_CPU_SOCKETS 2 // max count of cpu packages (any range of APIC IDs is ok)
#define MAX_LOGICAL_CPU 64 // max count of cpu found in MADT
#define MAX_CORES 16 // Based on full range of Core APID ID values (max of 4 bits for core APIC ID mask)
#elif defined(PROFILE_NEHALEM_EP_UP_DP)
#define MAX_CPU_SOCKETS 2 // max count of cpu packages (any range of APIC IDs is ok)
#define MAX_LOGICAL_CPU 32 // max count of cpu found in MADT
#define MAX_CORES 8 // Based on full range of Core APID ID values (max of 3 bits for core APIC ID mask)
#elif defined(PROFILE_SANDY_BRIDGE_UP)
#define MAX_CPU_SOCKETS 1 // max count of cpu packages (any range of APIC IDs is ok)
#define MAX_LOGICAL_CPU 8 // max count of cpu found in MADT
#define MAX_CORES 4
#endif
#define MAX_PSTATES 16
#define MAX_CSTATES 4
#define MAX_TSTATES 15
//Define ACPI_CSD to force building ACPI _CSD
//#define BUILD_ACPI_CSD
#ifndef DWORD_REGS_TYPEDEF
#define DWORD_REGS_TYPEDEF
typedef struct dword_regs {
U32 _eax;
U32 _ebx;
U32 _ecx;
U32 _edx;
} DWORD_REGS;
#endif
typedef struct acpi_tables {
// Define the Storage Locations for all the ACPI Table Pointers.
ACPI_TABLE_DSDT *DsdtPointer; // Differentiated System Description Table (RSDP->RSDT->FACP->DSDT)
ACPI_TABLE_DSDT *DsdtPointer64; // Differentiated System Description Table (RSDP->XSDT->FACP->XDSDT)
ACPI_TABLE_FADT *FacpPointer; // Fixed ACPI Description Table (RSDP->RSDT->FACP)
ACPI_TABLE_FACS *FacsPointer; // Firmware ACPI Control Structure (RSDP->RSDT->FACP->FACS)
ACPI_TABLE_FACS *FacsPointer64; // Firmware ACPI Control Structure (RSDP->XSDT->FACP->XFACS)
ACPI_TABLE_RSDP *RsdPointer; // Root System Description Pointer Structure (RSDP)
ACPI_TABLE_RSDT *RsdtPointer; // Root System Description Table (RSDP->RSDT)
ACPI_TABLE_MADT *MadtPointer; // Multiple APIC Description Table (RSDP->RSDT->APIC)
ACPI_TABLE_MADT *MadtPointer64; // Multiple APIC Description Table (RSDP->XSDT->APIC)
ACPI_TABLE_XSDT *XsdtPointer; // Extended Root System Description Table (RSDP->XSDT)
ACPI_TABLE_FADT *FacpPointer64; // Fixed ACPI Description Table (RSDP->XSDT->FACP)
} ACPI_TABLES;
typedef struct pstate {
U32 frequency;
U32 power;
U32 ratio;
U32 translatency;
U32 bmlatency;
U32 control;
U32 status;
} PSTATE;
typedef struct pkg_pstates {
U32 num_pstates;
PSTATE pstate[MAX_PSTATES];
} PKG_PSTATES;
typedef struct tstate {
U32 freqpercent;
U32 power;
U32 latency;
U32 control;
U32 status;
} TSTATE;
typedef struct pkg_tstates {
U32 num_tstates;
TSTATE tstate[MAX_TSTATES];
} PKG_TSTATES;
typedef enum cstate_encoding {
IO_REDIRECTION = 0,
NATIVE_MWAIT = 1,
} CSTATE_ENCODING;
typedef enum cpu_cstate {
CPU_C1 = 1,
//CPU_C2 = 2,
CPU_C3_ACPI_C2 = 3,
CPU_C3_ACPI_C3 = 4,
CPU_C4 = 5,
CPU_C6 = 6,
CPU_C7 = 7,
} CPU_CSTATE;
typedef struct cstate {
U8 type;
U16 latency;
U32 power;
} CSTATE;
typedef struct pkg_cstates {
U32 num_cstates;
CSTATE cstate[MAX_CSTATES];
ACPI_GENERIC_ADDRESS gas[MAX_CSTATES];
} PKG_CSTATES;
typedef struct cpu_details {
U32 present;
U32 x2apic_id;
U32 socket_id;
U32 intra_package_mask_width;
U32 intra_package_mask;
U32 smt_mask_width;
U32 smt_select_mask;
U32 core_select_mask;
DWORD_REGS cpuid1;
DWORD_REGS cpuid5;
DWORD_REGS cpuid6;
DWORD_REGS cpuidB_0;
DWORD_REGS cpuidB_1;
U32 eist_cpuid_feature_flag;
U32 turbo_cpuid_feature_flag;
U32 turbo_misc_enables_feature_flag;
U32 invariant_apic_timer_flag;
U32 tdc_limit;
U32 tdp_limit;
U32 turbo_available;
U32 max_ratio_as_mfg;
U32 max_ratio_as_cfg;
U32 min_ratio;
U32 tdc_tdp_limits_for_turbo_flag;
U32 ratio_limits_for_turbo_flag;
U32 xe_available;
U32 logical_processor_count_from_madt;
U32 core_logical_processor_count_from_madt[MAX_CORES];
PKG_PSTATES pkg_pstates;
PKG_CSTATES pkg_mwait_cstates;
PKG_CSTATES pkg_io_cstates;
PKG_TSTATES pkg_tstates;
U32 package_cstate_limit;
U32 core_c1_supported;
U32 core_c2_supported;
U32 core_c3_supported;
U32 core_c4_supported;
U32 core_c6_supported;
U32 core_c7_supported;
U32 mwait_supported;
U32 acpi_support_cpuid_feature_flag;
U32 energy_perf_bias_supported;
U64 package_power_limit;
U64 package_power_sku_unit;
} CPU_DETAILS;
typedef struct socket_info {
U32 signature;
U32 socket_count;
CPU_DETAILS cpu[MAX_CPU_SOCKETS];
} SOCKET_INFO;
typedef struct lapic_info {
U32 processorId;
U32 apicId;
U32 pkg_index;
U32 core_apic_id;
U32 core_index;
PROCESSOR_NUMBER_TO_NAMESEG *namepath;
U32 madt_type;
U32 uid;
} LAPIC_INFO;
typedef struct proc_info {
U32 processorId;
U32 apicId;
} PROC_INFO;
typedef struct madt_info {
U32 lapic_count;
LAPIC_INFO lapic[MAX_LOGICAL_CPU];
} MADT_INFO;
typedef struct rsdt_info {
U32 proc_count;
PROC_INFO processor[MAX_LOGICAL_CPU];
} RSDT_INFO;
typedef struct smp_exit_state {
U32 signature;
// Number of Failure or Informative codes included in the buffer
U32 error_code_count;
// Buffer of Failure or Informative codes
U32 error_codes[10];
} SMP_EXIT_STATE;
typedef enum smp_exit_code {
// Generic successful
SMP_EXIT_CODE_OK = 1,
// Generic failure
EXIT_CODE_FAILED = 2,
// First logical processor for this socket unable to find available structure
EXIT_CODE_FAILED_SOCKET_PROXY_SAVE = 3,
} SMP_EXIT_CODE;
typedef struct ppm_host {
U32 signature;
U32 pstates_enabled;
U32 pstate_coordination;
U32 turbo_enabled;
U32 cstates_enabled;
U32 tstates_enabled;
U32 performance_per_watt;
ACPI_TABLES acpi_tables;
RSDT_INFO rsdt_info;
MADT_INFO madt_info;
SOCKET_INFO skt_info;
PPM_SETUP_OPTIONS *options;
SMP_EXIT_STATE smp_exit_state;
U32 detected_cpu_family;
} PPM_HOST;
#endif // ppm_h
trunk/i386/modules/Sata/include/include/ppmsetup.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ppmsetup_h
#define ppmsetup_h
#include "datatype.h"
#define CURRENT_PPM_RCM_INTERFACE_SPECIFICATION 11
#ifndef nameseg_defined
#define nameseg_defined
#define NAMESEG(s) (((U32)(s[0]) << 0) \
|((U32)(s[1]) << 8) \
|((U32)(s[2]) << 16) \
|((U32)(s[3]) << 24))
#endif
typedef enum ssdt_loc_flag {
// Flag indicating the SSDT ACPI structure should be built in a stack-based
// buffer. If the SSDT is successfully created, then the following occurs:
// (1) the RSDT ACPI structure is moved lower in memory and updated to
// include a pointer to the new SSDT.
// (2) the SSDT APCI structure is copied into memory just above the moved
// RSDT structure
// (3) the RSD ACPI structure is updated to included the new location of
// the just moved RSDT ACPI structure
// Note: The XSDT is not updated!
//
// NOTE: THIS OPTION WILL DEPRECATED AND REMOVED
// IN A FUTURE VERSION OF THIS SPECIFICATION.
SSDT_LOC_FLAG_ACPI_RECLAIM = 0,
// Flag indicating the SSDT should be built directly in the memory region
// provided by the ssdt_mem_addr option parameter.
// If the SSDT is successfully created, then the following occurs:
// (1) the RSDT ACPI structure is moved lower in memory and updated to
// include a pointer to the new SSDT.
// (2) the RSD ACPI structure is updated to include the new location of the
// RSDT ACPI structure.
// Note: The XSDT is not updated!
//
// NOTE: THIS OPTION WILL DEPRECATED AND REMOVED
// IN A FUTURE VERSION OF THIS SPECIFICATION.
SSDT_LOC_FLAG_ADDR_PROVIDED = 1,
// Flag indicating the SSDT should be built directly in the memory region
// provided by the ssdt_mem_addr option parameter.
// After SSDT is successfully created, no further processing occurs.
SSDT_LOC_FLAG_ADDR_PROVIDED_NO_INSERT = 2,
// Flag indicating the SSDT should be built directly in the memory region
// provided by the ssdt_mem_addr option parameter.
// After SSDT is successfully created, then the following occurs:
// (1) the RSDT ACPI structure is not moved but is updated to
// include a 32-bit pointer to the new SSDT.
// (2) If the XSDT exists, it is not moved but is updated to
// include a 64-bit pointer to the new SSDT.
SSDT_LOC_FLAG_ADDR_PROVIDED_INSERT = 3,
} SSDT_LOC_FLAG;
typedef enum exit_code {
// PPM RCM completed all initialization successfully
EXIT_CODE_PPM_COMPLETED = 1,
// Failed building P-state table
EXIT_CODE_FAILED_BUILD_PSTATES = 2,
EXIT_CODE_PPM_EIST_DISABLED = 3,
// Failed to find ACPI tables
EXIT_CODE_FAILED_FIND_ACPI_TABLES = 4,
// Failed to process the ACPI MADT structure
EXIT_CODE_FAILED_PROCESS_MADT = 5,
// Failed to resolve ACPI MADT structure against available logical
// processors
EXIT_CODE_FAILED_PROCESS_MADT_INFO = 6,
// Failed to build ACPI SSDT structure
EXIT_CODE_FAILED_PROCESS_SSDT = 7,
// Failed to build and intialize HOST structure
EXIT_CODE_FAILED_HOST_INIT = 8,
// Failed during wake of all NBSP to gather processor information
EXIT_CODE_FAILED_COLLECT_SOCKET_INFO = 9,
// Failed to resolve target configuration between desired options and
// processor features
EXIT_CODE_FAILED_DETERMINE_CONFIGURATION = 0x0a,
// No SSDT ACPI struture was created
EXIT_CODE_NO_SSDT_CREATED = 0x0b,
// Failed to build Cstates correctly
EXIT_CODE_FAILED_BUILD_CSTATES = 0x0c,
// Failed to build Tstates correctly
EXIT_CODE_FAILED_BUILD_TSTATES = 0x0d,
// Failed to find package index of logical processor listed in MADT ACPI table
EXIT_CODE_FAILED_FIND_PKG_INDEX_FROM_LAPIC = 0x0e,
// Failed with invalid input provided for SSDT location flag
EXIT_CODE_FAILED_INVALID_SSDT_LOCATION_FLAG = 0x0f,
// Failed with no logical processors found in MADT
EXIT_CODE_FAILED_NO_LAPIC_FOUND_IN_MADT = 0x10,
// Failed with SSDT size exceeded during SSDT creation
EXIT_CODE_FAILED_SSDT_SIZE_EXCEEDED = 0x11,
// Failed to build ACPI SSDT structure
EXIT_CODE_FAILED_BUILD_SSDT = 0x12,
// Failed with core index of logical processor listed in MADT ACPI table exceeding max
EXIT_CODE_MAX_CORES_EXCEEDED = 0x13,
// Failed to find CPU Scope from array of ACPI processor number to ACPI CPU NameSeg structures
EXIT_CODE_FAILED_FIND_CPU_SCOPE_NAME_SEG = 0x14,
// Failed to update FADT
EXIT_CODE_FAILED_UPDATE_FADT = 0x15,
// GPF detected
EXIT_CODE_GPF_DETECTED = 0x16,
// Failed with invalid SSDT buffer address
EXIT_CODE_INVALID_SSDT_ADDR = 0x17,
// Failed with invalid SSDT buffer length
EXIT_CODE_INVALID_SSDT_LEN = 0x18,
} EXIT_CODE;
typedef struct exit_state {
// 1 = success, 0 = failure
U32 return_status;
// Number of Failure or Informative codes included in the buffer
U32 error_code_count;
// Buffer of Failure or Informative codes
U32 error_codes[10];
// This 32-bit physical memory address specifies the final location for the
// SSDT ACPI structure built by the PPM RC.
U32 ssdt_mem_addr;
// This value specifies the final size of the SSDT ACPI structure for the
// SSDT ACPI structure built by the PPM RC.
U32 ssdt_mem_size;
// The final state for the P-state initialization
// 1=enabled; 0=disabled
U32 pstates_enabled;
// The final state for the Turbo feature initialization
// 1=enabled; 0=disabled
U32 turbo_enabled;
// The final state for the C-state initialization
// 1=enabled; 0=disabled
U32 cstates_enabled;
// The final state for the T-state initialization
// 1=enabled; 0=disabled
U32 tstates_enabled;
} EXIT_STATE;
typedef enum cpu_namespace_flag {
// Flag indicating the SSDT ACPI structure should be built
// using ACPI 1.0 compliant processor namespace "_PR"
CPU_NAMESPACE_PR = 0,
// Flag indicating the SSDT ACPI structure should be built
// using ACPI 2.0+ compliant processor namespace "_SB"
CPU_NAMESPACE_SB = 1,
} CPU_NAMESPACE_FLAG;
// Define the total number of required NameSegs to reach the DSDT processor
// device or object declarations
#define MAX_SUPPORTED_CPU_NAMESEGS 3
typedef struct processor_number_to_nameseg {
// Contains one of the ACPI processor ID values used in a
// ACPI Declare Processor statement in the DSDT or XSDT
U32 acpi_processor_number;
// Number of NameSpace segments in NamePath to processor devices/objects
U32 seg_count;
// Contains the corresponding ACPI Name Scope in the form
// of a series of NameSegs constituting the NamePath to a
// processor device or object declaration
U32 nameseg[MAX_SUPPORTED_CPU_NAMESEGS];
} PROCESSOR_NUMBER_TO_NAMESEG;
typedef struct ppm_setup_options {
// This 32-bit physical memory address specifies a read-write memory region
// below 1MB. Minimum size is 8KB. This memory is used by the callback as
// the SIPI target and stack for each AP. This region is not required to be
// cacheable.
U32 mem_region_below_1M;
// Number of CPU sockets which exist on the platform
U32 num_sockets;
// Desired state for the P-state initialization
// 1=enabled; 0=disabled
U32 pstates_enabled;
// Desired state for the P-state hardware coordination
// ACPI_PSD_COORD_TYPE_SW_ALL = 0xFC
// ACPI_PSD_COORD_TYPE_SW_ANY = 0xFD
// ACPI_PSD_COORD_TYPE_HW_ALL = 0xFE
U32 pstate_coordination;
// Desired state for the Turbo state initialization
// 1=enabled; 0=disabled
U32 turbo_enabled;
// Desired state for the C-state initialization
// 1=enabled; 0=disabled
U32 cstates_enabled;
// Desired state for the C1E initialization
// 1=enabled; 0=disabled
U32 c1e_enabled;
// Desired state for the processor core C3 state included in the _CST
// 0= processor core C3 cannot be used as an ACPI C state
// 2= processor core C3 can be used as an ACPI C2 state
// 3= processor core C3 can be used as an ACPI C3 state
// 4= processor core C3 can be used as an ACPI C2 state
// if Invariant APIC Timer detected, else not used as ACPI C state
// 5= processor core C3 can be used as an ACPI C2 state
// if Invariant APIC Timer detected, else APIC C3 state
U32 c3_enabled;
// Desired state for the processor core C6 state included in the _CST as an
// ACPI C3 state.
// 1= processor core C6 can be used as an ACPI C3 state
// 0= processor core C6 cannot be used as an ACPI C3 state
U32 c6_enabled;
// Desired state for the processor core C7 state included in the _CST as an
// ACPI C3 state.
// 1= processor core C7 can be used as an ACPI C7 state
// 0= processor core C7 cannot be used as an ACPI C7 state
U32 c7_enabled;
// Desired state for providing alternate ACPI _CST structure using MWAIT
// extensions
// 1= Alternate _CST using MWAIT extension is enabled for OSPM use
// 0= Alternate _CST using MWAIT extension is disabled for OSPM use
U32 mwait_enabled;
// Power management base address used for processors
U32 pmbase;
// Desired state for the C-state package limit.
// Note: The C-state package limit may be further limited by the
// capabilities of the processor
// 000b = C0 (No package C-state support)
// 001b = C1 (Behavior is the same as 000b)
// 010b = C3
// 011b = C6
// 100b = C7
// 111b = No package C-state limit
U32 package_cstate_limit;
// Desired state for the T-state initialization
// 1=enabled; 0=disabled
U32 tstates_enabled;
// This 32-bit physical memory address specifies a read-write memory region
// for the SSDT ACPI structure built by the PPM RC. Minimum size is 16KB.
U32 ssdt_mem_addr;
// This value specifies the size of the SSDT memory region. Minimum size is
// 16KB.
U32 ssdt_mem_size;
// This value specifies the PPM RCM behavior related to creation and
// incorporation of the new SSDT ACPI structure. See definition of the
// SSDT_LOC_FLAG for acceptable values.
U32 ssdt_loc_flag;
// This value specifies the PPM RCM behavior related to creation and
// incorporation of the new SSDT ACPI structure. If all power management
// features are disabled by input options, the SSDT can still be created
// for debug review.
// 1 = Create SSDT even if all power management features are disabled
// 0 = Do not create SSDT if all power management features are disabled
U32 ssdt_force_creation;
// Exit structure intended to convey state to the caller and/or subsequent
// init code
EXIT_STATE exit_state;
// Flag indicating the processor namespace that should be used in the
// SSDT ACPI structure for each CPU.
// See definition of the CPU_NAMESPACE_FLAG for acceptable values.
U32 cpu_namespace_flag;
// This version number identifies the PPM RCM specification.
// Specifically denotes the version of this structure definition is compliant
// with with file nehalem-ppm-rcm-vX.txt where X is the version number.
// PPMSETUP.C should always use the version definition from the top of
// this file called CURRENT_PPM_RCM_INTERFACE_SPECIFICATION.
U32 ppm_rcm_interface_specification;
// This flag indicates whether or not after all AP Wakes are completed,
// that the AP should be forced to jump to the real mode address specified
// in the realmode_callback_address field below.
// realmode_callback = 0 means leave AP in INIT or Wait For SIPI (WFS) state
// realmode_callback = 1 means AP should jump to real mode address specified below
U32 realmode_callback_flag;
// This file contains the real mode callback address which AP must jump to after
// INIT_SIPI_SIPI sequences used to force AP initalization for PPM.
// Upper 16-bits specify target real mode segment for a far 16-bit jump instruction
// Lower 16-bits specify target real mode offset for a far 16-bit jump instruction
U32 realmode_callback_address;
// Number of ACPI processor number to ACPI CPU NameSeg structures
U32 cpu_map_count;
// Array of ACPI processor number to ACPI CPU NameSeg structures
PROCESSOR_NUMBER_TO_NAMESEG *cpu_map;
// This flag indicates whether or not PPM RC should update an existing ACPI FADT.
// modify_fadt_flag = 0 means do not modify existing ACPI FADT structure
// modify_fadt_flag = 1 means do check and if needed, modify existing ACPI FADT structure
U32 modify_fadt_flag;
// Desired state for the performance_per_watt optimizations
// performance_per_watt = 2 means "Low Power"
// performance_per_watt = 1 means "Power Optimized or Power Balanced"
// performance_per_watt = 0 means "Traditional or Max Performance"
U32 performance_per_watt;
} PPM_SETUP_OPTIONS;
#endif // ppmsetup_h
trunk/i386/modules/Sata/include/include/acpidecode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ACPI_DECODE_H
#define ACPI_DECODE_H
#include "acpi_tools.h"
/* acpidecode.h contains functions needed only for decoding ACPI to produce the
* inputs to the PPM code, but not needed for encoding ACPI as done inside the
* PPM code. */
#define ACPI_NAMESPACE_MAX_DEPTH 10
struct acpi_namespace {
U32 nameseg[ACPI_NAMESPACE_MAX_DEPTH];
U32 depth;
};
void dprint_nameseg(U32 i);
void *decodeTableHeader(void *current, ACPI_TABLE_HEADER ** tableHeader);
void parse_acpi_termlist(const struct acpi_namespace *ns, U8 * current, U8 * end);
/* Globals used for retrieving ACPI processor structures from the DSDT */
#define CPU_MAP_LIMIT 256 /* Any bigger than 256 and we'd have to support the x2APIC structures, which we don't yet anyway. */
struct acpi_processor {
struct acpi_namespace ns;
U8 id;
U32 pmbase;
};
extern U32 acpi_processor_count;
extern struct acpi_processor acpi_processors[CPU_MAP_LIMIT];
#if UNUSED
/* If 0, look for a processor namespace and set to 1 if found. */
extern U32 acpi_ns_found;
#endif
extern U8* UIDPointer;
#endif /* ACPI_DECODE_H */
trunk/i386/modules/Sata/include/include/acpicode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
73
74
75
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef acpi_code_h
#define acpi_code_h
#include "datatype.h"
#include "acpi.h"
#include "ppm.h"
void setRsdpchecksum(ACPI_TABLE_RSDP *rsdp);
void setRsdpXchecksum(ACPI_TABLE_RSDP *rsdp);
U32 update_rsdp_with_xsdt(ACPI_TABLE_RSDP *rsdp, ACPI_TABLE_XSDT *xsdt);
U32 update_rsdp_with_rsdt(ACPI_TABLE_RSDP *rsdp, ACPI_TABLE_RSDT *rsdt);
void SetChecksum(struct acpi_table_header *header);
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);
U32 ProcessFadt(ACPI_TABLE_FADT * FadtPointer, U32 pmbase);
U32 ProcessDsdt(ACPI_TABLE_DSDT * DsdtPointer, U8 * PCIUIDPointer, U8 uid);
void setByteConst(ACPI_BYTE_CONST * byteConst, U8 byteData);
void *buildByteConst(void *current, U8 byteData);
void setWordConst(ACPI_WORD_CONST * wordConst, U16 wordData);
void *buildWordConst(void *current, U16 wordData);
void setDwordConst(ACPI_DWORD_CONST * dwordConst, U32 dwordData);
void *buildDwordConst(void *current, U32 dwordData);
void *buildSmallBuffer(void *current);
void *buildEndTag(void *current);
void *buildGenericRegister(void *current, const ACPI_GENERIC_ADDRESS * gas);
void *buildSmallMethod(void *current, U32 name, U8 methodFlags);
void *buildMethod(void *current, U32 name, U8 methodFlags);
void *buildReturnZero(void *current);
void *buildReturnOpcode(void *current, U8 opcodeToReturn);
void *buildReturnPackage(void *current, U8 numElements);
void *buildNamedDword(void *current, U32 name, U32 dword);
void *buildOpCode(void *current, U8 opCode);
void *buildNameSeg(void *current, U32 name);
void setSmallPackage(ACPI_SMALL_PACKAGE * package, U8 numElements);
void *buildSmallPackage(void *current, U8 numElements);
void setPackageLength(ACPI_PACKAGE_LENGTH * packageLength, U32 length);
void *buildPackageLength(void *current, U32 Length);
void *buildNamePath(void *current, U32 name);
void *buildTableHeader(void *current, U32 signature, U64 oemTableId);
#endif // acpi_code_h
trunk/i386/modules/Sata/include/include/intel_acpi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
/* Per ACPI 3.0a spec */
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __LIBSAIO_INTEL_ACPI_H
#define __LIBSAIO_INTEL_ACPI_H
#include "datatype.h"
#include "ppmsetup.h"
//
// All tables and structures must be byte-packed to match the ACPI specification
//#pragma pack(1)
#define ACPI_SIG_DSDT "DSDT" // Differentiated System Description Table
#define ACPI_SIG_FADT "FACP" // Fixed ACPI Description Table
#define ACPI_SIG_FACS "FACS" // Firmware ACPI Control Structure
#define ACPI_SIG_PSDT "PSDT" // Persistent System Description Table
#define ACPI_SIG_RSDP "RSD PTR " // Root System Description Pointer
#define ACPI_SIG_RSDT "RSDT" // Root System Description Table
#define ACPI_SIG_XSDT "XSDT" // Extended System Description Table
#define ACPI_SIG_SSDT "SSDT" // Secondary System Description Table
#define ACPI_RSDP_NAME "RSDP" // Short name for RSDP, not signature
#define ACPI_SIG_MADT "APIC" // Multiple APIC Description Table
#define ACPI_SIG_SBST "SBST" // Smart Battery Specification Table
#define ACPI_SIG_ECDT "ECDT" // Embedded Controller Boot Resources Table
#define ACPI_SIG_ASF "ASF!" // Alert Standard Format table
#define ACPI_SIG_DMAR "DMAR" // DMA Remapping table
#define ACPI_SIG_HPET "HPET" // High Precision Event Timer table
#define ACPI_SIG_MCFG "MCFG" // PCI Memory Mapped Configuration table
#define ACPI_SIG_UEFI "UEFI" // Uefi Boot Optimization Table
#ifndef nameseg_defined
#define nameseg_defined
#define NAMESEG(s) (((U32)(s[0]) << 0) \
|((U32)(s[1]) << 8) \
|((U32)(s[2]) << 16) \
|((U32)(s[3]) << 24))
#endif
#define NAMESEG64(s) (((U64)(s[0]) << 0) \
|((U64)(s[1]) << 8) \
|((U64)(s[2]) << 16) \
|((U64)(s[3]) << 24) \
|((U64)(s[4]) << 32) \
|((U64)(s[5]) << 40) \
|((U64)(s[6]) << 48) \
|((U64)(s[7]) << 56)) \
// Data Objects Encoding values.
#define AML_EXT_OP_PREFIX 0x5B
// Name Space Modifier Objects Encoding values.
#define AML_NAME_OP 0x08 // Name operator.
#define AML_SCOPE_OP 0x10 // Scope operator.
// Named Objects Encoding values.
#define AML_MUTEX_OP 0x01
#define AML_METHOD_OP 0x14 // Method operator.
#define AML_OPREGION_OP 0x80 // Operation Region operator.
#define AML_FIELD_OP 0x81
#define AML_DEVICE_OP 0x82
#define AML_PROCESSOR_OP 0x83 // Processor operator.
// Type2 Opcodes Encoding values.
#define AML_NULL_NAME 0x00
#define AML_ZERO_OP 0x00
#define AML_ALIAS_OP 0x06
#define AML_ONE_OP 0x01
#define AML_BYTE_OP 0x0a
#define AML_WORD_OP 0x0b
#define AML_DWORD_OP 0x0c
#define AML_STRING_OP 0x0d
#define AML_QWORD_OP 0x0e
#define AML_BUFFER_OP 0x11
#define AML_PACKAGE_OP 0x12
#define AML_COND_REF_OF_OP 0x12 // Requires AML_EXT_OP_PREFIX
#define AML_CREATE_FIELD_OP 0x13 // Requires AML_EXT_OP_PREFIX
#define AML_DUAL_NAME_PREFIX 0x2e
#define AML_MULTI_NAME_PREFIX 0x2f
#define AML_REVISION_OP 0x30 // Requires AML_EXT_OP_PREFIX
#define AML_DEBUG_OP 0x31
#define AML_ROOT_PREFIX 0x5c
#define AML_PARENT_PREFIX 0x5e
#define AML_LOCAL0_OP 0x60
#define AML_LOCAL1_OP 0x61
#define AML_LOCAL2_OP 0x62
#define AML_LOCAL3_OP 0x63
#define AML_LOCAL4_OP 0x64
#define AML_LOCAL5_OP 0x65
#define AML_LOCAL6_OP 0x66
#define AML_LOCAL7_OP 0x67
#define AML_ARG0_OP 0x68
#define AML_ARG1_OP 0x69
#define AML_ARG2_OP 0x6A
#define AML_ARG3_OP 0x6B
#define AML_ARG4_OP 0x6C
#define AML_ARG5_OP 0x6D
#define AML_ARG6_OP 0x6E
#define AML_STORE_OP 0x70
#define AML_CONCAT_OP 0x73
#define AML_SUBTRACT_OP 0x74
#define AML_MULTIPLY_OP 0x77
#define AML_AND_OP 0x7B
#define AML_END_TAG_OP 0x79
#define AML_GEN_REG_FIELD 0x82
#define AML_PROCESSOR_OP 0x83
#define AML_INDEXFIELD_OP 0x86 // Requires AML_EXT_OP_PREFIX
#define AML_SIZEOF_OP 0x87
#define AML_INDEX_OP 0x88
#define AML_CREATE_DWORD_FIELD_OP 0x8A
#define AML_LAND_OP 0x90
#define AML_LOR_OP 0x91
#define AML_LNOT_OP 0x92
#define AML_LEQUAL_OP 0x93
#define AML_LGREATER_OP 0x94
#define AML_LLESS_OP 0x95
#define AML_IF_OP 0xA0
#define AML_ELSE_OP 0xA1
#define AML_RETURN_OP 0xA4
#define AML_ONES_OP 0xFF
#define GAS_TYPE_FFH 0x7f
#define GAS_TYPE_SYSTEM_IO 0x01
#define GAS_VENDOR_INTEL 0x01
#define GAS_CLASS_CODE_NATIVE 0x02
// Define the Generic System Description Table Structure.
// This common header is used by all tables except the RSDP and FACS.
// The define is used for direct inclusion of header into other ACPI tables
typedef struct acpi_table_header {
U8 Signature[4]; // ASCII table signature
U32 Length; // Length of table in bytes, including this header
U8 Revision; // ACPI Specification minor version #
U8 Checksum; // To make checksum of entire table == 0
U8 OemId[6]; // ASCII OEM identification
U8 OemTableId[8]; // ASCII OEM table identification
U32 OemRevision; // OEM revision number
U8 AslCompilerId[4]; // ASCII ASL compiler vendor ID
U32 AslCompilerRevision; // ASL compiler version
} __attribute__((packed))ACPI_TABLE_HEADER;
// GAS - Generic Address Structure (ACPI 2.0+)
typedef struct acpi_generic_address {
U8 SpaceId; // Address space where struct or register exists
U8 BitWidth; // Size in bits of given register
U8 BitOffset; // Bit offset within the register
U8 AccessWidth; // Minimum Access size (ACPI 3.0)
U64 Address; // 64-bit address of struct or register
} __attribute__((packed))ACPI_GENERIC_ADDRESS;
// RSDP - Root System Description Pointer (Signature is "RSD PTR ")
typedef struct acpi_table_rsdp {
U8 Signature[8]; // ACPI signature, contains "RSD PTR "
U8 Checksum; // ACPI 1.0 checksum
U8 OemId[6]; // OEM identification
U8 Revision; // Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+
U32 RsdtPhysicalAddress; // 32-bit physical address of the RSDT
U32 Length; // Table length in bytes, including header (ACPI 2.0+)
U64 XsdtPhysicalAddress; // 64-bit physical address of the XSDT (ACPI 2.0+)
U8 ExtendedChecksum; // Checksum of entire table (ACPI 2.0+)
U8 Reserved[3]; // Reserved, must be zero
} __attribute__((packed))ACPI_TABLE_RSDP;
#define ACPI_RSDP_REV0_SIZE 20 // Size of original ACPI 1.0 RSDP
// RSDT - Root System Description Table
typedef struct acpi_table_rsdt {
ACPI_TABLE_HEADER Header; // Common ACPI table header
U32 TableOffsetEntry[1]; // Array of pointers to ACPI tables
} __attribute__((packed))ACPI_TABLE_RSDT;
// XSDT - Root System Description Table
typedef struct acpi_table_xsdt {
ACPI_TABLE_HEADER Header; // Common ACPI table header
U64 TableOffsetEntry[1]; // Array of pointers to ACPI tables
} __attribute__((packed))ACPI_TABLE_XSDT;
// DSDT - Differentiated System Description Table
typedef struct acpi_table_dsdt {
ACPI_TABLE_HEADER Header; // Common ACPI table header
U32 EntryStart;
} __attribute__((packed))ACPI_TABLE_DSDT;
// FACS - Firmware ACPI Control Structure (FACS)
typedef struct acpi_table_facs {
U8 Signature[4]; // ASCII table signature
U32 Length; // Length of structure, in bytes
U32 HardwareSignature; // Hardware configuration signature
U32 FirmwareWakingVector; // 32-bit physical address of the Firmware Waking Vector
U32 GlobalLock; // Global Lock for shared hardware resources
U32 Flags;
U64 XFirmwareWakingVector; // 64-bit version of the Firmware Waking Vector (ACPI 2.0+)
U8 Version; // Version of this table (ACPI 2.0+)
U8 Reserved[31]; // Reserved, must be zero
} __attribute__((packed))ACPI_TABLE_FACS;
// SBST - Smart Battery Specification Table - Version 1
typedef struct acpi_table_sbst
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
U32 WarningLevel;
U32 LowLevel;
U32 CriticalLevel;
} __attribute__((packed))ACPI_TABLE_SBST;
// ASF - Alert Standard Format table (Signature "ASF!")
typedef struct acpi_table_asf
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
} ACPI_TABLE_ASF;
// DMAR - DMA Remapping table - Version 1
typedef struct acpi_table_dmar
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
U8Width; /* Host Address Width */
U8Flags;
U8Reserved[10];
} __attribute__((packed))ACPI_TABLE_DMAR;
// HPET - High Precision Event Timer table - Version 1
typedef struct acpi_table_hpet
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
U32Id; /* Hardware ID of event timer block */
ACPI_GENERIC_ADDRESS Address; /* Address of event timer block */
U8Sequence; /* HPET sequence number */
U16MinimumTick; /* Main counter min tick, periodic mode */
U8Flags;
} __attribute__((packed))ACPI_TABLE_HPET;
//MCFG - PCI Memory Mapped Configuration table and sub-table - Version 1
typedef struct acpi_table_mcfg
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
U8Reserved[8];
} ACPI_TABLE_MCFG;
//UEFI - UEFI Boot optimization Table - Version 1
typedef struct acpi_table_uefi
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
U8Identifier[16]; /* UUID identifier */
U16DataOffset; /* Offset of remaining data in table */
} __attribute__((packed))ACPI_TABLE_UEFI;
// ECDT - Embedded Controller Boot Resources Table - Version 1
typedef struct acpi_table_ecdt
{
ACPI_TABLE_HEADER Header; /* Common ACPI table header */
ACPI_GENERIC_ADDRESS Control; /* Address of EC command/status register */
ACPI_GENERIC_ADDRESS Data; /* Address of EC data register */
U32Uid; /* Unique ID - must be same as the EC _UID method */
U8Gpe; /* The GPE for the EC */
U8Id[1]; /* Full namepath of the EC in the ACPI namespace */
} __attribute__((packed))ACPI_TABLE_ECDT;
// FADT - Fixed ACPI Description Table (Signature "FACP")
typedef struct acpi_table_fadt {
ACPI_TABLE_HEADER Header; // Common ACPI table header
U32 Facs; // 32-bit physical address of FACS
U32 Dsdt; // 32-bit physical address of DSDT
U8 Model; // System Interrupt Model (ACPI 1.0) - not used in ACPI 2.0+
U8 PreferredProfile; // Conveys preferred power management profile to OSPM.
U16 SciInterrupt; // System vector of SCI interrupt
U32 SmiCommand; // 32-bit Port address of SMI command port
U8 AcpiEnable; // Value to write to smi_cmd to enable ACPI
U8 AcpiDisable; // Value to write to smi_cmd to disable ACPI
U8 S4BiosRequest; // Value to write to SMI CMD to enter S4BIOS state
U8 PstateControl; // Processor performance state control
U32 Pm1aEventBlock; // 32-bit Port address of Power Mgt 1a Event Reg Blk
U32 Pm1bEventBlock; // 32-bit Port address of Power Mgt 1b Event Reg Blk
U32 Pm1aControlBlock; // 32-bit Port address of Power Mgt 1a Control Reg Blk
U32 Pm1bControlBlock; // 32-bit Port address of Power Mgt 1b Control Reg Blk
U32 Pm2ControlBlock; // 32-bit Port address of Power Mgt 2 Control Reg Blk
U32 PmTimerBlock; // 32-bit Port address of Power Mgt Timer Ctrl Reg Blk
U32 Gpe0Block; // 32-bit Port address of General Purpose Event 0 Reg Blk
U32 Gpe1Block; // 32-bit Port address of General Purpose Event 1 Reg Blk
U8 Pm1EventLength; // Byte Length of ports at Pm1xEventBlock
U8 Pm1ControlLength; // Byte Length of ports at Pm1xControlBlock
U8 Pm2ControlLength; // Byte Length of ports at Pm2ControlBlock
U8 PmTimerLength; // Byte Length of ports at PmTimerBlock
U8 Gpe0BlockLength; // Byte Length of ports at Gpe0Block
U8 Gpe1BlockLength; // Byte Length of ports at Gpe1Block
U8 Gpe1Base; // Offset in GPE number space where GPE1 events start
U8 CstControl; // Support for the _CST object and C States change notification
U16 C2Latency; // Worst case HW latency to enter/exit C2 state
U16 C3Latency; // Worst case HW latency to enter/exit C3 state
U16 FlushSize; // Processor's memory cache line width, in bytes
U16 FlushStride; // Number of flush strides that need to be read
U8 DutyOffset; // Processor duty cycle index in processor's P_CNT reg
U8 DutyWidth; // Processor duty cycle value bit width in P_CNT register.
U8 DayAlarm; // Index to day-of-month alarm in RTC CMOS RAM
U8 MonthAlarm; // Index to month-of-year alarm in RTC CMOS RAM
U8 Century; // Index to century in RTC CMOS RAM
U16 BootFlags; // IA-PC Boot Architecture Flags. See Table 5-10 for description
U8 Reserved; // Reserved, must be zero
U32 Flags; // Miscellaneous flag bits (see below for individual flags)
ACPI_GENERIC_ADDRESS ResetRegister; // 64-bit address of the Reset register
U8 ResetValue; // Value to write to the ResetRegister port to reset the system
U8 Reserved4[3]; // Reserved, must be zero
U64 XFacs; // 64-bit physical address of FACS
U64 XDsdt; // 64-bit physical address of DSDT
ACPI_GENERIC_ADDRESS XPm1aEventBlock; // 64-bit Extended Power Mgt 1a Event Reg Blk address
ACPI_GENERIC_ADDRESS XPm1bEventBlock; // 64-bit Extended Power Mgt 1b Event Reg Blk address
ACPI_GENERIC_ADDRESS XPm1aControlBlock; // 64-bit Extended Power Mgt 1a Control Reg Blk address
ACPI_GENERIC_ADDRESS XPm1bControlBlock; // 64-bit Extended Power Mgt 1b Control Reg Blk address
ACPI_GENERIC_ADDRESS XPm2ControlBlock; // 64-bit Extended Power Mgt 2 Control Reg Blk address
ACPI_GENERIC_ADDRESS XPmTimerBlock; // 64-bit Extended Power Mgt Timer Ctrl Reg Blk address
ACPI_GENERIC_ADDRESS XGpe0Block; // 64-bit Extended General Purpose Event 0 Reg Blk address
ACPI_GENERIC_ADDRESS XGpe1Block; // 64-bit Extended General Purpose Event 1 Reg Blk address
} __attribute__((packed))ACPI_TABLE_FADT;
// SSDT - Secondary System Description Table
typedef struct acpi_table_ssdt {
ACPI_TABLE_HEADER Header; // Common ACPI table header
} __attribute__((packed))ACPI_TABLE_SSDT;
//MADT - Multiple APIC Description Table
typedef struct acpi_table_madt {
ACPI_TABLE_HEADER Header; // Common ACPI table header
U32 Address; // Physical address of local APIC
U32 Flags;
} __attribute__((packed))ACPI_TABLE_MADT;
// Values for subtable type in ACPI_SUBTABLE_HEADER
enum AcpiMadtType {
ACPI_MADT_TYPE_LOCAL_APIC = 0,
ACPI_MADT_TYPE_IO_APIC = 1,
ACPI_MADT_TYPE_INTERRUPT_OVERRIDE = 2,
ACPI_MADT_TYPE_NMI_SOURCE = 3,
ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4,
ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE = 5,
ACPI_MADT_TYPE_IO_SAPIC = 6,
ACPI_MADT_TYPE_LOCAL_SAPIC = 7,
ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8,
ACPI_MADT_TYPE_X2APIC = 9,
ACPI_MADT_TYPE_RESERVED = 10 // 10 and greater are reserved
};
// Common Sub-table header (used in MADT, SRAT, etc.)
typedef struct acpi_subtable_header {
U8 Type;
U8 Length;
} __attribute__((packed))ACPI_SUBTABLE_HEADER;
// MADT Sub-tables, correspond to Type in ACPI_SUBTABLE_HEADER
// 0: Processor Local APIC
typedef struct acpi_madt_local_apic {
ACPI_SUBTABLE_HEADER Header;
U8 ProcessorId; // ACPI processor id
U8 Id; // Processor's local APIC id
U32 LapicFlags;
} __attribute__((packed))ACPI_MADT_LOCAL_APIC;
// 1: IO APIC
typedef struct acpi_madt_io_apic {
ACPI_SUBTABLE_HEADER Header;
U8 Id; // I/O APIC ID
U8 Reserved; // Reserved - must be zero
U32 Address; // APIC physical address
U32 GlobalIrqBase; // Global system interrupt where INTI lines start
} __attribute__((packed))ACPI_MADT_IO_APIC;
// 2: Interrupt Override
typedef struct acpi_madt_interrupt_override {
ACPI_SUBTABLE_HEADER Header;
U8 Bus; // 0 - ISA
U8 SourceIrq; // Interrupt source (IRQ)
U32 GlobalIrq; // Global system interrupt
U16 IntiFlags;
} __attribute__((packed))ACPI_MADT_INTERRUPT_OVERRIDE;
// 3: NMI Source
typedef struct acpi_madt_nmi_source {
ACPI_SUBTABLE_HEADER Header;
U16 IntiFlags;
U32 GlobalIrq; // Global system interrupt
} __attribute__((packed))ACPI_MADT_NMI_SOURCE;
// 4: Local APIC NMI
typedef struct acpi_madt_local_apic_nmi {
ACPI_SUBTABLE_HEADER Header;
U8 ProcessorId; // ACPI processor id
U16 IntiFlags;
U8 Lint; // LINTn to which NMI is connected
} __attribute__((packed))ACPI_MADT_LOCAL_APIC_NMI;
// 5: Address Override
typedef struct acpi_madt_local_apic_override {
ACPI_SUBTABLE_HEADER Header;
U16 Reserved; // Reserved, must be zero
U64 Address; // APIC physical address
} __attribute__((packed))ACPI_MADT_LOCAL_APIC_OVERRIDE;
// 6: I/O Sapic
typedef struct acpi_madt_io_sapic {
ACPI_SUBTABLE_HEADER Header;
U8 Id; // I/O SAPIC ID
U8 Reserved; // Reserved, must be zero
U32 GlobalIrqBase; // Global interrupt for SAPIC start
U64 Address; // SAPIC physical address
} __attribute__((packed))ACPI_MADT_IO_SAPIC;
// 7: Local Sapic
typedef struct acpi_madt_local_sapic {
ACPI_SUBTABLE_HEADER Header;
U8 ProcessorId; // ACPI processor id
U8 Id; // SAPIC ID
U8 Eid; // SAPIC EID
U8 Reserved[3]; // Reserved, must be zero
U32 LapicFlags;
U32 Uid; // Numeric UID - ACPI 3.0
char UidString[1]; // String UID - ACPI 3.0
} __attribute__((packed))ACPI_MADT_LOCAL_SAPIC;
// 8: Platform Interrupt Source
typedef struct acpi_madt_interrupt_source {
ACPI_SUBTABLE_HEADER Header;
U16 IntiFlags;
U8 Type; // 1=PMI, 2=INIT, 3=corrected
U8 Id; // Processor ID
U8 Eid; // Processor EID
U8 IoSapicVector; // Vector value for PMI interrupts
U32 GlobalIrq; // Global system interrupt
U32 Flags; // Interrupt Source Flags
} __attribute__((packed))ACPI_MADT_INTERRUPT_SOURCE;
// 9: Processor X2APIC
typedef struct acpi_madt_x2apic {
ACPI_SUBTABLE_HEADER Header;
U16 Reserved; // Must be zero
U32 x2apicId; // Processor's X2APIC ID
U32 x2apicFlags;
U32 UID;
} __attribute__((packed))ACPI_MADT_X2APIC;
// Common flags fields for MADT subtables
// MADT Local APIC flags (LapicFlags)
#define ACPI_MADT_ENABLED (1) // 00: Processor is usable if set
// MADT MPS INTI flags (IntiFlags)
#define ACPI_MADT_POLARITY_MASK (3) // 00-01: Polarity of APIC I/O input signals
#define ACPI_MADT_TRIGGER_MASK (3<<2) // 02-03: Trigger mode of APIC input signals
// Values for MPS INTI flags
#define ACPI_MADT_POLARITY_CONFORMS 0
#define ACPI_MADT_POLARITY_ACTIVE_HIGH 1
#define ACPI_MADT_POLARITY_RESERVED 2
#define ACPI_MADT_POLARITY_ACTIVE_LOW 3
#define ACPI_MADT_TRIGGER_CONFORMS (0)
#define ACPI_MADT_TRIGGER_EDGE (1<<2)
#define ACPI_MADT_TRIGGER_RESERVED (2<<2)
#define ACPI_MADT_TRIGGER_LEVEL (3<<2)
#define ACPI_COORD_TYPE_SW_ALL 0xFC
#define ACPI_COORD_TYPE_SW_ANY 0xFD
#define ACPI_COORD_TYPE_HW_ALL 0xFE
typedef struct packageLength {
U8 packageLength0;
U8 packageLength1;
} __attribute__((packed))ACPI_PACKAGE_LENGTH;
typedef struct acpi_scope {
U8 scopeOpcode;
ACPI_PACKAGE_LENGTH pkgLength;
U8 rootChar;
} __attribute__((packed))ACPI_SCOPE;
typedef struct dual_name_path {
U8 prefix;
U32 nameseg[2];
} __attribute__((packed))DUAL_NAME_PATH;
typedef struct multi_name_path {
U8 prefix;
U8 segCount;
U32 nameseg[MAX_SUPPORTED_CPU_NAMESEGS];
} __attribute__((packed))MULTI_NAME_PATH;
typedef struct generic_register {
U8 genericRegisterField;
ACPI_PACKAGE_LENGTH pkgLength;
ACPI_GENERIC_ADDRESS gas;
} __attribute__((packed))ACPI_GENERIC_REGISTER;
typedef struct package {
U8 packageOpcode;
ACPI_PACKAGE_LENGTH pkgLength;
U8 numElements;
} __attribute__((packed))ACPI_PACKAGE;
typedef struct small_package {
U8 packageOpcode;
U8 packageLength;
U8 numElements;
} __attribute__((packed))ACPI_SMALL_PACKAGE;
typedef struct small_buffer {
U8 bufferOpcode;
U8 packageLength;
} __attribute__((packed))ACPI_SMALL_BUFFER;
typedef struct end_tag {
U8 endTagField;
U8 checksum;
} __attribute__((packed))ACPI_END_TAG;
typedef struct return_name_seg {
U8 returnOpcode;
U32 name;
} __attribute__((packed))ACPI_RETURN_NAME_SEG;
typedef struct return_package {
U8 returnOpcode;
ACPI_PACKAGE package;
} __attribute__((packed))ACPI_RETURN_PACKAGE;
typedef struct return_zero {
U8 returnOpcode;
U8 zeroOpcode;
} __attribute__((packed))ACPI_RETURN_ZERO;
typedef struct return_opcode {
U8 returnOpcode;
U8 opcodeToReturn;
} __attribute__((packed))ACPI_RETURN_OPCODE;
typedef struct byteConst {
U8 byteOpcode;
U8 byteData;
} __attribute__((packed))ACPI_BYTE_CONST;
typedef struct wordConst {
U8 wordOpcode;
U16 wordData;
} __attribute__((packed))ACPI_WORD_CONST;
typedef struct dwordConst {
U8 dwordOpcode;
U32 dwordData;
} __attribute__((packed))ACPI_DWORD_CONST;
typedef struct small_method {
U8 methodOpcode;
U8 packageLength;
U32 name;
U8 methodFlags;
} __attribute__((packed))ACPI_SMALL_METHOD;
typedef struct method {
U8 methodOpcode;
ACPI_PACKAGE_LENGTH pkgLength;
U32 name;
U8 methodFlags;
} __attribute__((packed))ACPI_METHOD;
typedef struct namePath {
U8 nameOpcode;
U32 name;
} __attribute__((packed))ACPI_NAME_PATH;
typedef struct named_dword {
ACPI_NAME_PATH namePath;
ACPI_DWORD_CONST dword;
} __attribute__((packed))ACPI_NAMED_DWORD;
typedef struct rootNamePath {
U8 nameOpcode;
U8 rootPrefix;
U32 name;
} ACPI_ROOT_NAME_PATH;
typedef struct root_named_dword {
ACPI_ROOT_NAME_PATH rootNamePath;
ACPI_DWORD_CONST dword;
} __attribute__((packed))ACPI_ROOT_NAMED_DWORD;
typedef struct named_object {
ACPI_NAME_PATH namePath;
ACPI_PACKAGE package;
} __attribute__((packed))ACPI_NAMED_OBJECT;
typedef struct small_named_object {
ACPI_NAME_PATH namePath;
ACPI_SMALL_PACKAGE package;
} __attribute__((packed))ACPI_SMALL_NAMED_OBJECT;
typedef struct create_dword_field {
ACPI_NAME_PATH namePath;
ACPI_SMALL_PACKAGE package;
} __attribute__((packed))ACPI_CREATE_DWORD_FIELD;
typedef struct tstate_package {
ACPI_SMALL_PACKAGE package;
ACPI_DWORD_CONST FreqPercent;
ACPI_DWORD_CONST Power;
ACPI_DWORD_CONST TransLatency;
ACPI_DWORD_CONST Control;
ACPI_DWORD_CONST Status;
} __attribute__((packed))ACPI_TSTATE_PACKAGE;
typedef struct pstate_package {
ACPI_SMALL_PACKAGE package;
ACPI_DWORD_CONST CoreFreq;
ACPI_DWORD_CONST Power;
ACPI_DWORD_CONST TransLatency;
ACPI_DWORD_CONST BMLatency;
ACPI_DWORD_CONST Control;
ACPI_DWORD_CONST Status;
} __attribute__((packed))ACPI_PSTATE_PACKAGE;
typedef struct psd_package {
ACPI_SMALL_PACKAGE package;
ACPI_BYTE_CONST NumberOfEntries;
ACPI_BYTE_CONST Revision;
ACPI_DWORD_CONST Domain;
ACPI_DWORD_CONST CoordType;
ACPI_DWORD_CONST NumProcessors;
} __attribute__((packed))ACPI_PSD_PACKAGE;
typedef struct csd_package {
ACPI_SMALL_PACKAGE package;
ACPI_BYTE_CONST NumberOfEntries;
ACPI_BYTE_CONST Revision;
ACPI_DWORD_CONST Domain;
ACPI_DWORD_CONST CoordType;
ACPI_DWORD_CONST NumProcessors;
ACPI_DWORD_CONST Index;
} __attribute__((packed))ACPI_CSD_PACKAGE;
typedef struct tsd_package {
ACPI_SMALL_PACKAGE package;
ACPI_BYTE_CONST NumberOfEntries;
ACPI_BYTE_CONST Revision;
ACPI_DWORD_CONST Domain;
ACPI_DWORD_CONST CoordType;
ACPI_DWORD_CONST NumProcessors;
} __attribute__((packed))ACPI_TSD_PACKAGE;
typedef struct processor {
U8 processorOpCode;
U8 packageLength;
U8 numElements;
ACPI_BYTE_CONST ProcID;
ACPI_DWORD_CONST PblkAddr;
ACPI_BYTE_CONST PblkLen;
} __attribute__((packed))ACPI_PROCESSOR;
//#pragma pack()
#endif /* !__LIBSAIO_INTEL_ACPI_H */
trunk/i386/modules/Sata/include/Cconfig
1
2
3
4
5
6
7
8
9
10
#
# Chameleon Modules
#
config ACPICODEC_MODULE
tristate "ACPICodec Module"
default m
---help---
Say Y here if you want to enable the use of this module.
trunk/i386/modules/Sata/include/acpicode.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "datatype.h"
#include "acpi.h"
#include "ppm.h"
#include "acpicode.h"
static void setPackage(ACPI_PACKAGE * package, U8 numElements);
static void setNamePath(ACPI_NAME_PATH * namePath, U32 name);
void SetChecksum(struct acpi_table_header *header)
{
header->Checksum = 0;
header->Checksum = 0 - GetChecksum(header, header->Length);
}
void setRsdpchecksum(ACPI_TABLE_RSDP *rsdp)
{
rsdp->Checksum = 0;
rsdp->Checksum = 0 - GetChecksum(rsdp, ACPI_RSDP_REV0_SIZE);
}
void setRsdpXchecksum(ACPI_TABLE_RSDP *rsdp)
{
rsdp->ExtendedChecksum = 0;
rsdp->ExtendedChecksum = 0 - GetChecksum(rsdp, rsdp->Length);
}
U32 update_rsdp_with_xsdt(ACPI_TABLE_RSDP *rsdp, ACPI_TABLE_XSDT *xsdt)
{
// 1. Update the XSDT pointer in the RSDP
// 2. Update the Xchecksum of the RSDP
{
// 1. Update the XSDT pointer in the RSDP
rsdp->XsdtPhysicalAddress = ((U64)((U32)xsdt));
}
{
// 2. Update the Xchecksum of the RSDP
setRsdpXchecksum(rsdp);
}
return (1);
}
U32 update_rsdp_with_rsdt(ACPI_TABLE_RSDP *rsdp, ACPI_TABLE_RSDT *rsdt)
{
// 1. Update the RSDT pointer in the RSDP
// 2. Update the checksum of the RSDP
{
// 1. Update the RSDT pointer in the RSDP
rsdp->RsdtPhysicalAddress = (U32)rsdt;
}
{
// 2. Update the checksum of the RSDP
setRsdpchecksum(rsdp);
}
return (1);
}
//-----------------------------------------------------------------------------
U32 ProcessMadtInfo(ACPI_TABLE_MADT * madt, MADT_INFO * madt_info)
{
void *current;
void *end;
// Quick sanity check for a valid MADT
if (madt == 0ul)
return (0ul);
madt_info->lapic_count = 0;
// Search MADT for Sub-tables with needed data
current = madt + 1;
end = (U8 *) madt + madt->Header.Length;
while (current < end)
{
ACPI_SUBTABLE_HEADER *subtable = current;
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;
{
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++;
// 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;
{
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++;
// 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;
}
default:
{
// Process all other sub-tables
current = (U8 *) subtable + subtable->Length;
break;
}
} // switch
} // while
return (1);
}
//-------------------------------------------------------------------------------
U32 ProcessDsdt(ACPI_TABLE_DSDT * DsdtPointer, U8 * PCIUIDPointer, U8 uid)
{
// 1. Sanity check
// 2. Replace UID value with the new value
// 3. Update the checksum of the DSDT
{
// 1. Sanity check
if ((memcmp(&uid, PCIUIDPointer, sizeof(U8)) == 0) || (PCIUIDPointer == (U8*)0) || (DsdtPointer == (void*)0ul))
return (0);
}
{
// 2. Replace UID value with the new value
buildOpCode((void*)PCIUIDPointer, uid);
}
{
// 3. Update the checksum of the DSDT
SetChecksum(&DsdtPointer->Header);
}
return (1);
}
//-------------------------------------------------------------------------------
void MoveRsdtInsertSsdt(ACPI_TABLE_RSDP * RsdPointer, ACPI_TABLE_RSDT * OldRsdtPointer, ACPI_TABLE_RSDT * NewRsdtPointer, ACPI_TABLE_SSDT * SsdtPointer)
{
// 1. Move the RSDT in memory to the new location
// 2. Add new pointer for the SSDT into the RSDT
// 3. Update the size of the RSDT
// 4. Update the checksum of the RSDT
// 5. Update the RSDT pointer in the RSDP
// 6. Update the checksum of the RSDP
{
// 1. Move the RSDT in memory to the new location
memcpy(NewRsdtPointer, OldRsdtPointer, OldRsdtPointer->Header.Length);
}
{
// 2. Add new pointer for the SSDT into the RSDT
// 3. Update the size of the RSDT
// 4. Update the checksum of the RSDT
InsertSsdt(NewRsdtPointer, SsdtPointer);
}
{
// 5. Update the RSDT pointer in the RSDP
RsdPointer->RsdtPhysicalAddress = (U32) NewRsdtPointer;
}
{
// 6. Update the checksum of the RSDP
setRsdpchecksum(RsdPointer);
}
}
//-------------------------------------------------------------------------------
void InsertSsdt(ACPI_TABLE_RSDT * RsdtPointer, ACPI_TABLE_SSDT * SsdtPointer)
{
// 1. Add new pointer for the SSDT into the RSDT
// 2. Update the size of the RSDT
// 3. Update the checksum of the RSDT
{
// 1. Add new pointer for the SSDT into the RSDT
U32 index = get_num_tables(RsdtPointer);
RsdtPointer->TableOffsetEntry[index] = (U32) SsdtPointer;
}
{
// 2. Update the size of the RSDT
RsdtPointer->Header.Length = RsdtPointer->Header.Length + sizeof(ACPI_TABLE_SSDT *);
}
{
// 3. Update the checksum of the RSDT
SetChecksum(&RsdtPointer->Header);
}
}
//-------------------------------------------------------------------------------
void InsertSsdt64(ACPI_TABLE_XSDT * XsdtPointer, ACPI_TABLE_SSDT * SsdtPointer)
{
{
void *null = 0ul;
if (XsdtPointer == null)
return;
}
// 1. Add new pointer for the SSDT into the XSDT
// 2. Update the size of the XSDT
// 3. Update the checksum of the XSDT
{
// 1. Add new pointer for the SSDT into the XSDT
U32 index = get_num_tables64(XsdtPointer);
XsdtPointer->TableOffsetEntry[index] = (U64) ((U32) SsdtPointer);
}
{
// 2. Update the size of the XSDT
XsdtPointer->Header.Length = XsdtPointer->Header.Length + sizeof(U64);
}
{
// 3. Update the checksum of the XSDT
SetChecksum(&XsdtPointer->Header);
}
}
//-----------------------------------------------------------------------------
void *buildNameSeg(void *current, U32 name)
{
U32 *nameSeg = current;
current = nameSeg + 1;
*nameSeg = name;
return (current);
}
//-----------------------------------------------------------------------------
void *buildOpCode(void *current, U8 opCode)
{
U8 *op = current;
current = op + 1;
*op = opCode;
return (current);
}
//-----------------------------------------------------------------------------
void *buildReturnPackage(void *current, U8 numElements)
{
ACPI_RETURN_PACKAGE *returnPackage = current;
current = returnPackage + 1;
returnPackage->returnOpcode = AML_RETURN_OP;
setPackage(&returnPackage->package, numElements);
return (current);
}
//-----------------------------------------------------------------------------
void *buildReturnZero(void *current)
{
ACPI_RETURN_ZERO *returnZero = current;
current = returnZero + 1;
returnZero->returnOpcode = AML_RETURN_OP;
returnZero->zeroOpcode = AML_ZERO_OP;
return (current);
}
//-----------------------------------------------------------------------------
void *buildReturnOpcode(void *current, U8 opcodeToReturn)
{
ACPI_RETURN_OPCODE *returnOpcode = current;
current = returnOpcode + 1;
returnOpcode->returnOpcode = AML_RETURN_OP;
returnOpcode->opcodeToReturn = opcodeToReturn;
return (current);
}
//-----------------------------------------------------------------------------
void *buildMethod(void *current, U32 name, U8 methodFlags)
{
ACPI_METHOD *method = current;
current = method + 1;
method->methodOpcode = AML_METHOD_OP;
method->name = name;
method->methodFlags = methodFlags;
return (current);
}
//-----------------------------------------------------------------------------
void *buildSmallMethod(void *current, U32 name, U8 methodFlags)
{
ACPI_SMALL_METHOD *method = current;
current = method + 1;
method->methodOpcode = AML_METHOD_OP;
method->name = name;
method->methodFlags = methodFlags;
return (current);
}
//-----------------------------------------------------------------------------
void *buildNamedDword(void *current, U32 name, U32 dword)
{
ACPI_NAMED_DWORD *namedDword = current;
current = namedDword + 1;
setNamePath(&namedDword->namePath, name);
setDwordConst(&namedDword->dword, dword);
return (current);
}
//-----------------------------------------------------------------------------
void *buildGenericRegister(void *current, const ACPI_GENERIC_ADDRESS * gas)
{
ACPI_GENERIC_REGISTER *genReg = current;
current = genReg + 1;
genReg->genericRegisterField = AML_GEN_REG_FIELD;
genReg->pkgLength.packageLength0 = 0x0c;
genReg->pkgLength.packageLength1 = 0;
genReg->gas.SpaceId = gas->SpaceId;
genReg->gas.BitWidth = gas->BitWidth;
genReg->gas.BitOffset = gas->BitOffset;
genReg->gas.AccessWidth = gas->AccessWidth;
genReg->gas.Address = gas->Address;
return (current);
}
//-----------------------------------------------------------------------------
void *buildSmallBuffer(void *current)
{
ACPI_SMALL_BUFFER *buffer = current;
current = buffer + 1;
buffer->bufferOpcode = AML_BUFFER_OP;
return (current);
}
//-----------------------------------------------------------------------------
void *buildEndTag(void *current)
{
ACPI_END_TAG *endTag = current;
current = endTag + 1;
endTag->endTagField = AML_END_TAG_OP;
endTag->checksum = 0;
return (current);
}
//-----------------------------------------------------------------------------
void setSmallPackage(ACPI_SMALL_PACKAGE * package, U8 numElements)
{
package->packageOpcode = AML_PACKAGE_OP;
package->numElements = numElements;
}
//-----------------------------------------------------------------------------
void *buildSmallPackage(void *current, U8 numElements)
{
ACPI_SMALL_PACKAGE *package = current;
current = package + 1;
setSmallPackage(package, numElements);
return (current);
}
//-----------------------------------------------------------------------------
static void setPackage(ACPI_PACKAGE * package, U8 numElements)
{
package->packageOpcode = AML_PACKAGE_OP;
package->numElements = numElements;
}
//-----------------------------------------------------------------------------
void setPackageLength(ACPI_PACKAGE_LENGTH * packageLength, U32 length)
{
packageLength->packageLength0 = 0x40 + (U8) (length & 0xf);
packageLength->packageLength1 = (U8) (length >> 4);
}
//-----------------------------------------------------------------------------
void *buildPackageLength(void *current, U32 length)
{
ACPI_PACKAGE_LENGTH *packageLength = current;
current = packageLength + 1;
setPackageLength(packageLength, length);
return (current);
}
//-----------------------------------------------------------------------------
static void setNamePath(ACPI_NAME_PATH * namePath, U32 name)
{
namePath->nameOpcode = AML_NAME_OP;
namePath->name = name;
}
//-----------------------------------------------------------------------------
void *buildNamePath(void *current, U32 name)
{
ACPI_NAME_PATH *namePath = current;
current = namePath + 1;
setNamePath(namePath, name);
return (current);
}
//-----------------------------------------------------------------------------
static void setTableHeader(ACPI_TABLE_HEADER * tableHeader, U32 signature, U64 oemTableId)
{
*(U32 *) &tableHeader->Signature = signature;
tableHeader->Length = 0;
tableHeader->Revision = 1;
tableHeader->Checksum = 0;
memcpy(&tableHeader->OemId[0], "INTEL ", 6);
*(U64 *) (tableHeader->OemTableId) = oemTableId;
tableHeader->OemRevision = 0x80000001;
*(U32 *) tableHeader->AslCompilerId = NAMESEG("INTL"); // ASCII ASL compiler vendor ID
tableHeader->AslCompilerRevision = 0x20061109; // ASL compiler version
}
//-----------------------------------------------------------------------------
void *buildTableHeader(void *current, U32 signature, U64 oemTableId)
{
ACPI_TABLE_HEADER *tableHeader = current;
current = tableHeader + 1;
setTableHeader(tableHeader, signature, oemTableId);
return (current);
}
//-----------------------------------------------------------------------------
void setByteConst(ACPI_BYTE_CONST * byteConst, U8 byteData)
{
byteConst->byteOpcode = AML_BYTE_OP;
byteConst->byteData = byteData;
}
//-----------------------------------------------------------------------------
void *buildByteConst(void *current, U8 byteData)
{
ACPI_BYTE_CONST *byteConst = current;
current = byteConst + 1;
setByteConst(byteConst, byteData);
return (current);
}
//-----------------------------------------------------------------------------
void setWordConst(ACPI_WORD_CONST * wordConst, U16 wordData)
{
wordConst->wordOpcode = AML_WORD_OP;
wordConst->wordData = wordData;
}
//-----------------------------------------------------------------------------
void *buildWordConst(void *current, U16 wordData)
{
ACPI_WORD_CONST *wordConst = current;
current = wordConst + 1;
setWordConst(wordConst, wordData);
return (current);
}
//-----------------------------------------------------------------------------
void setDwordConst(ACPI_DWORD_CONST * dwordConst, U32 dwordData)
{
dwordConst->dwordOpcode = AML_DWORD_OP;
dwordConst->dwordData = dwordData;
}
//-----------------------------------------------------------------------------
void *buildDwordConst(void *current, U32 dwordData)
{
ACPI_DWORD_CONST *dwordConst = current;
current = dwordConst + 1;
setDwordConst(dwordConst, dwordData);
return (current);
}
//-------------------------------------------------------------------------------
U32 ProcessFadt(ACPI_TABLE_FADT * FadtPointer, U32 pmbase)
{
{
// Update fields in FADT
// Update ACPI 1.0 fields first
FadtPointer->Pm1aEventBlock = pmbase;
FadtPointer->Pm1aControlBlock = pmbase + 4;
FadtPointer->Pm2ControlBlock = pmbase + 0x50;
FadtPointer->PmTimerBlock = pmbase + 8;
FadtPointer->Pm1EventLength = 4;
FadtPointer->Pm1ControlLength = 2;
FadtPointer->Pm2ControlLength = 1;
FadtPointer->PmTimerLength = 4;
// No legacy C2
FadtPointer->C2Latency = 101;
// No legacy C3
FadtPointer->C3Latency = 1001;
// C1 power state is supported on all processors
FadtPointer->BootFlags |= 1UL << 2;
// No legacy C2 on MP systems
FadtPointer->BootFlags &= ~(1UL << 3);
// Update ACPI 2.0+ fields if supported
if (FadtPointer->Header.Revision >= 3) {
// Address space where struct or register exists - System IO
FadtPointer->XPm1aEventBlock.SpaceId = 1;
// Size in bits of given register
FadtPointer->XPm1aEventBlock.BitWidth = 0x20;
// Bit offset within the register
FadtPointer->XPm1aEventBlock.BitOffset = 0;
// Minimum Access size (ACPI 3.0)
FadtPointer->XPm1aEventBlock.AccessWidth = 0;
// 64-bit address of struct or register
FadtPointer->XPm1aEventBlock.Address = pmbase;
// Address space where struct or register exists - System IO
FadtPointer->XPm1aControlBlock.SpaceId = 1;
// Size in bits of given register
FadtPointer->XPm1aControlBlock.BitWidth = 0x10;
// Bit offset within the register
FadtPointer->XPm1aControlBlock.BitOffset = 0;
// Minimum Access size (ACPI 3.0)
FadtPointer->XPm1aControlBlock.AccessWidth = 0;
// 64-bit address of struct or register
FadtPointer->XPm1aControlBlock.Address = pmbase + 4;
// Address space where struct or register exists - System IO
FadtPointer->XPm2ControlBlock.SpaceId = 1;
// Size in bits of given register
FadtPointer->XPm2ControlBlock.BitWidth = 0x08;
// Bit offset within the register
FadtPointer->XPm2ControlBlock.BitOffset = 0;
// Minimum Access size (ACPI 3.0)
FadtPointer->XPm2ControlBlock.AccessWidth = 0;
// 64-bit address of struct or register
FadtPointer->XPm2ControlBlock.Address = pmbase + 0x50;
// Address space where struct or register exists - System IO
FadtPointer->XPmTimerBlock.SpaceId = 1;
// Size in bits of given register
FadtPointer->XPmTimerBlock.BitWidth = 0x20;
// Bit offset within the register
FadtPointer->XPmTimerBlock.BitOffset = 0;
// Minimum Access size (ACPI 3.0)
FadtPointer->XPmTimerBlock.AccessWidth = 0;
// 64-bit address of struct or register
FadtPointer->XPmTimerBlock.Address = pmbase + 8;
}
}
// Update checksum in FADT
SetChecksum(&FadtPointer->Header);
return (1);
}
trunk/i386/modules/Sata/include/acpi_codec.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
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
3001
3002
3003
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
3054
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
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
/*
* Copyright 2008 mackerintel
*/
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 2011,2012 cparm <armelcadetpetit@gmail.com>. All rights reserved.
*
*/
#include "libsaio.h"
#include "bootstruct.h"
#include "acpi.h"
#include "acpidecode.h"
#include "acpicode.h"
#include "efi_tables.h"
#include "fake_efi.h"
#include "acpi_codec.h"
#include "platform.h"
#include "cpu.h"
#include "xml.h"
#include "sl.h"
#include "convert.h"
#include "modules.h"
#include "pci.h"
#include "pci_root.h"
U64 rsd_p;
ACPI_TABLES acpi_tables;
U32 uuid32;
U32 Model32;
bool checkOem = false;
extern EFI_STATUS addConfigurationTable();
extern EFI_GUID gEfiAcpiTableGuid;
extern EFI_GUID gEfiAcpi20TableGuid;
#ifndef DEBUG_ACPI
#define DEBUG_ACPI 0
#endif
#if DEBUG_ACPI==2
#define DBG(x...) {printf(x); sleep(1);}
#elif DEBUG_ACPI==1
#define DBG(x...) printf(x)
#else
#define DBG(x...)
#endif
#define OLD_SSDT 0
#define BETA 0
#define BUILD_ACPI_TSS 0
#define pstate_power_support 1
#if BETA
#ifdef pstate_power_support
#undef pstate_power_support
#endif
#define pstate_power_support 1
#endif
#if DEBUG_ACPI
static void print_nameseg(U32 i);
#endif
static ACPI_TABLE_HEADER * get_new_table_in_list(U32 *new_table_list, U32 Signature, U8 *retIndex );
static U8 get_number_of_tables_in_list(U32 *new_table_list, U32 Signature );
static U8 get_0ul_index_in_list(U32 *new_table_list, bool reserved );
static void sanitize_new_table_list(U32 *new_table_list );
static void move_table_list_to_kmem(U32 *new_table_list );
static ACPI_TABLE_RSDP * gen_alloc_rsdp_v2_from_v1(ACPI_TABLE_RSDP *rsdp );
static ACPI_TABLE_RSDT * gen_alloc_rsdt_from_xsdt(ACPI_TABLE_XSDT *xsdt);
static ACPI_TABLE_XSDT * gen_alloc_xsdt_from_rsdt(ACPI_TABLE_RSDT *rsdt);
#if 0
static void MakeAcpiSgn(void);
#endif
static void *loadACPITable(U32 *new_table_list, char *dirspec, const char *filename );
static int generate_cpu_map_from_acpi(ACPI_TABLE_DSDT * DsdtPointer);
static ACPI_GENERIC_ADDRESS FillGASStruct(U32 Address, U8 Length);
static U32 process_xsdt (ACPI_TABLE_RSDP *rsdp_mod , U32 *new_table_list);
static U32 process_rsdt(ACPI_TABLE_RSDP *rsdp_mod , bool gen_xsdt, U32 *new_table_list);
static ACPI_TABLE_FADT * patch_fadt(ACPI_TABLE_FADT *fadt, ACPI_TABLE_DSDT *new_dsdt, bool UpdateFADT);
#define IA32_MISC_ENABLES 0x01A0
#define MSR_TURBO_POWER_CURRENT_LIMIT 0x1AC
#define MSR_PKG_CST_CONFIG_CONTROL 0x00E2
#define MSR_RAPL_POWER_UNIT 0x606
#define MSR_PKG_RAPL_POWER_LIMIT 0x610
static U32 turbo_enabled = 0;
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);
static void collect_cpu_info(CPU_DETAILS * cpu);
#ifndef BETA
//static U32 BuildCoreIPstateInfo(CPU_DETAILS * cpu);
#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, 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);
static void * buildPSS(void * current, PKG_PSTATES * pkg_pstates);
static void * buildPSD(void * current, U32 domain, U32 cpusInDomain, U32 pstate_coordination);
static void * buildPPC(void * current);
static void * buildPCT(void * current);
static void * buildCstate(void * current, ACPI_GENERIC_ADDRESS * gas, CSTATE * cstate);
static void * buildReturnPackageCST(void * current, PKG_CSTATES * pkg_cstates);
static void * buildCST(void * current, PKG_CSTATES * mwait_pkg_cstates, PKG_CSTATES * io_pkg_cstates);
#if BUILD_ACPI_CSD
static void * buildCSD(void * current, U32 domain, U32 cpusInDomain, PKG_CSTATES * pkg_cstates);
#endif
#if BUILD_ACPI_TSS
static U32 BuildTstateInfo(CPU_DETAILS * cpu);
static void * buildTPC(void * current);
static void * buildPTC(void * current);
static void * buildTSS(void * current, PKG_TSTATES * pkg_tstates);
static void * buildTSD(void * current, U32 domain, U32 cpusInDomain);
#endif
#if pstate_power_support
static U64 mulU64byU64(U64 a, U64 b, U64 * high);
static U32 compute_pstate_power(CPU_DETAILS * cpu, U32 ratio, U32 TDP);
#endif
#if BUILD_ACPI_TSS || pstate_power_support
static U64 divU64byU64(U64 n, U64 d, U64 * rem);
static U32 compute_tdp(CPU_DETAILS * cpu);
#endif
static bool is_sandybridge(void);
static bool is_jaketown(void);
static U32 get_bclk(void);
static void GetMaxRatio(U32 * max_non_turbo_ratio);
//static U32 computePstateRatio(const U32 max, const U32 min, const U32 turboEnabled, const U32 numStates, const U32 pstate);
//static U32 computeNumPstates(const U32 max, const U32 min, const U32 turboEnabled, const U32 pssLimit);
#if UNUSED
static ACPI_TABLE_FACS* generate_facs(bool updatefacs );
#endif
#define MAX_NON_SSDT_TABLE 15
#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 & 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
#define RESERVED_AERA 3
#define ACPI_TABLE_LIST_FULL MAX_ACPI_TABLE + RESERVED_AERA + 1
#define ACPI_TABLE_LIST_FULL_NON_RESERVED MAX_ACPI_TABLE + 1
#ifndef ULONG_MAX_32
#define ULONG_MAX_32 4294967295UL
#endif
#define __RES(s, u)\
static inline unsigned u\
resolve_##s(unsigned u defaultentry, char *str, int base) \
{\
unsigned u entry = defaultentry;\
if (str && (strcmp(str,"Default") != 0)) {\
entry = strtoul((const char *)str, NULL,base);\
}\
return entry;\
}
__RES(pss, long)
__RES(cst, int)
static ACPI_TABLE_HEADER * get_new_table_in_list(U32 *new_table_list, U32 Signature, U8 *retIndex )
{
ACPI_TABLE_HEADER **table_array = (ACPI_TABLE_HEADER **) new_table_list;
U8 index ;
*retIndex = 0;
for (index = 0; index < (MAX_ACPI_TABLE + RESERVED_AERA); index++)
{
if (*(U32 *) (table_array[index]->Signature) == Signature)
{
*retIndex = index;
return table_array[index] ;
}
}
return (void*)0ul;
}
static U8 get_number_of_tables_in_list(U32 *new_table_list, U32 Signature )
{
ACPI_TABLE_HEADER **table_array = (ACPI_TABLE_HEADER **) new_table_list;
U8 index ;
U8 InstalledTables = 0;
for (index = 0; index < (MAX_ACPI_TABLE + RESERVED_AERA); index++)
{
if (*(U32 *) (table_array[index]->Signature) == Signature)
{
InstalledTables++ ;
}
}
return InstalledTables;
}
static U8 get_0ul_index_in_list(U32 *new_table_list, bool reserved )
{
U8 index ;
U8 maximum = (reserved == true) ? MAX_ACPI_TABLE + RESERVED_AERA : MAX_ACPI_TABLE;
for (index = 0; index < maximum; index++)
{
if (new_table_list[index] == 0ul)
{
return index ;
}
}
return (reserved == true)? ACPI_TABLE_LIST_FULL : ACPI_TABLE_LIST_FULL_NON_RESERVED;
}
/* cparm : This time we check it by the acpi signature */
static void sanitize_new_table_list(U32 *new_table_list )
{
ACPI_TABLE_HEADER **table_array = (ACPI_TABLE_HEADER **) new_table_list;
U8 index ;
for (index = 0; index < MAX_ACPI_TABLE; index++)
{
U32 current_sig = *(U32 *) (table_array[index]->Signature);
if ((current_sig == NAMESEG(ACPI_SIG_FACS) /* not supported */ )
|| (current_sig == NAMESEG(ACPI_SIG_XSDT))
|| (current_sig == NAMESEG(ACPI_SIG_RSDT)) || (*(volatile U64 *)table_array[index] == NAMESEG64(ACPI_SIG_RSDP)) )
{
void *buf = (void*)new_table_list[index];
free(buf);
new_table_list[index] = 0ul ;
}
}
}
/* cparm : move all tables to kernel memory */
static void move_table_list_to_kmem(U32 *new_table_list )
{
ACPI_TABLE_HEADER **table_array = (ACPI_TABLE_HEADER **) new_table_list;
U8 index ;
for (index = 0; index < MAX_ACPI_TABLE; index++)
{
if (new_table_list[index] != 0ul)
{
U32 current_sig = *(U32 *) (table_array[index]->Signature);
if ((current_sig != NAMESEG(ACPI_SIG_FACS) /* not supported */ )
&& (current_sig != NAMESEG(ACPI_SIG_XSDT))
&& (current_sig != NAMESEG(ACPI_SIG_RSDT)) && (*(volatile U64 *)table_array[index] != NAMESEG64(ACPI_SIG_RSDP))
&& (GetChecksum(table_array[index], table_array[index]->Length) == 0))
{
void *tableAddr=(void*)AllocateKernelMemory(table_array[index]->Length);
if (!tableAddr) {
printf("Unable to allocate kernel memory for aml file ");
void *buf = (void*)new_table_list[index];
free(buf);
new_table_list[index] = 0ul ;
continue;
}
bcopy(table_array[index], tableAddr, table_array[index]->Length);
new_table_list[index] = 0ul ;
new_table_list[index] = (U32)tableAddr ;
}
else
{
void *buf = (void*)new_table_list[index];
free(buf);
new_table_list[index] = 0ul ;
}
}
}
}
static ACPI_TABLE_RSDP * gen_alloc_rsdp_v2_from_v1(ACPI_TABLE_RSDP *rsdp )
{
ACPI_TABLE_RSDP * rsdp_conv = (ACPI_TABLE_RSDP *)AllocateKernelMemory(sizeof(ACPI_TABLE_RSDP));
if (rsdp_conv) {
bzero(rsdp_conv, sizeof(ACPI_TABLE_RSDP));
memcpy(rsdp_conv, rsdp, ACPI_RSDP_REV0_SIZE);
/* Add/change fields */
rsdp_conv->Revision = 2; /* ACPI version 3 */
rsdp_conv->Length = sizeof(ACPI_TABLE_RSDP);
/* Correct checksums */
setRsdpchecksum(rsdp_conv);
setRsdpXchecksum(rsdp_conv);
}
return (rsdp_conv) ? rsdp_conv : (void*)0ul ;
}
static ACPI_TABLE_RSDT * gen_alloc_rsdt_from_xsdt(ACPI_TABLE_XSDT *xsdt)
{
U32 index;
U32 num_tables;
DBG("Attempting to generate RSDT from XSDT \n");
num_tables= get_num_tables64(xsdt);
ACPI_TABLE_RSDT * rsdt_conv=(ACPI_TABLE_RSDT *)AllocateKernelMemory(sizeof(ACPI_TABLE_HEADER)+(num_tables * 4));
if (!rsdt_conv)
{
printf("Unable to allocate kernel memory for rsdt conv\n");
return (void*)0ul;
}
bzero(rsdt_conv, sizeof(ACPI_TABLE_HEADER)+(num_tables * 4));
memcpy(&rsdt_conv->Header, &xsdt->Header, sizeof(ACPI_TABLE_HEADER));
rsdt_conv->Header.Signature[0] = 'R';
rsdt_conv->Header.Signature[1] = 'S';
rsdt_conv->Header.Signature[2] = 'D';
rsdt_conv->Header.Signature[3] = 'T';
rsdt_conv->Header.Length = sizeof(ACPI_TABLE_HEADER)+(num_tables * 4);
for (index=0;index<num_tables;index++)
{
U64 ptr = xsdt->TableOffsetEntry[index];
{
if (ptr > ULONG_MAX)
{
#if DEBUG_ACPI
printf("Warning xsdt->TableOffsetEntry[%d]: Beyond addressable memory in this CPU mode, ignored !!!\n",index);
#endif
continue;
}
#if DEBUG_ACPI
printf("* Processing : ");
print_nameseg(*(U32 *) ((ACPI_TABLE_HEADER *) (unsigned long)ptr)->Signature);
printf("\n");
#endif
int method = 0;
getIntForKey(kAcpiMethod, &method, &bootInfo->chameleonConfig);
if (method != 0x2)
{
if (GetChecksum(((ACPI_TABLE_HEADER *) (unsigned long)ptr),
((ACPI_TABLE_HEADER *) (unsigned long)ptr)->Length) != 0)
{
#if DEBUG_ACPI
printf("Warning : Invalide checksum, ignored !!!\n",index);
#endif
continue;
}
}
}
{
if (*(U32 *) ((ACPI_TABLE_HEADER *) (unsigned long)ptr)->Signature == NAMESEG(ACPI_SIG_FADT))
{
ACPI_TABLE_FADT *fadt=(ACPI_TABLE_FADT *)((U32)ptr);
ACPI_TABLE_FADT *fadt_conv = (void*)0ul;
if (fadt->Header.Revision > 1)
{
U8 buffer[0x74];
DBG("Downgrading ACPI V%d FADT to ACPI V1 FADT \n", fadt->Header.Revision);
fadt_conv=(ACPI_TABLE_FADT *)buffer;
memcpy(fadt_conv, fadt, 0x74);
fadt_conv->Header.Length = 0x74;
fadt_conv->Header.Revision = 0x01;
SetChecksum(&fadt_conv->Header);
}
else
{
fadt_conv = fadt;
}
ACPI_TABLE_FADT *fadt_mod = patch_fadt(fadt_conv, ((ACPI_TABLE_DSDT*)((U32)fadt->XDsdt)), false);
if (fadt_mod == (void*)0ul)
{
printf("Error: Failed to patch FADT Table, trying wiht the original fadt pointer\n");
fadt_mod = fadt;
}
rsdt_conv->TableOffsetEntry[index] = ((U32)fadt_mod);
#if DEBUG_ACPI
print_nameseg(*(U32 *) ((ACPI_TABLE_HEADER *) (unsigned long)ptr)->Signature);
printf(" table converted and added succesfully\n");
#endif
continue;
}
}
{
rsdt_conv->TableOffsetEntry[index] = (U32)ptr;
#if DEBUG_ACPI
print_nameseg(*(U32 *) ((ACPI_TABLE_HEADER *) (unsigned long)ptr)->Signature);
printf(" table converted and added succesfully\n");
#endif
}
}
DBG("RSDT_CONV : Original checksum %d\n", rsdt_conv->Header.Checksum);
SetChecksum(&rsdt_conv->Header);
DBG("New checksum %d\n", rsdt_conv->Header.Checksum);
return rsdt_conv;
}
static ACPI_TABLE_XSDT * gen_alloc_xsdt_from_rsdt(ACPI_TABLE_RSDT *rsdt)
{
U32 index;
U32 num_tables;
DBG("Attempting to generate XSDT from RSDT \n");
num_tables= get_num_tables(rsdt);
ACPI_TABLE_XSDT * xsdt_conv=(ACPI_TABLE_XSDT *)AllocateKernelMemory(sizeof(ACPI_TABLE_HEADER)+(num_tables * 8));
if (!xsdt_conv) {
printf("Unable to allocate kernel memory for xsdt conv\n");
return (void*)0ul;
}
bzero(xsdt_conv, sizeof(ACPI_TABLE_HEADER)+(num_tables * 8));
memcpy(&xsdt_conv->Header, &rsdt->Header, sizeof(ACPI_TABLE_HEADER));
xsdt_conv->Header.Signature[0] = 'X';
xsdt_conv->Header.Signature[1] = 'S';
xsdt_conv->Header.Signature[2] = 'D';
xsdt_conv->Header.Signature[3] = 'T';
xsdt_conv->Header.Length = sizeof(ACPI_TABLE_HEADER)+(num_tables * 8);
ACPI_TABLE_HEADER **table_array = (ACPI_TABLE_HEADER **) rsdt->TableOffsetEntry;
for (index=0;index<num_tables;index++)
{
{
#if DEBUG_ACPI
printf("* Processing : ");
print_nameseg(*(U32*) (table_array[index]->Signature));
printf("\n");
#endif
int method = 0;
getIntForKey(kAcpiMethod, &method, &bootInfo->chameleonConfig);
if (method != 0x2)
{
if (GetChecksum(table_array[index], table_array[index]->Length) != 0)
{
#if DEBUG_ACPI
printf("Warning : Invalide checksum, ignored !!!\n",index);
#endif
continue;
}
}
}
{
if (*(U32 *) (table_array[index]->Signature) == NAMESEG(ACPI_SIG_FADT))
{
ACPI_TABLE_FADT *FacpPointer = ((ACPI_TABLE_FADT*)table_array[index]);
ACPI_TABLE_FADT *fadt_mod = (ACPI_TABLE_FADT *)patch_fadt(FacpPointer,((ACPI_TABLE_DSDT*)FacpPointer->Dsdt),true);
if (fadt_mod == (void*)0ul)
{
printf("Error: Failed to patch (& update) FADT Table, fallback to original fadt pointer\n");
fadt_mod = FacpPointer;
}
xsdt_conv->TableOffsetEntry[index] = ((U64)((U32)fadt_mod));
continue;
}
}
xsdt_conv->TableOffsetEntry[index] = ((U64)((U32)table_array[index]));
}
DBG("XSDT_CONV : Original checksum %d\n", xsdt_conv->Header.Checksum);
SetChecksum(&xsdt_conv->Header);
DBG("New checksum %d\n", xsdt_conv->Header.Checksum);
return xsdt_conv;
}
#if ACPISGN
static void MakeAcpiSgn(void)
{
char * DefaultplatformName = NULL;
Model32 = 0;
if ((DefaultplatformName = readDefaultPlatformName()))
{
Model32 = OSSwapHostToBigInt32(adler32( (unsigned char *) DefaultplatformName, strlen(DefaultplatformName)));
}
uuid32 = 0;
const char *uuidStr = getStringFromUUID((int8_t*)(uint32_t)get_env(envSysId));
if (strlen(uuidStr))
{
uuid32 = OSSwapHostToBigInt32(adler32( (unsigned char *) uuidStr, UUID_STR_LEN ));
}
}
#endif
static void *loadACPITable(U32 *new_table_list, char *dirspec, const char *filename )
{
int fd = -1;
char acpi_file[512];
DBG("Searching for %s file ...\n", filename);
// Check booting partition
sprintf(acpi_file, "%s%s",dirspec, filename);
fd=open(acpi_file,0);
if (fd<0)
{
DBG("Couldn't open ACPI Table: %s\n", acpi_file);
return (void *)0ul ;
}
void *tableAddr=(void*)malloc(file_size (fd));
if (tableAddr)
{
if (read (fd, tableAddr, file_size (fd))!=file_size (fd))
{
printf("Couldn't read table %s\n",acpi_file);
free (tableAddr);
close (fd);
return (void *)0ul ;
}
close (fd);
ACPI_TABLE_HEADER * header = (ACPI_TABLE_HEADER *)tableAddr;
if (*(U32*)(header->Signature) != NAMESEG("SSDT"))
{
U8 dummy = 0;
if (get_new_table_in_list(new_table_list, *(U32*)(header->Signature), &dummy))
{
#if DEBUG_ACPI
printf("Warning: A ");
print_nameseg(*(U32*) (header->Signature));
printf(" Aml file is already loaded and registred, file skipped !!\n");
#endif
free(tableAddr);
return (void*)0ul;
}
}
else
{
if (get_number_of_tables_in_list(new_table_list, NAMESEG("SSDT")) >= MAX_SSDT_TABLE)
{
DBG("Warning: Max number of SSDT aml files reached, file skipped !!\n");
free(tableAddr);
return (void*)0ul;
}
}
if (checkOem == true)
{
if (header->OemRevision == Model32)
{
goto continue_loading;
}
if (header->OemRevision == uuid32)
{
goto continue_loading;
}
DBG("Bad signature aka Oem Revision (0x%08lx) for Aml file (%s), file skipped !!\n", header->OemRevision, acpi_file);
DBG("uuid32 (0x%08lx) , model32 (0x%08lx)\n", uuid32, Model32);
free(tableAddr);
return (void*)0ul;
}
continue_loading:
if (GetChecksum(header, header->Length) == 0)
{
DBG("Found valid AML file : %s ", filename);
verbose("[ %s ] read and stored at: %x", acpi_file, tableAddr);
printf("\n");
return tableAddr;
}
else
{
printf("Warning : Incorrect cheksum for the file : %s,", acpi_file);
printf(" this file will be dropped.\n");
free(tableAddr);
return (void*)0ul;
}
}
else
{
printf("Couldn't allocate memory for table %s\n", acpi_file);
close (fd);
}
return (void *)0ul ;
}
static U32 pmbase;
static short cpuNamespace;
PROCESSOR_NUMBER_TO_NAMESEG cpu_map[CPU_MAP_LIMIT];
unsigned int cpu_map_count;
int cpu_map_error;
#if DEBUG_ACPI
static void print_nameseg(U32 i)
{
printf("%c%c%c%c",
(int)(i & 0x000000ff),
(int)((i & 0x0000ff00) >> 8),
(int)((i & 0x00ff0000) >> 16),
(int)(i >> 24));
}
#endif
static int generate_cpu_map_from_acpi(ACPI_TABLE_DSDT * DsdtPointer)
{
PROCESSOR_NUMBER_TO_NAMESEG *map = cpu_map;
U32 processor_namespace = 0;
U32 cpu;
U8 *current, *end;
ACPI_TABLE_HEADER *header;
struct acpi_namespace ns;
if ((cpu_map_error == 1) || (DsdtPointer == (void*)0ul))
return 1;
else if (cpu_map_count > 0)
return 0;
DBG("Attempting to autodetect CPU map from ACPI DSDT; wish me luck\n");
current = (U8 *) DsdtPointer;
current = decodeTableHeader(current, &header);
end = current - sizeof(*header) + header->Length;
ns.depth = 0;
acpi_processor_count = 0;
//DBG("* DSDT debug start\n");
parse_acpi_termlist(&ns, current, end);
//DBG("* DSDT debug end\n");
if (acpi_processor_count > CPU_MAP_LIMIT)
{
verbose("Too many processors: found %u processors\n", acpi_processor_count);
return (cpu_map_error = 1);
}
if (acpi_processor_count == 0)
{
verbose( "Found no processors in ACPI\n");
return (cpu_map_error = 1);
}
for (cpu = 0; cpu < acpi_processor_count; cpu++)
{
U32 nameseg;
if (acpi_processors[cpu].pmbase)
{
U32 cpu_pmbase = acpi_processors[cpu].pmbase - 0x10;
if (pmbase && cpu_pmbase != pmbase)
{
verbose("Found inconsistent pmbase addresses in ACPI: 0x%x and 0x%x\n", pmbase, cpu_pmbase);
return (cpu_map_error = 1);