diff --git a/src/userland/usbStorage/include/storage.h b/src/userland/usbStorage/include/storage.h index 76c4f30..da2e7a8 100644 --- a/src/userland/usbStorage/include/storage.h +++ b/src/userland/usbStorage/include/storage.h @@ -8,4 +8,26 @@ uint32_t deviceId; } StorageDevice; +typedef enum UsbStorageSubClass { + SCISI = 0, + RBC = 1, + MMC_5 = 2, + Obsolete1 = 3, + UFI = 4, + Obsolete2 = 5, + SCISI_Transparent = 6, + LSD_FS = 7, + IEEE_1667 = 8, + UnknownSubClass = 9 +} UsbStorageSubClass; + +typedef enum UsbStorageProtocol { + CBI1 = 0, + CBI2 = 1, + Obsolete = 2, + BulkOnly = 3, + UAS = 4, + UnknownProtocol = 5 +} UsbStorageProtocol; + #endif // STORAGE_H \ No newline at end of file diff --git a/src/userland/usbStorage/include/storage.h b/src/userland/usbStorage/include/storage.h index 76c4f30..da2e7a8 100644 --- a/src/userland/usbStorage/include/storage.h +++ b/src/userland/usbStorage/include/storage.h @@ -8,4 +8,26 @@ uint32_t deviceId; } StorageDevice; +typedef enum UsbStorageSubClass { + SCISI = 0, + RBC = 1, + MMC_5 = 2, + Obsolete1 = 3, + UFI = 4, + Obsolete2 = 5, + SCISI_Transparent = 6, + LSD_FS = 7, + IEEE_1667 = 8, + UnknownSubClass = 9 +} UsbStorageSubClass; + +typedef enum UsbStorageProtocol { + CBI1 = 0, + CBI2 = 1, + Obsolete = 2, + BulkOnly = 3, + UAS = 4, + UnknownProtocol = 5 +} UsbStorageProtocol; + #endif // STORAGE_H \ No newline at end of file diff --git a/src/userland/usbStorage/main.c b/src/userland/usbStorage/main.c index 953c029..ce9d5e5 100644 --- a/src/userland/usbStorage/main.c +++ b/src/userland/usbStorage/main.c @@ -8,6 +8,27 @@ } __attribute__((packed)) types; } UsbInterfaceType; +const char* subclassStrings[] = { + "SCISI", + "RBC", + "MMC-5", + "Obsolete", + "UFI", + "Obsolete", + "SCISI transparent", + "LSD FS", + "IEEE 1667", + "Unknown" +}; + +const char* protocolStrings[] = { + "CBI1", + "CBI2", + "Obsolete", + "Bulk-only", + "UAS", + "Unknown" +}; void setup(uint32_t in, uint32_t out, uint32_t serviceName, uint32_t serviceId) { uint32_t getType = getFunction(serviceId, "get_type"); @@ -21,33 +42,35 @@ printf("type is not 8 (Mass storage device), aborting...\n"); return; } + UsbStorageSubClass subClass; switch (typeIn.types.subClass) { - case 0: printf("subClass: SCISI\n"); break; - case 1: printf("subClass: RBC\n"); break; - case 2: printf("subClass: MMC-5\n"); break; - case 3: printf("subClass: obsolete\n"); break; - case 4: printf("subClass: UFI\n"); break; - case 5: printf("subClass: obsolete\n"); break; - case 6: printf("subClass: SCISI transparent\n"); break; - case 7: printf("subClass: LSD FS\n"); break; - case 8: printf("subClass: IEEE 1667\n"); break; - default: printf("subClass: unknown\n"); break; + case 0: subClass = SCISI; break; + case 1: subClass = RBC; break; + case 2: subClass = MMC_5; break; + case 3: subClass = Obsolete1; break; + case 4: subClass = UFI; break; + case 5: subClass = Obsolete2; break; + case 6: subClass = SCISI_Transparent; break; + case 7: subClass = LSD_FS; break; + case 8: subClass = IEEE_1667; break; + default: subClass = UnknownSubClass; break; } + UsbStorageProtocol protocol; switch (typeIn.types.protocol) { - case 0x00: printf("protocol: CBI1\n"); break; - case 0x01: printf("protocol: CBI2\n"); break; - case 0x02: printf("protocol: Obsolete\n"); break; - case 0x50: printf("protocol: Bulk-only\n"); break; - case 0x62: printf("protocol: UAS\n"); break; - default: printf("protocol: unknown\n"); break; + case 0x00: protocol = CBI1; break; + case 0x01: protocol = CBI2; break; + case 0x02: protocol = Obsolete; break; + case 0x50: protocol = BulkOnly; break; + case 0x62: protocol = UAS; break; + default: protocol = UnknownProtocol; break; } - if (typeIn.types.protocol != 0x50) { + printf("registered a new usb mass storage drive with sub class '%s' and protocol '%s'\n", subclassStrings[subClass], protocolStrings[protocol]); + if (protocol != BulkOnly) { printf("only bulk only protocol supported for now, aborting...\n"); return; } StorageDevice *device = malloc(sizeof(StorageDevice)); device->serviceId = serviceId; - printf("in: %x, out: %x, typeIn: %x, typeOut: %x\n", in, out, typeIn, typeOut); } int32_t main() {