From a3386b4e41c850b4628394f2d1022bf9f4a7f566 Mon Sep 17 00:00:00 2001 From: Vincent Barrilliot Date: Sat, 11 Nov 2023 14:46:32 +0100 Subject: [PATCH] Avoid possible collision between our "log" function and the math function. Disabling all logging now seems to make the "backspace" bug disappear. --- src/boot.c | 8 ++-- src/cli/dos_cmds.c | 12 +++--- src/cli/mem_cmds.c | 20 +++++----- src/dev/channel.c | 2 +- src/dev/fdc.c | 82 ++++++++++++++++++++--------------------- src/dev/fsys.c | 10 ++--- src/dev/pata.c | 24 ++++++------ src/dev/ps2.c | 4 +- src/dev/rtc.c | 8 ++-- src/dev/sdc.c | 6 +-- src/dev/txt_a2560u.c | 25 +++---------- src/dev/uart.c | 14 +++---- src/fatfs/c256_diskio.c | 4 +- src/foenixmcp.c | 12 +++--- src/log.c | 10 ++--- src/log.h | 42 +++++++++++---------- src/proc.c | 4 +- 17 files changed, 138 insertions(+), 149 deletions(-) diff --git a/src/boot.c b/src/boot.c index a15cfc5..fdf05b5 100644 --- a/src/boot.c +++ b/src/boot.c @@ -396,14 +396,14 @@ void boot_from_bdev(short device) { case 0x0000: // Boot from IDE device = BDEV_HDC; - log(LOG_INFO, "Boot DIP set for IDE"); + logmsg(LOG_INFO, "Boot DIP set for IDE"); strcpy(initial_path, "/hd"); break; case 0x0001: // Boot from SDC device = BDEV_SDC; - log(LOG_INFO, "Boot DIP set for SDC"); + logmsg(LOG_INFO, "Boot DIP set for SDC"); strcpy(initial_path, "/sd"); break; @@ -411,13 +411,13 @@ void boot_from_bdev(short device) { case 0x0002: // Boot from Floppy device = BDEV_FDC; - log(LOG_INFO, "Boot DIP set for FDC"); + logmsg(LOG_INFO, "Boot DIP set for FDC"); strcpy(initial_path, "/fd"); break; #endif default: // Boot straight to REPL - log(LOG_INFO, "Boot DIP set for REPL"); + logmsg(LOG_INFO, "Boot DIP set for REPL"); strcpy(initial_path, "/sd"); device = -1; break; diff --git a/src/cli/dos_cmds.c b/src/cli/dos_cmds.c index 4e7d063..3ff2882 100644 --- a/src/cli/dos_cmds.c +++ b/src/cli/dos_cmds.c @@ -423,9 +423,9 @@ short cmd_type(short screen, int argc, const char * argv[]) { short n = chan_read(fd, buffer, 128); log_num(LOG_INFO, "cmd_type chan_read: ", n); if (n > 0) { - log(LOG_INFO, "cmd_type chan_write: "); + logmsg(LOG_INFO, "cmd_type chan_write: "); chan_write(screen, buffer, n); - log(LOG_INFO, "/cmd_type chan_write: "); + logmsg(LOG_INFO, "/cmd_type chan_write: "); } else { break; } @@ -439,7 +439,7 @@ short cmd_type(short screen, int argc, const char * argv[]) { return fd; } } else { - log(LOG_ERROR, "Usage: TYPE "); + logmsg(LOG_ERROR, "Usage: TYPE "); return -1; } } @@ -460,9 +460,9 @@ short cmd_load(short screen, int argc, const char * argv[]) { short result = fsys_load(argv[1], destination, &start); if (result == 0) { if (start != 0) { - log(LOG_INFO, "Loaded file with a start adddress."); + logmsg(LOG_INFO, "Loaded file with a start adddress."); } else { - log(LOG_INFO, "File loaded."); + logmsg(LOG_INFO, "File loaded."); } } else { err_print(screen, "Unable to open file", result); @@ -471,7 +471,7 @@ short cmd_load(short screen, int argc, const char * argv[]) { return result; } else { - log(LOG_ERROR, "Usage: LOAD []"); + logmsg(LOG_ERROR, "Usage: LOAD []"); return -1; } } diff --git a/src/cli/mem_cmds.c b/src/cli/mem_cmds.c index 003b811..21f5f21 100644 --- a/src/cli/mem_cmds.c +++ b/src/cli/mem_cmds.c @@ -37,13 +37,13 @@ short mem_cmd_dump(short channel, int argc, const char * argv[]) { return 0; } else { - log(LOG_ERROR, "USAGE: DUMP
"); + logmsg(LOG_ERROR, "USAGE: DUMP
"); return -1; } } void test_thunk() { - log(LOG_ERROR, "CALL is working."); + logmsg(LOG_ERROR, "CALL is working."); } /* @@ -83,11 +83,11 @@ short mem_cmd_dasm(short channel, int argc, const char * argv[]) { return 0; } else { - log(LOG_ERROR, "USAGE: DASM
"); + logmsg(LOG_ERROR, "USAGE: DASM
"); return -1; } #else - log(LOG_ERROR, "DASM only available on m68k machines"); + logmsg(LOG_ERROR, "DASM only available on m68k machines"); return -1; #endif @@ -108,7 +108,7 @@ short mem_cmd_poke8(short channel, int argc, const char * argv[]) { return 0; } else { - log(LOG_ERROR, "USAGE: POKE8
"); + logmsg(LOG_ERROR, "USAGE: POKE8
"); return -1; } } @@ -129,7 +129,7 @@ short mem_cmd_peek8(short channel, int argc, const char * argv[]) { return c; } else { - log(LOG_ERROR, "USAGE: PEEK8
"); + logmsg(LOG_ERROR, "USAGE: PEEK8
"); return -1; } } @@ -149,7 +149,7 @@ short mem_cmd_poke16(short channel, int argc, const char * argv[]) { return 0; } else { - log(LOG_ERROR, "USAGE: POKE16
"); + logmsg(LOG_ERROR, "USAGE: POKE16
"); return -1; } } @@ -169,7 +169,7 @@ short mem_cmd_peek16(short channel, int argc, const char * argv[]) { return c; } else { - log(LOG_ERROR, "USAGE: PEEK16
"); + logmsg(LOG_ERROR, "USAGE: PEEK16
"); return -1; } } @@ -189,7 +189,7 @@ short mem_cmd_poke32(short channel, int argc, const char * argv[]) { return 0; } else { - log(LOG_ERROR, "USAGE: POKE32
"); + logmsg(LOG_ERROR, "USAGE: POKE32
"); return -1; } } @@ -209,7 +209,7 @@ short mem_cmd_peek32(short channel, int argc, const char * argv[]) { return 0; } else { - log(LOG_ERROR, "USAGE: PEEK32
"); + logmsg(LOG_ERROR, "USAGE: PEEK32
"); return -1; } } diff --git a/src/dev/channel.c b/src/dev/channel.c index e28127f..1ae41fd 100644 --- a/src/dev/channel.c +++ b/src/dev/channel.c @@ -350,7 +350,7 @@ short chan_write(short channel, const uint8_t * buffer, short size) { p_channel chan; p_dev_chan cdev; short res; - log(LOG_TRACE,"chan_write(%d,%p,%x)", channel, buffer, (int)size); + logmsg(LOG_TRACE,"chan_write(%d,%p,%x)", channel, buffer, (int)size); res = chan_get_records(channel, &chan, &cdev); if (res == 0) diff --git a/src/dev/fdc.c b/src/dev/fdc.c index 2f8518c..ad957a3 100644 --- a/src/dev/fdc.c +++ b/src/dev/fdc.c @@ -252,7 +252,7 @@ short fdc_in(unsigned char *ptr) { long target_ticks = timers_jiffies() + fdc_timeout; while ((*FDC_MSR & FDC_MSR_RQM) != FDC_MSR_RQM) { if (timers_jiffies() >= target_ticks) { - log(LOG_ERROR, "fdc_in: timeout waiting for RQM"); + logmsg(LOG_ERROR, "fdc_in: timeout waiting for RQM"); return DEV_TIMEOUT; } } @@ -272,7 +272,7 @@ short fdc_out(unsigned char x) { long target_ticks = timers_jiffies() + fdc_timeout; while ((*FDC_MSR & FDC_MSR_RQM) != FDC_MSR_RQM) { if (timers_jiffies() >= target_ticks) { - log(LOG_ERROR, "fdc_out: timeout waiting for RQM"); + logmsg(LOG_ERROR, "fdc_out: timeout waiting for RQM"); return DEV_TIMEOUT; } } @@ -296,7 +296,7 @@ short fdc_motor_on() { if (fdc_wait_rqm()) { /* Got a timeout after trying to turn on the motor */ - log(LOG_ERROR, "fdc_motor_on timeout"); + logmsg(LOG_ERROR, "fdc_motor_on timeout"); return DEV_TIMEOUT; } @@ -384,13 +384,13 @@ short fdc_sense_interrupt_status(unsigned char *st0, unsigned char *pcn) { if (fdc_wait_while_busy()) { /* Timed out waiting for the FDC to be free */ - log(LOG_ERROR, "fdc_sense_interrupt_status: fdc_wait_while_busy timeout"); + logmsg(LOG_ERROR, "fdc_sense_interrupt_status: fdc_wait_while_busy timeout"); return DEV_TIMEOUT; } if (fdc_wait_write()) { /* Timed out waiting for permission to write a command byte */ - log(LOG_ERROR, "fdc_sense_interrupt_status: fdc_wait_write timeout"); + logmsg(LOG_ERROR, "fdc_sense_interrupt_status: fdc_wait_write timeout"); return DEV_TIMEOUT; } @@ -399,13 +399,13 @@ short fdc_sense_interrupt_status(unsigned char *st0, unsigned char *pcn) { if (fdc_wait_rqm()) { /* Timed out waiting to receive data */ - log(LOG_ERROR, "fdc_sense_interrupt_status: fdc_wait_rqm timeout 1"); + logmsg(LOG_ERROR, "fdc_sense_interrupt_status: fdc_wait_rqm timeout 1"); return DEV_TIMEOUT; } if (fdc_wait_read()) { /* Timed out waiting to receive data */ - log(LOG_ERROR, "fdc_sense_interrupt_status: fdc_wait_read timeout 1"); + logmsg(LOG_ERROR, "fdc_sense_interrupt_status: fdc_wait_read timeout 1"); return DEV_TIMEOUT; } @@ -415,13 +415,13 @@ short fdc_sense_interrupt_status(unsigned char *st0, unsigned char *pcn) { if (fdc_wait_rqm()) { /* Timed out waiting to receive data */ - log(LOG_ERROR, "fdc_sense_interrupt_status: fdc_wait_rqm timeout 1"); + logmsg(LOG_ERROR, "fdc_sense_interrupt_status: fdc_wait_rqm timeout 1"); return DEV_TIMEOUT; } if (fdc_wait_read()) { /* Timed out waiting for permission to transfer another byte */ - log(LOG_ERROR, "fdc_sense_interrupt_status: fdc_wait_read timeout 2"); + logmsg(LOG_ERROR, "fdc_sense_interrupt_status: fdc_wait_read timeout 2"); return DEV_TIMEOUT; } @@ -444,13 +444,13 @@ short fdc_specify() { if (fdc_wait_while_busy()) { /* Timed out waiting for the FDC to be free */ - log(LOG_ERROR, "fdc_specify: fdc_wait_while_busy timeout"); + logmsg(LOG_ERROR, "fdc_specify: fdc_wait_while_busy timeout"); return DEV_TIMEOUT; } if (fdc_wait_write() < 0) { /* Timed out waiting for permission to write a command byte */ - log(LOG_ERROR, "fdc_specify: fdc_wait_write timeout 1"); + logmsg(LOG_ERROR, "fdc_specify: fdc_wait_write timeout 1"); return DEV_TIMEOUT; } @@ -459,7 +459,7 @@ short fdc_specify() { if (fdc_wait_write() < 0) { /* Timed out waiting for permission to write a command byte */ - log(LOG_ERROR, "fdc_specify: fdc_wait_write timeout 2"); + logmsg(LOG_ERROR, "fdc_specify: fdc_wait_write timeout 2"); return DEV_TIMEOUT; } @@ -468,7 +468,7 @@ short fdc_specify() { if (fdc_wait_write() < 0) { /* Timed out waiting for permission to write a command byte */ - log(LOG_ERROR, "fdc_specify: fdc_wait_write timeout 3"); + logmsg(LOG_ERROR, "fdc_specify: fdc_wait_write timeout 3"); return DEV_TIMEOUT; } @@ -498,13 +498,13 @@ short fdc_configure() { if (fdc_wait_while_busy()) { /* Timed out waiting for the FDC to be free */ - log(LOG_ERROR, "fdc_configure: fdc_wait_while_busy timeout"); + logmsg(LOG_ERROR, "fdc_configure: fdc_wait_while_busy timeout"); return DEV_TIMEOUT; } if (fdc_wait_write()) { /* Timed out waiting for the FDC to be free */ - log(LOG_ERROR, "fdc_configure: fdc_wait_write timeout 1"); + logmsg(LOG_ERROR, "fdc_configure: fdc_wait_write timeout 1"); return DEV_TIMEOUT; } @@ -513,7 +513,7 @@ short fdc_configure() { if (fdc_wait_write()) { /* Timed out waiting for the FDC to be free */ - log(LOG_ERROR, "fdc_configure: fdc_wait_write timeout 2"); + logmsg(LOG_ERROR, "fdc_configure: fdc_wait_write timeout 2"); return DEV_TIMEOUT; } @@ -522,7 +522,7 @@ short fdc_configure() { if (fdc_wait_write()) { /* Timed out waiting for the FDC to be free */ - log(LOG_ERROR, "fdc_configure: fdc_wait_write timeout 3"); + logmsg(LOG_ERROR, "fdc_configure: fdc_wait_write timeout 3"); return DEV_TIMEOUT; } @@ -531,7 +531,7 @@ short fdc_configure() { if (fdc_wait_write()) { /* Timed out waiting for the FDC to be free */ - log(LOG_ERROR, "fdc_configure: fdc_wait_write timeout 4"); + logmsg(LOG_ERROR, "fdc_configure: fdc_wait_write timeout 4"); return DEV_TIMEOUT; } @@ -555,13 +555,13 @@ short fdc_version(unsigned char *version) { if (fdc_wait_while_busy()) { /* Timed out waiting for the FDC to be free */ - log(LOG_ERROR, "fdc_version: fdc_wait_while_busy timeout"); + logmsg(LOG_ERROR, "fdc_version: fdc_wait_while_busy timeout"); return DEV_TIMEOUT; } if (fdc_wait_write()) { /* Timed out waiting for the FDC to be free */ - log(LOG_ERROR, "fdc_version: fdc_wait_write timeout 1"); + logmsg(LOG_ERROR, "fdc_version: fdc_wait_write timeout 1"); return DEV_TIMEOUT; } @@ -570,7 +570,7 @@ short fdc_version(unsigned char *version) { if (fdc_wait_write()) { /* Timed out waiting for the FDC to be free */ - log(LOG_ERROR, "fdc_version: fdc_wait_write timeout 2"); + logmsg(LOG_ERROR, "fdc_version: fdc_wait_write timeout 2"); return DEV_TIMEOUT; } @@ -621,7 +621,7 @@ short fdc_reset() { pcn = 0; if (fdc_sense_interrupt_status(&st0, &pcn) < 0) { /* Time out on sense interrupt */ - log(LOG_ERROR, "fdc_sense_interrupt_status timeout"); + logmsg(LOG_ERROR, "fdc_sense_interrupt_status timeout"); return DEV_TIMEOUT; } @@ -636,14 +636,14 @@ short fdc_reset() { /* Configure the FDC */ if (fdc_configure() < 0) { /* Timeout on sense interrupt */ - log(LOG_ERROR, "fdc_configure timeout"); + logmsg(LOG_ERROR, "fdc_configure timeout"); return DEV_TIMEOUT; } /* Specify seek and head times, and turn off DMA */ if (fdc_specify() < 0) { /* Timeout on sense interrupt */ - log(LOG_ERROR, "fdc_specify timeout"); + logmsg(LOG_ERROR, "fdc_specify timeout"); return DEV_TIMEOUT; } @@ -698,19 +698,19 @@ short fdc_command_dma(p_fdc_trans transaction) { if (fdc_wait_while_busy()) { /* Timed out waiting for the FDC to be free */ - log(LOG_ERROR, "fdc_command: fdc_wait_while_busy timeout"); + logmsg(LOG_ERROR, "fdc_command: fdc_wait_while_busy timeout"); return DEV_TIMEOUT; } result = fdc_out(transaction->command); /* Send the command byte */ if (result < 0) { - log(LOG_ERROR, "fdc_command: timeout sending command"); + logmsg(LOG_ERROR, "fdc_command: timeout sending command"); return result; } for (i = 0; i < transaction->parameter_count; i++) { if ((result = fdc_out(transaction->parameters[i])) < 0) { - log(LOG_ERROR, "fdc_command: timeout sending parameters"); + logmsg(LOG_ERROR, "fdc_command: timeout sending parameters"); return result; } } @@ -749,7 +749,7 @@ short fdc_command_dma(p_fdc_trans transaction) { for (i = 0; i < transaction->result_count; i++) { if ((result = fdc_in(&transaction->results[i])) < 0) { - log(LOG_ERROR, "fdc_command: timeout getting results"); + logmsg(LOG_ERROR, "fdc_command: timeout getting results"); return result; } } @@ -788,19 +788,19 @@ short fdc_command(p_fdc_trans transaction) { if (fdc_wait_while_busy()) { /* Timed out waiting for the FDC to be free */ - log(LOG_ERROR, "fdc_command: fdc_wait_while_busy timeout"); + logmsg(LOG_ERROR, "fdc_command: fdc_wait_while_busy timeout"); return DEV_TIMEOUT; } result = fdc_out(transaction->command); /* Send the command byte */ if (result < 0) { - log(LOG_ERROR, "fdc_command: timeout sending command"); + logmsg(LOG_ERROR, "fdc_command: timeout sending command"); return result; } for (i = 0; i < transaction->parameter_count; i++) { if ((result = fdc_out(transaction->parameters[i])) < 0) { - log(LOG_ERROR, "fdc_command: timeout sending parameters"); + logmsg(LOG_ERROR, "fdc_command: timeout sending parameters"); return result; } } @@ -815,7 +815,7 @@ short fdc_command(p_fdc_trans transaction) { if (*FDC_MSR & FDC_MSR_NONDMA) { for (i = 0; (i < transaction->data_count); i++) { if ((result = fdc_out(transaction->data[i])) < 0) { - log(LOG_ERROR, "fdc_command: timeout writing data"); + logmsg(LOG_ERROR, "fdc_command: timeout writing data"); return result; } } @@ -826,7 +826,7 @@ short fdc_command(p_fdc_trans transaction) { /* We're reading from the FDC */ for (i = 0; (i < transaction->data_count); i++) { if ((result = fdc_in(&transaction->data[i])) < 0) { - log(LOG_ERROR, "fdc_command: timeout getting data"); + logmsg(LOG_ERROR, "fdc_command: timeout getting data"); return result; } } @@ -842,7 +842,7 @@ short fdc_command(p_fdc_trans transaction) { for (i = 0; i < transaction->result_count; i++) { if ((result = fdc_in(&transaction->results[i])) < 0) { - log(LOG_ERROR, "fdc_command: timeout getting results"); + logmsg(LOG_ERROR, "fdc_command: timeout getting results"); return result; } } @@ -1067,12 +1067,12 @@ short fdc_read(long lba, unsigned char * buffer, short size) { if ((result == 0)) { //} && ((trans.results[0] & 0xC0) == 0)) { sprintf(message, "fdc_read: success? ST0=%02X ST1=%02X ST2=%02X C=%02X H=%02X R=%02X N=%02X", trans.results[0], trans.results[1], trans.results[2], trans.results[3], trans.results[4], trans.results[5], trans.results[6]); - log(LOG_INFO, message); + logmsg(LOG_INFO, message); return size; } else { sprintf(message, "fdc_read: retry ST0=%02X ST1=%02X ST2=%02X C=%02X H=%02X R=%02X N=%02X", trans.results[0], trans.results[1], trans.results[2], trans.results[3], trans.results[4], trans.results[5], trans.results[6]); - log(LOG_ERROR, message); + logmsg(LOG_ERROR, message); } fdc_init(); trans.retries--; @@ -1135,7 +1135,7 @@ short fdc_write(long lba, const unsigned char * buffer, short size) { } if ((trans.results[1] & 0x02) != 0) { - log(LOG_ERROR, "Disk is write protected"); + logmsg(LOG_ERROR, "Disk is write protected"); g_fdc_stat |= FDC_STAT_PROTECTED; return DEV_WRITEPROT; } @@ -1143,12 +1143,12 @@ short fdc_write(long lba, const unsigned char * buffer, short size) { if ((result == 0)) { //} && ((trans.results[0] & 0xC0) == 0)) { sprintf(message, "fdc_write: success? ST0=%02X ST1=%02X ST2=%02X C=%02X H=%02X R=%02X N=%02X", trans.results[0], trans.results[1], trans.results[2], trans.results[3], trans.results[4], trans.results[5], trans.results[6]); - log(LOG_INFO, message); + logmsg(LOG_INFO, message); return size; } else { sprintf(message, "fdc_write: retry ST0=%02X ST1=%02X ST2=%02X C=%02X H=%02X R=%02X N=%02X", trans.results[0], trans.results[1], trans.results[2], trans.results[3], trans.results[4], trans.results[5], trans.results[6]); - log(LOG_ERROR, message); + logmsg(LOG_ERROR, message); } fdc_init(); trans.retries--; @@ -1228,13 +1228,13 @@ short fdc_ioctrl(short command, unsigned char * buffer, short size) { */ short fdc_init() { if (fdc_reset() < 0) { - log(LOG_ERROR, "Unable to reset the FDC"); + logmsg(LOG_ERROR, "Unable to reset the FDC"); return DEV_TIMEOUT; } // Recalibrate the drive if (fdc_recalibrate()) { - log(LOG_ERROR, "Unable to recalibrate the drive"); + logmsg(LOG_ERROR, "Unable to recalibrate the drive"); return ERR_GENERAL; } diff --git a/src/dev/fsys.c b/src/dev/fsys.c index f28c641..a3f3fa0 100644 --- a/src/dev/fsys.c +++ b/src/dev/fsys.c @@ -615,7 +615,7 @@ short fchan_read(t_channel * chan, unsigned char * buffer, short size) { FRESULT result; int total_read; - log(LOG_TRACE, "fchan_read"); + logmsg(LOG_TRACE, "fchan_read"); file = fchan_to_file(chan); if (file) { @@ -660,7 +660,7 @@ short fchan_read_b(t_channel * chan) { short total_read; char buffer[2]; - log(LOG_TRACE, "fchan_read_b"); + logmsg(LOG_TRACE, "fchan_read_b"); file = fchan_to_file(chan); if (file) { @@ -1339,11 +1339,11 @@ static short fsys_load_ext(const char * path, const char * extension, long desti if (loader == 0) { if (destination != 0) { /* If a destination was specified, just load it into memory without interpretation */ - log(LOG_DEBUG, "Setting default loader."); + logmsg(LOG_DEBUG, "Setting default loader."); loader = fsys_default_loader; } else { - log(LOG_DEBUG, "Returning a bad extension."); + logmsg(LOG_DEBUG, "Returning a bad extension."); /* Return bad extension */ return ERR_BAD_EXTENSION; } @@ -1443,7 +1443,7 @@ short fsys_load(const char * path, long destination, long * start) { // Found path with valid loader fsys_load_ext(spath, extension, destination, start); } else { - log(LOG_ERROR, "Command not found."); + logmsg(LOG_ERROR, "Command not found."); return ERR_NOT_FOUND; } } diff --git a/src/dev/pata.c b/src/dev/pata.c index 338088d..00d72e5 100644 --- a/src/dev/pata.c +++ b/src/dev/pata.c @@ -51,7 +51,7 @@ short pata_wait_not_busy() { } while ((status & PATA_STAT_BSY) && (target_ticks > ticks)); if (target_ticks <= ticks) { - log(LOG_ERROR, "pata_wait_not_busy: timeout"); + logmsg(LOG_ERROR, "pata_wait_not_busy: timeout"); log_num(LOG_ERROR, "target_ticks: ", (int)target_ticks); log_num(LOG_ERROR, "ticks: ", (int)ticks); return DEV_TIMEOUT; @@ -80,7 +80,7 @@ short pata_wait_ready() { } while (((status & PATA_STAT_DRDY) == 0) && (target_ticks > ticks)); if (target_ticks <= ticks) { - log(LOG_ERROR, "pata_wait_ready: timeout"); + logmsg(LOG_ERROR, "pata_wait_ready: timeout"); return DEV_TIMEOUT; } else { return 0; @@ -112,7 +112,7 @@ short pata_wait_ready_not_busy() { } while (((*PATA_CMD_STAT & PATA_STAT_BSY) == PATA_STAT_BSY) && (target_ticks > ticks)); if (target_ticks <= ticks) { - log(LOG_ERROR, "pata_wait_ready_not_busy: timeout"); + logmsg(LOG_ERROR, "pata_wait_ready_not_busy: timeout"); log_num(LOG_ERROR, "target_ticks: ", (int)target_ticks); log_num(LOG_ERROR, "ticks: ", (int)ticks); @@ -142,7 +142,7 @@ short pata_wait_data_request() { } while (((status & PATA_STAT_DRQ) != PATA_STAT_DRQ) && (target_ticks > ticks)); if (target_ticks <= ticks) { - log(LOG_ERROR, "pata_wait_data_request: timeout"); + logmsg(LOG_ERROR, "pata_wait_data_request: timeout"); return DEV_TIMEOUT; } else { return 0; @@ -354,12 +354,12 @@ short pata_flush_cache() { status = *PATA_CMD_STAT; if ((status & PATA_STAT_DF) != 0){ - log(LOG_ERROR, "pata_flush_cache: device fault"); + logmsg(LOG_ERROR, "pata_flush_cache: device fault"); return -1; } if ((status & PATA_STAT_ERR) != 0) { - log(LOG_ERROR, "pata_flush_cache: error"); + logmsg(LOG_ERROR, "pata_flush_cache: error"); return -1; } @@ -390,7 +390,7 @@ short pata_write(long lba, const unsigned char * buffer, short size) { if (pata_wait_ready_not_busy()) { /* Turn off the HDD LED */ ind_set(IND_HDC, IND_OFF); - log(LOG_ERROR, "pata_write: pata_wait_ready_not_busy timeout 1"); + logmsg(LOG_ERROR, "pata_write: pata_wait_ready_not_busy timeout 1"); return DEV_TIMEOUT; } @@ -399,7 +399,7 @@ short pata_write(long lba, const unsigned char * buffer, short size) { if (pata_wait_ready_not_busy()) { /* Turn off the HDD LED */ ind_set(IND_HDC, IND_OFF); - log(LOG_ERROR, "pata_write: pata_wait_ready_not_busy timeout 2"); + logmsg(LOG_ERROR, "pata_write: pata_wait_ready_not_busy timeout 2"); return DEV_TIMEOUT; } @@ -417,7 +417,7 @@ short pata_write(long lba, const unsigned char * buffer, short size) { if (pata_wait_ready_not_busy()) { /* Turn off the HDD LED */ ind_set(IND_HDC, IND_OFF); - log(LOG_ERROR, "pata_write: pata_wait_ready_not_busy timeout 3"); + logmsg(LOG_ERROR, "pata_write: pata_wait_ready_not_busy timeout 3"); return DEV_TIMEOUT; } @@ -432,7 +432,7 @@ short pata_write(long lba, const unsigned char * buffer, short size) { if (pata_wait_ready_not_busy()) { /* Turn off the HDD LED */ ind_set(IND_HDC, IND_OFF); - log(LOG_ERROR, "pata_write: pata_wait_ready_not_busy timeout 4"); + logmsg(LOG_ERROR, "pata_write: pata_wait_ready_not_busy timeout 4"); return DEV_TIMEOUT; } @@ -441,7 +441,7 @@ short pata_write(long lba, const unsigned char * buffer, short size) { status = *PATA_CMD_STAT; if ((status & PATA_STAT_DF) != 0){ - log(LOG_ERROR, "pata_write: device fault"); + logmsg(LOG_ERROR, "pata_write: device fault"); /* Turn off the HDD LED */ ind_set(IND_HDC, IND_OFF); @@ -450,7 +450,7 @@ short pata_write(long lba, const unsigned char * buffer, short size) { } if ((status & PATA_STAT_ERR) != 0) { - log(LOG_ERROR, "pata_write: error"); + logmsg(LOG_ERROR, "pata_write: error"); /* Turn off the HDD LED */ ind_set(IND_HDC, IND_OFF); diff --git a/src/dev/ps2.c b/src/dev/ps2.c index 89519e9..a1cba91 100644 --- a/src/dev/ps2.c +++ b/src/dev/ps2.c @@ -335,7 +335,7 @@ const char g_us_sc_alt_shift[] = { short ps2_wait_out() { long target_ticks; - // log(LOG_TRACE, "ps2_wait_out"); + // logmsg(LOG_TRACE, "ps2_wait_out"); target_ticks = rtc_get_jiffies() + PS2_TIMEOUT_JF; while ((*PS2_STATUS & PS2_STAT_OBF) == 0) { @@ -356,7 +356,7 @@ short ps2_wait_out() { short ps2_wait_in() { long target_ticks; - // log(LOG_TRACE, "ps2_wait_in"); + // logmsg(LOG_TRACE, "ps2_wait_in"); target_ticks = rtc_get_jiffies() + PS2_TIMEOUT_JF; while ((*PS2_STATUS & PS2_STAT_IBF) != 0) { diff --git a/src/dev/rtc.c b/src/dev/rtc.c index b41c944..01a899c 100644 --- a/src/dev/rtc.c +++ b/src/dev/rtc.c @@ -138,7 +138,7 @@ void rtc_set_time(p_time time) { /* Temporarily disable updates to the clock */ ctrl = *RTC_CTRL; *RTC_CTRL = ctrl | RTC_UTI; - log(LOG_INFO, "RTC Disabled"); + logmsg(LOG_INFO, "RTC Disabled"); log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); log_num(LOG_INFO, "RTC Flags: ", *RTC_FLAGS); @@ -178,7 +178,7 @@ void rtc_set_time(p_time time) { /* Re-enable updates to the clock */ *RTC_CTRL = (ctrl & 0x07) | RTC_STOP; - log(LOG_INFO, "RTC Enabled"); + logmsg(LOG_INFO, "RTC Enabled"); log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); log_num(LOG_INFO, "RTC Flags: ", *RTC_FLAGS); @@ -199,7 +199,7 @@ void rtc_get_time(p_time time) { /* Temporarily disable updates to the clock */ ctrl = *RTC_CTRL; *RTC_CTRL = ctrl | RTC_UTI; - log(LOG_INFO, "RTC Disabled"); + logmsg(LOG_INFO, "RTC Disabled"); log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); log_num(LOG_INFO, "RTC Flags: ", *RTC_FLAGS); @@ -221,7 +221,7 @@ void rtc_get_time(p_time time) { /* Re-enable updates to the clock */ *RTC_CTRL = (ctrl & 0x07) | RTC_STOP; - log(LOG_INFO, "RTC Enabled"); + logmsg(LOG_INFO, "RTC Enabled"); log_num(LOG_INFO, "RTC Rates: ", *RTC_RATES); log_num(LOG_INFO, "RTC Enables: ", *RTC_ENABLES); log_num(LOG_INFO, "RTC Flags: ", *RTC_FLAGS); diff --git a/src/dev/sdc.c b/src/dev/sdc.c index c85a80c..f03b861 100644 --- a/src/dev/sdc.c +++ b/src/dev/sdc.c @@ -121,18 +121,18 @@ short sdc_init() { if (sdc_wait_busy() == 0) { // Wait for it to complete g_sdc_error = *SDC_TRANS_ERROR_REG; // Check for any error condition if (g_sdc_error == 0) { - log(LOG_INFO, "sdc_init: SUCCESS"); + logmsg(LOG_INFO, "sdc_init: SUCCESS"); g_sdc_status = 0; // Flag that the SD has been initialized return 0; } else { - log(LOG_ERROR, "sdc_init: DEV_CANNOT_INIT"); + logmsg(LOG_ERROR, "sdc_init: DEV_CANNOT_INIT"); g_sdc_status = SDC_STAT_NOINIT; return DEV_CANNOT_INIT; } } else { - log(LOG_ERROR, "sdc_init: DEV_TIMEOUT"); + logmsg(LOG_ERROR, "sdc_init: DEV_TIMEOUT"); g_sdc_status = SDC_STAT_NOINIT; return DEV_TIMEOUT; } diff --git a/src/dev/txt_a2560u.c b/src/dev/txt_a2560u.c index c309909..e9f31c1 100644 --- a/src/dev/txt_a2560u.c +++ b/src/dev/txt_a2560u.c @@ -172,11 +172,7 @@ static short txt_a2560u_set_resolution(short width, short height) { } } -{ - char msg[80]; - sprintf(msg, "Setting resolution %dx%d", width, height); - DEBUG(msg); -} + DEBUG2("Setting resolution %dx%d", width, height); /* Turn off resolution bits */ /* TODO: there gotta be a better way to do that */ @@ -239,7 +235,7 @@ static void txt_a2560u_set_border(short width, short height) { } // Recalculate the size of the screen - txt_a2560u_set_sizes(); + txt_a2560u_set_sizes(); } /** @@ -321,11 +317,7 @@ static short txt_a2560u_get_region(p_rect region) { region->size.width = a2560u_region.size.width; region->size.height = a2560u_region.size.height; - { - char msg[80]; - sprintf(msg,"txt_a2560u_get_region %p: x:%d, y:%d, w:%d, h:%d", region, region->origin.x, region->origin.y, region->size.width, region->size.height); - DEBUG(msg); - } + DEBUG5("txt_a2560u_get_region %p: x:%d, y:%d, w:%d, h:%d", region, region->origin.x, region->origin.y, region->size.width, region->size.height); return 0; } @@ -339,10 +331,7 @@ static short txt_a2560u_get_region(p_rect region) { * @return 0 on success, any other number means the region was invalid */ static short txt_a2560u_set_region(const p_rect region) { - char msg[80]; - sprintf(msg,"SET REGION %p x:%d, y:%d, w:%d, h:%d (visible:%d,%d)", - region, region->origin.x, region->origin.y, region->size.width, region->size.height, a2560u_visible_size.width, a2560u_visible_size.height); - DEBUG(msg); + DEBUG7("SET REGION %p x:%d, y:%d, w:%d, h:%d (visible:%d,%d)", region, region->origin.x, region->origin.y, region->size.width, region->size.height, a2560u_visible_size.width, a2560u_visible_size.height); if ((region->size.width == 0) || (region->size.height == 0)) { /* Set the region to the default (full screen) */ @@ -360,11 +349,7 @@ static short txt_a2560u_set_region(const p_rect region) { //DEBUG(msg); } - { - sprintf(msg,"txt_a2560u_set_region: NEW REGION %p x:%d, y:%d, w:%d, h:%d (visible:%d,%d)", - region, region->origin.x, region->origin.y, region->size.width, region->size.height, a2560u_visible_size.width, a2560u_visible_size.height); - //DEBUG(msg); - } + DEBUG7("txt_a2560u_set_region: NEW REGION %p x:%d, y:%d, w:%d, h:%d (visible:%d,%d)", region, region->origin.x, region->origin.y, region->size.width, region->size.height, a2560u_visible_size.width, a2560u_visible_size.height); return 0; } diff --git a/src/dev/uart.c b/src/dev/uart.c index 2991340..2ff72e2 100644 --- a/src/dev/uart.c +++ b/src/dev/uart.c @@ -297,7 +297,7 @@ short uart_open(p_channel chan, const char * spec, short mode) { break; default: - log(LOG_ERROR, "uart_open: Bad data word length"); + logmsg(LOG_ERROR, "uart_open: Bad data word length"); return ERR_BAD_ARGUMENT; } @@ -311,7 +311,7 @@ short uart_open(p_channel chan, const char * spec, short mode) { } else if (i == 2) { lcr_code |= LCR_STOPBIT_2; } else { - log(LOG_ERROR, "uart_open: Bad stop bits"); + logmsg(LOG_ERROR, "uart_open: Bad stop bits"); return ERR_BAD_ARGUMENT; } @@ -330,7 +330,7 @@ short uart_open(p_channel chan, const char * spec, short mode) { } else if (strcmp(token, "SPACE") == 0) { lcr_code |= LCR_PARITY_SPACE; } else { - log(LOG_ERROR, "uart_open: Bad parity"); + logmsg(LOG_ERROR, "uart_open: Bad parity"); return ERR_BAD_ARGUMENT; } @@ -339,19 +339,19 @@ short uart_open(p_channel chan, const char * spec, short mode) { return 0; } else { - log(LOG_ERROR, "uart_open: no parity token"); + logmsg(LOG_ERROR, "uart_open: no parity token"); return ERR_BAD_ARGUMENT; } } else { - log(LOG_ERROR, "uart_open: no stop bit token"); + logmsg(LOG_ERROR, "uart_open: no stop bit token"); return ERR_BAD_ARGUMENT; } } else { - log(LOG_ERROR, "uart_open: no data length token"); + logmsg(LOG_ERROR, "uart_open: no data length token"); return ERR_BAD_ARGUMENT; } } else { - log(LOG_ERROR, "uart_open: no BPS token"); + logmsg(LOG_ERROR, "uart_open: no BPS token"); return ERR_BAD_ARGUMENT; } diff --git a/src/fatfs/c256_diskio.c b/src/fatfs/c256_diskio.c index ffba134..6735b02 100644 --- a/src/fatfs/c256_diskio.c +++ b/src/fatfs/c256_diskio.c @@ -78,10 +78,10 @@ DRESULT disk_read ( if (result < 0) { log_num(LOG_ERROR, "disk_read error: ", result); if (result == ERR_MEDIA_CHANGE) { - log(LOG_ERROR, "disk changed."); + logmsg(LOG_ERROR, "disk changed."); return RES_NOTRDY; } else { - log(LOG_ERROR, "gerneral error"); + logmsg(LOG_ERROR, "gerneral error"); return RES_PARERR; } } else { diff --git a/src/foenixmcp.c b/src/foenixmcp.c index 8e1ca33..f05d317 100644 --- a/src/foenixmcp.c +++ b/src/foenixmcp.c @@ -460,14 +460,14 @@ void initialize() { if ((res = ps2_init())) { print_error(0, "FAILED: PS/2 keyboard initialization", res); } else { - log(LOG_INFO, "PS/2 keyboard initialized."); + logmsg(LOG_INFO, "PS/2 keyboard initialized."); } #if MODEL == MODEL_FOENIX_A2560K if ((res = kbdmo_init())) { log_num(LOG_ERROR, "FAILED: A2560K built-in keyboard initialization", res); } else { - log(LOG_INFO, "A2560K built-in keyboard initialized."); + logmsg(LOG_INFO, "A2560K built-in keyboard initialized."); } #endif @@ -475,7 +475,7 @@ void initialize() { if ((res = lpt_install())) { log_num(LOG_ERROR, "FAILED: LPT installation", res); } else { - log(LOG_INFO, "LPT installed."); + logmsg(LOG_INFO, "LPT installed."); } #endif @@ -483,14 +483,14 @@ void initialize() { if ((res = midi_install())) { log_num(LOG_ERROR, "FAILED: MIDI installation", res); } else { - log(LOG_INFO, "MIDI installed."); + logmsg(LOG_INFO, "MIDI installed."); } #endif if (res = uart_install()) { log_num(LOG_ERROR, "FAILED: serial port initialization", res); } else { - log(LOG_INFO, "Serial ports initialized."); + logmsg(LOG_INFO, "Serial ports initialized."); } if (res = cli_init()) { @@ -525,7 +525,7 @@ TRACE1("Booting from device %d",boot_dev); // Start the boot process boot_from_bdev(boot_dev); - log(LOG_INFO, "Stopping."); + logmsg(LOG_INFO, "Stopping."); #elif MODEL == MODEL_FOENIX_C256U || MODEL == MODEL_FOENIX_C256U_PLUS || MODEL == MODEL_FOENIX_FMX printf("\n\nSDC directory:\n"); int directory = fsys_opendir("/sd/"); diff --git a/src/log.c b/src/log.c index c08ebc5..f14010b 100644 --- a/src/log.c +++ b/src/log.c @@ -290,7 +290,7 @@ static void log_to_channel_A_low_level(const char *message) { * Caveat: * The total length should not exceed 512 chars. */ -void log(short level, const char * message, ...) { +void logmsg(short level, const char * message, ...) { if (level > log_level) return; @@ -330,7 +330,7 @@ void log2(short level, const char * message1, const char * message2) { if (level <= log_level) { char line[80]; sprintf(line, "%s%s\n", message1, message2); - log(level, line); + logmsg(level, line); } } @@ -347,7 +347,7 @@ void log3(short level, const char * message1, const char * message2, const char if (level <= log_level) { char line[80]; sprintf(line, "%s%s%s\n", message1, message2, message3); - log(level, line); + logmsg(level, line); } } @@ -364,7 +364,7 @@ void log_num(short level, char * message, int n) { if (level <= log_level) { sprintf(line, "%s%08X", message, n); - log(level, line); + logmsg(level, line); } } @@ -375,5 +375,5 @@ void log_c(short level, char c) { char line[2]; line[0] = c; line[1] = '\0'; - log(level, line); + logmsg(level, line); } diff --git a/src/log.h b/src/log.h index 0aa4258..09ece8c 100644 --- a/src/log.h +++ b/src/log.h @@ -80,7 +80,7 @@ extern void log_setlevel(short level); * level = the severity of the message... the logging level will filter messages displayed * message = the message to log */ -extern void log(short level, const char * message, ...); +extern void logmsg(short level, const char * message, ...); extern void trace(const char * message, ...); /* * Log a message to the console @@ -123,12 +123,12 @@ extern void log_c(short log_level, char c); */ #if DEFAULT_LOG_LEVEL >= LOG_ERROR -# define ERROR(m) log(LOG_ERROR, m) -# define ERROR1(a,b) log(LOG_ERROR, a, b) -# define ERROR2(a,b,c) log(LOG_ERROR, a, b, c) -# define ERROR3(a,b,c,d) log(LOG_ERROR, a, b, c, d) -# define ERROR4(a,b,c,d,e) log(LOG_ERROR, a, b, c, d, e) -# define ERROR5(a,b,c,d,e,f) log(LOG_ERROR, a, b, c, d, e, f) +# define ERROR(m) logmsg(LOG_ERROR, m) +# define ERROR1(a,b) logmsg(LOG_ERROR, a, b) +# define ERROR2(a,b,c) logmsg(LOG_ERROR, a, b, c) +# define ERROR3(a,b,c,d) logmsg(LOG_ERROR, a, b, c, d) +# define ERROR4(a,b,c,d,e) logmsg(LOG_ERROR, a, b, c, d, e) +# define ERROR5(a,b,c,d,e,f) logmsg(LOG_ERROR, a, b, c, d, e, f) #else # define ERROR(m) # define ERROR1(a,b) @@ -140,12 +140,12 @@ extern void log_c(short log_level, char c); #if DEFAULT_LOG_LEVEL >= LOG_INFO -# define INFO(m) log(LOG_INFO, m); -# define INFO1(a,b) log(LOG_INFO, a, b); -# define INFO2(a,b,c) log(LOG_INFO, a, b, c); -# define INFO3(a,b,c,d) log(LOG_INFO, a, b, c, d); -# define INFO4(a,b,c,d,e) log(LOG_INFO, a, b, c, d, e); -# define INFO5(a,b,c,d,e,f) log(LOG_INFO, a, b, c, d, e, f); +# define INFO(m) logmsg(LOG_INFO, m); +# define INFO1(a,b) logmsg(LOG_INFO, a, b); +# define INFO2(a,b,c) logmsg(LOG_INFO, a, b, c); +# define INFO3(a,b,c,d) logmsg(LOG_INFO, a, b, c, d); +# define INFO4(a,b,c,d,e) logmsg(LOG_INFO, a, b, c, d, e); +# define INFO5(a,b,c,d,e,f) logmsg(LOG_INFO, a, b, c, d, e, f); #else # define INFO(m) # define INFO1(a,b) @@ -156,12 +156,14 @@ extern void log_c(short log_level, char c); #endif #if DEFAULT_LOG_LEVEL >= LOG_DEBUG -# define DEBUG(m) log(LOG_DEBUG, m) -# define DEBUG1(a,b) log(LOG_DEBUG, a, b) -# define DEBUG2(a,b,c) log(LOG_DEBUG, a, b, c) -# define DEBUG3(a,b,c,d) log(LOG_DEBUG, a, b, c, d) -# define DEBUG4(a,b,c,d,e) log(LOG_DEBUG, a, b, c, d, e) -# define DEBUG5(a,b,c,d,e,f) log(LOG_DEBUG, a, b, c, d, e, f) +# define DEBUG(m) logmsg(LOG_DEBUG, m) +# define DEBUG1(a,b) logmsg(LOG_DEBUG, a, b) +# define DEBUG2(a,b,c) logmsg(LOG_DEBUG, a, b, c) +# define DEBUG3(a,b,c,d) logmsg(LOG_DEBUG, a, b, c, d) +# define DEBUG4(a,b,c,d,e) logmsg(LOG_DEBUG, a, b, c, d, e) +# define DEBUG5(a,b,c,d,e,f) logmsg(LOG_DEBUG, a, b, c, d, e, f) +# define DEBUG6(a,b,c,d,e,f,g) logmsg(LOG_DEBUG, a, b, c, d, e, f, g) +# define DEBUG7(a,b,c,d,e,f,g,h) logmsg(LOG_DEBUG, a, b, c, d, e, f, g, h) #else # define DEBUG(m) # define DEBUG1(a,b) @@ -169,6 +171,8 @@ extern void log_c(short log_level, char c); # define DEBUG3(a,b,c,d) # define DEBUG4(a,b,c,d,e) # define DEBUG5(a,b,c,d,e,f) +# define DEBUG6(a,b,c,d,e,f,g) +# define DEBUG7(a,b,c,d,e,f,g,h) #endif #if DEFAULT_LOG_LEVEL >= LOG_TRACE diff --git a/src/proc.c b/src/proc.c index c2a9e1b..860ebbd 100644 --- a/src/proc.c +++ b/src/proc.c @@ -37,8 +37,8 @@ extern void call_user(long start, long stack, int argc, char * argv[]); void proc_exec(long start, long stack, int argc, char * argv[]) { TRACE("proc_exec"); - log_num(LOG_INFO, "proc_exec start: ", start); - log_num(LOG_INFO, "proc_exec stack: ", stack); + INFO1(LOG_INFO, "proc_exec start: %d"); + INFO1(LOG_INFO, "proc_exec stack: %d"); g_proc_result = 0; call_user(start, stack, argc, argv);