Changeset 46947 in vbox for trunk/src/VBox/Devices/PC/BIOS
- Timestamp:
- Jul 3, 2013 5:39:01 PM (12 years ago)
- Location:
- trunk/src/VBox/Devices/PC/BIOS
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/BIOS/floppy.c
r44528 r46947 72 72 extern int diskette_param_table; /* At a fixed location. */ 73 73 74 #ifndef VBOX_WITH_FLOPPY_IRQ_POLLING 75 76 /** 77 * Wait for the 7th bit of 0040:003e to be set by int0e_handler. 78 * @returns first 7 bits of byte 0040:003e, interrupts disabled. 79 */ 80 uint8_t floppy_wait_for_interrupt(void) 81 { 82 int_disable(); 83 for (;;) 84 { 85 uint8_t val8 = read_byte(0x0040, 0x003e); 86 if (val8 & 0x80) 87 return val8 & ~0x7f; 88 int_enable_hlt_disable(); 89 } 90 } 91 92 /** 93 * Wait for the 7th bit of 0040:003e to be set by int0e_handler or 0040:0040 to 94 * be cleared by the timer, clearing the interrupt flag on success. 95 * 96 * @returns 0 on timeout with interrupts enabled. 97 * All 8 bits at 0040:003e on interrupt with interrupts disabled (i.e. 98 * non-zero), after first clearing the 7th bit at 0040:003e. 99 */ 100 uint8_t floppy_wait_for_interrupt_or_timeout(void) 101 { 102 int_disable(); 103 for (;;) 104 { 105 uint8_t val8 = read_byte(0x0040, 0x0040); 106 if (val8 == 0) { 107 int_enable(); 108 return 0; 109 } 110 111 val8 = read_byte(0x0040, 0x003e); 112 if (val8 & 0x80) { 113 write_byte(0x0040, 0x003e, val8 & 0x7f); 114 return val8; 115 } 116 int_enable_hlt_disable(); 117 } 118 } 119 120 #endif /* !VBOX_WITH_FLOPPY_IRQ_POLLING */ 121 74 122 void floppy_reset_controller(void) 75 123 { … … 107 155 108 156 // reset the disk motor timeout value of INT 08 109 write_byte(0x 40,0x40, BX_FLOPPY_ON_CNT);157 write_byte(0x0040,0x0040, BX_FLOPPY_ON_CNT); 110 158 111 159 // program data rate … … 120 168 121 169 if (prev_reset == 0) { 170 #ifdef VBOX_WITH_FLOPPY_IRQ_POLLING 122 171 // turn on interrupts 123 172 int_enable(); … … 128 177 val8 &= 0x7f; 129 178 int_disable(); 179 #else 180 val8 = floppy_wait_for_interrupt(); /* (7th bit cleared in ret val) */ 181 #endif 130 182 write_byte(0x0040, 0x003e, val8); 131 183 } … … 159 211 bx_bool floppy_read_id(uint16_t drive) 160 212 { 213 #ifdef VBOX_WITH_FLOPPY_IRQ_POLLING 161 214 uint8_t val8; 215 #endif 162 216 uint8_t return_status[7]; 163 217 int i; … … 169 223 outb(0x03f5, drive); // 0=drive0, 1=drive1, head always 0 170 224 225 #ifdef VBOX_WITH_FLOPPY_IRQ_POLLING 171 226 // turn on interrupts 172 227 int_enable(); … … 180 235 // turn off interrupts 181 236 int_disable(); 237 #else 238 floppy_wait_for_interrupt(); 239 #endif 182 240 183 241 // read 7 return status bytes from controller … … 203 261 outb(0x03f5, drive); // 0=drive0, 1=drive1 204 262 263 #ifdef VBOX_WITH_FLOPPY_IRQ_POLLING 205 264 // turn on interrupts 206 265 int_enable(); … … 214 273 // turn off interrupts 215 274 int_disable(); 216 275 217 276 // set 40:3e bit 7 to 0, and calibrated bit 218 277 val8 = read_byte(0x0040, 0x003e); 219 278 val8 &= 0x7f; 279 #else 280 val8 = floppy_wait_for_interrupt(); /* (7th bit cleared in ret val) */ 281 282 // set 40:3e bit 7 to 0, and calibrated bit 283 #endif 220 284 if (drive) { 221 285 val8 |= 0x02; // Drive 1 calibrated … … 563 627 outb(0x03f5, 0xff); // Gap length 564 628 629 #ifdef VBOX_WITH_FLOPPY_IRQ_POLLING 565 630 // turn on interrupts 566 631 int_enable(); 567 632 568 // wait on 40:3e bit 7 to become 1 633 // wait on 40:3e bit 7 to become 1 or timeout (latter isn't armed so it won't happen) 569 634 do { 570 635 val8 = read_byte(0x0040, 0x0040); 571 636 if (val8 == 0) { 572 637 floppy_reset_controller(); … … 583 648 // turn off interrupts 584 649 int_disable(); 585 650 586 651 // set 40:3e bit 7 to 0 587 652 val8 = read_byte(0x0040, 0x003e); 588 653 val8 &= 0x7f; 589 654 write_byte(0x0040, 0x003e, val8); 655 656 #else 657 val8 = floppy_wait_for_interrupt_or_timeout(); 658 if (val8 == 0) { /* Note! Interrupts enabled in this branch. */ 659 floppy_reset_controller(); 660 SET_AH(0x80); // drive not ready (timeout) 661 set_diskette_ret_status(0x80); 662 SET_AL(0); // no sectors read 663 SET_CF(); // error occurred 664 return; 665 } 666 #endif 590 667 591 668 // check port 3f4 for accessibility to status bytes … … 686 763 outb(0x03f5, 0xff); // Gap length 687 764 765 #ifdef VBOX_WITH_FLOPPY_IRQ_POLLING 688 766 // turn on interrupts 689 767 int_enable(); … … 706 784 // turn off interrupts 707 785 int_disable(); 708 786 709 787 // set 40:3e bit 7 to 0 710 788 val8 = read_byte(0x0040, 0x003e); 711 789 val8 &= 0x7f; 712 790 write_byte(0x0040, 0x003e, val8); 791 #else 792 val8 = floppy_wait_for_interrupt_or_timeout(); 793 if (val8 == 0) { /* Note! Interrupts enabled in this branch. */ 794 floppy_reset_controller(); 795 SET_AH(0x80); // drive not ready (timeout) 796 set_diskette_ret_status(0x80); 797 SET_AL(0); // no sectors written 798 SET_CF(); // error occurred 799 return; 800 } 801 #endif 713 802 714 803 // check port 3f4 for accessibility to status bytes … … 835 924 outb(0x03f5, 0); // Gap length 836 925 outb(0x03f5, 0xf6); // Fill byte 926 927 #ifdef VBOX_WITH_FLOPPY_IRQ_POLLING 837 928 // turn on interrupts 838 929 int_enable(); … … 854 945 // turn off interrupts 855 946 int_disable(); 947 856 948 // set 40:3e bit 7 to 0 857 949 val8 = read_byte(0x0040, 0x003e); 858 950 val8 &= 0x7f; 859 951 write_byte(0x0040, 0x003e, val8); 952 #else 953 val8 = floppy_wait_for_interrupt_or_timeout(); 954 if (val8 == 0) { /* Note! Interrupts enabled in this branch. */ 955 floppy_reset_controller(); 956 SET_AH(0x80); // drive not ready (timeout) 957 set_diskette_ret_status(0x80); 958 SET_CF(); // error occurred 959 return; 960 } 961 #endif 962 860 963 // check port 3f4 for accessibility to status bytes 861 964 val8 = inb(0x3f4); -
trunk/src/VBox/Devices/PC/BIOS/inlines.h
r44528 r46947 38 38 void int_disable(void); 39 39 #pragma aux int_disable = "cli" modify exact [] nomemory; 40 41 void int_enable_hlt_disable(void); 42 #pragma aux int_enable_hlt_disable = \ 43 "sti" \ 44 "hlt" \ 45 "cli" \ 46 modify exact [] nomemory; 40 47 41 48 uint16_t int_query(void); -
trunk/src/VBox/Devices/PC/BIOS/orgs.asm
r45669 r46947 1722 1722 1723 1723 ;; time to turn off floppy driv motor(s)? 1724 mov al, ds:[440h] 1724 mov al, ds:[440h] ;; @todo Shouldn't this be decreased if > 0? How would we ever get to zero otherwise? 1725 1725 or al, al 1726 1726 jz int08_floppy_off
Note:
See TracChangeset
for help on using the changeset viewer.