fix ENFORCE_SIZE to print "read from" / "write to"

Tue, 28 Dec 2010 18:58:51 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Tue, 28 Dec 2010 18:58:51 +0000
changeset 66
8ca92162fa89
parent 65
dc28926b353c
child 67
d6358bf2f5c2

fix ENFORCE_SIZE to print "read from" / "write to"

src/memory.c file | annotate | diff | revisions
     1.1 diff -r dc28926b353c -r 8ca92162fa89 src/memory.c
     1.2 --- a/src/memory.c	Tue Dec 28 18:36:39 2010 +0000
     1.3 +++ b/src/memory.c	Tue Dec 28 18:58:51 2010 +0000
     1.4 @@ -195,14 +195,24 @@
     1.5  /**
     1.6   * Issue a warning if a read operation is made with an invalid size
     1.7   */
     1.8 -inline static void ENFORCE_SIZE(int bits, uint32_t address, int allowed, char *regname)
     1.9 +inline static void ENFORCE_SIZE(int bits, uint32_t address, bool read, int allowed, char *regname)
    1.10  {
    1.11  	assert((bits == 8) || (bits == 16) || (bits == 32));
    1.12  	if ((bits & allowed) == 0) {
    1.13 -		printf("WARNING: write to 0x%08X (%s) with invalid size %d!\n", address, regname, bits);
    1.14 +		printf("WARNING: %s 0x%08X (%s) with invalid size %d!\n", read ? "read from" : "write to", address, regname, bits);
    1.15  	}
    1.16  }
    1.17  
    1.18 +inline static void ENFORCE_SIZE_R(int bits, uint32_t address, int allowed, char *regname)
    1.19 +{
    1.20 +	ENFORCE_SIZE(bits, address, true, allowed, regname);
    1.21 +}
    1.22 +
    1.23 +inline static void ENFORCE_SIZE_W(int bits, uint32_t address, int allowed, char *regname)
    1.24 +{
    1.25 +	ENFORCE_SIZE(bits, address, false, allowed, regname);
    1.26 +}
    1.27 +
    1.28  void IoWrite(uint32_t address, uint32_t data, int bits)/*{{{*/
    1.29  {
    1.30  	bool handled = false;
    1.31 @@ -228,7 +238,7 @@
    1.32  			case 0x050000:				// Phone status
    1.33  				break;
    1.34  			case 0x060000:				// DMA Count
    1.35 -				ENFORCE_SIZE(bits, address, 16, "DMACOUNT");
    1.36 +				ENFORCE_SIZE_W(bits, address, 16, "DMACOUNT");
    1.37  				state.dma_count = (data & 0x3FFF);
    1.38  				state.idmarw = ((data & 0x4000) == 0x4000);
    1.39  				state.dmaen = ((data & 0x8000) == 0x8000);
    1.40 @@ -272,7 +282,7 @@
    1.41  				}
    1.42  				break;
    1.43  			case 0x0A0000:				// Miscellaneous Control Register
    1.44 -				ENFORCE_SIZE(bits, address, 16, "MISCCON");
    1.45 +				ENFORCE_SIZE_W(bits, address, 16, "MISCCON");
    1.46  				// TODO: handle the ctrl bits properly
    1.47  				// TODO: &0x8000 --> dismiss 60hz intr
    1.48  				state.dma_reading = (data & 0x4000);
    1.49 @@ -303,7 +313,7 @@
    1.50  				handled = true;
    1.51  				break;
    1.52  			case 0x0E0000:				// Disk Control Register
    1.53 -				ENFORCE_SIZE(bits, address, 16, "DISKCON");
    1.54 +				ENFORCE_SIZE_W(bits, address, 16, "DISKCON");
    1.55  				// B7 = FDD controller reset
    1.56  				if ((data & 0x80) == 0) wd2797_reset(&state.fdc_ctx);
    1.57  				// B6 = drive 0 select -- TODO
    1.58 @@ -341,7 +351,7 @@
    1.59  					case 0x000000:		// [ef][08]xxxx ==> WD1010 hard disc controller
    1.60  						break;
    1.61  					case 0x010000:		// [ef][19]xxxx ==> WD2797 floppy disc controller
    1.62 -						ENFORCE_SIZE(bits, address, 16, "FDC REGISTERS");
    1.63 +						ENFORCE_SIZE_W(bits, address, 16, "FDC REGISTERS");
    1.64  						wd2797_write_reg(&state.fdc_ctx, (address >> 1) & 3, data);
    1.65  						handled = true;
    1.66  						break;
    1.67 @@ -354,28 +364,28 @@
    1.68  							case 0x040000:		// [ef][4c][08]xxx ==> EE
    1.69  								break;
    1.70  							case 0x041000:		// [ef][4c][19]xxx ==> PIE
    1.71 -								ENFORCE_SIZE(bits, address, 16, "PIE");
    1.72 +								ENFORCE_SIZE_W(bits, address, 16, "PIE");
    1.73  								state.pie = ((data & 0x8000) == 0x8000);
    1.74  								handled = true;
    1.75  								break;
    1.76  							case 0x042000:		// [ef][4c][2A]xxx ==> BP
    1.77  								break;
    1.78  							case 0x043000:		// [ef][4c][3B]xxx ==> ROMLMAP
    1.79 -								ENFORCE_SIZE(bits, address, 16, "ROMLMAP");
    1.80 +								ENFORCE_SIZE_W(bits, address, 16, "ROMLMAP");
    1.81  								state.romlmap = ((data & 0x8000) == 0x8000);
    1.82  								handled = true;
    1.83  								break;
    1.84  							case 0x044000:		// [ef][4c][4C]xxx ==> L1 MODEM
    1.85 -								ENFORCE_SIZE(bits, address, 16, "L1 MODEM");
    1.86 +								ENFORCE_SIZE_W(bits, address, 16, "L1 MODEM");
    1.87  								break;
    1.88  							case 0x045000:		// [ef][4c][5D]xxx ==> L2 MODEM
    1.89 -								ENFORCE_SIZE(bits, address, 16, "L2 MODEM");
    1.90 +								ENFORCE_SIZE_W(bits, address, 16, "L2 MODEM");
    1.91  								break;
    1.92  							case 0x046000:		// [ef][4c][6E]xxx ==> D/N CONNECT
    1.93 -								ENFORCE_SIZE(bits, address, 16, "D/N CONNECT");
    1.94 +								ENFORCE_SIZE_W(bits, address, 16, "D/N CONNECT");
    1.95  								break;
    1.96  							case 0x047000:		// [ef][4c][7F]xxx ==> Whole screen reverse video
    1.97 -								ENFORCE_SIZE(bits, address, 16, "WHOLE SCREEN REVERSE VIDEO");
    1.98 +								ENFORCE_SIZE_W(bits, address, 16, "WHOLE SCREEN REVERSE VIDEO");
    1.99  								break;
   1.100  						}
   1.101  					case 0x050000:		// [ef][5d]xxxx ==> 8274
   1.102 @@ -404,24 +414,24 @@
   1.103  		// I/O register space, zone A
   1.104  		switch (address & 0x0F0000) {
   1.105  			case 0x010000:				// General Status Register
   1.106 -				ENFORCE_SIZE(bits, address, 16, "GENSTAT");
   1.107 +				ENFORCE_SIZE_R(bits, address, 16, "GENSTAT");
   1.108  				return ((uint32_t)state.genstat << 16) + (uint32_t)state.genstat;
   1.109  				break;
   1.110  			case 0x030000:				// Bus Status Register 0
   1.111 -				ENFORCE_SIZE(bits, address, 16, "BSR0");
   1.112 +				ENFORCE_SIZE_R(bits, address, 16, "BSR0");
   1.113  				return ((uint32_t)state.bsr0 << 16) + (uint32_t)state.bsr0;
   1.114  				break;
   1.115  			case 0x040000:				// Bus Status Register 1
   1.116 -				ENFORCE_SIZE(bits, address, 16, "BSR1");
   1.117 +				ENFORCE_SIZE_R(bits, address, 16, "BSR1");
   1.118  				return ((uint32_t)state.bsr1 << 16) + (uint32_t)state.bsr1;
   1.119  				break;
   1.120  			case 0x050000:				// Phone status
   1.121 -				ENFORCE_SIZE(bits, address, 16, "PHONE STATUS");
   1.122 +				ENFORCE_SIZE_R(bits, address, 8 | 16, "PHONE STATUS");
   1.123  				break;
   1.124  			case 0x060000:				// DMA Count
   1.125  				// TODO: U/OERR- is always inactive (bit set)... or should it be = DMAEN+?
   1.126  				// Bit 14 is always unused, so leave it set
   1.127 -				ENFORCE_SIZE(bits, address, 16, "DMACOUNT");
   1.128 +				ENFORCE_SIZE_R(bits, address, 16, "DMACOUNT");
   1.129  				return (state.dma_count & 0x3fff) | 0xC000;
   1.130  				break;
   1.131  			case 0x070000:				// Line Printer Status Register
   1.132 @@ -500,7 +510,7 @@
   1.133  					case 0x000000:		// [ef][08]xxxx ==> WD1010 hard disc controller
   1.134  						break;
   1.135  					case 0x010000:		// [ef][19]xxxx ==> WD2797 floppy disc controller
   1.136 -						ENFORCE_SIZE(bits, address, 16, "FDC REGISTERS");
   1.137 +						ENFORCE_SIZE_R(bits, address, 16, "FDC REGISTERS");
   1.138  						return wd2797_read_reg(&state.fdc_ctx, (address >> 1) & 3);
   1.139  						break;
   1.140  					case 0x020000:		// [ef][2a]xxxx ==> Miscellaneous Control Register 2