Merge branch 'main' into a2560k

This commit is contained in:
Peter Weingartner 2021-12-10 20:32:37 -05:00
commit e0f8d03baa
40 changed files with 7454 additions and 8288 deletions

4
.gitignore vendored
View file

@ -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

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -3,7 +3,9 @@
*/
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#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);
}

View file

@ -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

View file

@ -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");

View file

@ -19,7 +19,7 @@
*
* DISKREAD <drive #> <sector #>
*/
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 <drive #> <sector #> <value>
*/
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 <drive #> <label>
*
*/
short cmd_label(short screen, int argc, char * argv[]) {
short cmd_label(short screen, int argc, const char * argv[]) {
if (argc > 2) {
short drive = cli_eval_number(argv[1]);
short result = fsys_setlabel(drive, argv[2]);
@ -433,7 +433,7 @@ short cmd_label(short screen, int argc, char * argv[]) {
*
* FORMAT <drive #>
*/
short cmd_format(short screen, int argc, char * argv[]) {
short cmd_format(short screen, int argc, const char * argv[]) {
if (argc > 1) {
short drive = cli_eval_number(argv[1]);
short result = fsys_mkfs(drive, "");

View file

@ -8,66 +8,66 @@
/*
* Execute a binary file
*/
extern short cmd_run(short screen, int argc, char * argv[]);
extern short cmd_run(short screen, int argc, const char * argv[]);
/*
* List the directory at the given path
*/
extern short cmd_dir(short screen, int argc, char * argv[]);
extern short cmd_dir(short screen, int argc, const char * argv[]);
/*
* Create a directory
*/
extern short cmd_mkdir(short screen, int argc, char * argv[]);
extern short cmd_mkdir(short screen, int argc, const char * argv[]);
/*
* Delete a file or directory
*/
extern short cmd_del(short screen, int argc, char * argv[]);
extern short cmd_del(short screen, int argc, const char * argv[]);
/*
* Copies file(s) to destination
*/
extern short cmd_copy(short screen, int argc, char * argv[]);
extern short cmd_copy(short screen, int argc, const char * argv[]);
/*
* Set the current working directory
*/
extern short cmd_cd(short screen, int argc, char * argv[]);
extern short cmd_cd(short screen, int argc, const char * argv[]);
/*
* Print the current working directory
*/
extern short cmd_pwd(short screen, int argc, char * argv[]);
extern short cmd_pwd(short screen, int argc, const char * argv[]);
/*
* Rename a file or directory
*/
extern short cmd_rename(short screen, int argc, char * argv[]);
extern short cmd_rename(short screen, int argc, const char * argv[]);
/*
* Print the contents of a file to the screen
*/
extern short cmd_type(short screen, int argc, char * argv[]);
extern short cmd_type(short screen, int argc, const char * argv[]);
/*
* Load a binary file into memory
*/
extern short cmd_load(short screen, int argc, char * argv[]);
extern short cmd_load(short screen, int argc, const char * argv[]);
/*
* Read a sector off a drive
*
* DISKREAD <drive #> <sector #>
*/
extern short cmd_diskread(short screen, int argc, char * argv[]);
extern short cmd_diskread(short screen, int argc, const char * argv[]);
/*
* Fill a sector of a drive with a byte value
*
* DISKFILL <drive #> <sector #> <value>
*/
extern short cmd_diskfill(short screen, int argc, char * argv[]);
extern short cmd_diskfill(short screen, int argc, const char * argv[]);
/*
* Set the label of a drive
@ -75,13 +75,13 @@ extern short cmd_diskfill(short screen, int argc, char * argv[]);
* LABEL <drive #> <label>
*
*/
extern short cmd_label(short screen, int argc, char * argv[]);
extern short cmd_label(short screen, int argc, const char * argv[]);
/*
* Format a drive
*
* FORMAT <drive #>
*/
extern short cmd_format(short screen, int argc, char * argv[]);
extern short cmd_format(short screen, int argc, const char * argv[]);
#endif

View file

@ -14,7 +14,7 @@
*
* DUMP <address> [<count>]
*/
short mem_cmd_dump(short channel, int argc, char * argv[]) {
short mem_cmd_dump(short channel, int argc, const char * argv[]) {
unsigned char * address = 0;
long count = 16;
long i;
@ -38,7 +38,7 @@ short mem_cmd_dump(short channel, int argc, char * argv[]) {
}
}
short mem_cmd_dasm(short channel, int argc, char * argv[]) {
short mem_cmd_dasm(short channel, int argc, const char * argv[]) {
unsigned long address = 0;
long count = 1000;
long i;
@ -73,7 +73,7 @@ short mem_cmd_dasm(short channel, int argc, char * argv[]) {
*
* POKE8 <address> <value>
*/
short mem_cmd_poke8(short channel, int argc, char * argv[]) {
short mem_cmd_poke8(short channel, int argc, const char * argv[]) {
TRACE("mem_cmd_poke8");
if (argc == 3) {
@ -93,7 +93,7 @@ short mem_cmd_poke8(short channel, int argc, char * argv[]) {
*
* PEEK8 <address>
*/
short mem_cmd_peek8(short channel, int argc, char * argv[]) {
short mem_cmd_peek8(short channel, int argc, const char * argv[]) {
TRACE("mem_cmd_peek8");
@ -114,7 +114,7 @@ short mem_cmd_peek8(short channel, int argc, char * argv[]) {
*
* POKE16 <address> <value>
*/
short mem_cmd_poke16(short channel, int argc, char * argv[]) {
short mem_cmd_poke16(short channel, int argc, const char * argv[]) {
TRACE("mem_cmd_poke16");
if (argc == 3) {
@ -134,11 +134,11 @@ short mem_cmd_poke16(short channel, int argc, char * argv[]) {
*
* PEEK16 <address>
*/
short mem_cmd_peek16(short channel, int argc, char * argv[]) {
short mem_cmd_peek16(short channel, int argc, const char * argv[]) {
TRACE("mem_cmd_peek16");
if (argc == 2) {
unsigned short * address = (unsigned char *)cli_eval_number(argv[1]);
unsigned short * address = (unsigned short *)cli_eval_number(argv[1]);
unsigned short c = *address;
print_hex_16(channel, c);
@ -154,7 +154,7 @@ short mem_cmd_peek16(short channel, int argc, char * argv[]) {
*
* POKE32 <address> <value>
*/
short mem_cmd_poke32(short channel, int argc, char * argv[]) {
short mem_cmd_poke32(short channel, int argc, const char * argv[]) {
TRACE("mem_cmd_poke32");
if (argc == 3) {
@ -174,11 +174,11 @@ short mem_cmd_poke32(short channel, int argc, char * argv[]) {
*
* PEEK32 <address>
*/
short mem_cmd_peek32(short channel, int argc, char * argv[]) {
short mem_cmd_peek32(short channel, int argc, const char * argv[]) {
TRACE("mem_cmd_peek32");
if (argc == 2) {
unsigned long * address = (unsigned char *)cli_eval_number(argv[1]);
unsigned long * address = (unsigned long *)cli_eval_number(argv[1]);
unsigned long c = *address;
print_hex_32(channel, c);

View file

@ -12,55 +12,55 @@
*
* DUMP <address> [<count>]
*/
extern short mem_cmd_dump(short channel, int argc, char * argv[]);
extern short mem_cmd_dump(short channel, int argc, const char * argv[]);
/*
* Print out the dissassembly of a block of memory
*
* DASM <address> [<count>]
*/
extern short mem_cmd_dasm(short channel, int argc, char * argv[]);
extern short mem_cmd_dasm(short channel, int argc, const char * argv[]);
/*
* Write an 8-bit byte to memory
*
* POKE8 <address> <value>
*/
extern short mem_cmd_poke8(short channel, int argc, char * argv[]);
extern short mem_cmd_poke8(short channel, int argc, const char * argv[]);
/*
* Read an 8-bit byte from memory and display it
*
* PEEK8 <address>
*/
extern short mem_cmd_peek8(short channel, int argc, char * argv[]);
extern short mem_cmd_peek8(short channel, int argc, const char * argv[]);
/*
* Write an 16-bit word to memory
*
* POKE16 <address> <value>
*/
extern short mem_cmd_poke16(short channel, int argc, char * argv[]);
extern short mem_cmd_poke16(short channel, int argc, const char * argv[]);
/*
* Read an 16-bit word from memory and display it
*
* PEEK16 <address>
*/
extern short mem_cmd_peek16(short channel, int argc, char * argv[]);
extern short mem_cmd_peek16(short channel, int argc, const char * argv[]);
/*
* Write an 32-bit long word to memory
*
* POKE32 <address> <value>
*/
extern short mem_cmd_poke32(short channel, int argc, char * argv[]);
extern short mem_cmd_poke32(short channel, int argc, const char * argv[]);
/*
* Read an 32-bit long word from memory and display it
*
* PEEK32 <address>
*/
extern short mem_cmd_peek32(short channel, int argc, char * argv[]);
extern short mem_cmd_peek32(short channel, int argc, const char * argv[]);
#endif

View file

@ -6,8 +6,10 @@
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "cli.h"
#include "log.h"
#include "errors.h"
#include "settings.h"
@ -73,7 +75,8 @@ short cli_set_register(const char * name, const char * help, cli_setter setter,
} else {
/* Set the fields for the setting */
cli_name_upper(setting->name, name);
strncpy(setting->help, help);
strncpy(setting->help, help, MAX_SETTING_HELP);
setting->help[MAX_SETTING_HELP] = '\0';
setting->setter = setter;
setting->getter = getter;
setting->next = 0;
@ -181,14 +184,12 @@ void cli_set_help(short channel) {
sys_chan_write(channel, setting->help, strlen(setting->help));
sys_chan_write(channel, "\n", 1);
}
return 0;
}
/*
* Command to set the value of a setting
*/
short cli_cmd_set(short channel, int argc, char * argv[]) {
short cli_cmd_set(short channel, int argc, const char * argv[]) {
char message[80];
short result;
@ -201,7 +202,7 @@ short cli_cmd_set(short channel, int argc, char * argv[]) {
}
return result;
} else if ((argc == 2) && ((strcmp(argv[1], "HELP") == 0) || (strcmp(argv[1], "help") == 0) || (strcmp(argv[1], "?") == 0)) {
} else if ((argc == 2) && (strcmp(argv[1], "HELP") == 0 || strcmp(argv[1], "help") == 0 || strcmp(argv[1], "?") == 0)) {
cli_set_help(channel);
} else {
@ -213,7 +214,7 @@ short cli_cmd_set(short channel, int argc, char * argv[]) {
/*
* Command to set the value of a setting
*/
short cli_cmd_get(short channel, int argc, char * argv[]) {
short cli_cmd_get(short channel, int argc, const char * argv[]) {
char buffer[128];
short result;
@ -223,7 +224,7 @@ short cli_cmd_get(short channel, int argc, char * argv[]) {
cli_set_help(channel);
} else {
result = cli_get_value(channel, argv[1], buffer, 128);
result = cli_get_value(channel, (char*)argv[1], buffer, 128);
if (result == 0) {
print(channel, buffer);
print(channel, "\n");
@ -328,19 +329,19 @@ short cli_date_set(short channel, const char * date) {
if ((i == 4) || (i == 7)) {
if (date[i] != '-') {
sys_chan_write(channel, usage, strlen(usage));
return -1;
return ERR_GENERAL;
}
} else {
if ((date[i] < '0') || (date[i] > '9')) {
sys_chan_write(channel, usage, strlen(usage));
return -1;
return ERR_GENERAL;
}
}
}
date_time.year = atoi_n(&date[0], 4);
date_time.month = atoi_n(&date[5], 2);
date_time.day = atoi_n(&date[8], 2);
date_time.year = atoi_n(&((char*)date)[0], 4);
date_time.month = atoi_n(&((char*)date)[5], 2);
date_time.day = atoi_n(&((char*)date)[8], 2);
rtc_set_time(&date_time);
@ -350,7 +351,7 @@ short cli_date_set(short channel, const char * date) {
/*
* DATE getter
*/
short cli_date_get(short channel, char * value) {
short cli_date_get(short channel, char * value, short size) {
t_time time;
rtc_get_time(&time);
@ -377,19 +378,19 @@ short cli_time_set(short channel, const char * time) {
if ((i == 2) || (i == 5)) {
if (time[i] != ':') {
sys_chan_write(channel, usage, strlen(usage));
return -1;
return ERR_GENERAL;
}
} else {
if ((time[i] < '0') || (time[i] > '9')) {
sys_chan_write(channel, usage, strlen(usage));
return -1;
return ERR_GENERAL;
}
}
}
date_time.hour = atoi_n(&time[0], 2);
date_time.minute = atoi_n(&time[3], 2);
date_time.second = atoi_n(&time[6], 2);
date_time.hour = atoi_n(&((char*)time)[0], 2);
date_time.minute = atoi_n(&((char*)time)[3], 2);
date_time.second = atoi_n(&((char*)time)[6], 2);
rtc_set_time(&date_time);
@ -399,7 +400,7 @@ short cli_time_set(short channel, const char * time) {
/*
* TIME getter
*/
short cli_time_get(short channel, char * value) {
short cli_time_get(short channel, char * value, short size) {
t_time time;
rtc_get_time(&time);
@ -443,7 +444,7 @@ short cli_font_set(short screen, const char * value) {
/*
* Font setter -- GET FONT <path>
*/
short cli_font_get(short channel, char * value) {
short cli_font_get(short channel, char * value, short size) {
/* We don't keep the font path */
*value = 0;
return 0;
@ -452,7 +453,7 @@ short cli_font_get(short channel, char * value) {
/*
* Volume setter -- SET VOLUME <value>
*/
short cli_volume_set(short channel, char * value) {
short cli_volume_set(short channel, const char * value) {
unsigned char volume = (unsigned char)cli_eval_number(value);
codec_set_volume(volume);
return 0;
@ -461,8 +462,8 @@ short cli_volume_set(short channel, char * value) {
/*
* Volume getter -- GET VOLUME
*/
short cli_volume_get(short channel, char * value) {
sprintf(value, "%d", codec_get_volume());
short cli_volume_get(short channel, char * value, short size) {
sprintf(value, "%d", (short)codec_get_volume());
return 0;
}
@ -494,7 +495,7 @@ short cli_layout_set(short channel, const char * value) {
/*
* Get the keyboard layout given a keyboard layout file -- GET LAYOUT
*/
short cli_layout_get(short channel, char * value) {
short cli_layout_get(short channel, char * value, short size) {
return 0;
}

View file

@ -29,24 +29,26 @@ extern void cli_set_init();
* Returns:
* 0 on success, any other number is an error
*/
extern short cli_set_register(const char * name, cli_setter setter, cli_getter getter);
extern short cli_set_register(const char * name, const char * help, cli_setter setter, cli_getter getter);
/*
* Set the value of a setting
*
* Inputs:
* channel = the channel to use for reporting success or error
* name = the name of the setting to update (case insensitive)
* value = the value to store in the setting (may be interpreted by the setting)
*
* Returns:
* 0 on success, any other number is an error
*/
extern short cli_set_value(const char * name, const char * value);
extern short cli_set_value(short channel, const char * name, const char * value);
/*
* Get the value of a setting
*
* Inputs:
* channel = the channel to use for reporting success or error
* name = the name of the setting to update (case insensitive)
* buffer = the place to copy a string representing the value of the setting
* size = the number of characters that can be stored in the buffer
@ -54,16 +56,16 @@ extern short cli_set_value(const char * name, const char * value);
* Returns:
* 0 on success, any other number is an error
*/
extern short cli_get_value(const char * name, char * buffer, short size);
extern short cli_get_value(short channel, const char * name, char * buffer, short size);
/*
* Command to set the value of a setting
*/
extern short cli_cmd_set(short screen, int argc, char * argv[]);
extern short cli_cmd_set(short screen, int argc, const char * argv[]);
/*
* Command to set the value of a setting
*/
extern short cli_cmd_get(short screen, int argc, char * argv[]);
extern short cli_cmd_get(short screen, int argc, const char * argv[]);
#endif

View file

@ -9,11 +9,12 @@
#include "snd/psg.h"
#include "snd/sid.h"
#include "dev/midi.h"
#include "syscalls.h"
/*
* Play a sound on the PSG
*/
short psg_test(short channel, int argc, char * argv[]) {
short psg_test(short channel, int argc, const char * argv[]) {
int i;
long target_time;
@ -314,7 +315,7 @@ const unsigned char opl3_tone_off[] = {
/*
* Play a sound on the OPL3
*/
short opl3_test(short channel, int argc, char * argv[]) {
short opl3_test(short channel, int argc, const char * argv[]) {
short i;
unsigned char reg;
unsigned char data;
@ -351,7 +352,7 @@ short opl3_test(short channel, int argc, char * argv[]) {
/*
* Perform a transmit test on the MIDI ports
*/
short midi_tx_test(short channel, int argc, char * argv[]) {
short midi_tx_test(short channel, int argc, const char * argv[]) {
#if MODEL == MODEL_FOENIX_A2560K
const char note_on[] = { 0x90, 0x3c, 0xff };
const char note_off[] = { 0x80, 0x3c, 0x00 };
@ -377,7 +378,7 @@ short midi_tx_test(short channel, int argc, char * argv[]) {
/*
* Perform a receive test on the MIDI ports
*/
short midi_rx_test(short channel, int argc, char * argv[]) {
short midi_rx_test(short channel, int argc, const char * argv[]) {
#if MODEL == MODEL_FOENIX_A2560K
char message[80];
unsigned short scancode = 0;
@ -416,7 +417,7 @@ short midi_rx_test(short channel, int argc, char * argv[]) {
/*
* Perform a loopback test on the MIDI ports
*/
short midi_loop_test(short channel, int argc, char * argv[]) {
short midi_loop_test(short channel, int argc, const char * argv[]) {
#if MODEL == MODEL_FOENIX_A2560K
char message[80];
unsigned short scancode = 0;

View file

@ -8,7 +8,7 @@
/*
* Play a sound on the PSG
*/
extern short psg_test(short channel, int argc, char * argv[]);
extern short psg_test(short channel, int argc, const char * argv[]);
/*
* Play a sound on the SID
@ -18,7 +18,7 @@ extern short sid_test(short channel, int argc, char * argv[]);
/*
* Play a sound on the OPL3
*/
extern short opl3_test(short channel, int argc, char * argv[]);
extern short opl3_test(short channel, int argc, const char * argv[]);
/*
* Play a sound on the OPM
@ -33,16 +33,16 @@ extern short opn_test(short channel, int argc, char * argv[]);
/*
* Perform a transmit test on the MIDI ports
*/
extern short midi_tx_test(short channel, int argc, char * argv[]);
extern short midi_tx_test(short channel, int argc, const char * argv[]);
/*
* Perform a receive test on the MIDI ports
*/
extern short midi_rx_test(short channel, int argc, char * argv[]);
extern short midi_rx_test(short channel, int argc, const char * argv[]);
/*
* Perform a loopback test on the MIDI ports
*/
extern short midi_loop_test(short channel, int argc, char * argv[]);
extern short midi_loop_test(short channel, int argc, const char * argv[]);
#endif

View file

@ -5,6 +5,7 @@
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include "cli.h"
#include "cli/test_cmds.h"
@ -18,6 +19,8 @@
#include "dev/uart.h"
#include "fatfs/ff.h"
#include "interrupt.h"
#include "log.h"
#include "dev/ps2.h"
#include "rtc_reg.h"
#include "simpleio.h"
#include "syscalls.h"
@ -157,7 +160,7 @@ int cli_test_gamepad(short channel, int argc, char * argv[]) {
return 0;
}
int cli_test_bitmap(short channel, int argc, char * argv[]) {
short cli_test_bitmap(short channel, int argc, const char * argv[]) {
int i,m,p;
unsigned char j;
unsigned short k;
@ -177,9 +180,11 @@ int cli_test_bitmap(short channel, int argc, char * argv[]) {
for (i = 0; i< 640 * 480; i++) {
VRAM_Bank0[i] = i & 0xff;
}
return 0;
}
int cli_test_uart(short channel, int argc, char * argv[]) {
short cli_test_uart(short channel, int argc, const char * argv[]) {
char c;
char buffer[80];
@ -190,7 +195,7 @@ int cli_test_uart(short channel, int argc, char * argv[]) {
sprintf(buffer, "COM1: 115200, no parity, 1 stop bit, 8 data bits\nPress ESC to finish (%d).\n", UART_115200);
sys_chan_write(0, buffer, strlen(buffer));
while (1) {
for (;;) {
c = kbd_getc();
if (c != 0) {
if (c == 0x1b) {
@ -202,9 +207,11 @@ int cli_test_uart(short channel, int argc, char * argv[]) {
sys_chan_write_b(channel, c);
}
}
return 0;
}
int cli_test_panic(short channel, int argc, char * argv[]) {
short cli_test_panic(short channel, int argc, const char * argv[]) {
volatile int x = 0;
return argc / x;
}
@ -212,7 +219,7 @@ int cli_test_panic(short channel, int argc, char * argv[]) {
/*
* Try using the RTC periodic interrupt in polled mode
*/
int cli_test_rtc(short channel, int argc, char * argv[]) {
short cli_test_rtc(short channel, int argc, const char * argv[]) {
char buffer[80];
char * spinner = "|/-\\";
short count = 0;
@ -224,28 +231,30 @@ int cli_test_rtc(short channel, int argc, char * argv[]) {
ticks = sys_time_jiffies();
sprintf(buffer, "Waiting for updated ticks starting from %d\n", ticks);
sprintf(buffer, "Waiting for updated ticks starting from %ld\n", ticks);
sys_chan_write(channel, buffer, strlen(buffer));
while (1) {
for (;;) {
if (ticks < sys_time_jiffies()) {
/* We got the periodic interrupt */
sprintf(buffer, "Tick! %d\n", ticks);
sprintf(buffer, "Tick! %ld\n", ticks);
sys_chan_write(channel, buffer, strlen(buffer));
ticks = sys_time_jiffies();
}
}
return 0;
}
/*
* Test the memory
*/
int cli_mem_test(short channel, int argc, char * argv[]) {
short cli_mem_test(short channel, int argc, const char * argv[]) {
volatile unsigned char * memory = 0x00000000;
t_sys_info sys_info;
const long mem_start = 0x00050000;
const long mem_start = 0x00050000; /* TODO find out better where the kernel stop */
long mem_end;
char message[80];
long i;
@ -257,29 +266,29 @@ int cli_mem_test(short channel, int argc, char * argv[]) {
sys_chan_write(channel, message, strlen(message));
for (i = mem_start; i < mem_end; i++) {
memory[i] = 0x55;
memory[i] = 0x55; /* Every other bit starting with 1 */
if (memory[i] != 0x55) {
sprintf(message, "\x1B[1;2H\x1B[KFailed to write 0x55... read %02X at %08X\n\n", memory[i], i);
sprintf(message, "\x1B[1;2H\x1B[KFailed to write 0x55... read %02X at %p\n\n", memory[i], (void*)i);
sys_chan_write(channel, message, strlen(message));
return -1;
return ERR_GENERAL;
}
memory[i] = 0xAA;
memory[i] = 0xAA; /* Every other bit starting with 0 */
if (memory[i] != 0xAA) {
sprintf(message, "\x1B[1;2H\x1B[KFailed to write 0xAA... read %02X at %08X\n\n", memory[i], i);
sprintf(message, "\x1B[1;2H\x1B[KFailed to write 0xAA... read %02X at %p\n\n", memory[i], (void*)i);
sys_chan_write(channel, message, strlen(message));
return -1;
return ERR_GENERAL;
}
memory[i] = 0x00;
if (memory[i] != 0x00) {
sprintf(message, "\x1B[1;2H\x1B[KFailed to write 0x00... read %02X at %08\n\nX", memory[i], i);
sprintf(message, "\x1B[1;2H\x1B[KFailed to write 0x00... read %02X at %p\n\nX", memory[i], (void*)i);
sys_chan_write(channel, message, strlen(message));
return -1;
return ERR_GENERAL;
}
if ((i % 1024) == 0) {
sprintf(message, "\x1B[H\x1B[0KMemory tested: %08X", i);
sprintf(message, "\x1B[H\x1B[0KMemory tested: %p", (void*)i);
sys_chan_write(channel, message, strlen(message));
}
}
@ -389,13 +398,13 @@ int cli_test_fdc(short screen, int argc, char * argv[]) {
/*
* Test the IDE interface by reading the MBR
*/
int cli_test_ide(short screen, int argc, char * argv[]) {
short cli_test_ide(short screen, int argc, const char * argv[]) {
unsigned char buffer[512];
short i;
short scancode;
short n = 0;
while (1) {
for (;;) {
n = bdev_read(BDEV_HDC, 0, buffer, 512);
if (n <= 0) {
err_print(screen, "Unable to read MBR", n);
@ -413,12 +422,14 @@ int cli_test_ide(short screen, int argc, char * argv[]) {
break;
}
}
return 0;
}
/*
* Test file creation
*/
int cli_test_create(short screen, int argc, char * argv[]) {
short cli_test_create(short screen, int argc, const char * argv[]) {
short n;
if (argc > 1) {
@ -435,16 +446,16 @@ int cli_test_create(short screen, int argc, char * argv[]) {
} else {
err_print(screen, "Unable to open to file", channel);
return -1;
return ERR_GENERAL;
}
} else {
print(screen, "USAGE: TEST CREATE <path>\n");
return -1;
return ERR_GENERAL;
}
}
int cli_test_lpt(short screen, int argc, char * argv[]) {
short cli_test_lpt(short screen, int argc, const char * argv[]) {
#if MODEL == MODEL_FOENIX_A2560K
char message[80];
unsigned char scancode;
@ -500,7 +511,7 @@ int cli_test_lpt(short screen, int argc, char * argv[]) {
return 0;
}
int cmd_test_print(short screen, int argc, char * argv[]) {
short cmd_test_print(short screen, int argc, const char * argv[]) {
#if MODEL == MODEL_FOENIX_A2560K
const char * test_pattern = "0123456789ABCDEFGHIJKLMNOPQRTSUVWZXYZ\r\n";
@ -554,8 +565,8 @@ const t_cli_test_feature cli_test_features[] = {
void test_help(short screen) {
p_cli_test_feature f;
short i;
short count;
int i;
int count;
print(screen, "USAGE: TEST <feature>\nFeatures supported...\n");
@ -571,7 +582,7 @@ void test_help(short screen) {
/*
* Test command
*/
int cmd_test(short screen, int argc, char * argv[]) {
short cmd_test(short screen, int argc, const char * argv[]) {
short i;
p_cli_test_feature f;
@ -584,7 +595,7 @@ int cmd_test(short screen, int argc, char * argv[]) {
feature_upcase[i] = toupper(feature_upcase[i]);
}
for (f = cli_test_features; f->name != 0; f++) {
for (f = (p_cli_test_feature)cli_test_features; f->name != 0; f++) {
if (strcmp(f->name, feature_upcase) == 0) {
f->handler(screen, argc - 1, &argv[1]);
return 0;
@ -592,9 +603,11 @@ int cmd_test(short screen, int argc, char * argv[]) {
}
test_help(screen);
return -1;
return ERR_GENERAL;
} else {
test_help(screen);
return -1;
return ERR_GENERAL;
}
return 0;
}

View file

@ -8,6 +8,6 @@
/*
* Test command
*/
extern int cmd_test(short channel, int argc, char * argv[]);
extern short cmd_test(short channel, int argc, const char * argv[]);
#endif

View file

@ -189,7 +189,7 @@ short cdev_init(short dev) {
* Returns:
* the number of the channel opened, negative number on error
*/
short chan_open(short dev, uint8_t * path, short mode) {
short chan_open(short dev, const uint8_t * path, short mode) {
short result;
p_channel chan;
p_dev_chan cdev;

View file

@ -65,12 +65,12 @@ typedef struct s_dev_chan {
short number; // The number of the device (assigned by registration)
char * name; // The name of the device
FUNC_V_2_S init; // short init() -- Initialize the device
FUNC_CBS_2_S open; // short open(t_channel * chan, uint8_t * path, short mode) -- open a channel for the device
FUNC_CcBS_2_S open; // short open(t_channel * chan, const uint8_t * path, short mode) -- open a channel for the device
FUNC_V_2_S close; // short close(t_channel * chan) -- called when a channel is closed
FUNC_CBS_2_S read; // short read(t_channel *, uint8_t * buffer, short size) -- Read a a buffer from the device
FUNC_CBS_2_S readline; // short readline(t_channel *, uint8_t * buffer, short size) -- Read a line of text from the device
FUNC_C_2_S read_b; // short read_b(t_channel *) -- read a single uint8_t from the device
FUNC_CcBS_2_S write; // short write(t_channel *, uint8_t * buffer, short size) -- Write a buffer to the device
FUNC_CcBS_2_S write; // short write(t_channel *, const uint8_t * buffer, short size) -- Write a buffer to the device
FUNC_CB_2_S write_b; // short write_b(t_channel *, const uint8_t b) -- Write a single uint8_t to the device
FUNC_C_2_S status; // short status(t_channel *) -- Get the status of the device
FUNC_C_2_S flush; // short flush(t_channel *) -- Ensure that any pending writes to teh device have been completed
@ -140,7 +140,7 @@ extern short cdev_init(short dev);
* Returns:
* the number of the channel opened, negative number on error
*/
extern short chan_open(short dev, uint8_t * path, short mode);
extern short chan_open(short dev, const uint8_t * path, short mode);
/*
* Close a channel

View file

@ -58,6 +58,7 @@ extern void ansi_el(p_channel chan, short arg_count, short args[]);
extern void ansi_ich(p_channel chan, short arg_count, short args[]);
extern void ansi_dch(p_channel chan, short arg_count, short args[]);
extern void ansi_sgr(p_channel chan, short arg_count, short args[]);
static short con_flush(p_channel chan);
/*
* Console variables and constants
@ -414,7 +415,7 @@ short con_init() {
* Returns
* 0 on success, negative number on failure
*/
short con_open(p_channel chan, uint8_t * path, short mode) {
short con_open(p_channel chan, const uint8_t * path, short mode) {
int i;
p_console_data con_data;
@ -422,7 +423,7 @@ short con_open(p_channel chan, uint8_t * path, short mode) {
/* Initialize the console data for this channel */
con_data = &(chan->data);
con_data = (p_console_data)&(chan->data);
con_data->control = CON_CTRL_ANSI;
con_data->ansi_buffer_count = 0;
for (i = 0; i < ANSI_BUFFER_SIZE; i++) {
@ -439,11 +440,11 @@ short con_open(p_channel chan, uint8_t * path, short mode) {
* Really only does something if the console is set to process ANSI escape codes
*
*/
short con_flush(p_channel chan) {
static short con_flush(p_channel chan) {
int i;
p_console_data con_data;
con_data = &(chan->data);
con_data = (p_console_data)&(chan->data);
if (con_data->control & CON_CTRL_ANSI) {
for (i = 0; i < con_data->ansi_buffer_count; i++) {
text_put_raw(chan->dev, con_data->ansi_buffer[i]);
@ -473,7 +474,7 @@ short con_write_b(p_channel chan, uint8_t b) {
p_console_data con_data;
/* Check to see if we need to process ANSI codes */
con_data = &(chan->data);
con_data = (p_console_data)&(chan->data);
if (con_data->control & CON_CTRL_ANSI) {
/* ANSI codes are to be processed */
ansi_process_c(chan, con_data, (char)b);
@ -492,7 +493,7 @@ short con_read_b(p_channel chan) {
p_console_data con_data;
/* Check to see if we need to process ANSI codes */
con_data = &(chan->data);
con_data = (p_console_data)&(chan->data);
char c;
do {
@ -625,7 +626,7 @@ short con_has_input(p_channel chan) {
char c;
/* Check to see if we need to process ANSI codes */
con_data = &(chan->data);
con_data = (p_console_data)&(chan->data);
if (con_data->key_buffer != 0) {
/* If we already peeked and have a character... return true */
@ -685,7 +686,7 @@ short con_ioctrl(p_channel chan, short command, uint8_t * buffer, short size) {
p_console_data con_data;
/* Check to see if we need to process ANSI codes */
con_data = &(chan->data);
con_data = (p_console_data)&(chan->data);
switch (command) {
case CON_IOCTRL_ANSI_ON:

View file

@ -7,16 +7,18 @@
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "log.h"
#include "syscalls.h"
#include "fsys.h"
#include "fatfs/ff.h"
#include "dev/channel.h"
#include "simpleio.h"
#include "errors.h"
#include "elf.h"
#include "fsys.h"
#include "fatfs/ff.h"
#include "log.h"
#include "syscalls.h"
#include "simpleio.h"
#define MAX_DRIVES 8 /* Maximum number of drives */
#define MAX_DIRECTORIES 8 /* Maximum number of open directories */
@ -330,7 +332,7 @@ short fsys_findnext(short dir, p_file_info file) {
FRESULT fres;
if (g_dir_state[dir]) {
fres = f_findnext(&g_dir_state[dir], &finfo);
fres = f_findnext(&g_directory[dir], &finfo);
if (fres != FR_OK) {
return fatfs_to_foenix(fres);
@ -373,7 +375,6 @@ short fsys_mkdir(const char * path) {
result = f_mkdir(path);
if (result == FR_OK) {
log_num(LOG_ERROR, "fsys_mkdir error: ", result);
return 0;
} else {
log_num(LOG_ERROR, "fsys_mkdir error: ", result);
@ -538,7 +539,7 @@ short fchan_read_b(t_channel * chan) {
file = fchan_to_file(chan);
if (file) {
result = f_read(file, buffer, 1, &total_read);
result = f_read(file, buffer, 1, (UINT*)&total_read);
if (result == FR_OK) {
return (short)(buffer[0] & 0x00ff);
} else {
@ -731,7 +732,7 @@ short fsys_getlabel(char * path, char * label) {
* drive = drive number
* label = buffer that holds the label
*/
short fsys_setlabel(short drive, char * label) {
short fsys_setlabel(short drive, const char * label) {
FRESULT fres;
char buffer[80];
@ -990,7 +991,7 @@ short fsys_elf_loader(short chan, long destination, long * start) {
elf32_program_header progHeader;
chan_seek(chan, 0, 0);
numBytes = chan_read(chan, &header, sizeof(header));
numBytes = chan_read(chan, (uint8_t*)&header, sizeof(header));
if (header.ident.magic[0] != 0x7F ||
header.ident.magic[1] != 'E' ||
@ -1001,7 +1002,7 @@ short fsys_elf_loader(short chan, long destination, long * start) {
}
if (header.machine != CPU_ARCH) {
sprintf(&log_buffer, "[!] Incompatible CPU arch: expected %s, but found %s\n", elf_cpu_desc[CPU_ARCH], elf_cpu_desc[header.machine]);
sprintf((char*)&log_buffer, "[!] Incompatible CPU arch: expected %s, but found %s\n", (char*)elf_cpu_desc[CPU_ARCH], (char*)elf_cpu_desc[header.machine]);
DEBUG(log_buffer);
return ERR_BAD_BINARY;
}
@ -1023,7 +1024,7 @@ short fsys_elf_loader(short chan, long destination, long * start) {
while (progIndex < header.progNum) {
chan_seek(chan, progIndex * header.progSize + header.progOffset, 0);
numBytes = chan_read(chan, &progHeader, sizeof(progHeader));
numBytes = chan_read(chan, (uint8_t*)&progHeader, sizeof(progHeader));
switch (progHeader.type) {
case PT_NULL:
case PT_PHDR:

View file

@ -141,7 +141,7 @@ extern short fsys_getlabel(char * path, char * label);
* drive = drive number
* label = buffer that holds the label
*/
extern short fsys_setlabel(short drive, char * label);
extern short fsys_setlabel(short drive, const char * label);
/*
* Format a drive

View file

@ -542,7 +542,7 @@ short pata_ioctrl(short command, unsigned char * buffer, short size) {
break;
case PATA_GET_DRIVE_INFO:
p_info = (p_drive_info *)buffer;
p_info = (p_drive_info)buffer;
result = pata_identity(p_info);
if (result != 0) {
return result;

View file

@ -3,12 +3,14 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "errors.h"
#include "log.h"
#include "types.h"
#include "ring_buffer.h"
#include "interrupt.h"
#include "simpleio.h"
#include "vicky_general.h"
#include "dev/ps2.h"
#include "dev/rtc.h"
@ -1101,14 +1103,14 @@ short kbd_layout(const char * tables) {
}
/* Reset the translation tables to their default values */
g_kbd_control.keys_unmodified = g_us_sc_unmodified;
g_kbd_control.keys_shift = g_us_sc_shift;
g_kbd_control.keys_control = g_us_sc_ctrl;
g_kbd_control.keys_control_shift = g_us_sc_ctrl_shift;
g_kbd_control.keys_caps = g_us_sc_lock;
g_kbd_control.keys_caps_shift = g_us_sc_lock_shift;
g_kbd_control.keys_r_alt = g_us_sc_alt;
g_kbd_control.keys_r_alt_shift = g_us_sc_alt_shift;
g_kbd_control.keys_unmodified = (char*)g_us_sc_unmodified;
g_kbd_control.keys_shift = (char*)g_us_sc_shift;
g_kbd_control.keys_control = (char*)g_us_sc_ctrl;
g_kbd_control.keys_control_shift = (char*)g_us_sc_ctrl_shift;
g_kbd_control.keys_caps = (char*)g_us_sc_lock;
g_kbd_control.keys_caps_shift = (char*)g_us_sc_lock_shift;
g_kbd_control.keys_r_alt = (char*)g_us_sc_alt;
g_kbd_control.keys_r_alt_shift = (char*)g_us_sc_alt_shift;
} else {
/* No: we're setting new tables */
@ -1162,14 +1164,14 @@ short ps2_init() {
// Set the default keyboard layout to US
g_kbd_control.keys_unmodified = g_us_sc_unmodified;
g_kbd_control.keys_shift = g_us_sc_shift;
g_kbd_control.keys_control = g_us_sc_ctrl;
g_kbd_control.keys_control_shift = g_us_sc_ctrl_shift;
g_kbd_control.keys_caps = g_us_sc_lock;
g_kbd_control.keys_caps_shift = g_us_sc_lock_shift;
g_kbd_control.keys_r_alt = g_us_sc_alt;
g_kbd_control.keys_r_alt_shift = g_us_sc_alt_shift;
g_kbd_control.keys_unmodified = (char*)g_us_sc_unmodified;
g_kbd_control.keys_shift = (char*)g_us_sc_shift;
g_kbd_control.keys_control = (char*)g_us_sc_ctrl;
g_kbd_control.keys_control_shift = (char*)g_us_sc_ctrl_shift;
g_kbd_control.keys_caps = (char*)g_us_sc_lock;
g_kbd_control.keys_caps_shift = (char*)g_us_sc_lock_shift;
g_kbd_control.keys_r_alt = (char*)g_us_sc_alt;
g_kbd_control.keys_r_alt_shift = (char*)g_us_sc_alt_shift;
g_kbd_control.translation_table = 0;
// Disable the PS/2 interrupts...

View file

@ -7,6 +7,7 @@
#include "gabe_reg.h"
#include "rtc.h"
#include "rtc_reg.h"
#include "simpleio.h"
#include "timers.h"
static long rtc_ticks;

View file

@ -102,6 +102,7 @@ int text_init() {
#endif
for (i = 0; i < MAX_TEXT_CHANNELS; i++) {
#pragma dontwarn 113 // only 0 should be assigned to pointer
text_channel[i].master_control = 0xffffffff;
text_channel[i].text_cells = 0xffffffff;
text_channel[i].color_cells = 0xffffffff;
@ -110,6 +111,7 @@ int text_init() {
text_channel[i].border_control = 0xffffffff;
text_channel[i].text_cursor_ptr = 0xffffffff;
text_channel[i].color_cursor_ptr = 0xffffffff;
#pragma popwarn
text_channel[i].current_color = 0;
text_channel[i].columns_max = 0;
text_channel[i].rows_max = 0;
@ -632,10 +634,10 @@ void text_scroll(short screen) {
for (row = 0; row < chan->rows_visible - 1; row++) {
short offset1 = row * chan->columns_max;
short offset2 = (row + 1) * chan->columns_max;
volatile short * text_dest = &chan->text_cells[offset1];
volatile short * color_dest = &chan->color_cells[offset1];
volatile short * text_src = &chan->text_cells[offset2];
volatile short * color_src = &chan->color_cells[offset2];
volatile short * text_dest = (short*)&chan->text_cells[offset1];
volatile short * color_dest = (short*)&chan->color_cells[offset1];
volatile short * text_src = (short*)&chan->text_cells[offset2];
volatile short * color_src = (short*)&chan->color_cells[offset2];
for (column = 0; column < chan->columns_max; column += 2) {
*text_dest++ = *text_src++;
@ -644,8 +646,8 @@ void text_scroll(short screen) {
}
short offset3 = (chan->rows_visible - 1) * chan->columns_max;
volatile short * text_dest = &chan->text_cells[offset3];
volatile short * color_dest = &chan->color_cells[offset3];
volatile short * text_dest = (short*)&chan->text_cells[offset3];
volatile short * color_dest = (short*)&chan->color_cells[offset3];
uint8_t color = chan->current_color;
for (column = 0; column < chan->columns_max; column += 2) {
*text_dest++ = ' ';

View file

@ -2,6 +2,7 @@
* Startup file for the Foenix/MCP
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sys_general.h"
@ -105,7 +106,7 @@ void load_splashscreen() {
long target_ticks;
int i;
unsigned char * pixels;
unsigned char * vram = VRAM_Bank0;
volatile unsigned char * vram = VRAM_Bank0;
/* Turn off the screen */
*MasterControlReg_A = VKY3_MCR_BLANK_EN;

Binary file not shown.

View file

@ -111,7 +111,7 @@ extern int32_t syscall(int32_t function, ...);
* Inputs:
* result = the code to return to the kernel
*/
extern void sys_exit(int result);
extern void sys_exit(short result);
/*
* Enable all interrupts
@ -245,7 +245,7 @@ extern short sys_chan_write_b(short channel, unsigned char b);
* Returns:
* number of bytes written, any negative number is an error code
*/
extern short sys_chan_write(short channel, unsigned char * buffer, short size);
extern short sys_chan_write(short channel, const unsigned char * buffer, short size);
/*
* Return the status of the channel device
@ -307,7 +307,7 @@ extern short sys_chan_ioctrl(short channel, short command, uint8_t * buffer, sho
* Returns:
* the number of the channel opened, negative number on error
*/
extern short sys_chan_open(short dev, uint8_t * path, short mode);
extern short sys_chan_open(short dev, const uint8_t * path, short mode);
/*
* Close a channel

View file

@ -6,6 +6,7 @@
#define __TYPES_H
#include <stdint.h>
#include <stdbool.h>
/*
* Function types
@ -15,7 +16,6 @@
* Integer types in their standard sizes, signed and unsigned.
*/
typedef unsigned char bool;
//
// A color (BGR)

View file

@ -2,9 +2,13 @@
* A logging utility
*/
#include <stdio.h>
#include <string.h>
#include "interrupt.h"
#include "log.h"
#include "simpleio.h"
#include "syscalls.h"
#include "dev/text_screen_iii.h"
static short log_channel = 0;
@ -95,7 +99,7 @@ void err_print(short channel, const char * message, short err_number) {
/*
* Display a panic screen
*/
void panic() {
void panic(void) {
char buffer[80];
short column = 18;
short row = 10;
@ -242,7 +246,7 @@ void log2(short level, char * message1, char * message2) {
* message2 = the second part of the message to log
* message3 = the third part of the message to log
*/
void log3(short level, char * message1, char * message2, char * message3) {
void log3(short level, const char * message1, const char * message2, const char * message3) {
if (level <= log_level) {
print(log_channel, message1);
print(log_channel, message2);

View file

@ -33,7 +33,7 @@ extern void err_print(short channel, const char * message, short err_number);
* Inputs:
* vector = the number of the vector that was called
*/
extern void panic(unsigned short exception_number);
extern void panic(void);
/*
* Set the maximum level of verbosity in logging.
@ -72,7 +72,7 @@ extern void log2(short level, char * message1, char * message2);
* message2 = the second part of the message to log
* message3 = the third part of the message to log
*/
extern void log3(short level, char * message1, char * message2, char * message3);
extern void log3(short level, const char * message1, const char * message2, const char * message3);
/*
* Log a message with a number

View file

@ -41,11 +41,11 @@ unsigned long syscall_dispatch(int32_t function, int32_t param0, int32_t param1,
case KFN_INT_ENABLE:
int_enable((unsigned short)param0);
return;
return 0;
case KFN_INT_DISABLE:
int_disable((unsigned short)param0);
return;
return 0;
case KFN_INT_ENABLE_ALL:
return int_enable_all();
@ -55,14 +55,14 @@ unsigned long syscall_dispatch(int32_t function, int32_t param0, int32_t param1,
case KFN_INT_CLEAR:
int_clear((unsigned short)param0);
return;
return 0;
case KFN_INT_PENDING:
return int_pending((unsigned short)param0);
case KFN_SYS_GET_INFO:
sys_get_information((p_sys_info)param0);
return;
return 0;
default:
return ERR_GENERAL;
@ -82,10 +82,10 @@ unsigned long syscall_dispatch(int32_t function, int32_t param0, int32_t param1,
return chan_read_b((short)param0);
case KFN_CHAN_READ:
return chan_read((short)param0, (const uint8_t *)param1, (short)param2);
return chan_read((short)param0, (uint8_t *)param1, (short)param2);
case KFN_CHAN_READ_LINE:
return chan_readline((short)param0, (const uint8_t *)param1, (short)param2);
return chan_readline((short)param0, (uint8_t *)param1, (short)param2);
case KFN_CHAN_STATUS:
return chan_status((short)param0);
@ -100,7 +100,7 @@ unsigned long syscall_dispatch(int32_t function, int32_t param0, int32_t param1,
return chan_ioctrl((short)param0, (short)param1, (unsigned char *)param2, (short)param3);
case KFN_CHAN_OPEN:
return chan_open((short)param0, (const char *)param1, (short)param2);
return chan_open((short)param0, (const uint8_t *)param1, (short)param2);
case KFN_CHAN_CLOSE:
return chan_close((short)param0);
@ -183,7 +183,7 @@ unsigned long syscall_dispatch(int32_t function, int32_t param0, int32_t param1,
return fsys_setlabel((short)param0, (char *)param1);
case KFN_GET_CWD:
return fsys_get_cwd((char *)param0);
return fsys_get_cwd((char *)param0, (short)param1);
case KFN_SET_CWD:
return fsys_set_cwd((char *)param0);
@ -201,7 +201,7 @@ unsigned long syscall_dispatch(int32_t function, int32_t param0, int32_t param1,
/* Process and Memory functions */
switch (function) {
case KFN_RUN:
return proc_run((char *)param0, (int)param1, (char *)param2);
return proc_run((char *)param0, (int)param1, (char **)param2);
break;
default:

View file

@ -13,13 +13,9 @@
;
; Interrupt registers for A2560U and U+
;
; PENDING_GRP0 = $00B00100
; PENDING_GRP1 = $00B00102
; PENDING_GRP2 = $00B00104
PENDING_GRP0 = $00C00100
PENDING_GRP1 = $00C00102
PENDING_GRP2 = $00C00104
PENDING_GRP0 = $00B00100
PENDING_GRP1 = $00B00102
PENDING_GRP2 = $00B00104
section "VECTORS",code
@ -49,11 +45,11 @@ PENDING_GRP2 = $00C00104
dc.l not_impl ; 23 - Reserved
dc.l _handle_spurious ; 24 - Spurious Interrupt
dc.l not_impl ; 25 - Level 1 Interrupt Autovector
dc.l autovec2 ; 26 - Level 2 Interrupt Autovector
dc.l not_impl ; 26 - Level 2 Interrupt Autovector
dc.l not_impl ; 27 - Level 3 Interrupt Autovector
dc.l not_impl ; 28 - Level 4 Interrupt Autovector
dc.l not_impl ; 29 - Level 5 Interrupt Autovector
dc.l not_impl ; 30 - Level 6 Interrupt Autovector
dc.l autovec2 ; 30 - Level 6 Interrupt Autovector
dc.l not_impl ; 31 - Level 7 Interrupt Autovector
dc.l not_impl ; 32 - TRAP #0
dc.l not_impl ; 33 - TRAP #1
@ -126,14 +122,20 @@ PENDING_GRP2 = $00C00104
coldboot: lea ___STACK,sp
bsr _int_disable_all
lea ___BSSSTART,a0
; Clear BSS segment
lea ___BSSSTART,a0
move.l #___BSSSIZE,d0
beq callmain
beq.s callmain
clr.l d1
clrloop: move.l d1,(a0)+
move.l #0,d1
clrloop: ; We don't use clr.l because it's a read-modify-write operation
; that is not yet supported by the FPGA's bus logic for now.
; So we use a move instead.
; clr.l (a0)+
move.l d1,(a0)+
subq.l #4,d0
bne clrloop
bne.s clrloop
; Set TRAP #15 vector handler
lea h_trap_15,a0 ; Address of the handler

15174
src/mapfile

File diff suppressed because it is too large Load diff

View file

@ -255,7 +255,7 @@ const unsigned char splashscreen_lut[] = {
0xFD, 0xFD, 0xFD, 0x00,
0xFE, 0xFE, 0xFE, 0x00,
0xFF, 0xFF, 0xFF, 0x00,
}
};
const unsigned char splashscreen_pix[] = {
0xFF, 0x10, 0xFF, 0x10, 0xFF, 0x10, 0xFF, 0x10, 0xFF, 0x10, 0xFF, 0x10, 0xFF, 0x10, 0xFF, 0x10,

View file

@ -6,6 +6,7 @@
#include <string.h>
#include "syscalls.h"
#include "simpleio.h"
#include "dev/text_screen_iii.h"
/*
* Print a character to a channel
@ -26,10 +27,12 @@ void print_c(short channel, char c) {
* channel = the number of the channel
* message = the ASCII-Z string to print
*/
void print(short channel, char * message) {
int i;
for (i = 0; i < strlen(message); i++) {
print_c(channel, message[i]);
void print(short channel, const char * message) {
char *p = (char*)message;
char c;
while ((c = *p++)) {
print_c(channel, c);
}
// sys_chan_write(channel, message, strlen(message));
}
@ -93,7 +96,7 @@ void print_hex_16(short channel, unsigned short x) {
* channel = the number of the channel
* n = the number to print
*/
void print_hex_32(short channel, long n) {
void print_hex_32(short channel, unsigned long n) {
char number[9];
short digit;
short i;
@ -159,7 +162,7 @@ unsigned char i_to_bcd(unsigned short n) {
* size = the number of bytes to print
* labels = 0: none, 1: offset, 2: address
*/
void dump_buffer(short channel, unsigned char * buffer, short size, short labels) {
void dump_buffer(short channel, const unsigned char * buffer, short size, short labels) {
short i, j, ascii_idx;
char ascii_buffer[17];
unsigned char c;

View file

@ -12,7 +12,7 @@
* channel = the number of the channel
* message = the ASCII-Z string to print
*/
extern void print(short channel, char * message);
extern void print(short channel, const char * message);
/*
* Print a character to a channel
@ -30,7 +30,7 @@ extern void print_c(short channel, char c);
* channel = the number of the channel
* n = the number to print
*/
extern void print_hex_8(short channel, short n);
extern void print_hex_8(short channel, unsigned short n);
/*
* Print an 16-bit number as hex to a channel
@ -39,7 +39,7 @@ extern void print_hex_8(short channel, short n);
* channel = the number of the channel
* n = the number to print
*/
extern void print_hex_16(short channel, short n);
extern void print_hex_16(short channel, unsigned short n);
/*
* Print an 32-bit number as hex to a channel
@ -48,7 +48,7 @@ extern void print_hex_16(short channel, short n);
* channel = the number of the channel
* n = the number to print
*/
extern void print_hex_32(short channel, long n);
extern void print_hex_32(short channel, unsigned long n);
/*
* Convert a BCD byte to an integer
@ -81,6 +81,6 @@ extern unsigned char i_to_bcd(unsigned short n);
* size = the number of bytes to print
* labels = 0: none, 1: offset, 2: address
*/
extern void dump_buffer(short channel, unsigned char * buffer, short size, short labels);
extern void dump_buffer(short channel, const unsigned char * buffer, short size, short labels);
#endif

View file

@ -4,7 +4,7 @@
#include "snd/codec.h"
static unsigned byte volume = 0xff;
static unsigned char volume = 0xff;
/*
* Wait for the CODEC to be ready to receive more data.
@ -41,10 +41,10 @@ void init_codec() {
void codec_set_volume(unsigned char vol) {
volume = vol;
*CODEC = 0x0A00 | (0xFF - (vol & 0xFF));
*CODEC = 0x0A00 | (0xFF - vol);
codec_wait();
*CODEC = 0x0400 | ((vol >> 1) & 0xff);
*CODEC = 0x0400 | (vol >> 1);
codec_wait();
}

View file

@ -175,7 +175,7 @@ short sys_chan_write_b(short channel, unsigned char b) {
* Returns:
* number of bytes written, any negative number is an error code
*/
short sys_chan_write(short channel, unsigned char * buffer, short size) {
short sys_chan_write(short channel, const unsigned char * buffer, short size) {
return syscall(KFN_CHAN_WRITE, channel, buffer, size);
}
@ -247,7 +247,7 @@ short sys_chan_ioctrl(short channel, short command, uint8_t * buffer, short size
* Returns:
* the number of the channel opened, negative number on error
*/
short sys_chan_open(short dev, uint8_t * path, short mode) {
short sys_chan_open(short dev, const uint8_t * path, short mode) {
return syscall(KFN_CHAN_OPEN, path, mode);
}
@ -272,7 +272,7 @@ short sys_chan_close(short chan) {
* screen = the screen number 0 for channel A, 1 for channel B
*/
void sys_text_setsizes(short chan) {
return syscall(KFN_TEXT_SETSIZES, chan);
syscall(KFN_TEXT_SETSIZES, chan);
}
/***
@ -467,7 +467,7 @@ short sys_fsys_findnext(short dir, p_file_info file) {
* path = path to the drive
* label = buffer that will hold the label... should be at least 35 bytes
*/
short sys_fsys_get_label(char * path, char * label) {
short sys_fsys_get_label(const char * path, char * label) {
return (short)syscall(KFN_GET_LABEL, path, label);
}