-aponzi fixed 4kbit EEPROM support

-Removed some unnecessary code
-Reading/Writing of file has been disabled until it can be rewritten
This commit is contained in:
cyberwarriorx 2006-11-14 17:21:01 +00:00
parent b20ea3a201
commit 480c0cbcf1
3 changed files with 15 additions and 22 deletions

View File

@ -1,5 +1,4 @@
#include <stdlib.h> #include <stdlib.h>
#include "MMU.h"
#include "debug.h" #include "debug.h"
#include "types.h" #include "types.h"
#include "mc.h" #include "mc.h"
@ -60,13 +59,6 @@ u8 *mc_alloc(memory_chip_t *mc, u32 size)
u8 *buffer; u8 *buffer;
buffer = malloc(size); buffer = malloc(size);
//Experimental code
/*
if(size<MC_SIZE_64KBITS) mc->type=MC_TYPE_EEPROM1; mc->addr_size = 1;
else if((size>MC_SIZE_64KBITS)&&(size<=MC_SIZE_512KBITS)) mc->type=MC_TYPE_EEPROM2; mc->addr_size = 2;
else if((size>MC_SIZE_1MBITS)&&(size<MC_SIZE_64MBITS)) mc->type=MC_TYPE_FLASH; mc->addr_size = 3;
*/
if(!buffer) { return NULL; } if(!buffer) { return NULL; }
mc->data = buffer; mc->data = buffer;
mc->size = size; mc->size = size;
@ -84,11 +76,11 @@ void mc_reset_com(memory_chip_t *mc)
mc->com = 0; mc->com = 0;
} }
void mc_realloc(int type, u32 size) void mc_realloc(memory_chip_t *mc, int type, u32 size)
{ {
if(MMU.bupmem.data) free(MMU.bupmem.data); if(mc->data) free(mc->data);
mc_init(&MMU.bupmem, type); mc_init(mc, type);
mc_alloc(&MMU.bupmem, size); mc_alloc(mc, size);
} }
void mc_read_file(memory_chip_t *mc, char* filename) void mc_read_file(memory_chip_t *mc, char* filename)
@ -188,7 +180,7 @@ u8 fw_transfer(memory_chip_t *mc, u8 data)
u8 bm_transfer(memory_chip_t *mc, u8 data) u8 bm_transfer(memory_chip_t *mc, u8 data)
{ {
mc_read_file(mc,"test.sav"); // mc_read_file(mc,"test.sav");
if(mc->com == BM_CMD_READLOW || mc->com == BM_CMD_READHIGH || if(mc->com == BM_CMD_READLOW || mc->com == BM_CMD_READHIGH ||
mc->com == BM_CMD_WRITELOW || mc->com == BM_CMD_WRITEHIGH) /* check if we are in a command that needs multiple byte address */ mc->com == BM_CMD_WRITELOW || mc->com == BM_CMD_WRITEHIGH) /* check if we are in a command that needs multiple byte address */
{ {
@ -264,7 +256,7 @@ u8 bm_transfer(memory_chip_t *mc, u8 data)
case BM_CMD_WRITEHIGH: /* write command that's only available on ST M95040-W that I know of */ case BM_CMD_WRITEHIGH: /* write command that's only available on ST M95040-W that I know of */
if(mc->write_enable) if(mc->write_enable)
{ {
mc->addr = 0x1; mc->addr = 0x100;
mc->addr_shift = mc->addr_size; mc->addr_shift = mc->addr_size;
mc->com = BM_CMD_WRITELOW; mc->com = BM_CMD_WRITELOW;
} }
@ -272,9 +264,10 @@ u8 bm_transfer(memory_chip_t *mc, u8 data)
break; break;
case BM_CMD_READHIGH: /* read command that's only available on ST M95040-W that I know of */ case BM_CMD_READHIGH: /* read command that's only available on ST M95040-W that I know of */
mc->addr = 0x1; mc->addr = 0x100;
mc->addr_shift = mc->addr_size; mc->addr_shift = mc->addr_size;
mc->com = BM_CMD_READLOW; mc->com = BM_CMD_READLOW;
break; break;
default: default:
@ -283,7 +276,7 @@ u8 bm_transfer(memory_chip_t *mc, u8 data)
} }
} }
mc_write_file(mc,"test.sav"); // mc_write_file(mc,"test.sav");
return data; return data;
} }

View File

@ -44,7 +44,7 @@ typedef struct
void mc_init(memory_chip_t *mc, int type); /* reset and init values for memory struct */ void mc_init(memory_chip_t *mc, int type); /* reset and init values for memory struct */
u8 *mc_alloc(memory_chip_t *mc, u32 size); /* alloc mc memory */ u8 *mc_alloc(memory_chip_t *mc, u32 size); /* alloc mc memory */
void mc_realloc(int type, u32 size); /* realloc mc memory */ void mc_realloc(memory_chip_t *mc, int type, u32 size); /* realloc mc memory */
void mc_free(memory_chip_t *mc); /* delete mc memory */ void mc_free(memory_chip_t *mc); /* delete mc memory */
void mc_reset_com(memory_chip_t *mc); /* reset communication with mc */ void mc_reset_com(memory_chip_t *mc); /* reset communication with mc */
u8 fw_transfer(memory_chip_t *mc, u8 data); /* transfer to, then receive data from firmware */ u8 fw_transfer(memory_chip_t *mc, u8 data); /* transfer to, then receive data from firmware */

View File

@ -829,23 +829,23 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
case IDC_SAVETYPE1: case IDC_SAVETYPE1:
saver(MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED); saver(MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED);
mc_realloc(MC_TYPE_EEPROM1,MC_SIZE_4KBITS); mc_realloc(&MMU.bupmem, MC_TYPE_EEPROM1,MC_SIZE_4KBITS);
return 0; return 0;
case IDC_SAVETYPE2: case IDC_SAVETYPE2:
saver(MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED); saver(MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED);
mc_realloc(MC_TYPE_EEPROM2,MC_SIZE_64KBITS); mc_realloc(&MMU.bupmem, MC_TYPE_EEPROM2,MC_SIZE_64KBITS);
return 0; return 0;
case IDC_SAVETYPE3: case IDC_SAVETYPE3:
saver(MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED); saver(MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED);
mc_realloc(MC_TYPE_EEPROM2,MC_SIZE_512KBITS); mc_realloc(&MMU.bupmem, MC_TYPE_EEPROM2,MC_SIZE_512KBITS);
return 0; return 0;
case IDC_SAVETYPE4: case IDC_SAVETYPE4:
saver(MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED); saver(MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED);
mc_realloc(MC_TYPE_FRAM,MC_SIZE_256KBITS); mc_realloc(&MMU.bupmem, MC_TYPE_FRAM,MC_SIZE_256KBITS);
return 0; return 0;
case IDC_SAVETYPE5: case IDC_SAVETYPE5:
saver(MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED); saver(MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED);
mc_realloc(MC_TYPE_FLASH,MC_SIZE_2MBITS); mc_realloc(&MMU.bupmem, MC_TYPE_FLASH,MC_SIZE_2MBITS);
return 0; return 0;
case IDM_RESET: case IDM_RESET: