Skip to content

Commit

Permalink
Use macOS SD-Card icon instead of the generic one
Browse files Browse the repository at this point in the history
  • Loading branch information
ffosilva authored and cholonam committed Feb 16, 2021
1 parent c78e806 commit 332048a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,5 @@ From higher to lower priority:
- Troubleshoot why after a soft reboot, for chip 525A version B, chip version is detected as 'A'.
- Use command gate instead of two workloops? Is it even possible?
- Prevent namespace pollution (OpenBSD functions pollute the namespace and may cause collisions).
- Use macOS SD-Card icon instead of the generic one.

Pull requests are very welcome, specially to add support for chips other than RTS525A (the only chip I can test).
16 changes: 16 additions & 0 deletions Sinetek-rtsx/SDDisk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <IOKit/IOLib.h>
#include <IOKit/storage/IOBlockStorageDevice.h>
#include <IOKit/storage/IOBlockStorageDriver.h> // kIOMediaStateOffline
#include <IOKit/storage/IOMedia.h> // kIOMediaIconKey
#include <IOKit/IOMemoryDescriptor.h>

#define UTL_THIS_CLASS "SDDisk::"
Expand Down Expand Up @@ -59,6 +60,20 @@ static void dma_free(void *kva, bus_size_t bufSize, bus_dma_segment_t *dma_segs,
bus_dmamem_free(gBusDmaTag, dma_segs, rsegs);
}

static void setIcon(IOService *sddiskIOService)
{
OSDictionary *dictionary = OSDictionary::withCapacity(2);
OSString *identifier = OSString::withCString("com.apple.iokit.IOSCSIArchitectureModelFamily");
OSString *resourceFile = OSString::withCString("SD.icns");

if (dictionary && identifier && resourceFile) {
dictionary->setObject("CFBundleIdentifier", identifier);
dictionary->setObject("IOBundleResourceFile", resourceFile);
}

sddiskIOService->setProperty(kIOMediaIconKey, dictionary);
}

} // namespace

bool SDDisk::init(struct sdmmc_softc *sc_sdmmc, OSDictionary* properties)
Expand All @@ -74,6 +89,7 @@ bool SDDisk::init(struct sdmmc_softc *sc_sdmmc, OSDictionary* properties)
debugRetainReleaseCount = 0;
#endif

setIcon(this);

UTL_DEBUG_FUN("END");
return true;
Expand Down

0 comments on commit 332048a

Please # to comment.