ata-all.c (2e1eb3321731aff4edf8d43bd61b5cb15eac6b6a) | ata-all.c (f924768c1387f659ffd72c358d405569311612c7) |
---|---|
1/*- 2 * Copyright (c) 1998 - 2008 Søren Schmidt <sos@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 46 unchanged lines hidden (view full) --- 55#include <cam/cam_ccb.h> 56#include <cam/cam_sim.h> 57#include <cam/cam_xpt_sim.h> 58#include <cam/cam_debug.h> 59 60/* prototypes */ 61static void ataaction(struct cam_sim *sim, union ccb *ccb); 62static void atapoll(struct cam_sim *sim); | 1/*- 2 * Copyright (c) 1998 - 2008 Søren Schmidt <sos@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 46 unchanged lines hidden (view full) --- 55#include <cam/cam_ccb.h> 56#include <cam/cam_sim.h> 57#include <cam/cam_xpt_sim.h> 58#include <cam/cam_debug.h> 59 60/* prototypes */ 61static void ataaction(struct cam_sim *sim, union ccb *ccb); 62static void atapoll(struct cam_sim *sim); |
63static void ata_conn_event(void *, int); | 63static void ata_cam_begin_transaction(device_t dev, union ccb *ccb); 64static void ata_cam_end_transaction(device_t dev, struct ata_request *request); 65static void ata_cam_request_sense(device_t dev, struct ata_request *request); 66static int ata_check_ids(device_t dev, union ccb *ccb); 67static void ata_conn_event(void *context, int dummy); 68static void ata_init(void); |
64static void ata_interrupt_locked(void *data); | 69static void ata_interrupt_locked(void *data); |
70static int ata_module_event_handler(module_t mod, int what, void *arg); |
|
65static void ata_periodic_poll(void *data); | 71static void ata_periodic_poll(void *data); |
72static int ata_str2mode(const char *str); 73static void ata_uninit(void); |
|
66 67/* global vars */ 68MALLOC_DEFINE(M_ATA, "ata_generic", "ATA driver generic layer"); 69int (*ata_raid_ioctl_func)(u_long cmd, caddr_t data) = NULL; 70devclass_t ata_devclass; 71uma_zone_t ata_request_zone; 72int ata_dma_check_80pin = 1; 73 --- 356 unchanged lines hidden (view full) --- 430 /* for now just use DELAY, the timer/sleep subsytems are not there yet */ 431 if (1 || interval < (1000000/hz) || ata_delayed_attach) 432 DELAY(interval); 433 else 434 pause("ataslp", interval/(1000000/hz)); 435} 436 437const char * | 74 75/* global vars */ 76MALLOC_DEFINE(M_ATA, "ata_generic", "ATA driver generic layer"); 77int (*ata_raid_ioctl_func)(u_long cmd, caddr_t data) = NULL; 78devclass_t ata_devclass; 79uma_zone_t ata_request_zone; 80int ata_dma_check_80pin = 1; 81 --- 356 unchanged lines hidden (view full) --- 438 /* for now just use DELAY, the timer/sleep subsytems are not there yet */ 439 if (1 || interval < (1000000/hz) || ata_delayed_attach) 440 DELAY(interval); 441 else 442 pause("ataslp", interval/(1000000/hz)); 443} 444 445const char * |
446ata_cmd2str(struct ata_request *request) 447{ 448 static char buffer[20]; 449 450 if (request->flags & ATA_R_ATAPI) { 451 switch (request->u.atapi.sense.key ? 452 request->u.atapi.saved_cmd : request->u.atapi.ccb[0]) { 453 case 0x00: return ("TEST_UNIT_READY"); 454 case 0x01: return ("REZERO"); 455 case 0x03: return ("REQUEST_SENSE"); 456 case 0x04: return ("FORMAT"); 457 case 0x08: return ("READ"); 458 case 0x0a: return ("WRITE"); 459 case 0x10: return ("WEOF"); 460 case 0x11: return ("SPACE"); 461 case 0x12: return ("INQUIRY"); 462 case 0x15: return ("MODE_SELECT"); 463 case 0x19: return ("ERASE"); 464 case 0x1a: return ("MODE_SENSE"); 465 case 0x1b: return ("START_STOP"); 466 case 0x1e: return ("PREVENT_ALLOW"); 467 case 0x23: return ("ATAPI_READ_FORMAT_CAPACITIES"); 468 case 0x25: return ("READ_CAPACITY"); 469 case 0x28: return ("READ_BIG"); 470 case 0x2a: return ("WRITE_BIG"); 471 case 0x2b: return ("LOCATE"); 472 case 0x34: return ("READ_POSITION"); 473 case 0x35: return ("SYNCHRONIZE_CACHE"); 474 case 0x3b: return ("WRITE_BUFFER"); 475 case 0x3c: return ("READ_BUFFER"); 476 case 0x42: return ("READ_SUBCHANNEL"); 477 case 0x43: return ("READ_TOC"); 478 case 0x45: return ("PLAY_10"); 479 case 0x47: return ("PLAY_MSF"); 480 case 0x48: return ("PLAY_TRACK"); 481 case 0x4b: return ("PAUSE"); 482 case 0x51: return ("READ_DISK_INFO"); 483 case 0x52: return ("READ_TRACK_INFO"); 484 case 0x53: return ("RESERVE_TRACK"); 485 case 0x54: return ("SEND_OPC_INFO"); 486 case 0x55: return ("MODE_SELECT_BIG"); 487 case 0x58: return ("REPAIR_TRACK"); 488 case 0x59: return ("READ_MASTER_CUE"); 489 case 0x5a: return ("MODE_SENSE_BIG"); 490 case 0x5b: return ("CLOSE_TRACK/SESSION"); 491 case 0x5c: return ("READ_BUFFER_CAPACITY"); 492 case 0x5d: return ("SEND_CUE_SHEET"); 493 case 0x96: return ("SERVICE_ACTION_IN"); 494 case 0xa1: return ("BLANK_CMD"); 495 case 0xa3: return ("SEND_KEY"); 496 case 0xa4: return ("REPORT_KEY"); 497 case 0xa5: return ("PLAY_12"); 498 case 0xa6: return ("LOAD_UNLOAD"); 499 case 0xad: return ("READ_DVD_STRUCTURE"); 500 case 0xb4: return ("PLAY_CD"); 501 case 0xbb: return ("SET_SPEED"); 502 case 0xbd: return ("MECH_STATUS"); 503 case 0xbe: return ("READ_CD"); 504 case 0xff: return ("POLL_DSC"); 505 } 506 } else { 507 switch (request->u.ata.command) { 508 case 0x00: return ("NOP"); 509 case 0x08: return ("DEVICE_RESET"); 510 case 0x20: return ("READ"); 511 case 0x24: return ("READ48"); 512 case 0x25: return ("READ_DMA48"); 513 case 0x26: return ("READ_DMA_QUEUED48"); 514 case 0x27: return ("READ_NATIVE_MAX_ADDRESS48"); 515 case 0x29: return ("READ_MUL48"); 516 case 0x30: return ("WRITE"); 517 case 0x34: return ("WRITE48"); 518 case 0x35: return ("WRITE_DMA48"); 519 case 0x36: return ("WRITE_DMA_QUEUED48"); 520 case 0x37: return ("SET_MAX_ADDRESS48"); 521 case 0x39: return ("WRITE_MUL48"); 522 case 0x70: return ("SEEK"); 523 case 0xa0: return ("PACKET_CMD"); 524 case 0xa1: return ("ATAPI_IDENTIFY"); 525 case 0xa2: return ("SERVICE"); 526 case 0xb0: return ("SMART"); 527 case 0xc0: return ("CFA ERASE"); 528 case 0xc4: return ("READ_MUL"); 529 case 0xc5: return ("WRITE_MUL"); 530 case 0xc6: return ("SET_MULTI"); 531 case 0xc7: return ("READ_DMA_QUEUED"); 532 case 0xc8: return ("READ_DMA"); 533 case 0xca: return ("WRITE_DMA"); 534 case 0xcc: return ("WRITE_DMA_QUEUED"); 535 case 0xe6: return ("SLEEP"); 536 case 0xe7: return ("FLUSHCACHE"); 537 case 0xea: return ("FLUSHCACHE48"); 538 case 0xec: return ("ATA_IDENTIFY"); 539 case 0xef: 540 switch (request->u.ata.feature) { 541 case 0x03: return ("SETFEATURES SET TRANSFER MODE"); 542 case 0x02: return ("SETFEATURES ENABLE WCACHE"); 543 case 0x82: return ("SETFEATURES DISABLE WCACHE"); 544 case 0xaa: return ("SETFEATURES ENABLE RCACHE"); 545 case 0x55: return ("SETFEATURES DISABLE RCACHE"); 546 } 547 sprintf(buffer, "SETFEATURES 0x%02x", 548 request->u.ata.feature); 549 return (buffer); 550 case 0xf5: return ("SECURITY_FREE_LOCK"); 551 case 0xf8: return ("READ_NATIVE_MAX_ADDRESS"); 552 case 0xf9: return ("SET_MAX_ADDRESS"); 553 } 554 } 555 sprintf(buffer, "unknown CMD (0x%02x)", request->u.ata.command); 556 return (buffer); 557} 558 559const char * |
|
438ata_mode2str(int mode) 439{ 440 switch (mode) { 441 case -1: return "UNSUPPORTED"; 442 case ATA_PIO0: return "PIO0"; 443 case ATA_PIO1: return "PIO1"; 444 case ATA_PIO2: return "PIO2"; 445 case ATA_PIO3: return "PIO3"; --- 13 unchanged lines hidden (view full) --- 459 default: 460 if (mode & ATA_DMA_MASK) 461 return "BIOSDMA"; 462 else 463 return "BIOSPIO"; 464 } 465} 466 | 560ata_mode2str(int mode) 561{ 562 switch (mode) { 563 case -1: return "UNSUPPORTED"; 564 case ATA_PIO0: return "PIO0"; 565 case ATA_PIO1: return "PIO1"; 566 case ATA_PIO2: return "PIO2"; 567 case ATA_PIO3: return "PIO3"; --- 13 unchanged lines hidden (view full) --- 581 default: 582 if (mode & ATA_DMA_MASK) 583 return "BIOSDMA"; 584 else 585 return "BIOSPIO"; 586 } 587} 588 |
467int | 589static int |
468ata_str2mode(const char *str) 469{ 470 471 if (!strcasecmp(str, "PIO0")) return (ATA_PIO0); 472 if (!strcasecmp(str, "PIO1")) return (ATA_PIO1); 473 if (!strcasecmp(str, "PIO2")) return (ATA_PIO2); 474 if (!strcasecmp(str, "PIO3")) return (ATA_PIO3); 475 if (!strcasecmp(str, "PIO4")) return (ATA_PIO4); --- 20 unchanged lines hidden (view full) --- 496int 497ata_atapi(device_t dev, int target) 498{ 499 struct ata_channel *ch = device_get_softc(dev); 500 501 return (ch->devices & (ATA_ATAPI_MASTER << target)); 502} 503 | 590ata_str2mode(const char *str) 591{ 592 593 if (!strcasecmp(str, "PIO0")) return (ATA_PIO0); 594 if (!strcasecmp(str, "PIO1")) return (ATA_PIO1); 595 if (!strcasecmp(str, "PIO2")) return (ATA_PIO2); 596 if (!strcasecmp(str, "PIO3")) return (ATA_PIO3); 597 if (!strcasecmp(str, "PIO4")) return (ATA_PIO4); --- 20 unchanged lines hidden (view full) --- 618int 619ata_atapi(device_t dev, int target) 620{ 621 struct ata_channel *ch = device_get_softc(dev); 622 623 return (ch->devices & (ATA_ATAPI_MASTER << target)); 624} 625 |
626void 627ata_timeout(struct ata_request *request) 628{ 629 struct ata_channel *ch; 630 631 ch = device_get_softc(request->parent); 632 //request->flags |= ATA_R_DEBUG; 633 ATA_DEBUG_RQ(request, "timeout"); 634 635 /* 636 * If we have an ATA_ACTIVE request running, we flag the request 637 * ATA_R_TIMEOUT so ata_cam_end_transaction() will handle it correctly. 638 * Also, NULL out the running request so we wont loose the race with 639 * an eventual interrupt arriving late. 640 */ 641 if (ch->state == ATA_ACTIVE) { 642 request->flags |= ATA_R_TIMEOUT; 643 if (ch->dma.unload) 644 ch->dma.unload(request); 645 ch->running = NULL; 646 ch->state = ATA_IDLE; 647 ata_cam_end_transaction(ch->dev, request); 648 } 649 mtx_unlock(&ch->state_mtx); 650} 651 |
|
504static void 505ata_cam_begin_transaction(device_t dev, union ccb *ccb) 506{ 507 struct ata_channel *ch = device_get_softc(dev); 508 struct ata_request *request; 509 510 if (!(request = ata_alloc_request())) { 511 device_printf(dev, "FAILURE - out of memory in start\n"); --- 141 unchanged lines hidden (view full) --- 653 654 ata_free_request(request); 655 xpt_done(ccb); 656 /* Do error recovery if needed. */ 657 if (fatalerr) 658 ata_reinit(dev); 659} 660 | 652static void 653ata_cam_begin_transaction(device_t dev, union ccb *ccb) 654{ 655 struct ata_channel *ch = device_get_softc(dev); 656 struct ata_request *request; 657 658 if (!(request = ata_alloc_request())) { 659 device_printf(dev, "FAILURE - out of memory in start\n"); --- 141 unchanged lines hidden (view full) --- 801 802 ata_free_request(request); 803 xpt_done(ccb); 804 /* Do error recovery if needed. */ 805 if (fatalerr) 806 ata_reinit(dev); 807} 808 |
661void | 809static void |
662ata_cam_end_transaction(device_t dev, struct ata_request *request) 663{ 664 struct ata_channel *ch = device_get_softc(dev); 665 union ccb *ccb = request->ccb; 666 int fatalerr = 0; 667 668 if (ch->requestsense) { 669 ata_cam_process_sense(dev, request); --- 353 unchanged lines hidden --- | 810ata_cam_end_transaction(device_t dev, struct ata_request *request) 811{ 812 struct ata_channel *ch = device_get_softc(dev); 813 union ccb *ccb = request->ccb; 814 int fatalerr = 0; 815 816 if (ch->requestsense) { 817 ata_cam_process_sense(dev, request); --- 353 unchanged lines hidden --- |