Chameleon

Chameleon Commit Details

Date:2010-02-04 02:24:46 (9 years 5 months ago)
Author:Rekursor
Commit:62
Parents: 61
Message:Started to apply Andy patch with few differences: added my r60 api search_and_get_acpi_fd() that is reuse in other parts of the code, added an algo. that matches the path of DSDT override and deduct the path of other acpi files...
Changes:
M/branches/rekursor/i386/libsaio/dsdt_patcher.c
M/branches/rekursor/i386/boot2/boot.c
M/branches/rekursor/i386/libsaio/usb.c
M/branches/rekursor/i386/boot2/boot.h
M/branches/rekursor/i386/libsaio/pci.c
M/branches/rekursor/i386/libsaio/pci_setup.c
M/branches/rekursor/i386/boot2/options.c
M/branches/rekursor/i386/libsaio/pci_root.c
M/branches/rekursor/i386/libsaio/acpi.h

File differences

branches/rekursor/i386/libsaio/pci_root.c
77
88
99
10
10
1111
1212
1313
#include "bootstruct.h"
#ifndef DEBUG_PCIROOT
#define DEBUG_PCIROOT 1
#define DEBUG_PCIROOT 0
#endif
#if DEBUG_PCIROOT
branches/rekursor/i386/libsaio/usb.c
146146
147147
148148
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
149239
150240
151241
return 1;
}
int legacy_off (pci_dt_t *pci_dev)
{
// Set usb legacy off modification by Signal64
uint32_tcapaddr, opaddr;
uint8_teecp;
uint32_tusbcmd, usbsts, usbintr;
uint32_tusblegsup, usblegctlsts;
int isOSowned;
int isBIOSowned;
verbose("Setting Legacy USB Off on controller [%04x:%04x] at %02x:%2x.%x\n",
pci_dev->vendor_id, pci_dev->device_id,
pci_dev->dev.bits.bus, pci_dev->dev.bits.dev, pci_dev->dev.bits.func);
// capaddr = Capability Registers = dev.addr + offset stored in dev.addr + 0x10 (USBBASE)
capaddr = pci_config_read32(pci_dev->dev.addr, 0x10);
// opaddr = Operational Registers = capaddr + offset (8bit CAPLENGTH in Capability Registers + offset 0)
opaddr = capaddr + *((unsigned char*)(capaddr));
// eecp = EHCI Extended Capabilities offset = capaddr HCCPARAMS bits 15:8
eecp=*((unsigned char*)(capaddr + 9));
DBG("capaddr=%x opaddr=%x eecp=%x\n", capaddr, opaddr, eecp);
usbcmd = *((unsigned int*)(opaddr));// Command Register
usbsts = *((unsigned int*)(opaddr + 4));// Status Register
usbintr = *((unsigned int*)(opaddr + 8));// Interrupt Enable Register
DBG("usbcmd=%08x usbsts=%08x usbintr=%08x\n", usbcmd, usbsts, usbintr);
// read PCI Config 32bit USBLEGSUP (eecp+0)
usblegsup = pci_config_read32(pci_dev->dev.addr, eecp);
// informational only
isBIOSowned = !!((usblegsup) & (1 << (16)));
isOSowned = !!((usblegsup) & (1 << (24)));
// read PCI Config 32bit USBLEGCTLSTS (eecp+4)
usblegctlsts = pci_config_read32(pci_dev->dev.addr, eecp + 4);
DBG("usblegsup=%08x isOSowned=%d isBIOSowned=%d usblegctlsts=%08x\n", usblegsup, isOSowned, isBIOSowned, usblegctlsts);
// Reset registers to Legacy OFF
DBG("Clearing USBLEGCTLSTS\n");
pci_config_write32(pci_dev->dev.addr, eecp + 4, 0);//usblegctlsts
// if delay value is in milliseconds it doesn't appear to work.
// setting value to anything up to 65535 does not add the expected delay here.
delay(100);
usbcmd = *((unsigned int*)(opaddr));
usbsts = *((unsigned int*)(opaddr + 4));
usbintr = *((unsigned int*)(opaddr + 8));
DBG("usbcmd=%08x usbsts=%08x usbintr=%08x\n", usbcmd, usbsts, usbintr);
DBG("Clearing Registers\n");
// clear registers to default
usbcmd = (usbcmd & 0xffffff00);
*((unsigned int*)(opaddr)) = usbcmd;
*((unsigned int*)(opaddr + 8)) = 0;//usbintr - clear interrupt registers
*((unsigned int*)(opaddr + 4)) = 0x1000;//usbsts - clear status registers
pci_config_write32(pci_dev->dev.addr, eecp, 1);//usblegsup
// get the results
usbcmd = *((unsigned int*)(opaddr));
usbsts = *((unsigned int*)(opaddr + 4));
usbintr = *((unsigned int*)(opaddr + 8));
DBG("usbcmd=%08x usbsts=%08x usbintr=%08x\n", usbcmd, usbsts, usbintr);
// read 32bit USBLEGSUP (eecp+0)
usblegsup = pci_config_read32(pci_dev->dev.addr, eecp);
// informational only
isBIOSowned = !!((usblegsup) & (1 << (16)));
isOSowned = !!((usblegsup) & (1 << (24)));
// read 32bit USBLEGCTLSTS (eecp+4)
usblegctlsts = pci_config_read32(pci_dev->dev.addr, eecp + 4);
DBG("usblegsup=%08x isOSowned=%d isBIOSowned=%d usblegctlsts=%08x\n", usblegsup, isOSowned, isBIOSowned, usblegctlsts);
verbose("Legacy USB Off Done\n");
return 1;
}
int uhci_reset (pci_dt_t *pci_dev)
{
uint32_t base, port_base;
branches/rekursor/i386/libsaio/dsdt_patcher.c
7272
7373
7474
75
7576
76
77
7778
7879
7980
81
8082
81
83
84
85
8286
83
84
85
86
87
88
89
90
8791
88
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
89107
90108
91109
......
117135
118136
119137
120
138
121139
122140
123141
124142
125
143
126144
127145
128146
......
147165
148166
149167
168
169
170
171
172
173
174
175
150176
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
151253
152
254
153255
154
155
256
156257
157258
259
158260
159261
160262
161
263
162264
163265
164266
......
168270
169271
170272
171
273
274
172275
173276
174
277
278
175279
176
177
178
179
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
180328
181
182
183
184
185
186329
187330
188331
189332
190333
191
192
334
335
193336
194337
195338
......
197340
198341
199342
200
201
343
344
202345
203346
204347
205
206
348
349
207350
208351
209
210
352
353
211354
212355
213356
......
218361
219362
220363
221
222
223
224
225
226
364
365
227366
228367
229368
369
370
371
372
373
230374
231375
232376
......
260404
261405
262406
263
407
264408
265
266
267
268
269
409
410
411
412
413
414
415
416
270417
271
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
272439
273440
274
275
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
276467
277
278
468
469
470
471
472
473
474
279475
280476
477
478
479
480
481
281482
282483
283
484
284485
486
285487
286
488
287489
288490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
289515
290516
291517
......
304530
305531
306532
307
308
533
534
535
536
537
538
539
540
309541
310542
311543
......
321553
322554
323555
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
324588
325589
326590
......
335599
336600
337601
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
338715
339716
340717
......
354731
355732
356733
357
734
358735
359736
360737
361738
362739
363740
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
364827
365828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
366844
367845
368846
......
383861
384862
385863
386
864
865
866
867
868
387869
388870
389871
......
391873
392874
393875
394
395
396
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
397893
398894
399895
......
407903
408904
409905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
410926
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
4111020
4121021
4131022
......
4321041
4331042
4341043
435
1044
4361045
4371046
4381047
......
4441053
4451054
4461055
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
4471142
4481143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
4491160
4501161
4511162
}
return NULL;
}
/** The folowing ACPI Table search algo. should be reused anywhere needed:*/
int search_and_get_acpi_fd(const char * filename, const char ** outDirspec)
int search_and_get_acpi_fd(const char * key, const char ** outDirspec)
{
int fd=0;
const char * overriden_pathname=NULL;
char filename[64];
static char dirspec[512]="";
int len=0;
int len=0,i=0;
sprintf(filename, "%s.aml", key);
/// Take in accound user overriding if it's DSDT only
if (strstr(filename, "DSDT") &&
getValueForKey(kDSDT, &overriden_pathname, &len,
&bootInfo->bootConfig))
/// Take in account user overriding for 'DSDT'.aml table
// and try to find <key>.aml at the same place
if (getValueForKey("DSDT", &overriden_pathname, &len,
&bootInfo->bootConfig) && len>0)
{
sprintf(dirspec, "%s", overriden_pathname); // start searching root
strcpy(dirspec, overriden_pathname);
for (i=len-1; i>=0; i--)
{
if (dirspec[i]=='/')
{
dirspec[i+1]='\0';
strcat(dirspec, filename);
break;
}
else if (i==0) // no '/' found copy filename and seek in current directory
{
strcpy(dirspec, filename);
break;
}
}
fd=open (dirspec,0);
if (fd>=0) goto success_fd;
}
return fd;
}
void *loadACPITable (const char * filename)
void *loadACPITable (const char * key)
{
void *tableAddr;
const char * dirspec=NULL;
int fd = search_and_get_acpi_fd(filename, &dirspec);
int fd = search_and_get_acpi_fd(key, &dirspec);
if (fd>=0)
{
return NULL;
}
void *loadSSDTTable(int ssdt_number)
{
void *tableAddr;
int fd = -1;
char dirspec[512];
char filename[512];
const char * overriden_pathname=NULL;
int len=0;
sprintf(filename, "SSDT-%d.aml", ssdt_number);
// Check booting partition
// Rek: if user specified a full path name then take it in consideration
if (getValueForKey(kSSDT, &overriden_pathname, &len,
&bootInfo->bootConfig))
{
sprintf(dirspec, "%s-%d.aml", overriden_pathname, ssdt_number); // start searching root
//printf("Using custom %s path %s\n", key, dirspec);
//getc();
}
else
sprintf(dirspec, "/%s", filename); // start searching root
fd=open (dirspec,0);
if (fd<0)
{// Check Extra on booting partition
//verbose("Searching for %s.aml file ...\n", key);
sprintf(dirspec,"/Extra/%s",filename);
fd=open (dirspec,0);
if (fd<0)
{// Fall back to booter partition
sprintf(dirspec,"bt(0,0)/Extra/%s",filename);
fd=open (dirspec,0);
if (fd<0)
{
verbose("SSDT Table not found: %s\n", filename);
return NULL;
}
}
}
tableAddr=(void*)AllocateKernelMemory(file_size (fd));
if (tableAddr)
{
if (read (fd, tableAddr, file_size (fd))!=file_size (fd))
{
printf("Couldn't read table %s\n",dirspec);
free (tableAddr);
close (fd);
return NULL;
}
DBG("Table %s read and stored at: %x\n", dirspec, tableAddr);
close (fd);
return tableAddr;
}
printf("Couldn't allocate memory for table %s\n", dirspec);
close (fd);
return NULL;
}
struct acpi_2_gas FillGASStruct(uint32_t Address, uint8_t Length)
{
struct acpi_2_gas TmpGAS;
TmpGAS.Address_Space_ID = 1; /* I/O Address */
if (Address == 0)
{
TmpGAS.Register_Bit_Width = 0;
} else {
TmpGAS.Register_Bit_Width = Length * 8;
}
TmpGAS.Register_Bit_Offset = 0;
TmpGAS.Access_Size = 0; /* Not set for Legacy reasons... */
TmpGAS.Address = (uint64_t)Address;
return(TmpGAS);
}
struct acpi_2_fadt *
patch_fadt(struct acpi_2_fadt *fadt, void *new_dsdt)
patch_fadt(struct acpi_2_fadt *fadt, void *new_dsdt, bool UpdateFADT)
{
extern void setupSystemType();
extern void setupSystemType();
struct acpi_2_fadt *fadt_mod;
struct acpi_2_fadt *fadt_file = (struct acpi_2_fadt *)loadACPITable(kFADT);
bool fadt_rev2_needed = false;
bool fix_restart;
const char * value;
// Restart Fix
if (Platform.CPU.Vendor == 0x756E6547) {/* Intel */
fix_restart = true;
fix_restart = false;
}
if (fix_restart) fadt_rev2_needed = true;
if (fix_restart)
fadt_rev2_needed = true;
// Allocate new fadt table
if (fadt->Length < 0x84 && fadt_rev2_needed)
if ((UpdateFADT) && (((fadt_file) && (fadt_file->Length < sizeof(struct acpi_2_fadt))) ||
((!fadt_file) && (fadt->Length < sizeof(struct acpi_2_fadt)))))
{
fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(0x84);
memcpy(fadt_mod, fadt, fadt->Length);
fadt_mod->Length = 0x84;
fadt_mod->Revision = 0x02; // FADT rev 2 (ACPI 1.0B MS extensions)
fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(sizeof(struct acpi_2_fadt));
if (fadt_file)
memcpy(fadt_mod, fadt_file, fadt_file->Length);
else
memcpy(fadt_mod, fadt, fadt->Length);
fadt_mod->Length = sizeof(struct acpi_2_fadt);
fadt_mod->Revision = 0x04; // FADT rev 4
fadt_mod->RESET_REG = FillGASStruct(0, 0);
fadt_mod->RESET_VALUE = 0;
fadt_mod->Reserved2[0] = 0;
fadt_mod->Reserved2[1] = 0;
fadt_mod->Reserved2[2] = 0;
fadt_mod->X_PM1a_EVT_BLK = FillGASStruct(fadt_mod->PM1a_EVT_BLK, fadt_mod->PM1_EVT_LEN);
fadt_mod->X_PM1b_EVT_BLK = FillGASStruct(fadt_mod->PM1b_EVT_BLK, fadt_mod->PM1_EVT_LEN);
fadt_mod->X_PM1a_CNT_BLK = FillGASStruct(fadt_mod->PM1a_CNT_BLK, fadt_mod->PM1_CNT_LEN);
fadt_mod->X_PM1b_CNT_BLK = FillGASStruct(fadt_mod->PM1b_CNT_BLK, fadt_mod->PM1_CNT_LEN);
fadt_mod->X_PM2_CNT_BLK = FillGASStruct(fadt_mod->PM2_CNT_BLK, fadt_mod->PM2_CNT_LEN);
fadt_mod->X_PM_TMR_BLK = FillGASStruct(fadt_mod->PM_TMR_BLK, fadt_mod->PM_TMR_LEN);
fadt_mod->X_GPE0_BLK = FillGASStruct(fadt_mod->GPE0_BLK, fadt_mod->GPE0_BLK_LEN);
fadt_mod->X_GPE1_BLK = FillGASStruct(fadt_mod->GPE1_BLK, fadt_mod->GPE1_BLK_LEN);
verbose("Converted ACPI V%d FADT to ACPI V4 FADT\n", (fadt_file) ? fadt_file->Revision : fadt->Revision);
} else {
if (((!fadt_file) && ((fadt->Length < 0x84) && (fadt_rev2_needed))) ||
((fadt_file) && ((fadt_file->Length < 0x84) && (fadt_rev2_needed))))
{
fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(0x84);
if (fadt_file)
memcpy(fadt_mod, fadt_file, fadt_file->Length);
else
memcpy(fadt_mod, fadt, fadt->Length);
fadt_mod->Length = 0x84;
fadt_mod->Revision = 0x02; // FADT rev 2 (ACPI 1.0B MS extensions)
}
else
{
if (fadt_file)
{
fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt_file->Length);
memcpy(fadt_mod, fadt_file, fadt_file->Length);
} else {
fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length);
memcpy(fadt_mod, fadt, fadt->Length);
}
}
}
else
{
fadt_mod=(struct acpi_2_fadt *)AllocateKernelMemory(fadt->Length);
memcpy(fadt_mod, fadt, fadt->Length);
}
// Determine system type / PM_Model
if ( (value=getStringForKey(kSystemType, &bootInfo->bootConfig))!=NULL)
{
if (Platform.Type > 6)
{
if(fadt_mod->PM_Profile<=6)
Platform.Type = fadt_mod->PM_Profile; // get the fadt if correct
if(fadt_mod->Preferred_PM_Profile<=6)
Platform.Type = fadt_mod->Preferred_PM_Profile; // get the fadt if correct
else
Platform.Type = 1;/* Set a fixed value (Desktop) */
verbose("Error: system-type must be 0..6. Defaulting to %d !\n", Platform.Type);
else
Platform.Type = (unsigned char) strtoul(value, NULL, 10);
}
// Set PM_Profile from System-type if only if user wanted this value to be forced
if (fadt_mod->PM_Profile != Platform.Type)
// Set Preferred_PM_Profile from System-type if only if user wanted this value to be forced
if (fadt_mod->Preferred_PM_Profile != Platform.Type)
{
if (value)
{ // user has overriden the SystemType so take care of it in FACP
verbose("FADT: changing PM_Profile from 0x%02x to 0x%02x\n", fadt_mod->PM_Profile, Platform.Type);
fadt_mod->PM_Profile = Platform.Type;
verbose("FADT: changing Preferred_PM_Profile from 0x%02x to 0x%02x\n", fadt_mod->Preferred_PM_Profile, Platform.Type);
fadt_mod->Preferred_PM_Profile = Platform.Type;
}
else
{ // PM_Profile has a different value and no override has been set, so reflect the user value to ioregs
Platform.Type = fadt_mod->PM_Profile <= 6 ? fadt_mod->PM_Profile : 1;
{ // Preferred_PM_Profile has a different value and no override has been set, so reflect the user value to ioregs
Platform.Type = fadt_mod->Preferred_PM_Profile <= 6 ? fadt_mod->Preferred_PM_Profile : 1;
}
}
// We now have to write the systemm-type in ioregs: we cannot do it before in setupDeviceTree()
if (fix_restart)
{
fadt_mod->Flags|= 0x400;
fadt_mod->Reset_SpaceID= 0x01; // System I/O
fadt_mod->Reset_BitWidth= 0x08; // 1 byte
fadt_mod->Reset_BitOffset= 0x00; // Offset 0
fadt_mod->Reset_AccessWidth= 0x01; // Byte access
fadt_mod->Reset_Address= 0x0cf9; // Address of the register
fadt_mod->Reset_Value= 0x06; // Value to write to reset the system
fadt_mod->RESET_REG = FillGASStruct(0x0cf9, 1);
fadt_mod->RESET_VALUE = 0x06;
verbose("FADT: Restart Fix applied !\n");
}
// Patch FACS Address
fadt_mod->FIRMWARE_CTRL=(uint32_t)fadt->FIRMWARE_CTRL;
if ((uint32_t)(&(fadt_mod->X_FIRMWARE_CTRL))-(uint32_t)fadt_mod+8<=fadt_mod->Length)
fadt_mod->X_FIRMWARE_CTRL=(uint32_t)fadt->FIRMWARE_CTRL
// Patch DSDT Address
DBG("DSDT: Old @%x,%x, ",fadt_mod->DSDT,fadt_mod->X_DSDT);
int setupAcpi(void)
{
int version;
void *new_dsdt;
void *new_dsdt=NULL, *new_hpet=NULL, *new_sbst=NULL, *new_ecdt=NULL, *new_asft=NULL, *new_dmar=NULL, *new_apic=NULL, *new_mcfg=NULL, *new_ssdts[30];
bool drop_ssdt;
// Load replacement DSDT
new_dsdt=loadACPITable("DSDT.aml");
if (!new_dsdt)
bool oem_dsdt=false, oem_ssdt=false, oem_hpet=false, oem_sbst=false, oem_ecdt=false, oem_asft=false, oem_dmar=false, oem_apic=false, oem_mcfg=false;
bool drop_ssdt=false, drop_hpet=false, drop_slic=false, drop_sbst=false, drop_ecdt=false, drop_asft=false, drop_dmar=false;
bool update_acpi=false, gen_xsdt=false;
bool hpet_replaced=false, sbst_replaced=false, ecdt_replaced=false, asft_replaced=false, dmar_replaced=false, apic_replaced=false, mcfg_replaced=false;
bool hpet_added=false, sbst_added=false, ecdt_added=false, asft_added=false, dmar_added=false, apic_added=false, mcfg_added=false;
int curssdt=0, loadtotssdt=0, totssdt=0, newtotssdt=0;
{
return setupAcpiNoMod();
bool tmpval;
drop_ssdt=getBoolForKey(kDropSSDT, &tmpval, &bootInfo->bootConfig)&&tmpval;
drop_hpet=getBoolForKey(kDropHPET, &tmpval, &bootInfo->bootConfig)&&tmpval;
drop_slic=getBoolForKey(kDropSLIC, &tmpval, &bootInfo->bootConfig)&&tmpval;
drop_sbst=getBoolForKey(kDropSBST, &tmpval, &bootInfo->bootConfig)&&tmpval;
drop_ecdt=getBoolForKey(kDropECDT, &tmpval, &bootInfo->bootConfig)&&tmpval;
drop_asft=getBoolForKey(kDropASFT, &tmpval, &bootInfo->bootConfig)&&tmpval;
drop_dmar=getBoolForKey(kDropDMAR, &tmpval, &bootInfo->bootConfig)&&tmpval;
oem_dsdt=getBoolForKey(kOEMDSDT, &tmpval, &bootInfo->bootConfig)&&tmpval;
oem_ssdt=getBoolForKey(kOEMSSDT, &tmpval, &bootInfo->bootConfig)&&tmpval;
oem_hpet=getBoolForKey(kOEMHPET, &tmpval, &bootInfo->bootConfig)&&tmpval;
oem_sbst=getBoolForKey(kOEMSBST, &tmpval, &bootInfo->bootConfig)&&tmpval;
oem_ecdt=getBoolForKey(kOEMECDT, &tmpval, &bootInfo->bootConfig)&&tmpval;
oem_asft=getBoolForKey(kOEMASFT, &tmpval, &bootInfo->bootConfig)&&tmpval;
oem_dmar=getBoolForKey(kOEMDMAR, &tmpval, &bootInfo->bootConfig)&&tmpval;
oem_apic=getBoolForKey(kOEMAPIC, &tmpval, &bootInfo->bootConfig)&&tmpval;
oem_mcfg=getBoolForKey(kOEMMCFG, &tmpval, &bootInfo->bootConfig)&&tmpval;
update_acpi=getBoolForKey(kUpdateACPI, &tmpval, &bootInfo->bootConfig)&&tmpval;
}
DBG("New DSDT Loaded in memory\n");
// Load replacement ACPI tables
if (!oem_dsdt)
new_dsdt=loadACPITable(kDSDT);
if (!oem_hpet)
new_hpet=loadACPITable(kHPET);
if (!oem_sbst)
new_sbst=loadACPITable(kSBST);
if (!oem_ecdt)
new_ecdt=loadACPITable(kECDT);
if (!oem_asft)
new_asft=loadACPITable(kASFT);
if (!oem_dmar)
new_dmar=loadACPITable(kDMAR);
if (!oem_apic)
new_apic=loadACPITable(kAPIC);
if (!oem_mcfg)
new_mcfg=loadACPITable(kMCFG);
if (!oem_ssdt)
{
bool tmp;
drop_ssdt=getBoolForKey(kDropSSDT, &tmp, &bootInfo->bootConfig)&&tmp;
for (curssdt=0;curssdt<30;curssdt++)
{
new_ssdts[curssdt]=loadSSDTTable(curssdt);
if (new_ssdts[curssdt])
loadtotssdt++;
}
curssdt=0;
}
if (!new_dsdt)
return setupAcpiNoMod();
DBG("New ACPI tables Loaded in memory\n");
// Do the same procedure for both versions of ACPI
for (version=0; version<2; version++) {
struct acpi_2_rsdp *rsdp, *rsdp_mod;
struct acpi_2_rsdp *rsdp, *rsdp_mod, *rsdp_conv=(struct acpi_2_rsdp *)0;
struct acpi_2_rsdt *rsdt, *rsdt_mod;
struct acpi_2_xsdt *xsdt_conv = (struct acpi_2_xsdt *)0;
int rsdplength;
// Find original rsdp
rsdp=(struct acpi_2_rsdp *)(version?getAddressOfAcpi20Table():getAddressOfAcpiTable());
if ((update_acpi) && (rsdp->Revision == 0))
{
rsdp_conv = (struct acpi_2_rsdp *)AllocateKernelMemory(sizeof(struct acpi_2_rsdp));
memcpy(rsdp_conv, rsdp, 20);
/* Add/change fields */
rsdp_conv->Revision = 2; /* ACPI version 3 */
rsdp_conv->Length = sizeof(struct acpi_2_rsdp);
/* Correct checksums */
rsdp_conv->Checksum = 0;
rsdp_conv->Checksum = 256-checksum8(rsdp_conv, 20);
rsdp_conv->ExtendedChecksum = 0;
rsdp_conv->ExtendedChecksum = 256-checksum8(rsdp_conv, rsdp_conv->Length);
rsdp = rsdp_conv;
gen_xsdt = true;
version = 1;
addConfigurationTable(&gEfiAcpiTableGuid, NULL, "ACPI");
verbose("Converted ACPI RSD PTR version 1 to version 3\n");
}
if (!rsdp)
{
DBG("No ACPI version %d found. Ignoring\n", version+1);
* For more info see ACPI Specification pages 110 and following
*/
rsdp_mod=(struct acpi_2_rsdp *) AllocateKernelMemory(rsdplength);
memcpy(rsdp_mod, rsdp, rsdplength);
if (gen_xsdt)
{
rsdp_mod=rsdp_conv;
} else {
rsdp_mod=(struct acpi_2_rsdp *) AllocateKernelMemory(rsdplength);
memcpy(rsdp_mod, rsdp, rsdplength);
}
rsdt=(struct acpi_2_rsdt *)(rsdp->RsdtAddress);
DBG("RSDT @%x, Length %d\n",rsdt, rsdt->Length);
rsdp_mod->RsdtAddress=(uint32_t)rsdt_mod;
rsdt_entries_num=(rsdt_mod->Length-sizeof(struct acpi_2_rsdt))/4;
rsdt_entries=(uint32_t *)(rsdt_mod+1);
if (gen_xsdt)
{
uint64_t *xsdt_conv_entries;
xsdt_conv=(struct acpi_2_xsdt *)AllocateKernelMemory(sizeof(struct acpi_2_xsdt)+(rsdt_entries_num * 8));
memcpy(xsdt_conv, rsdt, sizeof(struct acpi_2_rsdt));
xsdt_conv->Signature[0] = 'X';
xsdt_conv->Signature[1] = 'S';
xsdt_conv->Signature[2] = 'D';
xsdt_conv->Signature[3] = 'T';
xsdt_conv->Length = sizeof(struct acpi_2_xsdt)+(rsdt_entries_num * 8);
xsdt_conv_entries=(uint64_t *)(xsdt_conv+1);
for (i=0;i<rsdt_entries_num;i++)
{
xsdt_conv_entries[i] = (uint64_t)rsdt_entries[i];
}
xsdt_conv->Checksum = 0;
xsdt_conv->Checksum = 256-checksum8(xsdt_conv, xsdt_conv->Length);
rsdp->XsdtAddress = (uint32_t)xsdt_conv;
rsdp->ExtendedChecksum = 0;
rsdp->ExtendedChecksum = 256-checksum8(rsdp, rsdp->Length);
verbose("Converted RSDT table to XSDT table\n");
}
for (i=0;i<rsdt_entries_num;i++)
{
char *table=(char *)(rsdt_entries[i]);
dropoffset++;
continue;
}
if (drop_hpet && table[0]=='H' && table[1]=='P' && table[2]=='E' && table[3]=='T')
{
dropoffset++;
continue;
}
if (drop_slic && table[0]=='S' && table[1]=='L' && table[2]=='I' && table[3]=='C')
{
dropoffset++;
continue;
}
if (drop_sbst && table[0]=='S' && table[1]=='B' && table[2]=='S' && table[3]=='T')
{
dropoffset++;
continue;
}
if (drop_ecdt && table[0]=='E' && table[1]=='C' && table[2]=='D' && table[3]=='T')
{
dropoffset++;
continue;
}
if (drop_asft && table[0]=='A' && table[1]=='S' && table[2]=='F' && table[3]=='!')
{
dropoffset++;
continue;
}
if (drop_dmar && table[0]=='D' && table[1]=='M' && table[2]=='A' && table[3]=='R')
{
dropoffset++;
continue;
}
if ((!(oem_hpet)) && table[0]=='H' && table[1]=='P' && table[2]=='E' && table[3]=='T')
{
DBG("HPET found\n");
if (new_hpet)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_hpet;
hpet_replaced=true;
}
continue;
}
if ((!(oem_sbst)) && table[0]=='S' && table[1]=='B' && table[2]=='S' && table[3]=='T')
{
DBG("SBST found\n");
if (new_sbst)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_sbst;
sbst_replaced=true;
}
continue;
}
if ((!(oem_ecdt)) && table[0]=='E' && table[1]=='C' && table[2]=='D' && table[3]=='T')
{
DBG("ECDT found\n");
if (new_ecdt)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_ecdt;
ecdt_replaced=true;
}
continue;
}
if ((!(oem_asft)) && table[0]=='A' && table[1]=='S' && table[2]=='F' && table[3]=='!')
{
DBG("ASF! found\n");
if (new_asft)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_asft;
asft_replaced=true;
}
continue;
}
if ((!(oem_dmar)) && table[0]=='D' && table[1]=='M' && table[2]=='A' && table[3]=='R')
{
DBG("DMAR found\n");
if (new_dmar)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_dmar;
dmar_replaced=true;
}
continue;
}
if ((!(oem_apic)) && table[0]=='A' && table[1]=='P' && table[2]=='I' && table[3]=='C')
{
DBG("APIC found\n");
if (new_apic)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_apic;
apic_replaced=true;
}
continue;
}
if ((!(oem_mcfg)) && table[0]=='M' && table[1]=='C' && table[2]=='F' && table[3]=='G')
{
DBG("MCFG found\n");
if (new_mcfg)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_mcfg;
mcfg_replaced=true;
}
continue;
}
if ((!(oem_ssdt)) && table[0]=='S' && table[1]=='S' && table[2]=='D' && table[3]=='T')
{
DBG("SSDT %d found", curssdt);
if (new_ssdts[curssdt])
{
DBG(" and replaced");
rsdt_entries[i-dropoffset]=(uint32_t)new_ssdts[curssdt];
totssdt++;
}
DBG("\n");
curssdt++;
continue;
}
if (table[0]=='D' && table[1]=='S' && table[2]=='D' && table[3]=='T')
{
DBG("DSDT found\n");
continue;
}
fadt_mod = patch_fadt(fadt, new_dsdt);
fadt_mod = patch_fadt(fadt, new_dsdt, update_acpi);
rsdt_entries[i-dropoffset]=(uint32_t)fadt_mod;
continue;
}
}
DBG("\n");
if ((!oem_hpet) && (!hpet_replaced))
{
if (new_hpet)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_hpet;
hpet_added=true;
i++;
}
}
if ((!oem_sbst) && (!sbst_replaced))
{
if (new_sbst)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_sbst;
sbst_added=true;
i++;
}
}
if ((!oem_ecdt) && (!ecdt_replaced))
{
if (new_ecdt)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_ecdt;
ecdt_added=true;
i++;
}
}
if ((!oem_asft) && (!asft_replaced))
{
if (new_asft)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_asft;
asft_added=true;
i++;
}
}
if ((!oem_dmar) && (!dmar_replaced))
{
if (new_dmar)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_dmar;
dmar_added=true;
i++;
}
}
if ((!oem_apic) && (!apic_replaced))
{
if (new_apic)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_apic;
apic_added=true;
i++;
}
}
if ((!oem_mcfg) && (!mcfg_replaced))
{
if (new_mcfg)
{
rsdt_entries[i-dropoffset]=(uint32_t)new_mcfg;
mcfg_added=true;
i++;
}
}
if (!oem_ssdt)
{
while ((totssdt < loadtotssdt) && (curssdt < 30))
{
if (new_ssdts[curssdt])
{
DBG("adding SSDT %d\n", curssdt);
rsdt_entries[i-dropoffset]=(uint32_t)new_ssdts[curssdt];
totssdt++;
newtotssdt++;
i++;
}
curssdt++;
}
}
// Correct the checksum of RSDT
rsdt_mod->Length-=4*dropoffset;
rsdt_mod->Length+=4*newtotssdt;
if (hpet_added)
rsdt_mod->Length+=4;
if (sbst_added)
rsdt_mod->Length+=4;
if (ecdt_added)
rsdt_mod->Length+=4;
if (asft_added)
rsdt_mod->Length+=4;
if (dmar_added)
rsdt_mod->Length+=4;
if (apic_added)
rsdt_mod->Length+=4;
if (mcfg_added)
rsdt_mod->Length+=4;
DBG("RSDT: Original checksum %d, ", rsdt_mod->Checksum);
// FIXME: handle 64-bit address correctly
xsdt=(struct acpi_2_xsdt*) ((uint32_t)rsdp->XsdtAddress);
if (gen_xsdt)
xsdt=xsdt_conv;
else
xsdt=(struct acpi_2_xsdt*) ((uint32_t)rsdp->XsdtAddress);
DBG("XSDT @%x;%x, Length=%d\n", (uint32_t)(rsdp->XsdtAddress>>32),(uint32_t)rsdp->XsdtAddress,
xsdt->Length);
if (xsdt && (uint64_t)rsdp->XsdtAddress<0xffffffff && xsdt->Length<0x10000)
uint64_t *xsdt_entries;
int xsdt_entries_num, i;
int dropoffset=0;
xsdt_mod=(struct acpi_2_xsdt*)AllocateKernelMemory(xsdt->Length);
memcpy(xsdt_mod, xsdt, xsdt->Length);
curssdt=0, totssdt=0, newtotssdt=0;
hpet_replaced=false, hpet_added=false;
sbst_replaced=false, sbst_added=false;
ecdt_replaced=false, ecdt_added=false;
asft_replaced=false, asft_added=false;
dmar_replaced=false, dmar_added=false;
apic_replaced=false, apic_added=false;
mcfg_replaced=false, mcfg_added=false;
if (gen_xsdt)
xsdt_mod=xsdt;
else
{
xsdt_mod=(struct acpi_2_xsdt*)AllocateKernelMemory(xsdt->Length);
memcpy(xsdt_mod, xsdt, xsdt->Length);
}
rsdp_mod->XsdtAddress=(uint32_t)xsdt_mod;
xsdt_entries_num=(xsdt_mod->Length-sizeof(struct acpi_2_xsdt))/8;
xsdt_entries=(uint64_t *)(xsdt_mod+1);
{
dropoffset++;
continue;
}
if (drop_hpet && table[0]=='H' && table[1]=='P' && table[2]=='E' && table[3]=='T')
{
dropoffset++;
continue;
}
if (drop_slic && table[0]=='S' && table[1]=='L' && table[2]=='I' && table[3]=='C')
{
dropoffset++;
continue;
}
if (drop_sbst && table[0]=='S' && table[1]=='B' && table[2]=='S' && table[3]=='T')
{
dropoffset++;
continue;
}
if (drop_ecdt && table[0]=='E' && table[1]=='C' && table[2]=='D' && table[3]=='T')
{
dropoffset++;
continue;
}
if (drop_asft && table[0]=='A' && table[1]=='S' && table[2]=='F' && table[3]=='!')
{
dropoffset++;
continue;
}
if (drop_dmar && table[0]=='D' && table[1]=='M' && table[2]=='A' && table[3]=='R')
{
dropoffset++;
continue;
}
if ((!(oem_hpet)) && table[0]=='H' && table[1]=='P' && table[2]=='E' && table[3]=='T')
{
DBG("HPET found\n");
if (new_hpet)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_hpet;
hpet_replaced=true;
}
continue;
}
if ((!(oem_sbst)) && table[0]=='S' && table[1]=='B' && table[2]=='S' && table[3]=='T')
{
DBG("SBST found\n");
if (new_sbst)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_sbst;
sbst_replaced=true;
}
continue;
}
if ((!(oem_ecdt)) && table[0]=='E' && table[1]=='C' && table[2]=='D' && table[3]=='T')
{
DBG("ECDT found\n");
if (new_ecdt)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_ecdt;
ecdt_replaced=true;
}
continue;
}
if ((!(oem_asft)) && table[0]=='A' && table[1]=='S' && table[2]=='F' && table[3]=='!')
{
DBG("ASF! found\n");
if (new_asft)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_asft;
asft_replaced=true;
}
continue;
}
if ((!(oem_dmar)) && table[0]=='D' && table[1]=='M' && table[2]=='A' && table[3]=='R')
{
DBG("DMAR found\n");
if (new_dmar)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_dmar;
dmar_replaced=true;
}
continue;
}
if ((!(oem_apic)) && table[0]=='A' && table[1]=='P' && table[2]=='I' && table[3]=='C')
{
DBG("APIC found\n");
if (new_apic)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_apic;
apic_replaced=true;
}
continue;
}
if ((!(oem_mcfg)) && table[0]=='M' && table[1]=='C' && table[2]=='F' && table[3]=='G')
{
DBG("MCFG found\n");
if (new_mcfg)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_mcfg;
mcfg_replaced=true;
}
continue;
}
if ((!(oem_ssdt)) && table[0]=='S' && table[1]=='S' && table[2]=='D' && table[3]=='T')
{
DBG("SSDT %d found", curssdt);
if (new_ssdts[curssdt])
{
DBG(" and replaced");
xsdt_entries[i-dropoffset]=(uint32_t)new_ssdts[curssdt];
totssdt++;
}
DBG("\n");
curssdt++;
continue;
}
if (table[0]=='D' && table[1]=='S' && table[2]=='D' && table[3]=='T')
{
DBG("DSDT found\n");
goto drop_xsdt;
}
fadt_mod = patch_fadt(fadt, new_dsdt);
fadt_mod = patch_fadt(fadt, new_dsdt,update_acpi);
xsdt_entries[i-dropoffset]=(uint32_t)fadt_mod;
DBG("TABLE %c%c%c%c@%x,",table[0],table[1],table[2],table[3],xsdt_entries[i]);
}
if ((!oem_hpet) && (!hpet_replaced))
{
if (new_hpet)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_hpet;
hpet_added=true;
i++;
}
}
if ((!oem_sbst) && (!sbst_replaced))
{
if (new_sbst)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_sbst;
sbst_added=true;
i++;
}
}
if ((!oem_ecdt) && (!ecdt_replaced))
{
if (new_ecdt)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_ecdt;
ecdt_added=true;
i++;
}
}
if ((!oem_asft) && (!asft_replaced))
{
if (new_asft)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_asft;
asft_added=true;
i++;
}
}
if ((!oem_dmar) && (!dmar_replaced))
{
if (new_dmar)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_dmar;
dmar_added=true;
i++;
}
}
if ((!oem_apic) && (!apic_replaced))
{
if (new_apic)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_apic;
apic_added=true;
i++;
}
}
if ((!oem_mcfg) && (!mcfg_replaced))
{
if (new_mcfg)
{
xsdt_entries[i-dropoffset]=(uint32_t)new_mcfg;
mcfg_added=true;
i++;
}
}
if (!oem_ssdt)
{
while ((totssdt < loadtotssdt) && (curssdt < 30))
{
if (new_ssdts[curssdt])
{
DBG("adding SSDT %d\n", curssdt);
xsdt_entries[i-dropoffset]=(uint32_t)new_ssdts[curssdt];
totssdt++;
newtotssdt++;
i++;
}
curssdt++;
}
}
// Correct the checksum of XSDT
xsdt_mod->Length-=8*dropoffset;
xsdt_mod->Length+=8*newtotssdt;
if (hpet_added)
xsdt_mod->Length+=8;
if (sbst_added)
xsdt_mod->Length+=8;
if (ecdt_added)
xsdt_mod->Length+=8;
if (asft_added)
xsdt_mod->Length+=8;
if (dmar_added)
xsdt_mod->Length+=8;
if (apic_added)
xsdt_mod->Length+=8;
if (mcfg_added)
xsdt_mod->Length+=8;
xsdt_mod->Checksum=0;
xsdt_mod->Checksum=256-checksum8(xsdt_mod,xsdt_mod->Length);
}
branches/rekursor/i386/libsaio/acpi.h
5959
6060
6161
62
63
64
65
66
67
68
69
70
6271
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
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
94132
95133
96134
} __attribute__((packed));
// TODO Migrate
struct acpi_2_gas {
uint8_tAddress_Space_ID;
uint8_tRegister_Bit_Width;
uint8_tRegister_Bit_Offset;
uint8_tAccess_Size;
uint64_tAddress;
} __attribute__((packed));
// TODO Migrate
struct acpi_2_fadt {
char Signature[4];
uint32_t Length;
uint8_t Revision;
uint8_t Checksum;
char OEMID[6];
char OEMTableId[8];
uint32_t OEMRevision;
uint32_t CreatorId;
uint32_t CreatorRevision;
uint32_t FIRMWARE_CTRL;
uint32_t DSDT;
uint8_t Model;// JrCs
uint8_t PM_Profile;// JrCs
/*We absolutely don't care about theese fields*/
uint8_t notimp1[66];
/* Begin Asere */
//Reset Fix
uint32_t Flags;
uint8_t Reset_SpaceID;
uint8_t Reset_BitWidth;
uint8_t Reset_BitOffset;
uint8_t Reset_AccessWidth;
uint64_t Reset_Address;
uint8_t Reset_Value;
uint8_t Reserved[3];
uint64_t X_FIRMWARE_CTRL;
uint64_t X_DSDT;
/* End Asere */
/*We absolutely don't care about theese fields*/
uint8_tnotimp2[96];
charSignature[4];
uint32_tLength;
uint8_tRevision;
uint8_tChecksum;
charOEMID[6];
charOEMTableId[8];
uint32_tOEMRevision;
uint32_tCreatorId;
uint32_tCreatorRevision;
uint32_tFIRMWARE_CTRL;
uint32_tDSDT;
uint8_tINT_MODEL; // JrCs
uint8_tPreferred_PM_Profile; // JrCs
uint16_tSCI_INT;
uint32_tSMI_CMD;
uint8_tACPI_ENABLE;
uint8_tACPI_DISABLE;
uint8_tS4BIOS_REQ;
uint8_tPSTATE_CNT;
uint32_tPM1a_EVT_BLK;
uint32_tPM1b_EVT_BLK;
uint32_tPM1a_CNT_BLK;
uint32_tPM1b_CNT_BLK;
uint32_tPM2_CNT_BLK;
uint32_tPM_TMR_BLK;
uint32_tGPE0_BLK;
uint32_tGPE1_BLK;
uint8_tPM1_EVT_LEN;
uint8_tPM1_CNT_LEN;
uint8_tPM2_CNT_LEN;
uint8_tPM_TMR_LEN;
uint8_tGPE0_BLK_LEN;
uint8_tGPE1_BLK_LEN;
uint8_tGPE1_BASE;
uint8_tCST_CNT;
uint16_tP_LVL2_LAT;
uint16_tP_LVL3_LAT;
uint16_tFLUSH_SIZE;
uint16_tFLUSH_STRIDE;
uint8_tDUTY_OFFSET;
uint8_tDUTY_WIDTH;
uint8_tDAY_ALRM;
uint8_tMON_ALRM;
uint8_tCENTURY;
uint16_tIAPC_BOOT_ARCH;
uint8_tReserved1;
uint32_tFlags;
struct acpi_2_gasRESET_REG;
uint8_tRESET_VALUE;
uint8_tReserved2[3];
uint64_tX_FIRMWARE_CTRL;
uint64_tX_DSDT;
struct acpi_2_gasX_PM1a_EVT_BLK;
struct acpi_2_gasX_PM1b_EVT_BLK;
struct acpi_2_gasX_PM1a_CNT_BLK;
struct acpi_2_gasX_PM1b_CNT_BLK;
struct acpi_2_gasX_PM2_CNT_BLK;
struct acpi_2_gasX_PM_TMR_BLK;
struct acpi_2_gasX_GPE0_BLK;
struct acpi_2_gasX_GPE1_BLK;
} __attribute__((packed));
#endif /* !__LIBSAIO_ACPI_H */
branches/rekursor/i386/libsaio/pci_setup.c
77
88
99
10
1011
1112
1213
1314
1415
1516
16
17
1718
1819
19
20
2021
2122
2223
......
2627
2728
2829
30
2931
3032
3133
......
6870
6971
7072
73
74
7175
7276
7377
extern void set_eth_builtin(pci_dt_t *eth_dev);
extern int ehci_acquire(pci_dt_t *pci_dev);
extern int legacy_off(pci_dt_t *pci_dev);
extern int uhci_reset(pci_dt_t *pci_dev);
extern void force_enable_hpet(pci_dt_t *lpc_dev);
void setup_pci_devs(pci_dt_t *pci_dt)
{
char *devicepath;
bool do_eth_devprop, do_gfx_devprop, fix_ehci, fix_uhci, fix_usb, do_enable_hpet;
bool do_eth_devprop, do_gfx_devprop, fix_ehci, fix_legoff, fix_uhci, fix_usb, do_enable_hpet;
pci_dt_t *current = pci_dt;
do_eth_devprop = do_gfx_devprop = fix_ehci = fix_uhci = fix_usb = do_enable_hpet = false;
do_eth_devprop = do_gfx_devprop = fix_ehci = fix_legoff = fix_uhci = fix_usb = do_enable_hpet = false;
getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->bootConfig);
getBoolForKey(kGraphicsEnabler, &do_gfx_devprop, &bootInfo->bootConfig);
getBoolForKey(kEHCIacquire, &fix_ehci, &bootInfo->bootConfig);
getBoolForKey(kUHCIreset, &fix_uhci, &bootInfo->bootConfig);
}
getBoolForKey(kUSBLegacyOff, &fix_legoff, &bootInfo->bootConfig);
getBoolForKey(kForceHPET, &do_enable_hpet, &bootInfo->bootConfig);
while (current)
case 0x20:
if (fix_ehci)
ehci_acquire(current);
if (fix_legoff)
legacy_off(current);
break;
/* UHCI */
branches/rekursor/i386/libsaio/pci.c
1010
1111
1212
13
13
1414
1515
1616
#include "pci_root.h"
#ifndef DEBUG_PCI
#define DEBUG_PCI 1
#define DEBUG_PCI 0
#endif
#if DEBUG_PCI
branches/rekursor/i386/boot2/boot.c
413413
414414
415415
416
417
418
416419
417420
418421
if (getValueForKey(k32BitModeFlag, &val, &len, &bootInfo->bootConfig)) {
archCpuType = CPU_TYPE_I386;
}
if (getValueForKey(k64BitModeFlag, &val, &len, &bootInfo->bootConfig)) {
archCpuType = CPU_TYPE_X86_64;
}
if (!getBoolForKey (kWake, &tryresume, &bootInfo->bootConfig)) {
tryresume = true;
branches/rekursor/i386/boot2/boot.h
6666
6767
6868
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
6988
89
90
91
92
93
94
95
7096
7197
7298
......
77103
78104
79105
106
80107
81108
82109
......
97124
98125
99126
127
100128
101129
102130
#define kProductVersion"ProductVersion"/* boot.c */
#define karch"arch"/* boot.c */
#define kDSDT"DSDT"/* dsdt_patcher.c */
#define kSSDT"SSDT"/* dsdt_patcher.c */
#define kHPET"HPET"/* dsdt_patcher.c */
#define kSBST"SBST"/* dsdt_patcher.c */
#define kECDT"ECDT"/* dsdt_patcher.c */
#define kASFT"ASFT"/* dsdt_patcher.c */
#define kDMAR"DMAR"/* dsdt_patcher.c */
#define kFADT"FADT"/* dsdt_patcher.c */
#define kAPIC"APIC"/* dsdt_patcher.c */
#define kMCFG"MCFG"/* dsdt_patcher.c */
#define kOEMDSDT"oemDSDT"/* dsdt_patcher.c */
#define kOEMSSDT"oemSSDT"/* dsdt_patcher.c */
#define kOEMHPET"oemHPET"/* dsdt_patcher.c */
#define kOEMSBST"oemSBST"/* dsdt_patcher.c */
#define kOEMECDT"oemECDT"/* dsdt_patcher.c */
#define kOEMASFT"oemASFT"/* dsdt_patcher.c */
#define kOEMDMAR"oemDMAR"/* dsdt_patcher.c */
#define kOEMFADT"oemFADT"/* dsdt_patcher.c */
#define kOEMAPIC"oemAPIC"/* dsdt_patcher.c */
#define kOEMMCFG"oemMCFG"/* dsdt_patcher.c */
#define kDropSSDT"DropSSDT"/* dsdt_patcher.c */
#define kDropHPET"DropHPET"/* dsdt_patcher.c */
#define kDropSLIC"DropSLIC"/* dsdt_patcher.c */
#define kDropSBST"DropSBST"/* dsdt_patcher.c */
#define kDropECDT"DropECDT"/* dsdt_patcher.c */
#define kDropASFT"DropASFT"/* dsdt_patcher.c */
#define kDropDMAR"DropDMAR"/* dsdt_patcher.c */
#define kUpdateACPI"UpdateACPI"/* dsdt_patcher.c */
#define kRestartFix"RestartFix"/* dsdt_patcher.c */
#define kSMBIOS"SMBIOS"/* fake_efi.c */
#define kSystemID"SystemId"/* fake_efi.c */
#define kEthernetBuiltIn"EthernetBuiltIn"/* pci_setup.c */
#define kGraphicsEnabler"GraphicsEnabler"/* pci_setup.c */
#define kUSBBusFix"USBBusFix"/* pci_setup.c */
#define kUSBLegacyOff"USBLegacyOff"/* pci_setup.c */
#define kEHCIacquire"EHCIacquire"/* pci_setup.c */
#define kUHCIreset"UHCIreset"/* pci_setup.c */
#define kForceHPET"ForceHPET"/* pci_setup.c */
#define kIgnoreBootFileFlag"-F"
#define kSingleUserModeFlag"-s"
#define k32BitModeFlag"-x32"
#define k64BitModeFlag"-x64"
/*
* Booter behavior control
branches/rekursor/i386/boot2/options.c
724724
725725
726726
727
727
728728
729729
730
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
731747
732
748
749
733750
734751
735752
736
737
738
753
754
755
756
757
758
759
760
739761
740
762
741763
742764
743765
744
766
745767
746768
747
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
748785
749
786
750787
751788
752
753
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
754806
755
756807
757808
758809
// If the user is holding down a modifier key, enter safe mode.
if ((readKeyboardShiftFlags() & 0x0F) != 0) {
gBootMode |= kBootModeSafe;
gBootMode |= kBootModeSafe;
}
// If user typed F8, abort quiet mode, and display the menu.
/*
Patch from 18seven & modified by me to make it even more mac like and to include couple of commands
* Bootargs keyboard shortcut
* Keys were obtaiend from ApplePS2ToADBMap.h
* F8 abort quiet mode, and display the menu.
* alt+f old safe mode
* shift+f ignore boot configuration file
* alt+s single user mode
* alt+v verbose (in mac its command +v)
* alt+x safe mode (aka boot args with -x , in macs its command +x)
* alt+l legacy mode (not sure why you need this)
* 6 +4 = 64-bit
* 3 + 2 = 32-bit
*/
clearBootArgs();
{
bool f8press = false, spress = false, vpress = false;
bool f8 = false, altf = false, shiftf = false, alts = false,
altv = false, x32 = false, x64 = false, altx = false;
int key;
while (readKeyboardStatus()) {
key = bgetc ();
if (key == 0x4200) f8press = true;
if ((key & 0xff) == 's' || (key & 0xff) == 'S') spress = true;
if ((key & 0xff) == 'v' || (key & 0xff) == 'V') vpress = true;
if (key == 0x4200) f8 = true;
if (key == 0x2100) altf = true;
if (key == 0x2146) shiftf = true;
if (key == 0x1F00) alts = true;
if (key == 0x2F00) altv = true;
if (key == 0x2D00) altx = true;
if (key == 0x0403) x32 = true;
if (key == 0x0705) x64 = true;
}
if (f8press) {
if (f8) {
gBootMode &= ~kBootModeQuiet;
timeout = 0;
}
if ((gBootMode & kBootModeQuiet) && firstRun && vpress && (gBootArgsPtr + 3 < gBootArgsEnd)) {
if ((altf) && (gBootArgsPtr + 3 < gBootArgsEnd)) {
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 'v';
*(gBootArgsPtr++) = 'f';
}
if ((shiftf) && (gBootArgsPtr + 3 < gBootArgsEnd)) {
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 'F';
}
if ((alts) && (gBootArgsPtr + 3 < gBootArgsEnd)) {
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 's';
}
if ((altv) && (gBootArgsPtr + 3 < gBootArgsEnd)) {
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 'v';
}
if ((gBootMode & kBootModeQuiet) && firstRun && spress && (gBootArgsPtr + 3 < gBootArgsEnd)) {
if ((altx) && (gBootArgsPtr + 3 < gBootArgsEnd)) {
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 's';
}
*(gBootArgsPtr++) = 'x';
}
if ((x32) && (gBootArgsPtr + 5 < gBootArgsEnd)) { // Boot into 32-bit Kernel
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 'x';
*(gBootArgsPtr++) = '3';
*(gBootArgsPtr++) = '2';
}
if ((x64) && (gBootArgsPtr + 5 < gBootArgsEnd)) { // Boot into 64-bit Kernel (in case those who are using 32-bit and wanna try 64-bit)
*(gBootArgsPtr++) = ' ';
*(gBootArgsPtr++) = '-';
*(gBootArgsPtr++) = 'x';
*(gBootArgsPtr++) = '6';
*(gBootArgsPtr++) = '4';
}
}
clearBootArgs();
if (bootArgs->Video.v_display == VGA_TEXT_MODE) {
setCursorPosition(0, 0, 0);

Archive Download the corresponding diff file

Revision: 62