diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk.h b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk.h index de72895..a5a4d0a 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk.h +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk.h @@ -26,7 +26,7 @@ */ /* - * $Id: wdc_if_disk.h,v 1.10 2013/05/04 15:40:14 olivleh1 Exp $ + * $Id: wdc_if_disk.h,v 1.11 2013/05/09 12:30:25 olivleh1 Exp $ */ #ifndef WDC_IF_DISK_H_ @@ -56,6 +56,8 @@ t_drv_write_block drv_write_block; t_drv_read_multiblock drv_read_multiblock; t_drv_write_multiblock drv_write_multiblock; +#define wdc_number_of_disks() 1 + #define WDC_BLOCKLEN 512 #endif /* WDC_IF_DISK_H_ */ \ No newline at end of file diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_p8000.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_p8000.c index 64ec847..aa134d3 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_p8000.c +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_p8000.c @@ -26,7 +26,7 @@ */ /* - * $Id: wdc_if_p8000.c,v 1.16 2013/05/04 15:40:15 olivleh1 Exp $ + * $Id: wdc_if_p8000.c,v 1.17 2013/05/09 12:30:25 olivleh1 Exp $ */ #include "wdc_config.h" @@ -38,11 +38,11 @@ void wdc_wait_for_reset () { - while ( isset_info_reset() ) { - port_data_set ( DATA_CLEAR ); - port_info_set ( INFO_CLEAR ); - wdc_set_initialized ( 1 ); - } + port_data_set ( DATA_CLEAR ); + port_info_set ( INFO_CLEAR ); + wdc_set_initialized ( 1 ); + + while ( isset_info_reset() ) {} } uint8_t wdc_read_data_from_p8k ( uint8_t *buffer, uint16_t count, uint8_t wdc_status ) diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.c index af134d3..bbd9342 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.c +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.c @@ -27,7 +27,7 @@ /* - * $Id: wdc_main.c,v 1.35 2013/05/09 00:16:04 olivleh1 Exp $ + * $Id: wdc_main.c,v 1.36 2013/05/09 12:30:25 olivleh1 Exp $ * */ @@ -165,6 +165,22 @@ main ( void ) } else { wdc_send_error(); } + /* if the specified drive exceeds the number of drives, no drive commands are allowed */ + } else if ( cmd_buffer[1] >= wdc_number_of_disks() + && ( cmd_buffer[0] == CMD_RD_SECTOR + || cmd_buffer[0] == CMD_FMTRD_TRACK + || cmd_buffer[0] == CMD_RD_BLOCK + || cmd_buffer[0] == CMD_WR_BLOCK + || cmd_buffer[0] == CMD_FMTBTT_TRACK + || cmd_buffer[0] == CMD_VER_TRACK + || ( cmd_buffer[0] == CMD_RD_BTTAB && !wdc_get_btt_cleared() ) + ) + ) { + if ( cmd_buffer[0] == CMD_RD_BTTAB ) { + wdc_send_errorcode ( ERR_BTT_INVALID ); + } else { + wdc_send_errorcode ( ERR_DRIVE_NOT_READY ); + } } else { switch ( cmd_buffer[0] ) { diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.h b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.h index 9954c46..32a2327 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.h +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.h @@ -26,7 +26,7 @@ */ /* - * $Id: wdc_main.h,v 1.14 2013/05/04 15:40:15 olivleh1 Exp $ + * $Id: wdc_main.h,v 1.15 2013/05/09 12:30:25 olivleh1 Exp $ */ #ifndef MAIN_H_ @@ -59,8 +59,10 @@ #define CMD_ST_PARBTT 0xc2 /* store Parameter block and BTT on hard disk */ #define ERR_STANDARD 0x01 +#define ERR_DRIVE_NOT_READY 0x03 #define ERR_SECT_N_ON_SURFACE 0x0A #define ERR_BTT_FULL 0x16 +#define ERR_BTT_INVALID 0x18 #define ERR_NO_DRIVE_READY 0x27 #define ERR_CYL0_NOT_READABLE 0x31 diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_par.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_par.c index bb099fa..d4c0d6e 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_par.c +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_par.c @@ -26,7 +26,7 @@ */ /* - * $Id: wdc_par.c,v 1.9 2013/05/04 15:40:15 olivleh1 Exp $ + * $Id: wdc_par.c,v 1.10 2013/05/09 12:30:25 olivleh1 Exp $ */ #include @@ -104,6 +104,7 @@ const uint8_t uint8_t valid_disk = 1; uint8_t initialized; +uint8_t btt_cleared = 0; void wdc_read_par_table ( uint8_t *buffer, uint16_t count ) { @@ -146,6 +147,7 @@ void wdc_del_wdc_btt () } par_table[122 + POS_PAR_WDC_BTT] = 0xff; + btt_cleared = 1; } void wdc_read_wdc_btt ( uint8_t *buffer, uint16_t count ) @@ -277,4 +279,9 @@ void wdc_set_initialized ( uint8_t num ) uint8_t wdc_get_initialized () { return initialized; +} + +uint8_t wdc_get_btt_cleared () +{ + return btt_cleared; } \ No newline at end of file diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_par.h b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_par.h index a1d2a4c..b765685 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_par.h +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_par.h @@ -26,7 +26,7 @@ */ /* - * $Id: wdc_par.h,v 1.6 2013/05/04 15:40:15 olivleh1 Exp $ + * $Id: wdc_par.h,v 1.7 2013/05/09 12:30:25 olivleh1 Exp $ */ #ifndef WDC_PAR_H_ @@ -52,6 +52,7 @@ extern void wdc_set_no_disk (); extern uint8_t wdc_get_num_of_drvs (); extern void wdc_set_initialized ( uint8_t num ); extern uint8_t wdc_get_initialized (); +extern uint8_t wdc_get_btt_cleared (); #define POS_PAR_VERSION 0 /* defines at which position in the PAR table the WDC version string starts */ #define POS_PAR_WDC_PAR 8 /* defines at which position in the PAR table the WDC parameter section starts */