Remove warnings, fix bug in fsys_findnext

This commit is contained in:
Vincent Barrilliot 2021-12-09 20:44:54 +01:00
parent e1c2148c43
commit f95099cf41
14 changed files with 53 additions and 48 deletions

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

@ -9,16 +9,16 @@
#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 */
@ -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:

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

@ -2,6 +2,7 @@
* Startup file for the Foenix/MCP
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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;

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

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

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.

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

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

View file

@ -2,9 +2,11 @@
* A simple collection of I/O functions the kernel will need often
*/
#include <ctype.h>
#include <string.h>
#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;

View file

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

View file

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