Ticket #853: rtems-4.6.99.2_ata.diff
File rtems-4.6.99.2_ata.diff, 9.3 KB (added by thomas.doerfler, on 12/03/06 at 13:31:12) |
---|
-
rtems-4.6.99.2/c/src/libchip/ide/ata.c
diff -Nur -x Makefile.in -x CVS -x '*.cache' -x '*~' -x configure rtems-4.6.99.2/c/src/libchip/ide/ata.c ../rtems-4.6.99.2/c/src/libchip/ide/ata.c
../ 26 26 #include <libchip/ide_ctrl_cfg.h> 27 27 #include "ata_internal.h" 28 28 #include <libchip/ata.h> 29 30 #define DEBUG 29 /* #define DEBUG */ 31 30 32 31 #ifdef DEBUG 33 32 #include <stdio.h> 34 33 #endif 35 34 35 /* 36 * FIXME: make this better... 37 * find out, which exception model is used 38 * assume, that all i386 BSPs use new exception handling 39 * assume, that some PPC BSPs use new exception handling 40 * assume, that all other BSPs use old exception handling 41 */ 42 #if defined(_OLD_EXCEPTIONS) || (!defined(__i386__) && !defined(__PPC__)) 43 44 #define ATA_USE_OLD_EXCEPTIONS 45 #endif 46 47 #if !defined(ATA_USE_OLD_EXCEPTIONS) 48 #include <bsp/irq.h> 49 #define ATA_IRQ_CHAIN_MAX_CNT 4 /* support up to 4 ATA devices */ 50 typedef struct { 51 rtems_irq_number name; 52 Chain_Control irq_chain; 53 } ata_irq_chain_t; 54 55 ata_irq_chain_t ata_irq_chain[ATA_IRQ_CHAIN_MAX_CNT]; 56 int ata_irq_chain_cnt = 0; 57 #endif 58 36 59 #define SAFE 37 60 #ifdef SAFE 38 61 typedef rtems_mode preemption_key; … … 95 118 static rtems_id ata_task_id; 96 119 static rtems_id ata_queue_id; 97 120 121 #if defined (ATA_USE_OLD_EXCEPTIONS) 98 122 /* Mapping of interrupt vectors to devices */ 99 123 static Chain_Control ata_int_vec[ATA_MAX_RTEMS_INT_VEC_NUMBER + 1]; 124 #endif 100 125 101 126 static void 102 127 ata_process_request(rtems_device_minor_number ctrl_minor); … … 554 579 Chain_Append(&ata_ide_ctrls[ctrl_minor].reqs, &areq->link); 555 580 if (Chain_Has_only_one_node(&ata_ide_ctrls[ctrl_minor].reqs)) 556 581 { 557 uint16_t val; 582 558 583 ata_queue_msg_t msg; 559 584 560 585 #ifdef DEBUG 586 uint16_t val; 561 587 /* 562 588 * read IDE_REGISTER_ALTERNATE_STATUS instead IDE_REGISTER_STATUS 563 589 * to prevent clearing of pending interrupt … … 584 610 * RETURNS: 585 611 * NONE 586 612 */ 613 #if defined(ATA_USE_OLD_EXCEPTIONS) 587 614 rtems_isr 588 615 ata_interrupt_handler(rtems_vector_number vec) 589 616 { … … 607 634 the_node = the_node->next; 608 635 } 609 636 } 637 #else 638 639 void ata_interrupt_handler(rtems_irq_hdl_param handle) 640 { 641 int ata_irq_chain_index = (int) handle; 642 Chain_Node *the_node = 643 ata_irq_chain[ata_irq_chain_index].irq_chain.last; 644 ata_queue_msg_t msg; 645 uint16_t byte; /* emphasize that only 8 low bits is meaningful */ 646 647 648 for ( ; !Chain_Is_tail(&ata_irq_chain[ata_irq_chain_index].irq_chain, 649 the_node) ; ) 650 { 651 /* if (1) - is temporary hack - currently I don't know how to identify 652 * controller which asserted interrupt if few controllers share one 653 * interrupt line 654 */ 655 if (1) 656 { 657 msg.ctrl_minor = ((ata_int_st_t *)the_node)->ctrl_minor; 658 ide_controller_read_register(msg.ctrl_minor, IDE_REGISTER_STATUS, 659 &byte); 660 ATA_SEND_EVT(msg, ATA_MSG_GEN_EVT, msg.ctrl_minor, 0); 661 } 662 the_node = the_node->next; 663 } 664 } 665 666 void ata_interrupt_on(const rtems_irq_connect_data *ptr) 667 { 668 669 /* enable ATA device interrupt */ 670 ide_controller_write_register(0, 671 IDE_REGISTER_DEVICE_CONTROL_OFFSET, 672 0x00 673 ); 674 } 675 676 677 void ata_interrupt_off(const rtems_irq_connect_data *ptr) 678 { 679 680 /* disable ATA device interrupt */ 681 ide_controller_write_register(0, 682 IDE_REGISTER_DEVICE_CONTROL_OFFSET, 683 IDE_REGISTER_DEVICE_CONTROL_nIEN 684 ); 685 } 686 687 688 int ata_interrupt_isOn(const rtems_irq_connect_data *ptr) 689 { 690 uint16_t byte; /* emphasize that only 8 low bits is meaningful */ 691 692 /* return int. status od ATA device */ 693 ide_controller_read_register(0, 694 IDE_REGISTER_DEVICE_CONTROL_OFFSET, 695 &byte 696 ); 697 698 return !(byte & IDE_REGISTER_DEVICE_CONTROL_nIEN); 699 } 700 701 702 static rtems_irq_connect_data ata_irq_data = 703 { 704 705 0, /* filled out before use... */ 706 (rtems_irq_hdl) ata_interrupt_handler,/* filled out before use... */ 707 (rtems_irq_hdl_param) NULL, 708 (rtems_irq_enable) ata_interrupt_on, 709 (rtems_irq_disable) ata_interrupt_off, 710 (rtems_irq_is_enabled) ata_interrupt_isOn 711 }; 712 #endif 610 713 611 714 /* ata_pio_in_protocol -- 612 715 * ATA PIO_IN protocol implementation, see specification … … 810 913 break; 811 914 812 915 default: 916 #ifdef DEBUG 813 917 printf("ata_queue_task: non-supported command type\n"); 918 #endif 814 919 ata_request_done(areq, ctrl_minor, 815 920 RTEMS_UNSATISFIED, 816 921 RTEMS_NOT_IMPLEMENTED); … … 907 1012 char name[ATA_MAX_NAME_LENGTH]; 908 1013 dev_t device; 909 1014 ata_int_st_t *int_st; 1015 #if defined(ATA_USE_OLD_EXCEPTIONS) 910 1016 rtems_isr_entry old_isr; 1017 #else 1018 int ata_irq_chain_use; 1019 #endif 911 1020 912 1021 if (ata_initialized) 913 1022 return RTEMS_SUCCESSFUL; … … 976 1085 for (i = 0; i < (2 * IDE_CTRL_MAX_MINOR_NUMBER); i++) 977 1086 ata_devs[i].device = ATA_UNDEFINED_VALUE; 978 1087 1088 #if defined(ATA_USE_OLD_EXCEPTIONS) 979 1089 /* prepare ATA driver for handling interrupt driven devices */ 980 1090 for (i = 0; i < ATA_MAX_RTEMS_INT_VEC_NUMBER; i++) 981 1091 Chain_Initialize_empty(&ata_int_vec[i]); 1092 #else 1093 for (i = 0; i < ATA_IRQ_CHAIN_MAX_CNT; i++) { 1094 Chain_Initialize_empty(&(ata_irq_chain[i].irq_chain)); 1095 } 1096 #endif 982 1097 983 1098 /* 984 1099 * during ATA driver initialization EXECUTE DEVICE DIAGNOSTIC and … … 1017 1132 } 1018 1133 1019 1134 int_st->ctrl_minor = ctrl_minor; 1020 1135 #if defined(ATA_USE_OLD_EXCEPTIONS) 1021 1136 status = rtems_interrupt_catch( 1022 1137 ata_interrupt_handler, 1023 1138 IDE_Controller_Table[ctrl_minor].int_vec, 1024 1139 &old_isr); 1140 #else 1141 /* 1142 * FIXME: check existing entries. if they use the same 1143 * IRQ name, then append int_st to respective chain 1144 * otherwise, use new ata_irq_chain entry 1145 */ 1146 ata_irq_chain_use = -1; 1147 for (i = 0; 1148 ((i < ata_irq_chain_cnt) && 1149 (ata_irq_chain_use < 0));i++) { 1150 if (ata_irq_chain[i].name == 1151 IDE_Controller_Table[ctrl_minor].int_vec) { 1152 ata_irq_chain_use = i; 1153 } 1154 } 1155 if (ata_irq_chain_use < 0) { 1156 /* 1157 * no match found, try to use new channel entry 1158 */ 1159 if (ata_irq_chain_cnt < ATA_IRQ_CHAIN_MAX_CNT) { 1160 ata_irq_chain_use = ata_irq_chain_cnt++; 1161 1162 ata_irq_chain[ata_irq_chain_use].name = 1163 IDE_Controller_Table[ctrl_minor].int_vec; 1164 ata_irq_data.name = 1165 IDE_Controller_Table[ctrl_minor].int_vec; 1166 ata_irq_data.hdl = ata_interrupt_handler; 1167 ata_irq_data.handle = ctrl_minor; 1168 1169 status = ((0 == BSP_install_rtems_irq_handler(&ata_irq_data)) 1170 ? RTEMS_INVALID_NUMBER 1171 : RTEMS_SUCCESSFUL); 1172 } 1173 else { 1174 status = RTEMS_TOO_MANY; 1175 } 1176 } 1177 #endif 1025 1178 if (status != RTEMS_SUCCESSFUL) 1026 1179 { 1027 1180 free(int_st); … … 1031 1184 rtems_disk_io_done(); 1032 1185 return status; 1033 1186 } 1187 #if defined(ATA_USE_OLD_EXCEPTIONS) 1034 1188 Chain_Append( 1035 1189 &ata_int_vec[IDE_Controller_Table[ctrl_minor].int_vec], 1036 1190 &int_st->link); 1191 #else 1192 Chain_Append( 1193 &(ata_irq_chain[ata_irq_chain_use].irq_chain), 1194 &int_st->link); 1195 #endif 1037 1196 1038 1197 /* disable interrupts */ 1039 1198 ide_controller_write_register(ctrl_minor, … … 1310 1469 break; 1311 1470 1312 1471 default: 1472 #ifdef DEBUG 1313 1473 printf("ata_queue_task: non-supported command type\n"); 1474 #endif 1314 1475 areq->breq->status = RTEMS_UNSATISFIED; 1315 1476 areq->breq->error = RTEMS_NOT_IMPLEMENTED; 1316 1477 break; -
rtems-4.6.99.2/c/src/libchip/ide/ide_controller.c
diff -Nur -x Makefile.in -x CVS -x '*.cache' -x '*~' -x configure rtems-4.6.99.2/c/src/libchip/ide/ide_controller.c ../rtems-4.6.99.2/c/src/libchip/ide/ide_controller.c
../ 51 51 { 52 52 IDE_Controller_Table[minor].status = IDE_CTRL_NON_INITIALIZED; 53 53 54 if ((IDE_Controller_Table[minor].probe != NULL && 55 IDE_Controller_Table[minor].probe(minor)) || 56 IDE_Controller_Table[minor].fns->ctrl_probe(minor)) 54 if ((IDE_Controller_Table[minor].probe == NULL || 55 IDE_Controller_Table[minor].probe(minor)) && 56 (IDE_Controller_Table[minor].fns->ctrl_probe == NULL || 57 IDE_Controller_Table[minor].fns->ctrl_probe(minor))) 57 58 { 58 59 status = rtems_io_register_name(IDE_Controller_Table[minor].name, 59 60 major, minor);