From 35cb20db0821da1d442bf79ec8596f435cc0ab17 Mon Sep 17 00:00:00 2001 From: Oliver Lehmann Date: Wed, 20 Jun 2012 18:58:24 +0000 Subject: [PATCH] rename mmc enable/disable function remove double declaration of _buffer vars for perf. measurement and normal usage --- .../P8000_WDC_Emulator/Makefile | 8 +-- .../P8000_WDC_Emulator/wdc_avr.c | 3 +- .../P8000_WDC_Emulator/wdc_avr.h | 8 ++- .../P8000_WDC_Emulator/wdc_config.h | 4 +- .../P8000_WDC_Emulator/wdc_drv_mmc.c | 50 +++++++++---------- .../P8000_WDC_Emulator/wdc_if_disk_perf.c | 12 +++-- .../P8000_WDC_Emulator/wdc_main.c | 17 +++---- 7 files changed, 48 insertions(+), 54 deletions(-) diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/Makefile b/P8000_WDC_Emulator/P8000_WDC_Emulator/Makefile index 46363c9..c80e68b 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/Makefile +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/Makefile @@ -4,22 +4,22 @@ MCU= -mmcu=atmega1284p CC=avr-gcc CFLAGS= -I/usr/local/avr/include -funsigned-char -funsigned-bitfields -O1 \ -ffunction-sections -fpack-struct -fshort-enums -Wall -Wundef \ - -Werror -pedantic -pedantic-errors -c -std=c99 ${MCU} + -Werror -pedantic -pedantic-errors -c ${MCU} LDFLAGS=-Wl,-Map="${OUTPUT_FILE}.map" -Wl,--start-group -Wl,-lm \ - -Wl,--end-group -Wl,--gc-sections -mrelax ${MCU} + -Wl,--end-group -Wl,--gc-sections ${MCU} RM := rm -rf OBJS += \ wdc_avr.o \ +wdc_drv_pata.o \ wdc_main.o \ wdc_drv_mmc.o \ -wdc_drv_pata.o \ +wdc_if_disk_perf.o \ uart.o \ wdc_if_p8000.o \ wdc_if_disk.o \ -wdc_if_disk_perf.o \ wdc_par.o \ wdc_ram.o diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.c index 4669099..a43b49e 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.c +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.c @@ -26,7 +26,7 @@ */ /* - * $Id: wdc_avr.c,v 1.3 2012/06/14 20:24:24 olivleh1 Exp $ + * $Id: wdc_avr.c,v 1.4 2012/06/20 18:58:24 olivleh1 Exp $ */ @@ -61,7 +61,6 @@ void wdc_init_avr() configure_pin_miso(); configure_pin_sck(); configure_pin_mosi(); - configure_pin_mmc_cs(); /* configure the ATA interface */ configure_ata_wr(); diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.h b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.h index 7f7aa8d..2227ede 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.h +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_avr.h @@ -26,7 +26,7 @@ */ /* - * $Id: wdc_avr.h,v 1.3 2012/06/14 20:24:24 olivleh1 Exp $ + * $Id: wdc_avr.h,v 1.4 2012/06/20 18:58:24 olivleh1 Exp $ */ @@ -61,6 +61,8 @@ #define disable_rdwrtoata() PORT_ADRDEC &= ~( 1 << PIN_ADRDEC_ADDR1 ) #define enable_atalatch() PORT_ADRDEC |= ( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 )) #define disable_atalatch() PORT_ADRDEC &= ~( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 )) +#define enable_mmc() PORT_ADRDEC |= ( 1 << PIN_ADRDEC_ADDR2 ); +#define disable_mmc() PORT_ADRDEC &= ~( 1 << PIN_ADRDEC_ADDR2 ); #define enable_sysconf() PORT_ADRDEC |= ( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 ) | ( 1 << PIN_ADRDEC_ADDR2 ) ) #define disable_sysconf() PORT_ADRDEC &= ~( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 ) | ( 1 << PIN_ADRDEC_ADDR2 ) ) @@ -68,10 +70,6 @@ #define configure_pin_miso() DDR_MMC &= ~ ( 1 << PIN_MMC_MISO ) #define configure_pin_sck() DDR_MMC |= ( 1 << PIN_MMC_SCK ) #define configure_pin_mosi() DDR_MMC |= ( 1 << PIN_MMC_MOSI ) -#define configure_pin_mmc_cs() DDR_MMC |= ( 1 << PIN_MMC_CS ) - -#define mmc_disable() PORT_MMC |= (1< @@ -187,13 +187,13 @@ uint8_t mmc_init () SPCR = ( 1 << SPE ) | ( 1 << MSTR ) | ( 1 << SPR0 ) | ( 1 << SPR1 ); /* Enable SPI, SPI in Master Mode */ SPSR = ( 0 << SPI2X ); - mmc_disable(); + disable_mmc(); for ( a = 0; a < 0x0f; a++ ) { send_dummy_byte(); } - mmc_enable(); + enable_mmc(); /* * send CMD0 @@ -206,7 +206,7 @@ uint8_t mmc_init () cmd[5] = 0x95; while ( mmc_cmd ( cmd ) != 1 ) { if ( t16++ > 1000 ) { - mmc_disable(); + disable_mmc(); return ( 1 ); } } @@ -251,7 +251,7 @@ uint8_t mmc_init () while ( mmc_cmd ( cmd ) != 0 ) { send_dummy_byte(); if ( t16++ > 1000 ) { - mmc_disable(); + disable_mmc(); return ( 2 ); } } @@ -266,7 +266,7 @@ uint8_t mmc_init () mmc_enable_crc ( 1 ); #endif - mmc_disable(); + disable_mmc(); return ( 0 ); } @@ -308,7 +308,7 @@ uint8_t mmc_write_sector ( uint32_t addr, uint8_t *buffer ) uint8_t crcl, crch; #endif - mmc_enable(); + enable_mmc(); wait_till_card_ready(); /* convert blocks to bytes */ @@ -325,7 +325,7 @@ uint8_t mmc_write_sector ( uint32_t addr, uint8_t *buffer ) */ tmp = mmc_cmd ( cmd ); if ( tmp != 0 ) { - mmc_disable(); + disable_mmc(); return ( tmp ); } @@ -361,11 +361,11 @@ uint8_t mmc_write_sector ( uint32_t addr, uint8_t *buffer ) /* check for errors */ send_dummy_byte(); if ( ( recv_byte() & 0x1F ) != 0x05 ) { - mmc_disable(); + disable_mmc(); return ( 2 ); } - mmc_disable(); + disable_mmc(); return ( 0 ); } @@ -378,12 +378,12 @@ uint8_t mmc_read_block ( uint8_t *cmd, uint8_t *buffer, uint16_t bytes ) uint16_t crc; #endif - mmc_enable(); + enable_mmc(); wait_till_card_ready(); /* send command */ if ( mmc_cmd ( cmd ) != 0 ) { - mmc_disable(); + disable_mmc(); return ( 1 ); } @@ -419,14 +419,14 @@ uint8_t mmc_read_block ( uint8_t *cmd, uint8_t *buffer, uint16_t bytes ) wait_till_send_done(); crc |= recv_byte(); if ( crc != crc16 ( buffer, bytes ) ) { - mmc_disable(); + disable_mmc(); return ( 3 ); } #else send_dummy_byte(); #endif - mmc_disable(); + disable_mmc(); return ( 0 ); } @@ -463,7 +463,7 @@ uint8_t mmc_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks uint16_t crc; #endif - mmc_enable(); + enable_mmc(); #ifdef MMC_MULTIBLOCK #ifdef MMC_PRESET_MULTIBLOCKCOUNT @@ -505,7 +505,7 @@ uint8_t mmc_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks */ resp = mmc_cmd ( cmd ); if ( resp > 1 ) { - mmc_disable(); + disable_mmc(); return ( 1 ); } #else @@ -526,7 +526,7 @@ uint8_t mmc_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks */ resp = mmc_cmd ( cmd ); if ( resp > 1 ) { - mmc_disable(); + disable_mmc(); return ( 1 ); } x.value32 += MMC_BLOCKLEN; @@ -559,7 +559,7 @@ uint8_t mmc_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks send_dummy_byte(); crc |= recv_byte(); if ( crc != crc16 ( buffer, MMC_BLOCKLEN ) ) { - mmc_disable(); + disable_mmc(); return ( 3 ); } buffer = buffer + MMC_BLOCKLEN; @@ -583,7 +583,7 @@ uint8_t mmc_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks /* TODO: Apacer Card I have sends 0x7f after some reads - No idea why - CRC was correct if ( resp > 1 ) { - mmc_disable(); + disable_mmc(); return ( 2 ); } */ @@ -591,7 +591,7 @@ uint8_t mmc_read_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks send_dummy_byte(); #endif - mmc_disable() + disable_mmc() return ( 0 ); } @@ -608,7 +608,7 @@ uint8_t mmc_write_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks uint8_t crcl, crch; #endif - mmc_enable(); + enable_mmc(); wait_till_card_ready(); #ifdef MMC_MULTIBLOCK #ifdef MMC_PRESET_MULTIBLOCKCOUNT @@ -646,7 +646,7 @@ uint8_t mmc_write_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks */ resp = mmc_cmd ( cmd ); if ( resp > 1 ) { - mmc_disable(); + disable_mmc(); return ( 1 ); } #else @@ -666,7 +666,7 @@ uint8_t mmc_write_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks */ resp = mmc_cmd ( cmd ); if ( resp != 0 ) { - mmc_disable(); + disable_mmc(); return ( resp ); } x.value32 += MMC_BLOCKLEN; @@ -716,7 +716,7 @@ uint8_t mmc_write_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks send_dummy_byte(); if ( ( recv_byte() & 0x1F ) != 0x05 ) { - mmc_disable(); + disable_mmc(); return ( 2 ); } @@ -736,7 +736,7 @@ uint8_t mmc_write_multiblock ( uint32_t addr, uint8_t *buffer, uint8_t numblocks /* Pad 8 */ send_dummy_byte(); #endif - mmc_disable(); + disable_mmc(); return ( 0 ); } diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk_perf.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk_perf.c index 1ff6351..0266216 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk_perf.c +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_if_disk_perf.c @@ -26,7 +26,7 @@ */ /* - * $Id: wdc_if_disk_perf.c,v 1.9 2012/06/17 16:40:42 olivleh1 Exp $ + * $Id: wdc_if_disk_perf.c,v 1.10 2012/06/20 18:58:24 olivleh1 Exp $ */ #include @@ -44,11 +44,15 @@ #ifdef MEASURE_DISK_PERFORMANCE #define BLOCKNO 300000 -extern uint32_t overflow; +volatile uint32_t overflow = 0; +ISR ( TIMER0_OVF_vect ) +{ + overflow ++; +} /* switched from local to global for keeping an eye on memory usage */ -uint8_t data_buffer[4096]; -uint8_t cmd_buffer[9]; +extern uint8_t data_buffer[]; +extern uint8_t cmd_buffer[]; void test_write4k ( uint8_t numblocks, uint8_t nr_of_tests ) diff --git a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.c b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.c index e78a0cd..6e74381 100644 --- a/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.c +++ b/P8000_WDC_Emulator/P8000_WDC_Emulator/wdc_main.c @@ -29,7 +29,7 @@ /* * P8000 WDC Emulator * - * $Id: wdc_main.c,v 1.29 2012/06/16 19:34:39 olivleh1 Exp $ + * $Id: wdc_main.c,v 1.30 2012/06/20 18:58:24 olivleh1 Exp $ * * TODO: - right now, BTT entries are not taken into account */ @@ -54,19 +54,14 @@ void atmega_setup ( void ); -#ifdef MEASURE_DISK_PERFORMANCE -extern void measure_performance(); -volatile uint32_t overflow = 0; -ISR ( TIMER0_OVF_vect ) -{ - overflow ++; -} -#else - -/* switched from local to global for keeping an eye on memory usage */ uint8_t data_buffer[4096]; uint8_t cmd_buffer[9]; +#ifdef MEASURE_DISK_PERFORMANCE +extern void measure_performance(); +#else + +/* switched from local to global for keeping an eye on memory usage */ extern uint8_t valid_disk; #endif