VirtualBox

Changeset 74 in kStuff


Ignore:
Timestamp:
Dec 21, 2015 12:40:51 AM (9 years ago)
Author:
bird
Message:

xtide util hacking, included bios patch.

Location:
hacks/xtide
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • hacks/xtide/atalib.c

    r73 r74  
    4343uint16_t g_uBasePort;
    4444uint16_t g_uCtrlPort;
    45 uint16_t g_uPortShift;
     45uint8_t  g_cPortShift;
    4646uint8_t  g_bDevice;
    4747uint8_t  g_fUseLbaMode = 1;
     
    201201    cb >>= 1;
    202202
    203     if (f8BitData)
     203    if (f8BitData == 1)
    204204    {
    205205        while (cb-- > 0)
     
    223223
    224224    cb >>= 1;
    225     if (f8BitData)
     225    if (f8BitData == 1)
    226226    {
    227227        while (cb-- > 0)
     
    363363    outp(ATA_REG_CYLINDER_HIGH(g_uBasePort),    0);
    364364
    365     bSts = AtaSubmitCommandAndWaitForData(ATA_CMD_WRITE_SECTORS);
     365    bSts = AtaSubmitCommandAndWaitForData(ATA_CMD_WRITE_BUFFER);
    366366    if (bSts & ATA_STS_ERR)
    367367        return AtaError(bSts, "writing buffer (#1)");
     
    466466    /* Set the reset flat. */
    467467    outp(ATA_REG_CONTROL(g_uBasePort), ATA_CTL_SRST);
     468/** @todo This still needs work - it doesn't work when ERR is set. */
    468469
    469470    /* Wait for the busy flag response. */
    470     ATA_DELAY_400NS();
    471     ATA_DELAY_400NS();
     471    for (bSts = 0; bSts < 20; bSts++)
     472        ATA_DELAY_400NS();
    472473    while (!(bSts = inp(ATA_REG_STATUS(g_uBasePort))) & ATA_STS_BUSY)
    473474        ATA_DELAY_400NS();
     
    521522}
    522523
    523 int AtaInit(uint16_t uBasePort, uint16_t uCtrlPort, uint8_t uPortShift, uint8_t bDevice, uint8_t f8BitData)
     524int AtaInit(uint16_t uBasePort, uint16_t uCtrlPort, uint8_t cPortShift, uint8_t bDevice, uint8_t f8BitData)
    524525{
    525526    int rc;
     
    528529    g_uBasePort  = uBasePort;
    529530    g_uCtrlPort  = uCtrlPort;
    530     g_uPortShift = uPortShift;
     531    g_cPortShift = cPortShift;
    531532    g_bDevice    = bDevice;
    532533    g_f8BitData  = f8BitData;
     
    539540    inp(ATA_REG_STATUS(g_uBasePort));
    540541    bSts    = inp(ATA_REG_STATUS(g_uBasePort));
    541     bStsAlt = inp(ATA_REG_ALT_STATUS(g_uBasePort));
     542    bStsAlt = inp(ATA_REG_ALT_STATUS(g_uCtrlPort));
    542543    if (bSts != bStsAlt || bSts == 0xff)
    543544    {
    544545        fprintf(stderr, "Status register differs or is 0xff\n");
    545         fprintf(stderr, "     status=");
    546         AtaPrintStatus(stdout, bSts);
     546        fprintf(stderr, " port %#05x    status=", ATA_REG_STATUS(g_uBasePort));
     547        AtaPrintStatus(stderr, bSts);
    547548        fprintf(stderr, "\n");
    548         fprintf(stderr, " alt status=");
    549         AtaPrintStatus(stdout, bStsAlt);
     549        fprintf(stderr, " port %#05x alt status=", ATA_REG_ALT_STATUS(g_uCtrlPort));
     550        AtaPrintStatus(stderr, bStsAlt);
    550551        fprintf(stderr, "\n");
    551552        return -1;
     
    619620
    620621        /* Figure 5-9 in SanDisk Manual Rev 12.0: */
    621         if (   (g_awIdentify[83] & UINT16_C(0xc00)) == UINT16_C(0x4000)
    622             && (g_awIdentify[84] & UINT16_C(0xc00)) == UINT16_C(0x4000))
     622printf("debug: word82=%#x word83=%#x word84=%#x\n", g_awIdentify[82], g_awIdentify[83], g_awIdentify[84]);
     623        if (   g_awIdentify[82] != 0 && g_awIdentify[82] != UINT16_C(0xffff)
     624            && g_awIdentify[83] != 0 && g_awIdentify[83] != UINT16_C(0xffff)
     625            && g_awIdentify[84] != 0 && g_awIdentify[84] != UINT16_C(0xffff)
     626            && (g_awIdentify[83] & UINT16_C(0xc000)) == UINT16_C(0x4000)
     627            && (g_awIdentify[84] & UINT16_C(0xc000)) == UINT16_C(0x4000) )
    623628        {
    624629            g_fSupportsWriteBuffer = (g_awIdentify[82] & UINT16_C(0x1000)) != 0;
     
    628633               g_fSupportsWriteBuffer == 1 ? "have" : g_fSupportsWriteBuffer == 0 ? "no" : "uncertain",
    629634               g_fSupportsReadBuffer  == 1 ? "have" : g_fSupportsReadBuffer  == 0 ? "no" : "uncertain");
     635        break;
    630636    }
    631637
     
    729735                 || strcmp(pszArg, "-8") == 0)
    730736            f8BitData = 1;
     737        else if (   strcmp(pszArg, "--8-bit-data-plus") == 0
     738                 || strcmp(pszArg, "-8+") == 0)
     739            f8BitData = 3;
    731740        else if (   strcmp(pszArg, "--16-bit-data") == 0
    732741                 || strcmp(pszArg, "-16") == 0)
    733742            f8BitData = 0;
     743        else if (strcmp(pszArg, "--ide") == 0)
     744        {
     745            /* Normal IDE, primary. */
     746            uBasePort  = 0x1f0;
     747            uCtrlPort  = 0x3f0;
     748            cShiftPort = 0;
     749            f8BitData  = 0;
     750        }
     751        else if (strcmp(pszArg, "--xt-cf") == 0)
     752        {
     753            /* Lo-tech CF-lite. */
     754            uBasePort  = 0x300;
     755            uCtrlPort  = 0x310;
     756            cShiftPort = 1;
     757            f8BitData  = 1;
     758        }
    734759    }
    735760
  • hacks/xtide/atalib.h

    r73 r74  
    2929
    3030/* The necessary I/O ports, indexed by "bus". */
    31 #define ATA_PORT_SHIFT      1 /* For XT-CF trick */
     31#define ATA_PORT_SHIFT      (g_cPortShift) /* For XT-CF trick */
    3232#define ATA_REG_DATA(a_uBasePort)           (a_uBasePort)
    3333#define ATA_REG_FEATURES(a_uBasePort)       ((a_uBasePort) + (1 << ATA_PORT_SHIFT))
  • hacks/xtide/atarwbuf.c

    r73 r74  
    2929#include <io.h>
    3030#include <conio.h>
     31#include <time.h>
    3132
    3233#include "atalib.h"
     
    4041    int             rc;
    4142    unsigned        i;
     43    uint32_t        cSectors;
     44    clock_t         tsStart;
     45    clock_t         cTicksElapsed;
    4246
    4347    rc = AtaInitFromArgv(1, argc, argv);
     
    6468    }
    6569
     70    /*
     71     * Do some performance testing.
     72     */
     73    /* read */
     74    cSectors = 0;
     75    cTicksElapsed = clock();
     76    do
     77        tsStart = clock();
     78    while (tsStart == cTicksElapsed);
     79    do
     80    {
     81        rc = AtaReadBuffer(s_abBuf2, 0 /*fExtraChecks*/);
     82        if (rc == 0)
     83            rc = AtaReadBuffer(s_abBuf2, 0 /*fExtraChecks*/);
     84        if (rc != 0)
     85            return 1;
     86        cSectors += 2;
     87        cTicksElapsed = clock() - tsStart;
     88    } while (cTicksElapsed < CLOCKS_PER_SEC * 2);
     89    cSectors >>= 1;
     90    printf("Read:  %lu bytes/sec (%u sec/s)\n", cSectors * 512, cSectors);
     91
     92    /* write */
     93    cSectors = 0;
     94    cTicksElapsed = clock();
     95    do
     96        tsStart = clock();
     97    while (tsStart == cTicksElapsed);
     98    do
     99    {
     100        rc = AtaWriteBuffer(s_abBuf1, 0 /*fExtraChecks*/);
     101        if (rc == 0)
     102            rc = AtaWriteBuffer(s_abBuf1, 0 /*fExtraChecks*/);
     103        if (rc != 0)
     104            return 1;
     105        cSectors += 2;
     106        cTicksElapsed = clock() - tsStart;
     107    } while (cTicksElapsed < CLOCKS_PER_SEC * 2);
     108    cSectors >>= 1;
     109    printf("Write:  %lu bytes/sec (%u sec/s)\n", cSectors * 512, cSectors);
     110
     111
    66112    return 0;
    67113}
    68114
    69 
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