Chameleon

Chameleon Commit Details

Date:2015-01-02 01:30:54 (5 years 11 months ago)
Author:ErmaC
Commit:2528
Parents: 2527
Message:Add turning off USB legacy for XHCI (XHCILegacyOff) credits to Zenith432
Changes:
M/trunk/doc/BootHelp.txt
M/trunk/i386/libsaio/usb.c
M/trunk/i386/boot2/boot.h
M/trunk/CHANGES
M/trunk/package/OptionalSettings/General.txt

File differences

trunk/i386/libsaio/usb.c
3131
3232
3333
34
35
36
34
35
36
37
3738
3839
3940
......
6465
6566
6667
67
68
68
69
6970
7071
7172
72
73
7374
7475
7576
77
7678
7779
7880
......
8486
8587
8688
89
90
91
92
93
8794
88
95
8996
9097
9198
9299
93100
94101
95
102
96103
97104
98105
......
103110
104111
105112
106
113
107114
108115
109116
......
197204
198205
199206
200
207
201208
202209
203210
......
321328
322329
323330
324
331
325332
326333
327334
......
342349
343350
344351
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
struct pciList* usbList = NULL;
int legacy_off (pci_dt_t *pci_dev);
int ehci_acquire (pci_dt_t *pci_dev);
int uhci_reset (pci_dt_t *pci_dev);
static int legacy_off (pci_dt_t *pci_dev);
static int ehci_acquire (pci_dt_t *pci_dev);
static int uhci_reset (pci_dt_t *pci_dev);
static int xhci_legacy_off(pci_dt_t *pci_dev);
// Add usb device to the list
void notify_usb_dev(pci_dt_t *pci_dev)
int usb_loop()
{
int retVal = 1;
bool fix_ehci, fix_uhci, fix_usb, fix_legacy;
fix_ehci = fix_uhci = fix_usb = fix_legacy = false;
bool fix_xhci, fix_ehci, fix_uhci, fix_usb, fix_legacy;
fix_xhci = fix_ehci = fix_uhci = fix_usb = fix_legacy = false;
if (getBoolForKey(kUSBBusFix, &fix_usb, &bootInfo->chameleonConfig))
{
fix_ehci = fix_uhci = fix_legacy = fix_usb;// Disable all if none set
fix_xhci = fix_ehci = fix_uhci = fix_legacy = fix_usb;// Disable all if none set
}
else
{
getBoolForKey(kXHCILegacyOff, &fix_xhci, &bootInfo->chameleonConfig);
getBoolForKey(kEHCIacquire, &fix_ehci, &bootInfo->chameleonConfig);
getBoolForKey(kUHCIreset, &fix_uhci, &bootInfo->chameleonConfig);
getBoolForKey(kLegacyOff, &fix_legacy, &bootInfo->chameleonConfig);
{
switch (pci_config_read8(current->pciDev->dev.addr, PCI_CLASS_PROG))
{
// XHCI
case PCI_IF_XHCI:
if(fix_xhci || fix_legacy) retVal &= xhci_legacy_off(current->pciDev);
break;
// EHCI
case 0x20:
case PCI_IF_EHCI:
if(fix_ehci) retVal &= ehci_acquire(current->pciDev);
if(fix_legacy) retVal &= legacy_off(current->pciDev);
break;
// UHCI
case 0x00:
case PCI_IF_UHCI:
if (fix_uhci) retVal &= uhci_reset(current->pciDev);
break;
return retVal;
}
int legacy_off (pci_dt_t *pci_dev)
static int legacy_off (pci_dt_t *pci_dev)
{
// Set usb legacy off modification by Signal64
// NOTE: This *must* be called after the last file is loaded from the drive in the event that we are booting form usb.
return 1;
}
int ehci_acquire (pci_dt_t *pci_dev)
static int ehci_acquire (pci_dt_t *pci_dev)
{
intj, k;
uint32_tbase;
return 1;
}
int uhci_reset (pci_dt_t *pci_dev)
static int uhci_reset (pci_dt_t *pci_dev)
{
uint32_t base, port_base;
outw (port_base,0);
return 1;
}
static int xhci_legacy_off(pci_dt_t *pci_dev)
{
uint32_t bar0, hccparams1, extendCap, value;
int32_t timeOut;
verbose("Setting Legacy USB Off on xHC [%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);
bar0 = pci_config_read32(pci_dev->dev.addr, 16);
/*
* Check if memory bar
*/
if (bar0 & 1)
{
DBG("%s: BAR0 not a memory range\n", __FUNCTION__);
return 0;
}
/*
* Check if outside 32-bit physical address space
*/
if (((bar0 & 6) == 4) &&
pci_config_read32(pci_dev->dev.addr, 20))
{
DBG("%s: BAR0 outside 32-bit physical address space\n", __FUNCTION__);
return 0;
}
bar0 &= ~15;
hccparams1 = *(uint32_t const volatile*) (bar0 + 16);
if (hccparams1 == ~0)
{
DBG("%s: hccparams1 invalid 0x%x\n", __FUNCTION__, hccparams1);
return 0;
}
extendCap = (hccparams1 >> 14) & 0x3fffc;
while (extendCap) {
value = *(uint32_t const volatile*) (bar0 + extendCap);
if (value == ~0)
{
break;
}
if ((value & 0xff) == 1) {
#if DEBUG_USB
verbose("%s: Found USBLEGSUP 0x%x, USBLEGCTLSTS 0x%x\n", __FUNCTION__,
value, *(uint32_t const volatile*) (bar0 + extendCap + 4));
#endif
value |= (1 << 24);
*(uint32_t volatile*) (bar0 + extendCap) = value;
timeOut = 40;
while (timeOut--)
{
delay(1);
value = *(uint32_t const volatile*) (bar0 + extendCap);
if (value == ~0)
{
timeOut = -1;
break;
}
if ((value & 0x01010000) == 0x01000000)
{
timeOut = -1;/* Optional - always disable the SMI */
break;
}
}
#if DEBUG_USB
verbose("%s: USBLEGSUP 0x%x, USBLEGCTLSTS 0x%x\n", __FUNCTION__,
value, *(uint32_t const volatile*) (bar0 + extendCap + 4));
#endif
if (timeOut >= 0)
{
break;
}
/*
* Disable the SMI in USBLEGCTLSTS if BIOS doesn't respond
*/
value = *(uint32_t const volatile*) (bar0 + extendCap + 4);
if (value == ~0)
{
break;
}
value &= 0x1f1fee;
value |= 0xe0000000;
*(uint32_t volatile*) (bar0 + extendCap + 4) = value;
break;
}
if (!(value & 0xff00))
break;
extendCap += ((value >> 6) & 0x3fc);
}
verbose("XHCI Legacy Off Done\n");
return 1;
}
trunk/i386/boot2/boot.h
119119
120120
121121
122
123
124
122125
123126
124127
#define kEHCIhard"EHCIhard"/* usb.c */
#define kDefaultPartition"Default Partition"/* sys.c */
/* Zenith432: added this */
#define kXHCILegacyOff"XHCILegacyOff"/* usb.c */
/* Duvel300: added this */
#define kRestartFix"RestartFix"/* acpi_patcher.c */
trunk/package/OptionalSettings/General.txt
3434
3535
3636
37
3738
3839
3940
Bool@ForceFullMemInfo:ForceFullMemInfo=Yes
Bool@RestartFix:RestartFix=No
Bool@UHCIreset:UHCIreset=Yes
Bool@XHCILegacyOff:XHCILegacyOff=Yes
Bool@UseMemDetect:UseMemDetect=No
Bool@UseKernelCache:UseKernelCache=Yes
Bool@Wake:Wake=Yes
trunk/doc/BootHelp.txt
111111
112112
113113
114
114
115115
116116
117
117
118
118119
119120
120121
for ethernet interfaces.
ForceHPET=Yes|No Force HPET on (disabled by default).
USBBusFix=Yes Enable the EHCI and UHCI fixes (disabled by default).
USBBusFix=Yes Enable the XHCI, EHCI and UHCI fixes (disabled by default).
EHCIacquire=Yes Enable the EHCI fix (disabled by default).
UHCIreset=Yes Enable the UHCI fix (disabled by default).
USBLegacyOff=Yes Force USB Legacy off (disabled by default).
USBLegacyOff=Yes Force USB Legacy off for XHCI and EHCI (disabled by default).
XHCILegacyOff=Yes Force USB Legacy off for XHCI (disabled by default).
Wake=No Disable wake up after hibernation (enbaled by default).
ForceWake=Yes Force using the sleepimage (disabled by default).
trunk/CHANGES
1
12
23
34
- Zenith432 : Add turning off USB legacy for XHCI (XHCILegacyOff)
- ErmaC : C6 & C7 States credits to Clover Team.
- ErmaC : define recursive cpu series for BrandString
- Zenith432 : saio_types.h, biosfn.c - minor typo in bios-defined data structure that isn't actually used.

Archive Download the corresponding diff file

Revision: 2528