VirtualBox

Changeset 36336 in vbox


Ignore:
Timestamp:
Mar 21, 2011 10:19:21 PM (14 years ago)
Author:
vboxsync
Message:

DevATA: Signal no current profile if no medium is loaded and add mandatory features for GET CONFIGURATION, fixes automount on recent Linux distros

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevATA.cpp

    r36316 r36336  
    23262326}
    23272327
     2328static size_t atapiGetConfigurationFillFeatureListProfiles(ATADevState *s, uint8_t *pbBuf, size_t cbBuf)
     2329{
     2330    if (cbBuf < 3*4)
     2331        return 0;
     2332
     2333    ataH2BE_U16(pbBuf, 0x0); /* feature 0: list of profiles supported */
     2334    pbBuf[2] = (0 << 2) | (1 << 1) | (1 || 0); /* version 0, persistent, current */
     2335    pbBuf[3] = 8; /* additional bytes for profiles */
     2336    /* The MMC-3 spec says that DVD-ROM read capability should be reported
     2337     * before CD-ROM read capability. */
     2338    ataH2BE_U16(pbBuf + 4, 0x10); /* profile: read-only DVD */
     2339    pbBuf[6] = (0 << 0); /* NOT current profile */
     2340    ataH2BE_U16(pbBuf + 8, 0x08); /* profile: read only CD */
     2341    pbBuf[10] = (1 << 0); /* current profile */
     2342
     2343    return 3*4; /* Header + 2 profiles entries */
     2344}
     2345
     2346static size_t atapiGetConfigurationFillFeatureCore(ATADevState *s, uint8_t *pbBuf, size_t cbBuf)
     2347{
     2348    if (cbBuf < 12)
     2349        return 0;
     2350
     2351    ataH2BE_U16(pbBuf, 0x1); /* feature 0001h: Core Feature */
     2352    pbBuf[2] = (0x2 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */
     2353    pbBuf[3] = 8; /* Additional length */
     2354    ataH2BE_U16(pbBuf + 4, 0x00000002); /* Physical interface ATAPI. */
     2355    pbBuf[8] = RT_BIT(0); /* DBE */
     2356    /* Rest is reserved. */
     2357
     2358    return 12;
     2359}
     2360
     2361static size_t atapiGetConfigurationFillFeatureMorphing(ATADevState *s, uint8_t *pbBuf, size_t cbBuf)
     2362{
     2363    if (cbBuf < 8)
     2364        return 0;
     2365
     2366    ataH2BE_U16(pbBuf, 0x2); /* feature 0002h: Morphing Feature */
     2367    pbBuf[2] = (0x1 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */
     2368    pbBuf[3] = 4; /* Additional length */
     2369    pbBuf[4] = RT_BIT(1) | 0x0; /* OCEvent | !ASYNC */
     2370    /* Rest is reserved. */
     2371
     2372    return 8;
     2373}
     2374
     2375static size_t atapiGetConfigurationFillFeatureRemovableMedium(ATADevState *s, uint8_t *pbBuf, size_t cbBuf)
     2376{
     2377    if (cbBuf < 8)
     2378        return 0;
     2379
     2380    ataH2BE_U16(pbBuf, 0x3); /* feature 0003h: Removable Medium Feature */
     2381    pbBuf[2] = (0x2 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */
     2382    pbBuf[3] = 4; /* Additional length */
     2383    /* Tray type loading | Load | Eject | !Pvnt Jmpr | !DBML | Lock */
     2384    pbBuf[4] = (0x2 << 5) | RT_BIT(4) | RT_BIT(3) | (0x0 << 2) | (0x0 << 1) | RT_BIT(0);
     2385    /* Rest is reserved. */
     2386
     2387    return 8;
     2388}
     2389
     2390static size_t atapiGetConfigurationFillFeatureRandomReadable(ATADevState *s, uint8_t *pbBuf, size_t cbBuf)
     2391{
     2392    if (cbBuf < 12)
     2393        return 0;
     2394
     2395    ataH2BE_U16(pbBuf, 0x10); /* feature 0010h: Random Readable Feature */
     2396    pbBuf[2] = (0x0 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */
     2397    pbBuf[3] = 8; /* Additional length */
     2398    ataH2BE_U32(pbBuf + 4, 2048); /* Logical block size. */
     2399    ataH2BE_U16(pbBuf + 8, 0x10); /* Blocking (0x10 for DVD, CD is not defined). */
     2400    pbBuf[10] = 0; /* PP not present */
     2401    /* Rest is reserved. */
     2402
     2403    return 12;
     2404}
     2405
     2406static size_t atapiGetConfigurationFillFeatureCDRead(ATADevState *s, uint8_t *pbBuf, size_t cbBuf)
     2407{
     2408    if (cbBuf < 8)
     2409        return 0;
     2410
     2411    ataH2BE_U16(pbBuf, 0x1e); /* feature 001Eh: CD Read Feature */
     2412    pbBuf[2] = (0x2 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */
     2413    pbBuf[3] = 0; /* Additional length */
     2414    pbBuf[4] = (0x0 << 7) | (0x0 << 1) | 0x0; /* !DAP | !C2-Flags | !CD-Text. */
     2415    /* Rest is reserved. */
     2416
     2417    return 8;
     2418}
     2419
     2420static size_t atapiGetConfigurationFillFeaturePowerManagement(ATADevState *s, uint8_t *pbBuf, size_t cbBuf)
     2421{
     2422    if (cbBuf < 4)
     2423        return 0;
     2424
     2425    ataH2BE_U16(pbBuf, 0x100); /* feature 0100h: Power Management Feature */
     2426    pbBuf[2] = (0x0 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */
     2427    pbBuf[3] = 0; /* Additional length */
     2428
     2429    return 4;
     2430}
     2431
     2432static size_t atapiGetConfigurationFillFeatureTimeout(ATADevState *s, uint8_t *pbBuf, size_t cbBuf)
     2433{
     2434    if (cbBuf < 8)
     2435        return 0;
     2436
     2437    ataH2BE_U16(pbBuf, 0x105); /* feature 0105h: Timeout Feature */
     2438    pbBuf[2] = (0x0 << 2) | RT_BIT(1) | RT_BIT(0); /* Version | Persistent | Current */
     2439    pbBuf[3] = 4; /* Additional length */
     2440    pbBuf[4] = 0x0; /* !Group3 */
     2441
     2442    return 8;
     2443}
    23282444
    23292445static bool atapiGetConfigurationSS(ATADevState *s)
    23302446{
    23312447    uint8_t *pbBuf = s->CTX_SUFF(pbIOBuffer);
     2448    size_t cbBuf = s->cbIOBuffer;
     2449    size_t cbCopied = 0;
    23322450    uint16_t u16Sfn = ataBE2H_U16(&s->aATAPICmd[2]);
    23332451
     
    23402458        return false;
    23412459    }
    2342     memset(pbBuf, '\0', 32);
    2343     ataH2BE_U32(pbBuf, 16);
     2460    memset(pbBuf, '\0', cbBuf);
    23442461    /** @todo implement switching between CD-ROM and DVD-ROM profile (the only
    2345      * way to differentiate them right now is based on the image size). Also
    2346      * implement signalling "no current profile" if no medium is loaded. */
    2347     ataH2BE_U16(pbBuf + 6, 0x08); /* current profile: read-only CD */
    2348 
    2349     ataH2BE_U16(pbBuf + 8, 0); /* feature 0: list of profiles supported */
    2350     pbBuf[10] = (0 << 2) | (1 << 1) | (1 || 0); /* version 0, persistent, current */
    2351     pbBuf[11] = 8; /* additional bytes for profiles */
    2352     /* The MMC-3 spec says that DVD-ROM read capability should be reported
    2353      * before CD-ROM read capability. */
    2354     ataH2BE_U16(pbBuf + 12, 0x10); /* profile: read-only DVD */
    2355     pbBuf[14] = (0 << 0); /* NOT current profile */
    2356     ataH2BE_U16(pbBuf + 16, 0x08); /* profile: read only CD */
    2357     pbBuf[18] = (1 << 0); /* current profile */
     2462     * way to differentiate them right now is based on the image size). */
     2463    if (s->cTotalSectors)
     2464        ataH2BE_U16(pbBuf + 6, 0x08); /* current profile: read-only CD */
     2465    else
     2466        ataH2BE_U16(pbBuf + 6, 0x00); /* current profile: none -> no media */
     2467    cbBuf    -= 8;
     2468    pbBuf    += 8;
     2469
     2470    cbCopied = atapiGetConfigurationFillFeatureListProfiles(s, pbBuf, cbBuf);
     2471    cbBuf -= cbCopied;
     2472    pbBuf += cbCopied;
     2473
     2474    cbCopied = atapiGetConfigurationFillFeatureCore(s, pbBuf, cbBuf);
     2475    cbBuf -= cbCopied;
     2476    pbBuf += cbCopied;
     2477
     2478    cbCopied = atapiGetConfigurationFillFeatureMorphing(s, pbBuf, cbBuf);
     2479    cbBuf -= cbCopied;
     2480    pbBuf += cbCopied;
     2481
     2482    cbCopied = atapiGetConfigurationFillFeatureRemovableMedium(s, pbBuf, cbBuf);
     2483    cbBuf -= cbCopied;
     2484    pbBuf += cbCopied;
     2485
     2486    cbCopied = atapiGetConfigurationFillFeatureRandomReadable(s, pbBuf, cbBuf);
     2487    cbBuf -= cbCopied;
     2488    pbBuf += cbCopied;
     2489
     2490    cbCopied = atapiGetConfigurationFillFeatureCDRead(s, pbBuf, cbBuf);
     2491    cbBuf -= cbCopied;
     2492    pbBuf += cbCopied;
     2493
     2494    cbCopied = atapiGetConfigurationFillFeaturePowerManagement(s, pbBuf, cbBuf);
     2495    cbBuf -= cbCopied;
     2496    pbBuf += cbCopied;
     2497
     2498    cbCopied = atapiGetConfigurationFillFeatureTimeout(s, pbBuf, cbBuf);
     2499    cbBuf -= cbCopied;
     2500    pbBuf += cbCopied;
     2501
     2502    /* Set data length now. */
     2503    ataH2BE_U32(s->CTX_SUFF(pbIOBuffer), s->cbIOBuffer - cbBuf);
     2504
    23582505    /* Other profiles we might want to add in the future: 0x40 (BD-ROM) and 0x50 (HDDVD-ROM) */
    23592506    s->iSourceSink = ATAFN_SS_NULL;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette