From f95099cf4106f354448b55f716c4212dec12d939 Mon Sep 17 00:00:00 2001 From: Vincent Barrilliot Date: Thu, 9 Dec 2021 20:44:54 +0100 Subject: [PATCH] Remove warnings, fix bug in fsys_findnext --- src/dev/channel.c | 2 +- src/dev/channel.h | 6 +++--- src/dev/console.c | 17 +++++++++-------- src/dev/fsys.c | 22 +++++++++++----------- src/dev/pata.c | 2 +- src/foenixmcp.c | 3 ++- src/include/syscalls.h | 4 ++-- src/log.c | 3 ++- src/log.h | 2 +- src/m68k/bios_m68k.c | 18 +++++++++--------- src/rsrc/bitmaps/splash_a2560u.h | 4 ++-- src/simpleio.c | 4 +++- src/simpleio.h | 6 +++--- src/syscalls.c | 8 ++++---- 14 files changed, 53 insertions(+), 48 deletions(-) diff --git a/src/dev/channel.c b/src/dev/channel.c index 1b8f8f0..e456382 100644 --- a/src/dev/channel.c +++ b/src/dev/channel.c @@ -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; diff --git a/src/dev/channel.h b/src/dev/channel.h index c9f5026..4ab84fc 100644 --- a/src/dev/channel.h +++ b/src/dev/channel.h @@ -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 diff --git a/src/dev/console.c b/src/dev/console.c index 5d33114..9468544 100644 --- a/src/dev/console.c +++ b/src/dev/console.c @@ -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: diff --git a/src/dev/fsys.c b/src/dev/fsys.c index f5904f7..0a40817 100644 --- a/src/dev/fsys.c +++ b/src/dev/fsys.c @@ -9,16 +9,16 @@ #include #include #include - #include -#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 */ @@ -332,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); @@ -539,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, (void*)buffer, 1, (UINT*)&total_read); if (result == FR_OK) { return (short)(buffer[0] & 0x00ff); } else { @@ -991,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' || @@ -1002,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; } @@ -1024,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: diff --git a/src/dev/pata.c b/src/dev/pata.c index 58c62ef..9eaf808 100644 --- a/src/dev/pata.c +++ b/src/dev/pata.c @@ -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; diff --git a/src/foenixmcp.c b/src/foenixmcp.c index b46f522..31d5186 100644 --- a/src/foenixmcp.c +++ b/src/foenixmcp.c @@ -2,6 +2,7 @@ * Startup file for the Foenix/MCP */ +#include #include #include #include "sys_general.h" @@ -101,7 +102,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; diff --git a/src/include/syscalls.h b/src/include/syscalls.h index c844615..8e62fb1 100644 --- a/src/include/syscalls.h +++ b/src/include/syscalls.h @@ -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 @@ -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 diff --git a/src/log.c b/src/log.c index bdd68ba..62a5f11 100644 --- a/src/log.c +++ b/src/log.c @@ -8,6 +8,7 @@ #include "interrupt.h" #include "log.h" #include "simpleio.h" +#include "syscalls.h" #include "dev/text_screen_iii.h" static short log_channel = 0; @@ -98,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; diff --git a/src/log.h b/src/log.h index 94871e8..3e95b5c 100644 --- a/src/log.h +++ b/src/log.h @@ -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. diff --git a/src/m68k/bios_m68k.c b/src/m68k/bios_m68k.c index 63fe53e..6eb8091 100644 --- a/src/m68k/bios_m68k.c +++ b/src/m68k/bios_m68k.c @@ -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: diff --git a/src/rsrc/bitmaps/splash_a2560u.h b/src/rsrc/bitmaps/splash_a2560u.h index 6ff0949..b334f11 100644 --- a/src/rsrc/bitmaps/splash_a2560u.h +++ b/src/rsrc/bitmaps/splash_a2560u.h @@ -255,7 +255,7 @@ unsigned char splashscreen_lut[] = { 0xFD, 0xFD, 0xFD, 0x00, 0xFE, 0xFE, 0xFE, 0x00, 0xFF, 0xFF, 0xFF, 0x00, -} +}; unsigned char splashscreen_pix[] = { 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, @@ -824,4 +824,4 @@ unsigned char splashscreen_pix[] = { 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0xFF, 0x1F, 0x69, 0x1F, 0x00, 0x00 -} +}; \ No newline at end of file diff --git a/src/simpleio.c b/src/simpleio.c index df78bfa..14a0ac4 100644 --- a/src/simpleio.c +++ b/src/simpleio.c @@ -2,9 +2,11 @@ * A simple collection of I/O functions the kernel will need often */ +#include #include #include "syscalls.h" #include "simpleio.h" +#include "dev/text_screen_iii.h" /* * Print a character to a channel @@ -94,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; diff --git a/src/simpleio.h b/src/simpleio.h index 22a753a..1054a98 100644 --- a/src/simpleio.h +++ b/src/simpleio.h @@ -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 diff --git a/src/syscalls.c b/src/syscalls.c index cb832cc..14afd99 100644 --- a/src/syscalls.c +++ b/src/syscalls.c @@ -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); } @@ -600,7 +600,7 @@ short sys_fsys_register_loader(const char * extension, p_file_loader loader) { * Returns: * the number of jiffies since the last reset */ -extern long sys_time_jiffies() { +long sys_time_jiffies() { return syscall(KFN_TIME_JIFFIES); }