DSTATUS disk_status(BYTE drv) { s32 ret; /* Check drive status */ switch (drv) { case DRIVE_SDHC: /* Check SD card status */ ret = sdio_IsInserted(); if (!ret) return STA_NODISK; break; case DRIVE_EHCI: /* Check USB device status */ ret = ehci_IsInserted(); if (!ret) return STA_NODISK; break; } return 0; }
s32 __SDHC_Ioctlv(u32 cmd, ioctlv *vector, u32 inlen, u32 iolen) { s32 ret = IPC_EINVAL; /* Invalidate cache */ InvalidateVector(vector, inlen, iolen); /* Parse IOCTLV command */ switch (cmd) { /** Initialize SDHC **/ case IOCTL_SDHC_INIT: { /* Initialize SDIO */ ret = !sdio_Startup(); break; } /** Read sectors **/ case IOCTL_SDHC_READ: { u32 sector = *(u32 *)(vector[0].data); u32 numSectors = *(u32 *)(vector[1].data); void *buffer = vector[2].data; /* Read sectors */ ret = !sdio_ReadSectors(sector, numSectors, buffer); break; } /** Write sectors **/ case IOCTL_SDHC_WRITE: { u32 sector = *(u32 *)(vector[0].data); u32 numSectors = *(u32 *)(vector[1].data); void *buffer = vector[2].data; /* Write sectors */ ret = !sdio_WriteSectors(sector, numSectors, buffer); break; } /** Check for SD card **/ case IOCTL_SDHC_ISINSERTED: { /* Check if SD card is inserted */ ret = !sdio_IsInserted(); break; } /** Open WBFS disc **/ case IOCTL_WBFS_OPEN_DISC: { u8 *discid = (u8 *)(vector[0].data); /* Open WBFS disc */ ret = WBFS_OpenDisc(discid); break; } /** Read WBFS disc **/ case IOCTL_WBFS_READ_DISC: { u32 offset = *(u32 *)(vector[0].data); u32 len = *(u32 *)(vector[1].data); void *buffer = vector[2].data; /* Read WBFS disc */ ret = WBFS_Read(buffer, len, offset); if (ret) ret = 0x8000; break; } default: break; } /* Flush cache */ FlushVector(vector, inlen, iolen); return ret; }