Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dhinakg committed May 1, 2021
0 parents commit b71f346
Show file tree
Hide file tree
Showing 11 changed files with 1,147 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:
release:
types: [published]

env:
PROJECT_TYPE: KEXT

jobs:
build:
name: Build
runs-on: macos-latest
env:
JOB_TYPE: BUILD
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
repository: acidanthera/MacKernelSDK
path: MacKernelSDK
- name: CI Bootstrap
run: |
src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/acidanthera/ocbuild/master/ci-bootstrap.sh) && eval "$src" || exit 1
- run: xcodebuild -jobs 1 -configuration Debug
- run: xcodebuild -jobs 1 -configuration Release

- name: Upload to Artifacts
uses: actions/upload-artifact@v2
with:
name: Artifacts
path: build/*/*.zip
- name: Upload to Release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@e74ff71f7d8a4c4745b560a485cc5fdb9b5b999d
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/*/*.zip
tag: ${{ github.ref }}
file_glob: true
56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Gcc Patch
/*.gcno

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

Lilu.kext
MacKernelSDK/
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# USBToolBoxᵇᵉᵗᵃ

*Making USB mapping simple(r)*

The USBToolBox kext is a kext intended to make common actions for USB mapping easier.

## Features

* Attach to the controller instance or parent device, allowing for more ways to match
* Ignore port definitions from ACPI to force macOS to enumerate all ports manually
* Bypasses borked ACPI as seen on some Ryzen motherboards and 400 series Intel motherboards
* Replaces SSDT-RHUB
* Override any built-in Apple USB maps attaching based on SMBIOS and controller name
* Removes the need for controller renames in ACPI patches
* Does not require model identifier specified in USB map (if attaching to PCI device)
* Very compatible with existing USB maps (port format is the same)
* Does not hardcode any port maps, unlike USBInjectAll

This does **not** patch the port limit.

## Configuration

USBToolBox supports configuration using boot arguments, properties, or in the map. You can set the properties on either the PCI device or the `AppleUSBHostController` instance.

Properties can be any type and only existence, not type, is checked, unless otherwise specified.

`-utboff` (property `utb-off`): Disable USBToolBox completely

`-utbacpioff` (property `utb-acpi-off`): Disable RHUB removal from ACPI plane (borked ACPI removal)

`-utbappleoff` (property `utb-apple-off`): Disable existing `ports` and `port-count` removal

`-utbmapoff` (property `utb-map-off`): Disable custom map (useful for testing)

`utbwait=XXX` (property `utb-wait`, type number): Custom delay for `waitForMatchingService`. Integer between 1-180, inclusive.

## Converting Existing Maps

Converting existing maps is fairly easy.

* For each IOKit personality, change the following:
* `CFBundleIdentifier` to `com.dhinakg.USBToolBox.kext`
* `IOClass` to `USBToolBox`
* `IOMatchCategory` to `USBToolBox`
* Add a dictionary named `OSBundleLibraries` to the root item. It should contain `com.dhinakg.USBToolBox.kext`, with value `1.0.0`.

## Usage

You can get the latest release from the GitHub [releases tab](https://github.com/USBToolBox/kext/releases).

The zip contains 2 kexts: the main `USBToolBox.kext`, and `UTBDefault.kext`, a codeless kext used for attaching USBToolBox to all PCIe USB controllers. This is designed for use before you map, so that you can have all USB ports working (assuming no port limit) before you map. However, it is not needed if you choose to map from the start (ie. from Windows, using the USBToolBox [tool](https://github.com/USBToolBox/tool)).

A basic fresh install flow would be as follows:

1. Add `USBToolBox.kext` and `UTBDefault.kext` to your `EFI/OC/Kexts` folder, and make sure to update your `config.plist`.
2. Install macOS.
3. Map your ports with the USBToolBox [tool](https://github.com/USBToolBox/tool).
4. Remove `UTBDefault.kext` and add your newly created `UTBMap.kext` (or whatever your USB map is called) to `EFI/OC/Kexts`.
5. Reboot and you should have a USB mapped system!

## Credits

@RehabMan for [USBInjectAll](https://github.com/RehabMan/USBInjectAll), an inspiration for this project

@acidanthera for [MacKernelSDK](https://github.com/acidanthera/MacKernelSDK)

My testing team (you know who you are) for testing
47 changes: 47 additions & 0 deletions Resources/UTBDefault.kext/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
<string>v1.0</string>
<key>CFBundleIdentifier</key>
<string>com.dhinakg.USBToolBox.injector</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>UTBMap</string>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>IOKitPersonalities</key>
<dict>
<key>XHC1</key>
<dict>
<key>CFBundleIdentifier</key>
<string>com.dhinakg.USBToolBox.kext</string>
<key>IOClass</key>
<string>USBToolBox</string>
<key>IOMatchCategory</key>
<string>USBToolBox</string>
<key>IOPCIClassMatch</key>
<string>0x0c030000&amp;0xffff0000</string>
<key>IOProviderClass</key>
<string>IOPCIDevice</string>
</dict>
</dict>
<key>OSBundleLibraries</key>
<dict>
<key>com.dhinakg.USBToolBox.kext</key>
<string>1.0.0</string>
</dict>
<key>OSBundleRequired</key>
<string>Root</string>
</dict>
</plist>
Loading

0 comments on commit b71f346

Please sign in to comment.