Changeset 74 for hacks/xtide/atalib.c
- Timestamp:
- Dec 21, 2015, 1:40:51 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
hacks/xtide/atalib.c
r73 r74 43 43 uint16_t g_uBasePort; 44 44 uint16_t g_uCtrlPort; 45 uint 16_t g_uPortShift;45 uint8_t g_cPortShift; 46 46 uint8_t g_bDevice; 47 47 uint8_t g_fUseLbaMode = 1; … … 201 201 cb >>= 1; 202 202 203 if (f8BitData )203 if (f8BitData == 1) 204 204 { 205 205 while (cb-- > 0) … … 223 223 224 224 cb >>= 1; 225 if (f8BitData )225 if (f8BitData == 1) 226 226 { 227 227 while (cb-- > 0) … … 363 363 outp(ATA_REG_CYLINDER_HIGH(g_uBasePort), 0); 364 364 365 bSts = AtaSubmitCommandAndWaitForData(ATA_CMD_WRITE_ SECTORS);365 bSts = AtaSubmitCommandAndWaitForData(ATA_CMD_WRITE_BUFFER); 366 366 if (bSts & ATA_STS_ERR) 367 367 return AtaError(bSts, "writing buffer (#1)"); … … 466 466 /* Set the reset flat. */ 467 467 outp(ATA_REG_CONTROL(g_uBasePort), ATA_CTL_SRST); 468 /** @todo This still needs work - it doesn't work when ERR is set. */ 468 469 469 470 /* 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(); 472 473 while (!(bSts = inp(ATA_REG_STATUS(g_uBasePort))) & ATA_STS_BUSY) 473 474 ATA_DELAY_400NS(); … … 521 522 } 522 523 523 int AtaInit(uint16_t uBasePort, uint16_t uCtrlPort, uint8_t uPortShift, uint8_t bDevice, uint8_t f8BitData)524 int AtaInit(uint16_t uBasePort, uint16_t uCtrlPort, uint8_t cPortShift, uint8_t bDevice, uint8_t f8BitData) 524 525 { 525 526 int rc; … … 528 529 g_uBasePort = uBasePort; 529 530 g_uCtrlPort = uCtrlPort; 530 g_ uPortShift = uPortShift;531 g_cPortShift = cPortShift; 531 532 g_bDevice = bDevice; 532 533 g_f8BitData = f8BitData; … … 539 540 inp(ATA_REG_STATUS(g_uBasePort)); 540 541 bSts = inp(ATA_REG_STATUS(g_uBasePort)); 541 bStsAlt = inp(ATA_REG_ALT_STATUS(g_u BasePort));542 bStsAlt = inp(ATA_REG_ALT_STATUS(g_uCtrlPort)); 542 543 if (bSts != bStsAlt || bSts == 0xff) 543 544 { 544 545 fprintf(stderr, "Status register differs or is 0xff\n"); 545 fprintf(stderr, " status=");546 AtaPrintStatus(std out, bSts);546 fprintf(stderr, " port %#05x status=", ATA_REG_STATUS(g_uBasePort)); 547 AtaPrintStatus(stderr, bSts); 547 548 fprintf(stderr, "\n"); 548 fprintf(stderr, " alt status=");549 AtaPrintStatus(std out, bStsAlt);549 fprintf(stderr, " port %#05x alt status=", ATA_REG_ALT_STATUS(g_uCtrlPort)); 550 AtaPrintStatus(stderr, bStsAlt); 550 551 fprintf(stderr, "\n"); 551 552 return -1; … … 619 620 620 621 /* 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)) 622 printf("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) ) 623 628 { 624 629 g_fSupportsWriteBuffer = (g_awIdentify[82] & UINT16_C(0x1000)) != 0; … … 628 633 g_fSupportsWriteBuffer == 1 ? "have" : g_fSupportsWriteBuffer == 0 ? "no" : "uncertain", 629 634 g_fSupportsReadBuffer == 1 ? "have" : g_fSupportsReadBuffer == 0 ? "no" : "uncertain"); 635 break; 630 636 } 631 637 … … 729 735 || strcmp(pszArg, "-8") == 0) 730 736 f8BitData = 1; 737 else if ( strcmp(pszArg, "--8-bit-data-plus") == 0 738 || strcmp(pszArg, "-8+") == 0) 739 f8BitData = 3; 731 740 else if ( strcmp(pszArg, "--16-bit-data") == 0 732 741 || strcmp(pszArg, "-16") == 0) 733 742 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 } 734 759 } 735 760
Note:
See TracChangeset
for help on using the changeset viewer.