<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Usb on A&#43; programming moments</title>
    <link>https://aplus.rs/tags/usb/</link>
    <description>Recent content in Usb on A&#43; programming moments</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Sun, 09 Feb 2020 04:42:00 +0000</lastBuildDate>
    
	<atom:link href="https://aplus.rs/tags/usb/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>How-to: USB mapping for OpenCore</title>
      <link>https://aplus.rs/2020/usb-mapping-how/</link>
      <pubDate>Sun, 09 Feb 2020 04:42:00 +0000</pubDate>
      
      <guid>https://aplus.rs/2020/usb-mapping-how/</guid>
      <description>&lt;p&gt;With the problem of USB mapping explained in the &lt;a href=&#34;../usb-mapping-why/&#34;&gt;previous article&lt;/a&gt;, now we need to see how to workaround it. The ultimate goal is to have all the available ports that we want working, as both USB 2.0/3.0.&lt;/p&gt;
&lt;p&gt;There are some interesting articles on this topic:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://usb-map.gitbook.io/project/terms-of-endearment&#34;&gt;USB Map&lt;/a&gt; by CorpNewt, useful for historical perspective and Intel-based machines.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.tonymacx86.com/threads/the-new-beginners-guide-to-usb-port-configuration.286553/#post-2029768&#34;&gt;The New Beginner&amp;rsquo;s Guide&lt;/a&gt; to USB Port Configuration, uses Hackintool which lists active port configuration in its USB tab. I found its display to be confusing and incorrect. Probably works OK for Intel machines.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/khronokernel/Opencore-Vanilla-Desktop-Guide/blob/master/AMD/AMD-USB-map.md&#34;&gt;AMD USB Map&lt;/a&gt; part of OpenCore Vanilla Desktop Guide, which is the only one related to AMD stuff but also way too terse.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;General rule for AMD builds: &lt;em&gt;ignore&lt;/em&gt; any guide that tells you to use &lt;a href=&#34;https://github.com/RehabMan/OS-X-USB-Inject-All&#34;&gt;USBInjectAll&lt;/a&gt; kext and/or &lt;a href=&#34;https://github.com/corpnewt/USBMap&#34;&gt;USBMap&lt;/a&gt; tool. They were made for Intel-based builds and do not work with AMD chipsets, at all.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Remember:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;OpenCore is not altering macOS in any way. Which means no kexts are placed inside &lt;code&gt;/System/Library/Extensions&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;OpenCore kexts are loaded before macOS loads its own.&lt;/li&gt;
&lt;li&gt;Thus .kext applied by macOS can’t be overridden.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So in my case, I can’t override &lt;code&gt;iMacPro1,1-XHC1&lt;/code&gt; mapping from previous article. Whatever I do, macOS will apply that map and hide my ports 1 and 9. &lt;code&gt;XHC1&lt;/code&gt; string is used in two places:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/iMacPro-xhc-map-details.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;in the &lt;code&gt;key&lt;/code&gt; itself: &lt;code&gt;iMacPro1,1-XHC1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;as the value of the &lt;code&gt;IONameMatch&lt;/code&gt; key&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Thus the only course of action is to rename that controller so Apple’s map – which is based on “XHC1” value in the &lt;code&gt;IONameMatch&lt;/code&gt; – has no physical ports to work with.&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;That brings me to another problem. Since the &lt;code&gt;.kext&lt;/code&gt; mapping is based on such a simple string name, I can’t use &lt;code&gt;XHC0&lt;/code&gt; for two different controllers – I need to rename one of them into something else.&lt;/p&gt;
&lt;p&gt;Hence, will remap &lt;code&gt;XHC1&lt;/code&gt; into &lt;code&gt;XHCI&lt;/code&gt; and also rename second &lt;code&gt;XHC0&lt;/code&gt; (under GP13) into &lt;code&gt;XHC2&lt;/code&gt;. This will be done using two custom SSDT files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://aplus.rs/efi-samples/SSDT-XHC1-to-XHCI.aml&#34;&gt;SSDT-XHC1-to-XHCI.aml&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://aplus.rs/efi-samples/SSDT-GP13.XHC0-to-XHC2.aml&#34;&gt;SSDT-GP13.XHC0-to-XHC2.aml&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I created these two files following the samples available in the Vanilla desktop guide.&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; I lack the  knowledge to write these from scratch and I’m grateful those samples are available.&lt;/p&gt;
&lt;p&gt;With those two files added into &lt;code&gt;config.plist&lt;/code&gt;, all of my ports were working and I did not need to create any .kexts because all 3 controllers have less than 15 ports (10, 10 and 8).&lt;/p&gt;
&lt;p&gt;So, job done, for me, without actually doing any port mapping, at all. When do you need a specific map?&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Port mapping means that you know exactly which physical port maps into which logical software port, both for USB 2.0 and 3.0 paths.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is fairly easy to do, with one caveat: what if your ACPI setup yields more than 15 ports per (one of the) controllers? macOS will ignore the upper ones and you’ll be unable to complete the mapping.&lt;/p&gt;
&lt;p&gt;In that case – and only in that case – you need to &lt;em&gt;temporarily&lt;/em&gt; apply a kernel patch to disable that limit. That patching is notoriously buggy and unstable thus you need to enable it only for the purpose of mapping out your ports and then disable it. In OpenCore, patching is enabled by simply turning value of &lt;code&gt;XhciPortLimit&lt;/code&gt; key to &lt;code&gt;true&lt;/code&gt; (&lt;code&gt;YES&lt;/code&gt;) in &lt;code&gt;config.plist&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/opencore-xhci-port-limit.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;building-the-map&#34;&gt;Building the map&lt;/h2&gt;
&lt;p&gt;Now, you need to draw yourself a map of the ports you are interested in and get ready to fill-in the details. Here’s how that looked like for me:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/port-mapping-paper.jpeg&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;To build the map, you’ll use IORegistryExplorer. Start it up, make sure that nothing is added into the Search field and scroll down to where the XHC controllers are. Ideally, you would be using Bluetooth mouse and keyboard, which will leave all the USB ports empty and ready to identify, one by one.&lt;/p&gt;
&lt;p&gt;If you do use USB mouse / keyboard then they will already appear, attached to their respective ports:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/usb-mouse-port.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Mouse and keyboard are usually USB 2.0 devices, so you can immediately mark those logical ports as USB 2.0.&lt;/p&gt;
&lt;p&gt;One of the ports will also be taken as Bluetooth USB 2.0 hub – all Bluetooth connected devices will appear here – for me that was &lt;code&gt;XHC0/PRT2&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/prt2-bluetooth-hub.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;But, that aside, what is the best way to mark ports as either USB 3.0 or USB 2.0? You need device(s) that are 2.0/3.0 and plug them in. The best solution is to use external USB hub like the one I have here, &lt;a href=&#34;https://www.anker.com/products/variant/4port-usb-30-ultra-slim-data-hub/A7516011&#34;&gt;from Anker&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/anker-hub.jpeg&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;What’s so great about it? It registers itself as both USB 2.0 and USB 3.0 device when plugged-in. In  IORegExplorer, this looks like this:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/ioreg-plugged-in.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Plugged-in device appears as green and clearly shows as 2.0 or 3.0 hub under its respective logical ports. When you pull the device out, these green lines become red and strike-through. With this, you know exactly how given physical USB port maps into logical ports.&lt;/p&gt;
&lt;p&gt;Now you simply go through all the ports you have and entire map is done in like 10 minutes. For USB-C ports, I used Apple’s USB-A to USB-C adapter and plugged Anker’s hub that way.&lt;/p&gt;
&lt;p&gt;That’s it, really. You have done your mapping. Don’t forget that motherboards have special USB connectors for USB-ports on the chassis. Depending on what kind of PC case you have, maybe you don’t have them connected. But if you do, procedure is the same with those ports too.&lt;/p&gt;
&lt;p&gt;In the end, you will know which of the logical ports are used and which are not, for your specific hardware. All that’s left to do is create the .kext file.&lt;/p&gt;
&lt;h3 id=&#34;creating-the-usb-mapkext&#34;&gt;Creating the USB-map.kext&lt;/h3&gt;
&lt;p&gt;Vanilla guide explains the &lt;a href=&#34;https://github.com/khronokernel/Opencore-Vanilla-Desktop-Guide/blob/master/AMD/AMD-USB-map.md&#34;&gt;important details&lt;/a&gt; of the structure you need to create, look for “So what kind of data do we shove into this plist?” on that page.&lt;/p&gt;
&lt;p&gt;But that sample did not work for me, because it seems based on Mojave structure of the .kext, where Apple used &lt;code&gt;IOKitPersonalities&lt;/code&gt; as the key while in Catalina it’s &lt;code&gt;IOKitPersonalities_x86_64&lt;/code&gt;.  So here’s &lt;a href=&#34;https://aplus.rs/efi-samples/USB-map-Catalina.kext.zip&#34;&gt;my sample .kext&lt;/a&gt;, which you can use to build upon.&lt;/p&gt;
&lt;p&gt;The top of the plist can be used to specify which manufacturer (maker) and which model is that kext for.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/kext-start.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Then inside the mentioned &lt;code&gt;IOKitPersonalities_x86_64&lt;/code&gt; dictionary, you need to create another dictionary named as in this example:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/kext-port-structure.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;where the most important part is to specify correct &lt;code&gt;IONameMatch&lt;/code&gt; value. The rest of the values should hopefully remain the same, I simply copied them from Apple’s kext.&lt;/p&gt;
&lt;p&gt;Inside the port structure, &lt;code&gt;UsbConnector&lt;/code&gt; is a number that specifies type of the port, already explained in the guide:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;0: USB 2.0 Type-A connector
3: USB 3.0 Type-A connector
8: Type C connector - USB 2.0-only
9: Type C connector - USB 2.0 and USB 3.0 with Switch, flipping the device **doesn&amp;#39;t** change the ACPI port
10: Type C connector - USB 2.0 and USB 3.0 without Switch, flipping the device **does** change the ACPI port
255: Proprietary connector - For Internal USB ports like Bluetooth
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Note that these values should already be specified for you, by the DSDT/SSDT. Type of connector is this part:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/dsdt-port-usbconnector-type.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;but I’m not sure this is always true though. I’ll need to see a lot of devices and configs to draw some firm conclusions. Here’s how the back I/O panel looks like for my motherboard:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/mb-back-panel.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;All ports there are USB-A 3.x (thus using &lt;code&gt;UsbConnector&lt;/code&gt; value of &lt;code&gt;3&lt;/code&gt;), except the TB3 port which is Type-C thus making it &lt;code&gt;9&lt;/code&gt; as I did not notice any changes in the port map when flipping the cable.&lt;/p&gt;
&lt;p&gt;When I briefly tested the motherboard in a case which has front USB-C port (connected to the 19pin connector on the mb), that port mapped into &lt;code&gt;XHC0/PRT1&lt;/code&gt; (USB 2.0 logical port) and &lt;code&gt;PRT7&lt;/code&gt; (USB 3.0 logical port).&lt;/p&gt;
&lt;p&gt;When I tried a different cable, one that goes from same 19pin connector on mb but splits into two USB-A 3.0 physical ports, then one of those two mapped into that same &lt;code&gt;PRT1&lt;/code&gt;+&lt;code&gt;PRT7&lt;/code&gt; pair while the other one mapped into &lt;code&gt;PRT3&lt;/code&gt;+&lt;code&gt;PRT8&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Which confirms my earlier note that full port mapping depends on the number of ports connected to every possible connector on the motherboard. So if it seems to you that some ports are unused, make sure to re-test that if you change cases where the PC build is housed-in.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;port&lt;/code&gt; must be specified as &lt;code&gt;Data&lt;/code&gt;; here I type just &lt;code&gt;03&lt;/code&gt; and let PlistEdit Pro convert that for me. Don’t forget: port numbers are hexadecimal when entered into the value field thus port &lt;code&gt;10&lt;/code&gt; is &lt;code&gt;0A&lt;/code&gt;, &lt;code&gt;11&lt;/code&gt; is &lt;code&gt;0B&lt;/code&gt; etc.&lt;/p&gt;
&lt;p&gt;Now, when you complete the map for the controller, take the highest port &lt;em&gt;value&lt;/em&gt; and copy it one level up, as value for &lt;code&gt;port-count&lt;/code&gt; key. The name of this key is confusing since it does not mean “total number of ports” but “highest port number used” instead.&lt;/p&gt;
&lt;p&gt;Here’s what I ended up with:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/final-kext.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Download that &lt;a href=&#34;https://aplus.rs/efi-samples/USBMap-ASRock-X570-Phantom-Gaming-ITX-TB3.kext.zip&#34;&gt;full USB-map.kext&lt;/a&gt; I created for my motherboard. It maps all back I/O ports + one USB-C front chassis port connected to motherboard 19-pin connector. &lt;em&gt;Use it as example.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Place your USB map kext into &lt;code&gt;EFI/OC/Kexts&lt;/code&gt; and add an entry for it in &lt;code&gt;config.plist&lt;/code&gt;. With all that loaded, I got this display in IOReg:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/ioreg-final.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;You can see I did not re-map &lt;code&gt;XHCITR&lt;/code&gt; as I don’t know how. I’m not sure how to reference it in SSDT nor in the .kext but fortunately I don’t have to since it just works. Its PRT3 is the USB 3.0 logical port for the back USB-C / TB3.&lt;/p&gt;
&lt;p&gt;That’s all. Happy port hunting!&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;It’s really interesting that with custom SSDT you can rename devices as you want and thus change hardware configuration etc. Crazy stuff. Here’s some starting links if you want to learn more: &lt;a href=&#34;https://khronokernel-2.gitbook.io/opencore-vanilla-desktop-guide/extras/acpi&#34;&gt;Getting started with ACPI&lt;/a&gt;, A layman&amp;rsquo;s guide to &lt;a href=&#34;https://www.reddit.com/r/hackintosh/comments/bwjj73/a_laymans_guide_to_creating_a_custom_ssdt/&#34;&gt;creating a custom SSDT&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;I think that Mykola wrote SSDT-XHC2.aml sample specifically for this ASRock board, since someone else who has the same motherboard asked him what to do on the Discord channel.&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Why you need to care about USB mapping</title>
      <link>https://aplus.rs/2020/usb-mapping-why/</link>
      <pubDate>Sun, 09 Feb 2020 04:32:00 +0000</pubDate>
      
      <guid>https://aplus.rs/2020/usb-mapping-why/</guid>
      <description>&lt;p&gt;This was the most infuriating part of Hackintoshing for me. There are so many outdated, confusing, incomplete and downright wrong articles and forums posts, it beggars belief. Even for Intel-based Hacks, let alone AMD ones.
Main issue is mix-up of historical context one needs to be aware of, with bewildering amount of inside-the-racket jargon that’s hard to grasp.&lt;/p&gt;
&lt;p&gt;After spending multiple days on this alone I can say that &lt;em&gt;none&lt;/em&gt; of the available guides is entirely correct nor clear what you should do and more importantly &lt;em&gt;why you should do what they tell you to do&lt;/em&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;When you choose some Mac model to emulate – say iMacPro1,1 – macOS will load USB hardware map for that particular machine. Apple knows exactly what their models use as hardware configuration so they don’t really need to scan for available ports or other hardware (like Windows or Linux must do). Everything is known before-hand. One thing they know is that none of their machines have more than dozen ports per USB controller thus in 10.11 (El Capitan) they introduced hard limit of 15 ports per controller.&lt;/p&gt;
&lt;p&gt;On the other hand, general PC hardware is infinitely varying. Most motherboards feature large number of internal and external ports. It’s not uncommon to see 6-8 or even more USB ports on the back panel I/O. Additional ports which are present on chassis are connected to internal points on the motherboard. Each USB 3.0 port is also backwards compatible with USB 2.0 hence each physical port is counted as 2 logical ports. Then you have USB-C ports which are USB 3.0/2.0 compatible but are reversible so they need to be treated a bit special.&lt;/p&gt;
&lt;p&gt;In general, depending on the chipset and motherboard features, that 15-port limit can be easily blown.&lt;/p&gt;
&lt;p&gt;Saving point here is that there are usually multiple USB controllers in PC hardware; how many, it depends on the chipset and manufacturer choices. External USB hubs and other devices do not count here, since whatever you attach shares that one port where it’s attached.&lt;/p&gt;
&lt;p&gt;What all this means in practice?&lt;/p&gt;
&lt;p&gt;Most obvious consequence is that some of those ports you have will simply not work. macOS will ignore any port enumerated over 15th on particular controller. There is no specific logic which ones will that be but usually it first enumerates USB 2.0 and then 3.0 logical ports. It’s possible that some ports will be ignored even if they are below 15th, simply due to enforced port map of the emulated Mac; on my ASRock motherboard, ports 1 and 9 were removed on one of the 3 controllers.&lt;/p&gt;
&lt;p&gt;As you’ll see, this map is not sequential and physical ports map to (more or less) random positions in the logical map.&lt;/p&gt;
&lt;h2 id=&#34;tools&#34;&gt;Tools&lt;/h2&gt;
&lt;p&gt;You will need these two tools and you’ll run them on your Hackintosh.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/acidanthera/MaciASL&#34;&gt;MaciASL&lt;/a&gt; – automatically reads DSDT/SSDTs for the machine, can create new SSDT files in ASL format.&lt;/li&gt;
&lt;li&gt;IORegistryExplorer to browse active ACPI setup. You can find this tool all over the Internet but if you have an Apple developer account, you can find it as part of Xcode 11 additional tools.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;know-your-hardware&#34;&gt;Know your hardware&lt;/h2&gt;
&lt;p&gt;When MaciASL opens, it automatically loads DSDT for the current system. You can filter that list of devices in the bottom part of the left panel and here I’m filtering per “XHC”.&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/maciasl-ryzen-dsdt-xhc.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;So AMD’s X570 chipset on ASRock ITX/TB3 motherboard has 3 USB controllers. You can see two of them have 10 ports and one has 8 ports. Thus in theory, I should have no problem and all my ports should be working out of the box.&lt;/p&gt;
&lt;p&gt;That’s only part of the story. DSDT can be augmented by manufacturer through a series of SSDTs. I assume this is done in layers because it allows them to have a base setup for particular chipset series and then customised for each particular model.&lt;/p&gt;
&lt;p&gt;MaciASL can show you what SSDTs are active for the hardware. Here’s a screenshot when MaciASL is ran on MacBookPro13,3:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/maciasl-ACPI-tables.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;These additional tables can add, alter and/or hide devices you see in the DSDT.&lt;/p&gt;
&lt;p&gt;Third layer of customisation is through OS device drivers. On macOS, this is done through .kexts. This third layer is primary source of confusion related to USB mapping for Hackintoshes. (More on that below.)&lt;/p&gt;
&lt;p&gt;Thus to summarize:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DSDT / SSDT = coming through ACPI (firmware, I guess)&lt;/li&gt;
&lt;li&gt;OS drivers (kexts) = specified in macOS&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now, when you run macOS on Apple’s hardware, Apple is the author of both the ACPI tables and kexts. When you run on non-Apple hardware, then original manufacturer (in my case ASRock) has done the ACPI part while Apple of course does macOS part.&lt;/p&gt;
&lt;p&gt;Your final XHCI configuration — known as USB map in Hackintosh circles — is combination of these 3 layers: DSDT / SSDT / kexts. To see that final result, use IORegistryExplorer which will display all devices it finds on your system. When filtered per “XHC”, this is what it showed for my build:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/ioreg-xhc-00.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Look closely and you’ll see a couple of strange things.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Ports listed under XHC1 controller are not named &lt;code&gt;PRTx&lt;/code&gt; (as the DSDT declared) but are actually &lt;code&gt;HSxx&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Ports 1 and 9 are missing under XHC1&lt;/li&gt;
&lt;li&gt;There’re two controllers named XHC0&lt;/li&gt;
&lt;li&gt;There’s an additional XHCITR controller&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Last discuss from bottom to the top.&lt;/p&gt;
&lt;p&gt;This motherboard has Thunderbolt 3 port at the back I/O, managed by special TB3 controller. TB3 is also acting as regular USB-C port thus it has its own paired XHCI controller for that. So my motherboard has 3 XHCI controllers from the X570 chipset + 1 additional coming from (Titan Ridge) Thunderbolt 3.&lt;/p&gt;
&lt;p&gt;The chipset has two XHC0 controllers but they are wired through different paths. It’s unfortunate for us that they are called the same (you’ll see why in the next article) but they are not problematic in general since they appear exactly as DSDT specifies.&lt;/p&gt;
&lt;p&gt;XHC1 is the problem. Not only are ports renamed, two of them are missing. You probably already suspect why — macOS specifies an additional .kext that alters the port mapping setup in the hardware.&lt;/p&gt;
&lt;h2 id=&#34;know-what-you-emulate&#34;&gt;Know what you emulate&lt;/h2&gt;
&lt;p&gt;In my OC build, I chose to emulate iMacPro1,1 model. Thus the .kext macOS applies must be somehow connected to that particular machine.&lt;/p&gt;
&lt;p&gt;Where are those .kext maps located? In &lt;code&gt;/System/Library/Extensions&lt;/code&gt; and then:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;in Mojave:&lt;br&gt;
&lt;code&gt;IOUSBHostFamily.kext/Contents/PlugIns/&lt;/code&gt;
&lt;code&gt;AppleUSBXHCIPCI.kext/Contents/Info.plist&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;in Catalina:&lt;br&gt;
&lt;code&gt;IOUSBHostFamily.kext/Contents/PlugIns/&lt;/code&gt;&lt;br&gt;
&lt;code&gt;AppleUSBHostPlatformProperties.kext/Contents/Info.plist&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;I mentioned Mojave to point out just how much stuff can change. They did not change just the file location but also the internal structure. This is one more reason why you should never rush to update to major macOS releases. With the push towards DriverKit, kext are going away and who knows what’s going to change in 10.16.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;When you open this Catalina .plist, this is the setup you’ll see:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/iMacPro-kext-map.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Well, well, well…You can see that this map for &lt;code&gt;XHC1&lt;/code&gt; on &lt;code&gt;iMacPro1,1&lt;/code&gt; essentially overwrites ACPI setup for &lt;code&gt;XHC1&lt;/code&gt;. Like it was never there…or?&lt;/p&gt;
&lt;p&gt;Look closer though: this map also specifies SS02-SS06 ports which do not appear in the IORegistryExplorer. So what happens with those ports..?&lt;/p&gt;
&lt;p&gt;To understand that, we need to look at the ACPI tables from the actual iMacPro, not from my build. If you know owner of one, you can ask them to run MaciASL for you 😉. Or you can look at &lt;a href=&#34;https://applelife.ru/threads/dampy-originalnyx-makov.2943712/&#34;&gt;this library&lt;/a&gt; of complete system dumps of various Mac models and find the one that interests you. For iMacPro, you’ll find the DSDT and 11 SSDTs:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/iMacPro-acpi-dump.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;DSDT has no XHCI setup, at all. XHC1 is declared in SSDT-10:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/iMacPro-SSDT-9.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;(SSDT-9 is also interesting, since it declares Thunderbolt 3 hardware.)&lt;/p&gt;
&lt;p&gt;And there you go. SSDT declares all the possible ports and then .kext augments that list by hiding (and possibly renaming) some ports. But the .kext can’t manufacture ports in software - they must exist in hardware.&lt;/p&gt;
&lt;p&gt;This is why in my build, which has 10 hardware ports under XHC1, I don’t see anything below HS10. But why is HS10 the last one visible, why not HS13? If you count the ports, my XHC1 has 10, while iMacPro’s is missing HS01 and HS09 so surely the next two in list should appear, right?&lt;/p&gt;
&lt;p&gt;Well, no. These are just display names which are mostly irrelevant. What matters is the physical port address. Here’s HS10 port number in iMacPro:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/iMacPro-HS10-port.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;and here it is on my build:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://aplus.rs/images/2020/usb-map/Ryzen5-PRT10-port.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;That’s how the ports match-up. Not through display name but through port address. HS12’s port number is &lt;code&gt;0x0C&lt;/code&gt; (12) which does not exist on my machine so the port is not showing up in IORegExplorer.&lt;/p&gt;
&lt;p&gt;There are more details&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; here but I don’t understand them completely (yet). It’s out of scope for this article anyway.&lt;/p&gt;
&lt;p&gt;I hope it’s now somewhat clearer just how complicated USB mapping is and why some ports on your PC appear dead. You can try switching SMBIOS to different Mac model and hope that things will be better. Community experience is that you are simply trading one set of problems for another.&lt;/p&gt;
&lt;p&gt;On my machine, it turns out that XHC1/PRT1 is the logical 2.0 position for the top-left USB port on the back I/O. The other hidden port, XHC1/PRT9, maps into logical USB 3 for the bottom-right port on the back I/O. So depending on what kind of USB device I plug in, it may or may not work.&lt;/p&gt;
&lt;p&gt;I’ll explain how to map-out your ports in the &lt;a href=&#34;../usb-mapping-how/&#34;&gt;next article&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;XHCI stands for &lt;a href=&#34;https://en.wikipedia.org/wiki/Extensible_Host_Controller_Interface&#34;&gt;eXtensible Host Controller Interface&lt;/a&gt; which deals with USB. Read on the Wikipedia if you are interested in the details.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;Like how exactly Apple uses the concept of USBCompanion ports to shuttle 2.0 logical port for each TB3/USB-c physical port to appear under XHC1 but keeps the 3.0 logical port under XHCTR. Lots of voodoo there.&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
  </channel>
</rss>