Voodooprojects
Chameleon => DevTalk => Patches => Topic started by: r007 on July 17, 2010, 12:28:14 PM
-
As detailed in my support forum post (http://forum.voodooprojects.org/index.php/topic,1498.0.html) resetting the USB when you still want to load data from it might not be a very bright idea.
This attached patch defers USB resets until setup of fake efi is through.
Issues:
- It's limited to max 10 Controllers of each type (UHCI, EHCI) due to lack of proper dynamically allocated queue
- It lacks a proper dynamically allocated queue ;)
Tell me what you think.
-
Well, my first comment is that it's probably a bad idea to have this line:
memcpy(&gUSBEnqueuedEHCI[gUSBEnqueuedEHCICount++], pci_dev, sizeof(pci_dt_t));
gUSBEnqueuedEHCI is hardcoded to a size of MAX_USB_DEVICES * sizeof(pci_dt_t), so if you ever have a machine with more than MAX_USB_DEVICES controllers, you're writing to memory that you shouldn't be. The same goes for the other pci_dt_t array.
If you really wanted to, you could change it to
if(gUSBEnqueuedEHCICount < MAX_USB_DEVICES ) memcpy(&gUSBEnqueuedEHCI[gUSBEnqueuedEHCICount++], pci_dev, sizeof(pci_dt_t));
I also have an implementation in my branch (http://forge.voodooprojects.org/p/chameleon/source/tree/HEAD/branches/meklort/i386/libsaio/usb.c) for the usb code, and inside of pci_setup.c as well. There is one main bug that I still haven't fixed with it (running the reset on the correct controller, but that's just two lines to fix)
-
Yup, I realize that that is extremely bad code (hey, it took me about an hour to fix what I was looking for...)
All in all I like your code better... (Sure enough, moving the commented-out switch statement from pci_setup.c to usb.c will do for calling the appropriate code for the controller.)
Only one question: shouldn't you be free()ing that array as well after usb_loop() is done?
Any chance this yours gets merged upstream anytime soon?
-
Any chance this yours gets merged upstream anytime soon?
I'm inspecting meklort's changes, and I'd like to merge his md0 ramdisk + usb changes back to the trunk.
-
Only one question: shouldn't you be free()ing that array as well after usb_loop() is done?
There isn't any reason to, the kernel with just reuse it when it's started up (I believe, correct me if I'm wrong).
-
Hello,
I have the same problem when I want to install Yosemite. How to apply this patch?
Show me UHCI controller.
How to fix this problem? I can not start the installation it keeps restart PC.
thank you