diff --git a/debug.h b/debug.h index 932bbf9..e10ce33 100644 --- a/debug.h +++ b/debug.h @@ -26,13 +26,13 @@ // -------------- TOS debugging -------------- -#if 1 +#if 0 #define tos_debugf(...) iprintf(__VA_ARGS__) #else #define tos_debugf(...) #endif -#if 1 +#if 0 // ikbd debug output in red #define ikbd_debugf(a, ...) iprintf("\033[1;31mIKBD: " a "\033[0m\n", ##__VA_ARGS__) #else diff --git a/tos.c b/tos.c index 1d329a7..8407b56 100644 --- a/tos.c +++ b/tos.c @@ -93,7 +93,15 @@ static void hexdump(void *data, unsigned long size, unsigned long offset) { } } +static void mist_bus_request(char req) { + EnableFpga(); + SPI(req?MIST_BUS_REQ:MIST_BUS_REL); + DisableFpga(); +} + static void mist_memory_read(char *data, unsigned long words) { + mist_bus_request(1); + EnableFpga(); SPI(MIST_READ_MEMORY); @@ -105,6 +113,7 @@ static void mist_memory_read(char *data, unsigned long words) { DisableFpga(); + mist_bus_request(0); } static void mist_memory_read_block(char *data) { @@ -117,6 +126,8 @@ static void mist_memory_read_block(char *data) { } static void mist_memory_write(char *data, unsigned long words) { + mist_bus_request(1); + EnableFpga(); SPI(MIST_WRITE_MEMORY); @@ -126,6 +137,8 @@ static void mist_memory_write(char *data, unsigned long words) { } DisableFpga(); + + mist_bus_request(0); } static void mist_memory_write_block(char *data) { @@ -284,10 +297,6 @@ static void handle_fdc(unsigned char *buffer) { SPI(MIST_ACK_DMA); DisableFpga(); } - } else { - EnableFpga(); - SPI(MIST_NAK_DMA); - DisableFpga(); } } diff --git a/tos.h b/tos.h index 92a5829..59d72d4 100644 --- a/tos.h +++ b/tos.h @@ -13,7 +13,8 @@ #define MIST_SET_CONTROL 0x04 #define MIST_GET_DMASTATE 0x05 // reads state of dma and floppy controller #define MIST_ACK_DMA 0x06 // acknowledges a dma command -#define MIST_NAK_DMA 0x07 // don't acknowledge a dma command, but release bus +#define MIST_BUS_REQ 0x07 // request bus +#define MIST_BUS_REL 0x08 // release bus // tos sysconfig bits: // 0 - RESET