diff --git a/apps/tzreset/tzreset.c b/apps/tzreset/tzreset.c index 4e6dddb..a175dd2 100644 --- a/apps/tzreset/tzreset.c +++ b/apps/tzreset/tzreset.c @@ -87,6 +87,7 @@ void usage(void) printf(" -h | --help This help text.\n"); printf(" -r | --reset Perform a hardware reset.\n"); printf(" -l | --load Reload the default ROMS.\n"); + printf(" -m | --memorymode Set the startup memory mode.\n"); printf("\nOptions:-\n"); printf(" -v | --verbose Output more messages.\n"); @@ -111,6 +112,7 @@ uint32_t app(uint32_t param1, uint32_t param2) int verbose_flag = 0; int opt; int option_index = 0; + uint8_t memoryMode = TZMM_ORIG; long val = 0; char *argv[20]; char *ptr = strtok((char *)param1, " "); @@ -137,6 +139,7 @@ uint32_t app(uint32_t param1, uint32_t param2) { {"help", no_argument, 0, 'h'}, {"load", no_argument, 0, 'l'}, + {"memorymode", required_argument, 0, 'm'}, {"reset", no_argument, 0, 'r'}, {"verbose", no_argument, 0, 'v'}, {0, 0, 0, 0} @@ -144,7 +147,7 @@ uint32_t app(uint32_t param1, uint32_t param2) // Parse the command line options. // - while((opt = getopt_long(argc, argv, ":hlrv", long_options, &option_index)) != -1) + while((opt = getopt_long(argc, argv, ":hlm:rv", long_options, &option_index)) != -1) { switch(opt) { @@ -156,6 +159,15 @@ uint32_t app(uint32_t param1, uint32_t param2) load_flag = 1; break; + case 'm': + if(xatoi(&argv[optind-1], &val) == 0 || val >= 0x20) + { + printf("Illegal numeric:%s\n", argv[optind-1]); + return(1); + } + memoryMode = (uint8_t)val; + break; + case 'r': reset_flag = 1; break; @@ -180,17 +192,16 @@ uint32_t app(uint32_t param1, uint32_t param2) return(0); } - // Initialise the IO. - //setupZ80Pins(1, G->millis); - - // Call the reset method to do the hard work. + // Reload the memory on the tranZPUter to boot default if load flag set. // - resetZ80(); - - // Reload the memory on the tranZPUter to boot default. if(load_flag) { loadTranZPUterDefaultROMS(); + } else + { + // Call the reset method to do the hard work. + // + resetZ80(memoryMode); } return(0); diff --git a/common/tranzputer.c b/common/tranzputer.c index bf52e94..55cc234 100644 --- a/common/tranzputer.c +++ b/common/tranzputer.c @@ -532,7 +532,7 @@ void setupZ80Pins(uint8_t initK64F, volatile uint32_t *millisecondTick) // Method to reset the Z80 CPU. // -void resetZ80(void) +void resetZ80(uint8_t memoryMode) { // Locals. // @@ -548,6 +548,13 @@ void resetZ80(void) pinInput(Z80_RESET); __enable_irq(); + // Set the memory mode to the one provided. + // + if(memoryMode != TZMM_ORIG) + { + setCtrlLatch(memoryMode); + } + // Wait a futher settling period before reinstating the interrupt. // while((*ms - startTime) < 400); @@ -2083,14 +2090,11 @@ void loadTranZPUterDefaultROMS(void) // if(!result) { - // Set the memory model to BOOT so we can bootstrap TZFS. - setCtrlLatch(TZMM_BOOT); - // If autoboot flag set, force a restart to the ROM which will call User ROM startup code. if(osControl.tzAutoBoot) { - delay(100); - fillZ80Memory(MZ_MROM_STACK_ADDR, MZ_MROM_STACK_SIZE, 0x00, 1); + // Set the memory model to BOOT so we can bootstrap TZFS. + resetZ80(TZMM_BOOT); } // No longer need refresh on the mainboard as all operations are in static RAM. @@ -3722,7 +3726,7 @@ void processServiceRequest(void) z80Control.disableRefresh = 0; // Now reset the machine so everything starts as power on. - resetZ80(); + resetZ80(TZMM_ORIG); // Disable the interrupts so no further service processing. disableIRQ(); @@ -3855,9 +3859,6 @@ void setupTranZPUter(void) // Check to see if autoboot is needed. osControl.tzAutoBoot = testTZFSAutoBoot(); - - // Ensure the machine is ready by performing a RESET. - resetZ80(); } ////////////////////////////////////////////////////////////// diff --git a/include/tranzputer.h b/include/tranzputer.h index 3b12993..29da0ae 100755 --- a/include/tranzputer.h +++ b/include/tranzputer.h @@ -41,7 +41,7 @@ #define RFSH_BYTE_CNT 256 // Number of bytes we can write before needing a full refresh for the DRAM. #define HOST_MON_TEST_VECTOR 0x4 // Address in the host monitor to test to identify host type. #define DEFAULT_BUSREQ_TIMEOUT 5000 // Timeout for a Z80 Bus request operation in milliseconds. -#define DEFAULT_RESET_PULSE_WIDTH 1000 // Pulse width of a reset signal in |K4F clock ticks. +#define DEFAULT_RESET_PULSE_WIDTH 80000 // Pulse width of a reset signal in K64F clock ticks. // tranZPUter Memory Modes - select one of the 32 possible memory models using these constants. // @@ -642,7 +642,7 @@ extern uint8_t pinMap[MAX_TRANZPUTER_PINS]; void yield(void); #endif void setupZ80Pins(uint8_t, volatile uint32_t *); -void resetZ80(void); +void resetZ80(uint8_t); uint8_t reqZ80Bus(uint32_t); uint8_t reqMainboardBus(uint32_t); uint8_t reqTranZPUterBus(uint32_t); diff --git a/libraries/lib/libimath2-k64f.a b/libraries/lib/libimath2-k64f.a index a5e750c..5c9b1ab 100644 Binary files a/libraries/lib/libimath2-k64f.a and b/libraries/lib/libimath2-k64f.a differ diff --git a/libraries/lib/libumansi-k64f.a b/libraries/lib/libumansi-k64f.a index 0a9f9cd..18d367a 100644 Binary files a/libraries/lib/libumansi-k64f.a and b/libraries/lib/libumansi-k64f.a differ diff --git a/libraries/lib/libummath-k64f.a b/libraries/lib/libummath-k64f.a index d96e7c6..a46cc14 100644 Binary files a/libraries/lib/libummath-k64f.a and b/libraries/lib/libummath-k64f.a differ diff --git a/libraries/lib/libummathf-k64f.a b/libraries/lib/libummathf-k64f.a index f6727c5..ec77e44 100644 Binary files a/libraries/lib/libummathf-k64f.a and b/libraries/lib/libummathf-k64f.a differ diff --git a/libraries/lib/libummisc-k64f.a b/libraries/lib/libummisc-k64f.a index b673787..2383c97 100644 Binary files a/libraries/lib/libummisc-k64f.a and b/libraries/lib/libummisc-k64f.a differ diff --git a/libraries/lib/libumstdio-k64f.a b/libraries/lib/libumstdio-k64f.a index 09ba09d..6a77f48 100644 Binary files a/libraries/lib/libumstdio-k64f.a and b/libraries/lib/libumstdio-k64f.a differ diff --git a/zOS/src/zOS.cpp b/zOS/src/zOS.cpp index d353c18..bfe1242 100644 --- a/zOS/src/zOS.cpp +++ b/zOS/src/zOS.cpp @@ -253,9 +253,6 @@ void tranZPUterControl(void) // if(isZ80Reset()) { - // Reset Z80 - This is to extend the reset signal to allow all the CPLD's/FPGA's to sync. - resetZ80(); - // Reload the memory on the tranZPUter to boot default. loadTranZPUterDefaultROMS();