diff --git a/.gitignore b/.gitignore index c45086b..7416ae5 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,7 @@ src/foenixmcp_flash.bin src/bin/archive/foenixmcp_u_flash_20211111_03.bin src/bin/archive/foenixmcp_u_flash_20211112_06.bin src/Shit2Flash.bin +src/bin/archive/foenixmcp_u_ram_20211206_02.bin +src/bin/archive/foenixmcp_u_ram_20211206_01.bin +src/bin/archive/foenixmcp_u_flash_20211206_02.bin +src/bin/archive/foenixmcp_u_flash_20211206_01.bin diff --git a/docs/FoenixMCP Manual.epub b/docs/FoenixMCP Manual.epub index ae04b89..a4ad7cf 100644 Binary files a/docs/FoenixMCP Manual.epub and b/docs/FoenixMCP Manual.epub differ diff --git a/docs/FoenixMCP Manual.odt b/docs/FoenixMCP Manual.odt index 5a4f652..5d80865 100644 Binary files a/docs/FoenixMCP Manual.odt and b/docs/FoenixMCP Manual.odt differ diff --git a/docs/FoenixMCP Manual.pdf b/docs/FoenixMCP Manual.pdf index eddc302..3194dba 100644 Binary files a/docs/FoenixMCP Manual.pdf and b/docs/FoenixMCP Manual.pdf differ diff --git a/src/cli/cli.c b/src/cli/cli.c index afd9239..f513076 100644 --- a/src/cli/cli.c +++ b/src/cli/cli.c @@ -3,7 +3,9 @@ */ #include +#include #include + #include "log.h" #include "types.h" #include "interrupt.h" @@ -39,11 +41,11 @@ typedef struct s_cli_command { cli_cmd_handler handler; } t_cli_command, *p_cli_command; -extern short cmd_sysinfo(short channel, int argc, char * argv[]); -extern short cmd_cls(short channel, int argc, char * argv[]); -extern short cmd_showint(short channel, int argc, char * argv[]); -extern short cmd_getjiffies(short channel, int argc, char * argv[]); -extern short cmd_get_ticks(short channel, int argc, char * argv[]); +extern short cmd_sysinfo(short channel, int argc, const char * argv[]); +extern short cmd_cls(short channel, int argc, const char * argv[]); +extern short cmd_showint(short channel, int argc, const char * argv[]); +extern short cmd_getjiffies(short channel, int argc, const char * argv[]); +extern short cmd_get_ticks(short channel, int argc, const char * argv[]); /* * Variables @@ -89,20 +91,20 @@ const t_cli_command g_cli_commands[] = { // // List all the commands // -int cmd_help(short channel, int argc, char * argv[]) { +short cmd_help(short channel, int argc, const char * argv[]) { p_cli_command command; - for (command = g_cli_commands; (command != 0) && (command->name != 0); command++) { + for (command = (p_cli_command)g_cli_commands; (command != 0) && (command->name != 0); command++) { sys_chan_write(channel, command->help, strlen(command->help)); sys_chan_write(channel, "\n", 2); } return 0; } -short cmd_getjiffies(short channel, int argc, char * argv[]) { +short cmd_getjiffies(short channel, int argc, const char * argv[]) { char buffer[80]; - sprintf(buffer, "%d\n", timers_jiffies()); + sprintf(buffer, "%ld\n", timers_jiffies()); sys_chan_write(channel, buffer, strlen(buffer));; return 0; } @@ -110,10 +112,10 @@ short cmd_getjiffies(short channel, int argc, char * argv[]) { /* * Print the number of ticks since last restart */ -short cmd_get_ticks(short channel, int argc, char * argv[]) { +short cmd_get_ticks(short channel, int argc, const char * argv[]) { char buffer[80]; - sprintf(buffer, "%d\n", rtc_get_jiffies()); + sprintf(buffer, "%ld\n", rtc_get_jiffies()); sys_chan_write(channel, buffer, strlen(buffer)); return 0; } @@ -121,7 +123,7 @@ short cmd_get_ticks(short channel, int argc, char * argv[]) { /* * Clear the screen */ -short cmd_cls(short channel, int argc, char * argv[]) { +short cmd_cls(short channel, int argc, const char * argv[]) { const char * ansi_cls = "\x1B[2J\x1B[H"; sys_chan_write(channel, ansi_cls, strlen(ansi_cls)); @@ -131,7 +133,7 @@ short cmd_cls(short channel, int argc, char * argv[]) { /* * Display information about the system */ -short cmd_sysinfo(short channel, int argc, char * argv[]) { +short cmd_sysinfo(short channel, int argc, const char * argv[]) { t_sys_info info; char buffer[80]; @@ -143,22 +145,22 @@ short cmd_sysinfo(short channel, int argc, char * argv[]) { sprintf(buffer, "\nCPU: %s", info.cpu_name); sys_chan_write(channel, buffer, strlen(buffer)); - sprintf(buffer, "\nSystem Memory: 0x%X", info.system_ram_size); + sprintf(buffer, "\nSystem Memory: 0x%lX", info.system_ram_size); sys_chan_write(channel, buffer, strlen(buffer)); - sprintf(buffer, "\nPCB version: %s", &info.pcb_version); + sprintf(buffer, "\nPCB version: %s", (char*)&info.pcb_version); sys_chan_write(channel, buffer, strlen(buffer)); - sprintf(buffer, "\nFPGA Date: %08X", info.fpga_date); + sprintf(buffer, "\nFPGA Date: %08lX", info.fpga_date); sys_chan_write(channel, buffer, strlen(buffer)); - sprintf(buffer, "\nFPGA Model: %08X", info.fpga_model); + sprintf(buffer, "\nFPGA Model: %08lX", info.fpga_model); sys_chan_write(channel, buffer, strlen(buffer)); sprintf(buffer, "\nFPGA Version: %04X.%04X", info.fpga_version, info.fpga_subver); sys_chan_write(channel, buffer, strlen(buffer)); - sprintf(buffer, "\nMCP version: v%02d.%02d.%04d\n", info.mcp_version, info.mcp_rev, info.mcp_build); + sprintf(buffer, "\nMCP version: v%02u.%02u.%04u\n", info.mcp_version, info.mcp_rev, info.mcp_build); sys_chan_write(channel, buffer, strlen(buffer)); return 0; @@ -167,7 +169,7 @@ short cmd_sysinfo(short channel, int argc, char * argv[]) { /* * Show information about the interrupt registers */ -short cmd_showint(short channel, int argc, char * argv[]) { +short cmd_showint(short channel, int argc, const char * argv[]) { char buffer[80]; TRACE("cmd_showint"); @@ -197,9 +199,9 @@ short cmd_showint(short channel, int argc, char * argv[]) { // command = the upper case name of the command (first word of the command line) // parameters = the string of parameters to be passed to the command // -short cli_exec(short channel, char * command, int argc, char * argv[]) { +short cli_exec(short channel, char * command, int argc, const char * argv[]) { const char * cmd_not_found = "Command not found.\n"; - p_cli_command commands = g_cli_commands; + p_cli_command commands = (p_cli_command)g_cli_commands; log3(LOG_INFO, "cli_exec: '", argv[0], "'"); log_num(LOG_INFO, "argc = ", argc); @@ -249,7 +251,7 @@ char * strtok_r(char * source, const char * delimiter, char ** saveptr) { return x; } -short cli_rerepl() { +void cli_rerepl() { while (1) { cli_repl(g_current_channel); } diff --git a/src/cli/cli.h b/src/cli/cli.h index ef7a003..e1ef1c7 100644 --- a/src/cli/cli.h +++ b/src/cli/cli.h @@ -7,9 +7,9 @@ /* * A function pointer for command implementations: - * int cmd_foo(short screen, char * parameters) { ... } + * short cmd_foo(short screen, char * parameters) { ... } */ -typedef int (*cli_cmd_handler)(short screen, int argc, char * argv[]); +typedef short (*cli_cmd_handler)(short screen, int argc, const char * argv[]); /** * About the CLI... @@ -42,6 +42,6 @@ extern long cli_eval_number(const char * arg); /* * Print a help message */ -extern int cmd_help(short channel, int argc, char * argv[]); +extern short cmd_help(short channel, int argc, const char * argv[]); #endif diff --git a/src/cli/dis68k.c b/src/cli/dis68k.c index d1253ca..8f76ca3 100644 --- a/src/cli/dis68k.c +++ b/src/cli/dis68k.c @@ -124,23 +124,23 @@ static void sprintmode(unsigned int mode, unsigned int reg, unsigned int size, c const char ir[2] = {'W','L'}; /* for mode 6 */ switch(mode) { - case 0 : sprintf(out_s, "D%i", reg); break; - case 1 : sprintf(out_s, "A%i", reg); break; - case 2 : sprintf(out_s, "(A%i)", reg); break; - case 3 : sprintf(out_s, "(A%i)+", reg); break; - case 4 : sprintf(out_s, "-(A%i)", reg); break; + case 0 : sprintf(out_s, "D%u", reg); break; + case 1 : sprintf(out_s, "A%u", reg); break; + case 2 : sprintf(out_s, "(A%u)", reg); break; + case 3 : sprintf(out_s, "(A%u)+", reg); break; + case 4 : sprintf(out_s, "-(A%u)", reg); break; case 5 : /* reg + disp */ case 9 : { /* pcr + disp */ int32_t displacement = (int32_t) getword(); if (displacement >= 32768) displacement -= 65536; if (mode == 5) { - sprintf(out_s, "%+i(A%i)", displacement, reg); + sprintf(out_s, "%+li(A%u)", displacement, reg); } else { const uint32_t ldata = address - 2 + displacement; if (!rawmode) { - sprintf(out_s, "%+i(PC) {$%08u}", displacement, ldata); + sprintf(out_s, "%+li(PC) {$%08lu}", displacement, ldata); } else { - sprintf(out_s, "%+i(PC)", displacement); + sprintf(out_s, "%+li(PC)", displacement); } } } break; @@ -157,15 +157,15 @@ static void sprintmode(unsigned int mode, unsigned int reg, unsigned int size, c if (mode == 6) { if (itype == 0) { - sprintf(out_s, "%+i(A%i,D%i.%c)", displacement, reg, ireg, ir[isize]); + sprintf(out_s, "%+d(A%u,D%d.%c)", displacement, reg, ireg, ir[isize]); } else { - sprintf(out_s, "%+i(A%i,A%i.%c)", displacement, reg, ireg, ir[isize]); + sprintf(out_s, "%+d(A%u,A%d.%c)", displacement, reg, ireg, ir[isize]); } } else { /* PC */ if (itype == 0) { - sprintf(out_s, "%+i(PC,D%i.%c)", displacement, ireg, ir[isize]); + sprintf(out_s, "%+d(PC,D%d.%c)", displacement, ireg, ir[isize]); } else { - sprintf(out_s, "%+i(PC,A%i.%c)", displacement, ireg, ir[isize]); + sprintf(out_s, "%+d(PC,A%d.%c)", displacement, ireg, ir[isize]); } } } break; @@ -191,7 +191,7 @@ static void sprintmode(unsigned int mode, unsigned int reg, unsigned int size, c } } break; default : { - sprintf(line_buf, "Mode out of range in sprintmode = %i\n", mode); + sprintf(line_buf, "Mode out of range in sprintmode = %u\n", mode); print(0,line_buf); break; } @@ -224,7 +224,7 @@ void disasm(unsigned long int start, unsigned long int end) { char operand_s[100]; while (address < end) { - sprintf(line_buf, "%08x : ", address); + sprintf(line_buf, "%p : ", (void*)address); print(0, line_buf); const uint32_t start_address = address; @@ -505,11 +505,11 @@ void disasm(unsigned long int start, unsigned long int end) { int offset = (word & 0x00FF); if (offset != 0) { if (offset >= 128) offset -= 256; - sprintf(operand_s, "$%08x", address + offset); + sprintf(operand_s, "$%p", (void*)(address + offset)); } else { offset = getword(); if (offset >= 32768l) offset -= 65536l; - sprintf(operand_s, "$%08x" , address - 2 + offset); + sprintf(operand_s, "$%p" , (void*)(address - 2 + offset)); } decoded = true; } break; @@ -652,7 +652,7 @@ void disasm(unsigned long int start, unsigned long int end) { int offset = getword(); if (offset >= 32768) offset -= 65536; const int dreg = word & 0x0007; - sprintf(operand_s, "D%i,$%08x", dreg, address - 2 + offset); + sprintf(operand_s, "D%d,$%p", dreg, (void*)(address - 2 + offset)); decoded = true; } break; case 33 : { /* EXG */ @@ -1094,7 +1094,7 @@ void disasm(unsigned long int start, unsigned long int end) { //for (int i = 0 ; i < (5 - fetched); ++i) print(0," "); if (decoded != 0) { - sprintf(line_buf, "%-8s %s\n", opcode_s, operand_s) + sprintf(line_buf, "%-8s %s\n", opcode_s, operand_s); print(0,line_buf); } else { print(0,"???\n"); diff --git a/src/cli/dos_cmds.c b/src/cli/dos_cmds.c index 09860b5..87c6baa 100644 --- a/src/cli/dos_cmds.c +++ b/src/cli/dos_cmds.c @@ -19,7 +19,7 @@ * * DISKREAD */ -short cmd_diskread(short screen, int argc, char * argv[]) { +short cmd_diskread(short screen, int argc, const char * argv[]) { unsigned char buffer[512]; short bdev_number = 0; long lba = 0; @@ -34,7 +34,7 @@ short cmd_diskread(short screen, int argc, char * argv[]) { bdev_number = (short)cli_eval_number(argv[1]); lba = cli_eval_number(argv[2]); - sprintf(buffer, "Reading drive #%d, sector 0x%X\n", bdev_number, lba); + sprintf(buffer, "Reading drive #%d, sector %p\n", bdev_number, (void*)lba); print(screen, buffer); result = bdev_read(bdev_number, lba, buffer, 512); @@ -53,7 +53,7 @@ short cmd_diskread(short screen, int argc, char * argv[]) { * * DISKFILL */ -short cmd_diskfill(short screen, int argc, char * argv[]) { +short cmd_diskfill(short screen, int argc, const char * argv[]) { unsigned char buffer[512]; unsigned char value; short bdev_number = 0; @@ -70,7 +70,7 @@ short cmd_diskfill(short screen, int argc, char * argv[]) { lba = cli_eval_number(argv[2]); value = (unsigned char)cli_eval_number(argv[3]); - sprintf(buffer, "Filling drive #%d, sector 0x%X with 0x%02X\n", bdev_number, lba, value); + sprintf(buffer, "Filling drive #%d, sector %p with 0x%02X\n", bdev_number, (void*)lba, (short)value); print(screen, buffer); for (i = 0; i < 512; i++) { @@ -93,7 +93,7 @@ short cmd_diskfill(short screen, int argc, char * argv[]) { * * Command name is in argv[0]. */ -short cmd_run(short screen, int argc, char * argv[]) { +short cmd_run(short screen, int argc, const char * argv[]) { TRACE("cmd_run"); short result = proc_run(argv[0], argc, argv); @@ -108,7 +108,7 @@ short cmd_run(short screen, int argc, char * argv[]) { /* * Create a directory */ -short cmd_mkdir(short screen, int argc, char * argv[]) { +short cmd_mkdir(short screen, int argc, const char * argv[]) { TRACE("cmd_mkdir"); @@ -127,7 +127,7 @@ short cmd_mkdir(short screen, int argc, char * argv[]) { /* * Delete a file */ -short cmd_del(short screen, int argc, char * argv[]) { +short cmd_del(short screen, int argc, const char * argv[]) { TRACE("cmd_del"); @@ -143,7 +143,7 @@ short cmd_del(short screen, int argc, char * argv[]) { } } -short cmd_copy(short screen, int argc, char * argv[]) { +short cmd_copy(short screen, int argc, const char * argv[]) { FRESULT find_result; FRESULT result; DIR dir; /* Directory object */ @@ -228,7 +228,7 @@ error: /* * Change the directory */ -short cmd_cd(short screen, int argc, char * argv[]) { +short cmd_cd(short screen, int argc, const char * argv[]) { TRACE("cmd_cd"); @@ -253,7 +253,7 @@ short cmd_cd(short screen, int argc, char * argv[]) { /* * Change the directory */ -short cmd_pwd(short screen, int argc, char * argv[]) { +short cmd_pwd(short screen, int argc, const char * argv[]) { char buffer[128]; TRACE("cmd_pwd"); @@ -271,7 +271,7 @@ short cmd_pwd(short screen, int argc, char * argv[]) { /* * Rename a file or directory */ -short cmd_rename(short screen, int argc, char * argv[]) { +short cmd_rename(short screen, int argc, const char * argv[]) { TRACE("cmd_rename"); @@ -286,7 +286,7 @@ short cmd_rename(short screen, int argc, char * argv[]) { return 0; } -short cmd_dir(short screen, int argc, char * argv[]) { +short cmd_dir(short screen, int argc, const char * argv[]) { short result; char buffer[80]; t_file_info my_file; @@ -294,7 +294,7 @@ short cmd_dir(short screen, int argc, char * argv[]) { char label[40]; if (argc > 1) { - path = argv[1]; + path = (char*)(argv[1]); } short dir = fsys_opendir(path); @@ -342,11 +342,11 @@ short cmd_dir(short screen, int argc, char * argv[]) { /* * Print the contents of a file to the screen */ -short cmd_type(short screen, int argc, char * argv[]) { +short cmd_type(short screen, int argc, const char * argv[]) { if (argc > 1) { unsigned char buffer[128]; - log3(LOG_INFO, "Attempting to type [", argv[1], "]"); + log3(LOG_INFO, "Attempting to type [", (char*)(argv[1]), "]"); short fd = fsys_open(argv[1], FA_READ); if (fd >= 0) { log_num(LOG_INFO, "File open: ", fd); @@ -379,7 +379,7 @@ short cmd_type(short screen, int argc, char * argv[]) { * Load a binary file into memory * parameters: path [address] */ -short cmd_load(short screen, int argc, char * argv[]) { +short cmd_load(short screen, int argc, const char * argv[]) { if (argc > 1) { long start = 0; long destination = 0; @@ -413,7 +413,7 @@ short cmd_load(short screen, int argc, char * argv[]) { * LABEL