Compare commits

..

No commits in common. "experiments" and "main" have entirely different histories.

26 changed files with 374 additions and 424 deletions

8
.gitignore vendored
View file

@ -52,11 +52,3 @@ Mkfile.old
dkms.conf dkms.conf
.vscode/settings.json .vscode/settings.json
/misc/F256xE_Kernal_Code /misc/F256xE_Kernal_Code
# lsp / clangd
/.cache/
/.clangd
/compile_commands.json
build/
/foenixmgr.ini

142
Makefile
View file

@ -1,142 +0,0 @@
TARGET = toolbox
TARGET_RAM = $(TARGET)_ram
TARGET_ROM = $(TARGET)_rom
UNIT = F256K
SRCS_BASE = boot.c \
log.c \
memory.c \
proc.c \
ring_buffer.c \
simpleio.c \
sys_general.c \
timers.c \
toolbox.c \
utilities.c \
dev/block.c \
dev/channel.c \
dev/console.c \
dev/fsys.c \
dev/sprites.c \
dev/tiles.c \
dev/txt_screen.c \
dev/rtc.c \
dev/uart.c \
snd/codec_c256.c \
snd/psg.c \
snd/sid.c \
fatfs/ff.c \
fatfs/ffsystem.c \
fatfs/ffunicode.c
SRCS_BASE_F256 = cartridge.c \
dev/txt_f256.c \
dev/kbd_f256.c \
dev/indicators_c256.c \
dev/interrupts_f256.c \
dev/sdc_f256.c \
dev/iec.c \
fatfs/toolbox_bdev.c \
C256/extras.s \
C256/f256-cstartup.s \
C256/iecll.s \
C256/interrupts.s \
C256/io_stubs.c \
C256/jumptable.s
ifeq ($(UNIT),F256)
TOOLCHAIN = 65816
SRCS_FOR_UNIT = $(SRCS_BASE_F256) dev/kbd_f256jr.c
CFLAGS_FOR_UNIT = -DMODEL=2 -DCPU=255 --target=f256
LDFLAGS_FOR_UNIT_ROM = src/C256/f256-flash.scm --cstartup=f256
LDFLAGS_FOR_UNIT_RAM = src/C256/f256-ld_lc.scm --cstartup=f256
else ifeq ($(UNIT),F256JR2)
TOOLCHAIN = 65816
SRCS_FOR_UNIT = $(SRCS_BASE_F256) dev/kbd_f256jr.c
CFLAGS_FOR_UNIT = -DMODEL=35 -DCPU=255 --target=f256
LDFLAGS_FOR_UNIT_ROM = src/C256/f256k2-flash.scm --cstartup=f256
LDFLAGS_FOR_UNIT_RAM = src/C256/f256-ld_lc.scm --cstartup=f256
else ifeq ($(UNIT),F256K)
TOOLCHAIN = 65816
SRCS_FOR_UNIT = $(SRCS_BASE_F256) dev/kbd_f256k.c
CFLAGS_FOR_UNIT = -DMODEL=18 -DCPU=255 --target=f256
LDFLAGS_FOR_UNIT_ROM = src/C256/f256-flash.scm --cstartup=f256
LDFLAGS_FOR_UNIT_RAM = src/C256/f256-ld_lc.scm --cstartup=f256
else ifeq ($(UNIT),F256K2)
TOOLCHAIN = 65816
SRCS_FOR_UNIT = $(SRCS_BASE_F256) dev/kbd_f256k.c
CFLAGS_FOR_UNIT = -DMODEL=17 -DCPU=255 --target=f256
LDFLAGS_FOR_UNIT_ROM = src/C256/f256k2-flash.scm --cstartup=f256
LDFLAGS_FOR_UNIT_RAM = src/C256/f256-ld_lc.scm --cstartup=f256
else
$(error Unrecognized UNIT: "$(UNIT)")
endif
ifeq ($(TOOLCHAIN),65816)
ifeq ($(strip $(CALYPSI_65816_ROOT)),)
$(error Please set CALYPSI_65816_ROOT in your environment!)
endif
CC = cc65816
AS = as65816
LD = ln65816
TOOLCHAIN_ROOT = $(CALYPSI_65816_ROOT)
else
$(error Unrecognized TOOLCHAIN: "$(TOOLCHAIN)")
endif
SRC_DIR = src
SRC_FILES = $(addprefix $(SRC_DIR)/, $(SRCS_BASE) $(SRCS_FOR_UNIT))
INCLUDE_DIRS = $(SRC_DIR) $(SRC_DIR)/include $(TOOLCHAIN_ROOT)/include
INCLUDES = $(foreach dir,$(INCLUDE_DIRS),-I$(dir))
BUILD_DIR = build
OBJ_DIR = $(BUILD_DIR)/obj
OBJ_FILES = $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(SRC_FILES)))
DEPENDS = $(OBJ_FILES:.o=.d)
CFLAGS = --code-model=large --data-model=large --list-file=$@.lst $(INCLUDES) $(CFLAGS_FOR_UNIT)
AFLAGS = --code-model=large --data-model=large $(INCLUDES)
LDFLAGS_FOR_ROM = --rom-code $(LDFLAGS_FOR_UNIT_ROM)
LDFLAGS_FOR_RAM = $(LDFLAGS_FOR_UNIT_RAM)
.PHONY: clean
all: rom ram flashable
rom: $(BUILD_DIR)/$(TARGET_ROM).s37
ram: $(BUILD_DIR)/$(TARGET_RAM).s37
flashable: $(BUILD_DIR)/$(TARGET).bin
clean:
rm -f $(BUILD_DIR)/*.s37
rm -f $(BUILD_DIR)/*.lst
rm -f $(BUILD_DIR)/*.bin
rm -rf $(OBJ_DIR)
$(BUILD_DIR)/$(TARGET_ROM).s37: $(OBJ_FILES)
$(LD) -o $@ $^ $(LDFLAGS_FOR_ROM) --output-format=s37 --list-file=$@.lst
$(BUILD_DIR)/$(TARGET_RAM).s37: $(OBJ_FILES)
$(LD) -o $@ $^ $(LDFLAGS_FOR_RAM) --output-format=s37 --list-file=$@.lst
$(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET_ROM).s37
python utils/srec2bin.py $(BUILD_DIR)/$(TARGET_ROM).s37
$(OBJ_DIR)/%.c.o: %.c
@mkdir -p $(dir $@)
$(CC) -MMD -MP -MF$(patsubst %.o,%.d,$@) $(CFLAGS) -o $@ $<
$(OBJ_DIR)/%.s.o: %.s
@mkdir -p $(dir $@)
$(AS) $(AFLAGS) -o $@ $<
-include $(DEPENDS)

View file

@ -556,13 +556,13 @@ void boot_screen() {
for (i = 0; i < boot_src_cnt; i++) { for (i = 0; i < boot_src_cnt; i++) {
if (bootable[i]) { if (bootable[i]) {
snprintf(message, 80, "\e[93mF%d\e[37m-%s\n", i+1, boot_source_name(boot_chain[i])); sprintf(message, "\e[93mF%d\e[37m-%s\n", i+1, boot_source_name(boot_chain[i]));
chan_write(0, (uint8_t *)message, strlen(message)); chan_write(0, (uint8_t *)message, strlen(message));
} }
} }
} }
snprintf(message, 80, "\nPress \e[93mSPACE\e[37m for default.\n"); sprintf(message, "\nPress \e[93mSPACE\e[37m for default.\n");
chan_write(0, (uint8_t *)message, strlen(message)); chan_write(0, (uint8_t *)message, strlen(message));
// Give the user time to press a key to select a boot source // Give the user time to press a key to select a boot source

View file

@ -34,7 +34,7 @@ void bdev_init_system() {
SYSTEMCALL short bdev_register(p_dev_block device) { SYSTEMCALL short bdev_register(p_dev_block device) {
short dev; short dev;
TRACE("bdev_register(%s)", device->name); TRACE1("bdev_register(%s)", device->name);
dev = device->number; dev = device->number;
if (dev < BDEV_DEVICES_MAX) { if (dev < BDEV_DEVICES_MAX) {
@ -68,7 +68,7 @@ SYSTEMCALL short bdev_register(p_dev_block device) {
// 0 on success, any negative number is an error code // 0 on success, any negative number is an error code
// //
short bdev_init(short dev) { short bdev_init(short dev) {
TRACE("bdev_init(%d)", (int)dev); TRACE1("bdev_init(%d)", (int)dev);
short ret = DEV_ERR_BADDEV; short ret = DEV_ERR_BADDEV;
@ -79,7 +79,7 @@ short bdev_init(short dev) {
} }
} }
TRACE("bdev_init returning %d", (int)ret); TRACE1("bdev_init returning %d", (int)ret);
return ret; return ret;
} }
@ -96,7 +96,7 @@ short bdev_init(short dev) {
// number of bytes read, any negative number is an error code // number of bytes read, any negative number is an error code
// //
SYSTEMCALL short bdev_read(short dev, long lba, unsigned char * buffer, short size) { SYSTEMCALL short bdev_read(short dev, long lba, unsigned char * buffer, short size) {
TRACE("bdev_read(%d,%ld,%p,%d)", (int)dev, lba, buffer, (int)size); TRACE4("bdev_read(%d,%ld,%p,%d)", (int)dev, lba, buffer, (int)size);
short ret = DEV_ERR_BADDEV; short ret = DEV_ERR_BADDEV;
@ -106,7 +106,7 @@ SYSTEMCALL short bdev_read(short dev, long lba, unsigned char * buffer, short si
ret = bdev->read(bdev, lba, buffer, size); ret = bdev->read(bdev, lba, buffer, size);
} }
TRACE("bdev_read returning %d", (int)ret); TRACE1("bdev_read returning %d", (int)ret);
return ret; return ret;
} }
@ -123,7 +123,7 @@ SYSTEMCALL short bdev_read(short dev, long lba, unsigned char * buffer, short si
// number of bytes written, any negative number is an error code // number of bytes written, any negative number is an error code
// //
SYSTEMCALL short bdev_write(short dev, long lba, const unsigned char * buffer, short size) { SYSTEMCALL short bdev_write(short dev, long lba, const unsigned char * buffer, short size) {
TRACE("bdev_write(%d,%ld,%p,%d)", (int)dev, lba, buffer, (int)size); TRACE4("bdev_write(%d,%ld,%p,%d)", (int)dev, lba, buffer, (int)size);
short ret = DEV_ERR_BADDEV; short ret = DEV_ERR_BADDEV;
@ -133,7 +133,7 @@ SYSTEMCALL short bdev_write(short dev, long lba, const unsigned char * buffer, s
ret = bdev->write(bdev, lba, buffer, size); ret = bdev->write(bdev, lba, buffer, size);
} }
TRACE("bdev_write returning %d", (int)ret); TRACE1("bdev_write returning %d", (int)ret);
return ret; return ret;
} }
@ -147,7 +147,7 @@ SYSTEMCALL short bdev_write(short dev, long lba, const unsigned char * buffer, s
// the status of the device // the status of the device
// //
SYSTEMCALL short bdev_status(short dev) { SYSTEMCALL short bdev_status(short dev) {
TRACE("bdev_status(%d)", dev); TRACE1("bdev_status(%d)", dev);
short ret = DEV_ERR_BADDEV; short ret = DEV_ERR_BADDEV;
@ -157,7 +157,7 @@ SYSTEMCALL short bdev_status(short dev) {
ret = bdev->status(bdev); ret = bdev->status(bdev);
} }
TRACE("bdev_status returning %d", (int)ret); TRACE1("bdev_status returning %d", (int)ret);
return ret; return ret;
} }
@ -171,7 +171,7 @@ SYSTEMCALL short bdev_status(short dev) {
// 0 on success, any negative number is an error code // 0 on success, any negative number is an error code
// //
SYSTEMCALL short bdev_flush(short dev) { SYSTEMCALL short bdev_flush(short dev) {
TRACE("bdev_flush(%d)", (int)dev); TRACE1("bdev_flush(%d)", (int)dev);
short ret = DEV_ERR_BADDEV; short ret = DEV_ERR_BADDEV;
@ -181,7 +181,7 @@ SYSTEMCALL short bdev_flush(short dev) {
return bdev->flush(bdev); return bdev->flush(bdev);
} }
TRACE("bdev_flush returning %d", (int)ret); TRACE1("bdev_flush returning %d", (int)ret);
return ret; return ret;
} }
@ -198,7 +198,7 @@ SYSTEMCALL short bdev_flush(short dev) {
// 0 on success, any negative number is an error code // 0 on success, any negative number is an error code
// //
SYSTEMCALL short bdev_ioctrl(short dev, short command, unsigned char * buffer, short size) { SYSTEMCALL short bdev_ioctrl(short dev, short command, unsigned char * buffer, short size) {
TRACE("bdev_ioctrl(%d, %d, %p, %d)", (int)dev, command, buffer, (int)size); TRACE4("bdev_ioctrl(%d, %d, %p, %d)", (int)dev, command, buffer, (int)size);
short ret = DEV_ERR_BADDEV; short ret = DEV_ERR_BADDEV;
@ -208,6 +208,6 @@ SYSTEMCALL short bdev_ioctrl(short dev, short command, unsigned char * buffer, s
ret = bdev->ioctrl(bdev, command, buffer, size); ret = bdev->ioctrl(bdev, command, buffer, size);
} }
TRACE("bdev_ioctrl returning %d", (int)ret); TRACE1("bdev_ioctrl returning %d", (int)ret);
return ret; return ret;
} }

View file

@ -48,7 +48,7 @@ void cdev_init_system() {
// //
short cdev_register(const p_dev_chan device) { short cdev_register(const p_dev_chan device) {
TRACE("cdev_register %s", device->name); TRACE1("cdev_register %s", device->name);
short dev; short dev;
dev = device->number; dev = device->number;
@ -73,7 +73,7 @@ short cdev_register(const p_dev_chan device) {
p_channel chan_alloc(short dev) { p_channel chan_alloc(short dev) {
int i; int i;
TRACE("chan_alloc(%d)", (int)dev); TRACE1("chan_alloc(%d)", (int)dev);
if ((dev >= CDEV_CONSOLE) && (dev < CDEV_FILE)) { if ((dev >= CDEV_CONSOLE) && (dev < CDEV_FILE)) {
/* For most devices (all but files): the channel is always the same number as the device */ /* For most devices (all but files): the channel is always the same number as the device */
@ -114,7 +114,7 @@ p_channel chan_get_record(short c) {
// chan = a pointer to the channel record to return to the kernel // chan = a pointer to the channel record to return to the kernel
// //
void chan_free(p_channel chan) { void chan_free(p_channel chan) {
INFO("chan_free: %d", chan->number); log_num(LOG_INFO, "chan_free: ", chan->number);
chan->number = -1; chan->number = -1;
chan->dev = -1; chan->dev = -1;
@ -139,12 +139,12 @@ short chan_get_records(short channel, p_channel * chan, p_dev_chan * cdev) {
*cdev = &g_channel_devs[(*chan)->dev]; *cdev = &g_channel_devs[(*chan)->dev];
return 0; return 0;
} else { } else {
ERROR("chan_get_records 1: %d", (*chan)->dev); log_num(LOG_ERROR, "chan_get_records 1: ", (*chan)->dev);
return DEV_ERR_BADDEV; return DEV_ERR_BADDEV;
} }
} else { } else {
ERROR("chan_get_records 2: %d", channel); log_num(LOG_ERROR, "chan_get_records 2: ", channel);
return DEV_ERR_BADDEV; return DEV_ERR_BADDEV;
} }
@ -189,7 +189,7 @@ SYSTEMCALL short chan_open(short dev, const uint8_t * path, short mode) {
p_dev_chan cdev; p_dev_chan cdev;
TRACE("chan_open"); TRACE("chan_open");
DEBUG("dev = %d", dev); log_num(LOG_DEBUG, "dev = ", dev);
if (dev < CDEV_DEVICES_MAX) { if (dev < CDEV_DEVICES_MAX) {
/* Get the device record */ /* Get the device record */
@ -236,7 +236,7 @@ SYSTEMCALL short chan_open(short dev, const uint8_t * path, short mode) {
* nothing useful * nothing useful
*/ */
SYSTEMCALL short chan_close(short channel) { SYSTEMCALL short chan_close(short channel) {
TRACE("chan_close(%d)", channel); TRACE1("chan_close(%d)", channel);
p_channel chan; p_channel chan;
p_dev_chan cdev; p_dev_chan cdev;
if (chan_get_records(channel, &chan, &cdev) == 0) { if (chan_get_records(channel, &chan, &cdev) == 0) {
@ -265,14 +265,14 @@ SYSTEMCALL short chan_read(short channel, uint8_t * buffer, short size) {
p_dev_chan cdev; p_dev_chan cdev;
short res; short res;
TRACE("chan_read(%d,%p,%d)", (int)channel, buffer, (int)size); TRACE3("chan_read(%d,%p,%d)", (int)channel, buffer, (int)size);
res = chan_get_records(channel, &chan, &cdev); res = chan_get_records(channel, &chan, &cdev);
if (res == 0) { if (res == 0) {
DEBUG("chan_read: %s", cdev->name); DEBUG1("chan_read: %s", cdev->name);
res = cdev->read ? cdev->read(chan, buffer, size) : 0; res = cdev->read ? cdev->read(chan, buffer, size) : 0;
} else { } else {
DEBUG("Couldn't get channel: %d", (int)res); DEBUG1("Couldn't get channel: %d", (int)res);
} }
return res; return res;
} }
@ -347,13 +347,13 @@ SYSTEMCALL short chan_write(short channel, const uint8_t * buffer, short size) {
p_channel chan; p_channel chan;
p_dev_chan cdev; p_dev_chan cdev;
short res; short res;
TRACE("chan_write(%d,%p,%x)", channel, buffer, (int)size); log(LOG_TRACE,"chan_write(%d,%p,%x)", channel, buffer, (int)size);
res = chan_get_records(channel, &chan, &cdev); res = chan_get_records(channel, &chan, &cdev);
if (res == 0) if (res == 0)
res = cdev->write ? cdev->write(chan, buffer, size) : 0; res = cdev->write ? cdev->write(chan, buffer, size) : 0;
else else
ERROR("chan_write error: %d", res); ERROR1("chan_write error: %d", res);
return res; return res;
} }
@ -378,7 +378,7 @@ SYSTEMCALL short chan_write_b(short channel, uint8_t b) {
if (res == 0) if (res == 0)
res = cdev->write_b ? cdev->write_b(chan, b) : 0; res = cdev->write_b ? cdev->write_b(chan, b) : 0;
else else
ERROR("chan_write_b error: %d", res); ERROR1("chan_write_b error: %d", res);
return res; return res;
} }
@ -402,7 +402,7 @@ SYSTEMCALL short chan_status(short channel) {
if (res == 0) if (res == 0)
res = cdev->status ? cdev->status(chan) : 0; res = cdev->status ? cdev->status(chan) : 0;
else else
ERROR("chan_status error: %d", res); ERROR1("chan_status error: %d", res);
return res; return res;
} }
@ -425,7 +425,7 @@ SYSTEMCALL short chan_flush(short channel) {
if (res == 0) if (res == 0)
res = cdev->flush ? cdev->flush(chan) : 0; res = cdev->flush ? cdev->flush(chan) : 0;
else else
ERROR("flush error: %d", res); ERROR1("flush error: %d", res);
return res; return res;
} }
@ -451,7 +451,7 @@ SYSTEMCALL short chan_seek(short channel, long position, short base) {
if (res == 0) if (res == 0)
res = cdev->seek ? cdev->seek(chan, position, base) : 0; res = cdev->seek ? cdev->seek(chan, position, base) : 0;
else else
ERROR("chan_seek error: %d", res); ERROR1("chan_seek error: %d", res);
return res; return res;
} }
@ -477,7 +477,7 @@ SYSTEMCALL short chan_ioctrl(short channel, short command, uint8_t * buffer, sho
if (res == 0) if (res == 0)
res = cdev->ioctrl ? cdev->ioctrl(chan, command, buffer, size) : 0; res = cdev->ioctrl ? cdev->ioctrl(chan, command, buffer, size) : 0;
else else
ERROR("chan_seek error: %d", res); ERROR1("chan_seek error: %d", res);
return res; return res;
} }

View file

@ -134,7 +134,7 @@ SYSTEMCALL short fsys_open(const char * path, short mode) {
p_channel chan = 0; p_channel chan = 0;
short i, fd = -1; short i, fd = -1;
TRACE("fsys_open(\"%s\",%d)", path, (int)mode); TRACE2("fsys_open(\"%s\",%d)", path, (int)mode);
// If the file being opened is on the floppy drive, make sure the FDC status // If the file being opened is on the floppy drive, make sure the FDC status
// is updated correctly for disk change by spinning up the motor and checking the DIR register // is updated correctly for disk change by spinning up the motor and checking the DIR register
@ -159,7 +159,7 @@ SYSTEMCALL short fsys_open(const char * path, short mode) {
chan = chan_alloc(CDEV_FILE); chan = chan_alloc(CDEV_FILE);
if (chan) { if (chan) {
INFO("chan_alloc: %d", (int)chan->number); INFO1("chan_alloc: %d", (int)chan->number);
chan->dev = CDEV_FILE; chan->dev = CDEV_FILE;
FRESULT result = f_open(&g_file[fd], path, mode); FRESULT result = f_open(&g_file[fd], path, mode);
if (result == 0) { if (result == 0) {
@ -167,7 +167,7 @@ SYSTEMCALL short fsys_open(const char * path, short mode) {
return chan->number; return chan->number;
} else { } else {
/* There was an error... deallocate the channel and file descriptor */ /* There was an error... deallocate the channel and file descriptor */
ERROR("fsys_open error: %d", result); ERROR1("fsys_open error: %d", result);
g_fil_state[fd] = 0; g_fil_state[fd] = 0;
chan_free(chan); chan_free(chan);
return fatfs_to_foenix(result); return fatfs_to_foenix(result);
@ -249,7 +249,7 @@ SYSTEMCALL short fsys_opendir(const char * path) {
} }
if (fres != FR_OK) { if (fres != FR_OK) {
/* If there was a problem, return an error number */ /* If there was a problem, return an error number */
ERROR("FATFS Error: %d", fres); ERROR1("FATFS Error: %d", fres);
return fatfs_to_foenix(fres); return fatfs_to_foenix(fres);
} else { } else {
/* Otherwise, allocate and return the handle */ /* Otherwise, allocate and return the handle */
@ -506,7 +506,7 @@ SYSTEMCALL short fsys_mkdir(const char * path) {
if (result == FR_OK) { if (result == FR_OK) {
return 0; return 0;
} else { } else {
ERROR("fsys_mkdir error: %d", result); log_num(LOG_ERROR, "fsys_mkdir error: ", result);
return fatfs_to_foenix(result); return fatfs_to_foenix(result);
} }
} }
@ -531,7 +531,7 @@ SYSTEMCALL short fsys_delete(const char * path) {
if (result == FR_OK) { if (result == FR_OK) {
return 0; return 0;
} else { } else {
ERROR("fsys_delete error: %d", result); log_num(LOG_ERROR, "fsys_delete error: ", result);
return fatfs_to_foenix(result); return fatfs_to_foenix(result);
} }
} }
@ -580,7 +580,7 @@ SYSTEMCALL short fsys_set_cwd(const char * path) {
f_getcwd(g_current_directory, MAX_PATH_LEN); f_getcwd(g_current_directory, MAX_PATH_LEN);
return 0; return 0;
} else { } else {
ERROR("fsys_set_cwd error: %d", result); log_num(LOG_ERROR, "fsys_set_cwd error: ", result);
return fatfs_to_foenix(result); return fatfs_to_foenix(result);
} }
} }
@ -627,7 +627,7 @@ short fchan_read(t_channel * chan, unsigned char * buffer, short size) {
FRESULT result; FRESULT result;
unsigned total_read; unsigned total_read;
TRACE("fchan_read"); log(LOG_TRACE, "fchan_read");
file = fchan_to_file(chan); file = fchan_to_file(chan);
if (file) { if (file) {
@ -673,7 +673,7 @@ short fchan_read_b(t_channel * chan) {
short total_read; short total_read;
char buffer[2]; char buffer[2];
TRACE("fchan_read_b"); log(LOG_TRACE, "fchan_read_b");
file = fchan_to_file(chan); file = fchan_to_file(chan);
if (file) { if (file) {
@ -704,7 +704,7 @@ short fchan_write(p_channel chan, const unsigned char * buffer, short size) {
if (result == FR_OK) { if (result == FR_OK) {
return (short)total_written; return (short)total_written;
} else { } else {
ERROR("fchan_write error: %d", result); log_num(LOG_ERROR, "fchan_write error: ", result);
return fatfs_to_foenix(result); return fatfs_to_foenix(result);
} }
} }
@ -838,9 +838,9 @@ short fsys_mount(short bdev) {
drive[2] = 0; drive[2] = 0;
fres = f_mount(&g_drive[bdev], drive, 0); fres = f_mount(&g_drive[bdev], drive, 0);
INFO("fsys_mount called f_mount: %d", fres); INFO1("fsys_mount called f_mount: %d", fres);
if (fres != FR_OK) { if (fres != FR_OK) {
ERROR("Unable to mount drive %s, FatFS Error: %d", drive, fres); ERROR2("Unable to mount drive %s, FatFS Error: %d", drive, fres);
return fatfs_to_foenix(fres); return fatfs_to_foenix(fres);
} else { } else {
return 0; return 0;
@ -888,10 +888,10 @@ SYSTEMCALL short fsys_set_label(short drive, const char * label) {
} }
#endif #endif
snprintf(buffer, 80, "%d:%s", drive, label); sprintf(buffer, "%d:%s", drive, label);
fres = f_setlabel(buffer); fres = f_setlabel(buffer);
if (fres != FR_OK) { if (fres != FR_OK) {
ERROR("fsys_setlabel: %d", fres); log_num(LOG_ERROR, "fsys_setlabel: ", fres);
return fatfs_to_foenix(fres); return fatfs_to_foenix(fres);
} else { } else {
return 0; return 0;
@ -911,10 +911,10 @@ SYSTEMCALL short fsys_mkfs(short drive, char * label) {
char buffer[80]; char buffer[80];
FRESULT fres; FRESULT fres;
snprintf(buffer, 80, "%d:", drive); sprintf(buffer, "%d:", drive);
fres = f_mkfs(buffer, 0, workspace, FF_MAX_SS * 4); fres = f_mkfs(buffer, 0, workspace, FF_MAX_SS * 4);
if (fres != FR_OK) { if (fres != FR_OK) {
ERROR("fsys_mkfs: %d", fres); log_num(LOG_ERROR, "fsys_mkfs: ", fres);
return fatfs_to_foenix(fres); return fatfs_to_foenix(fres);
} else { } else {
return 0; return 0;
@ -941,7 +941,7 @@ short fsys_default_loader(short chan, long destination, long * start) {
unsigned char * dest = (unsigned char *)destination; unsigned char * dest = (unsigned char *)destination;
TRACE("fsys_default_loader"); TRACE("fsys_default_loader");
DEBUG("Channel: %d", chan); log_num(LOG_DEBUG, "Channel: ", chan);
/* The default loader cannot be used to load executable files, so clear the start address */ /* The default loader cannot be used to load executable files, so clear the start address */
*start = 0; *start = 0;
@ -1074,11 +1074,11 @@ short fsys_pgz_loader(short chan, long destination, long * start) {
break; break;
case 2: case 2:
address = address | ((uint32_t)chunk[i]) << 16; address = address | ((uint32_t)chunk[i]) << 16;
INFO("PGZ 24-bit address: %06lx", address); INFO1("PGZ 24-bit address: %06lx", address);
break; break;
case 3: case 3:
address = address | ((uint32_t)chunk[i]) << 24; address = address | ((uint32_t)chunk[i]) << 24;
INFO("PGZ 32-bit address: %08lx", address); INFO1("PGZ 32-bit address: %08lx", address);
break; break;
} }
@ -1096,17 +1096,17 @@ short fsys_pgz_loader(short chan, long destination, long * start) {
count = count | ((uint32_t)chunk[i]) << 16; count = count | ((uint32_t)chunk[i]) << 16;
if (!use_32bits && count == 0) { if (!use_32bits && count == 0) {
*start = address; *start = address;
INFO("PGZ 24-bit start address: %06lx", start); INFO1("PGZ 24-bit start address: %06lx", start);
} }
INFO("PGZ 24-bit count: %06lx", count); INFO1("PGZ 24-bit count: %06lx", count);
break; break;
case 3: case 3:
count = count | ((uint32_t)chunk[i]) << 24; count = count | ((uint32_t)chunk[i]) << 24;
if (use_32bits && count == 0) { if (use_32bits && count == 0) {
*start = address; *start = address;
INFO("PGZ 32-bit start address: %08lx", start); INFO1("PGZ 32-bit start address: %08lx", start);
} }
INFO("PGZ 32-bit count: %08lx", count); INFO1("PGZ 32-bit count: %08lx", count);
break; break;
} }
} else { } else {
@ -1140,6 +1140,7 @@ short fsys_pgz_loader(short chan, long destination, long * start) {
} }
short fsys_elf_loader(short chan, long destination, long * start) { short fsys_elf_loader(short chan, long destination, long * start) {
char log_buffer[100];
size_t numBytes, highMem = 0, progIndex = 0, lowMem = ~0; size_t numBytes, highMem = 0, progIndex = 0, lowMem = ~0;
elf32_header header; elf32_header header;
elf32_program_header progHeader; elf32_program_header progHeader;
@ -1156,7 +1157,8 @@ short fsys_elf_loader(short chan, long destination, long * start) {
} }
if (header.machine != CPU_ARCH) { if (header.machine != CPU_ARCH) {
DEBUG("[!] Incompatible CPU arch: expected %s, but found %s\n", (char*)elf_cpu_desc[CPU_ARCH], (char*)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; return ERR_BAD_BINARY;
} }
@ -1332,7 +1334,7 @@ static short fsys_load_ext(const char * path, const char * extension, long desti
TRACE("fsys_load_ext"); TRACE("fsys_load_ext");
VERBOSE("fsys_load_ext ext: %s", extension); log2(LOG_VERBOSE, "fsys_load_ext ext: ", extension);
if (extension[0] == 0) { if (extension[0] == 0) {
if (destination != 0) { if (destination != 0) {
@ -1351,7 +1353,7 @@ static short fsys_load_ext(const char * path, const char * extension, long desti
if (strcmp(g_file_loader[i].extension, extension) == 0) { if (strcmp(g_file_loader[i].extension, extension) == 0) {
/* If the extensions match, pass back the loader */ /* If the extensions match, pass back the loader */
loader = g_file_loader[i].loader; loader = g_file_loader[i].loader;
DEBUG("loader found: %s", g_file_loader[i].extension); log2(LOG_DEBUG, "loader found: ", g_file_loader[i].extension);
} }
} }
} }
@ -1361,11 +1363,11 @@ static short fsys_load_ext(const char * path, const char * extension, long desti
if (loader == 0) { if (loader == 0) {
if (destination != 0) { if (destination != 0) {
/* If a destination was specified, just load it into memory without interpretation */ /* If a destination was specified, just load it into memory without interpretation */
DEBUG("Setting default loader."); log(LOG_DEBUG, "Setting default loader.");
loader = fsys_default_loader; loader = fsys_default_loader;
} else { } else {
DEBUG("Returning a bad extension."); log(LOG_DEBUG, "Returning a bad extension.");
/* Return bad extension */ /* Return bad extension */
return ERR_BAD_EXTENSION; return ERR_BAD_EXTENSION;
} }
@ -1385,13 +1387,13 @@ static short fsys_load_ext(const char * path, const char * extension, long desti
fsys_close(chan); fsys_close(chan);
if (result != 0) { if (result != 0) {
ERROR("Could not load file: %d", result); log_num(LOG_ERROR, "Could not load file: ", result);
} }
return result; return result;
} else { } else {
/* File open returned an error... pass it along */ /* File open returned an error... pass it along */
ERROR("Could not open file: %d", chan); log_num(LOG_ERROR, "Could not open file: ", chan);
return chan; return chan;
} }
} }
@ -1457,7 +1459,7 @@ SYSTEMCALL short fsys_load(const char * path, long destination, long * start) {
f_closedir(&dj); f_closedir(&dj);
if (fr != FR_OK && fr != FR_NO_FILE) { if (fr != FR_OK && fr != FR_NO_FILE) {
ERROR("File system error: %d", fr); log_num(LOG_ERROR, "File system error: ", fr);
return FSYS_ERR_DISK_ERR; return FSYS_ERR_DISK_ERR;
} }
@ -1465,7 +1467,7 @@ SYSTEMCALL short fsys_load(const char * path, long destination, long * start) {
// Found path with valid loader // Found path with valid loader
fsys_load_ext(spath, extension, destination, start); fsys_load_ext(spath, extension, destination, start);
} else { } else {
ERROR("Command not found."); log(LOG_ERROR, "Command not found.");
return ERR_NOT_FOUND; return ERR_NOT_FOUND;
} }
} }
@ -1547,10 +1549,10 @@ short fsys_init() {
for (i = 0; i < MAX_DRIVES; i++) { for (i = 0; i < MAX_DRIVES; i++) {
short res = sys_bdev_status((short)i); short res = sys_bdev_status((short)i);
if (res >= 0) { if (res >= 0) {
INFO("Mounting drive #%d", i); INFO1("Mounting drive #%d", i);
short result = fsys_mount(i); short result = fsys_mount(i);
if (result < 0) { if (result < 0) {
ERROR("Could not mount device %d: %d", i, result); ERROR2("Could not mount device %d: %d", i, result);
} }
} }
} }

View file

@ -483,7 +483,7 @@ short kbd_sc_init() {
// Reset the keyboard // Reset the keyboard
result = kbd_send_cmd(0xff); result = kbd_send_cmd(0xff);
if (result < 0) { if (result < 0) {
INFO("PS/2: unable to reset the keyboard: %s", err_message(ressult)); INFO1("PS/2: unable to reset the keyboard: %s", err_message(ressult));
return result; return result;
} }
INFO("kbd_sc_init: ps/2 keyboard reset"); INFO("kbd_sc_init: ps/2 keyboard reset");
@ -493,7 +493,7 @@ short kbd_sc_init() {
// Disable scanning // Disable scanning
result = kbd_send_cmd(0xf5); result = kbd_send_cmd(0xf5);
if (result < 0) { if (result < 0) {
INFO("PS/2: unable to disable keyboard scanning: %s", err_message(ressult)); INFO1("PS/2: unable to disable keyboard scanning: %s", err_message(ressult));
return result; return result;
} }
INFO("kbd_sc_init: ps/2 scanning disabled"); INFO("kbd_sc_init: ps/2 scanning disabled");
@ -501,12 +501,12 @@ short kbd_sc_init() {
// Set scan code set #2 // Set scan code set #2
result = kbd_send_cmd(0xf0); result = kbd_send_cmd(0xf0);
if (result < 0) { if (result < 0) {
INFO("PS/2: unable to set scan code: %s", err_message(ressult)); INFO1("PS/2: unable to set scan code: %s", err_message(ressult));
return result; return result;
} }
result = kbd_send_cmd(0x02); result = kbd_send_cmd(0x02);
if (result < 0) { if (result < 0) {
INFO("PS/2: unable to send scan code set: %s", err_message(ressult)); INFO1("PS/2: unable to send scan code set: %s", err_message(ressult));
return result; return result;
} }
INFO("kbd_sc_init: ps/2 scan code set #2 selected"); INFO("kbd_sc_init: ps/2 scan code set #2 selected");
@ -514,7 +514,7 @@ short kbd_sc_init() {
// Enable scanning // Enable scanning
result = kbd_send_cmd(0xf4); result = kbd_send_cmd(0xf4);
if (result < 0) { if (result < 0) {
INFO("PS/2: unable to restart keyboard scanning: %s", err_message(ressult)); INFO1("PS/2: unable to restart keyboard scanning: %s", err_message(ressult));
return result; return result;
} }
INFO("kbd_sc_init: ps/2 scanning enabled"); INFO("kbd_sc_init: ps/2 scanning enabled");

View file

@ -14,7 +14,6 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include "features.h"
#include "interrupt.h" #include "interrupt.h"
#include "log.h" #include "log.h"
#include "ring_buffer.h" #include "ring_buffer.h"
@ -331,20 +330,11 @@ bool kbd_break() {
* *
*/ */
short kbd_sc_init() { short kbd_sc_init() {
// NOTE: Reading from the new optical keyboard IO registers on non-F256K2
// devices causes odd and sometimes intermittent issues not limited to
// the keyboard not working at all right after a cold bootup from flash.
// Possibly this can be addressed with future FPGA updates for
// non-F256K2 devices, but for now we want to avoid this situation.
#if HAS_OPTICAL_KBD_SUPPORT
if (KBD_OPTICAL->status & KBD_OPT_STAT_MECH) { if (KBD_OPTICAL->status & KBD_OPT_STAT_MECH) {
is_optical = false; is_optical = false;
} else { } else {
is_optical = true; is_optical = true;
} }
#else
is_optical = false;
#endif
// Initialize VIA0 -- we'll just read from PB7 // Initialize VIA0 -- we'll just read from PB7
via0->ddra = 0x00; via0->ddra = 0x00;

View file

@ -388,7 +388,7 @@ short ps2_controller_cmd(unsigned char cmd) {
} }
short result = (short)*PS2_DATA_BUF; short result = (short)*PS2_DATA_BUF;
// DEBUG("PS/2: ps2_controller_cmd(%02X) = %02X", cmd, result); // DEBUG2("PS/2: ps2_controller_cmd(%02X) = %02X", cmd, result);
return result; return result;
} }
@ -947,7 +947,7 @@ short ps2_mouse_command(unsigned char cmd) {
if (ps2_wait_in()) return -1; if (ps2_wait_in()) return -1;
*PS2_CMD_BUF = MOUSE_CMD_PREFIX; *PS2_CMD_BUF = MOUSE_CMD_PREFIX;
// VERBOSE("ps_mouse_command command: %d", cmd); // log_num(LOG_VERBOSE, "ps_mouse_command command: ", cmd);
if (ps2_wait_in()) return -1; if (ps2_wait_in()) return -1;
*PS2_DATA_BUF = cmd; *PS2_DATA_BUF = cmd;
@ -955,7 +955,7 @@ short ps2_mouse_command(unsigned char cmd) {
if (ps2_wait_out()) return -1; if (ps2_wait_out()) return -1;
result = *PS2_DATA_BUF; result = *PS2_DATA_BUF;
// VERBOSE("ps_mouse_command result: %d", result); // log_num(LOG_VERBOSE, "ps_mouse_command result: ", result);
return (short)result; return (short)result;
} }
@ -986,7 +986,7 @@ short ps2_mouse_get_packet() {
result = ps2_mouse_command(MOUSE_CMD_REQPACK); result = ps2_mouse_command(MOUSE_CMD_REQPACK);
if (result == -1) { if (result == -1) {
INFO("MOUSE_CMD_REQPACK: %d", result); log_num(LOG_INFO, "MOUSE_CMD_REQPACK: ", result);
return result; return result;
} }
@ -1046,7 +1046,7 @@ short mouse_init() {
result = ps2_mouse_command(MOUSE_CMD_RESET); result = ps2_mouse_command(MOUSE_CMD_RESET);
if (result == -1) { if (result == -1) {
INFO("MOUSE_CMD_RESET: %d", result); log_num(LOG_INFO, "MOUSE_CMD_RESET: ", result);
return result; return result;
} }
@ -1054,7 +1054,7 @@ short mouse_init() {
result = ps2_mouse_command_repeatable(MOUSE_CMD_DISABLE); result = ps2_mouse_command_repeatable(MOUSE_CMD_DISABLE);
if (result != PS2_RESP_ACK) { if (result != PS2_RESP_ACK) {
INFO("MOUSE_CMD_DISABLE: %d", result); log_num(LOG_INFO, "MOUSE_CMD_DISABLE: ", result);
return result; return result;
} }
@ -1062,7 +1062,7 @@ short mouse_init() {
result = ps2_mouse_command_repeatable(MOUSE_CMD_DEFAULTS); result = ps2_mouse_command_repeatable(MOUSE_CMD_DEFAULTS);
if (result != PS2_RESP_ACK) { if (result != PS2_RESP_ACK) {
INFO("MOUSE_CMD_DEFAULTS: %d", result); log_num(LOG_INFO, "MOUSE_CMD_DEFAULTS: ", result);
return result; return result;
} }
@ -1070,13 +1070,13 @@ short mouse_init() {
result = ps2_mouse_command_repeatable(MOUSE_CMD_SETRES); result = ps2_mouse_command_repeatable(MOUSE_CMD_SETRES);
if (result != PS2_RESP_ACK) { if (result != PS2_RESP_ACK) {
INFO("MOUSE_CMD_SETRES: %d", result); log_num(LOG_INFO, "MOUSE_CMD_SETRES: ", result);
return result; return result;
} }
result = ps2_mouse_command_repeatable(0x00); result = ps2_mouse_command_repeatable(0x00);
if (result != PS2_RESP_ACK) { if (result != PS2_RESP_ACK) {
INFO("MOUSE_CMD_SETRES resolution: %d", result); log_num(LOG_INFO, "MOUSE_CMD_SETRES resolution: ", result);
return result; return result;
} }
@ -1084,7 +1084,7 @@ short mouse_init() {
result = ps2_mouse_command_repeatable(MOUSE_CMD_ENABLE); result = ps2_mouse_command_repeatable(MOUSE_CMD_ENABLE);
if (result != PS2_RESP_ACK) { if (result != PS2_RESP_ACK) {
INFO("MOUSE_CMD_ENABLE: %d", result); log_num(LOG_INFO, "MOUSE_CMD_ENABLE: ", result);
return result; return result;
} }
@ -1211,9 +1211,9 @@ void ps2_identify(short port) {
} }
if (byte1 >= 0) { if (byte1 >= 0) {
INFO("PS/2: ps2_identification: %02X %02X.", byte0, byte1); INFO2("PS/2: ps2_identification: %02X %02X.", byte0, byte1);
} else { } else {
INFO("PS/2: ps2_identification: %02X.", byte0); INFO1("PS/2: ps2_identification: %02X.", byte0);
} }
res = ps2_kbd_cmd(KBD_CMD_ENABLE, 0); res = ps2_kbd_cmd(KBD_CMD_ENABLE, 0);
@ -1315,7 +1315,7 @@ short ps2_init() {
// if (mouse_present) { // if (mouse_present) {
// /* Initialize the mouse */ // /* Initialize the mouse */
// if ((mouse_error = mouse_init())) { // if ((mouse_error = mouse_init())) {
// INFO("Unable to initialize mouse: %d", mouse_error); // log_num(LOG_INFO, "Unable to initialize mouse", mouse_error);
// } // }
// } // }

View file

@ -34,7 +34,7 @@ void rtc_init() {
unsigned char rates; unsigned char rates;
unsigned char enables; unsigned char enables;
TRACE("rtc_init"); log(LOG_TRACE, "rtc_init");
int_disable(INT_RTC); int_disable(INT_RTC);
@ -124,13 +124,13 @@ SYSTEMCALL void rtc_set_time(p_time time) {
minute_bcd = i_to_bcd(time->minute); minute_bcd = i_to_bcd(time->minute);
second_bcd = i_to_bcd(time->second); second_bcd = i_to_bcd(time->second);
INFO("Century: %02d", century_bcd); INFO1("Century: %02d", century_bcd);
INFO("Year: %04d", year_bcd); INFO1("Year: %04d", year_bcd);
INFO("Month: %02d", month_bcd); INFO1("Month: %02d", month_bcd);
INFO("Day: %02d", day_bcd); INFO1("Day: %02d", day_bcd);
INFO("Hour: %02d", hour_bcd); INFO1("Hour: %02d", hour_bcd);
INFO("Minute: %02d", minute_bcd); INFO1("Minute: %02d", minute_bcd);
INFO("Second: %02d", second_bcd); INFO1("Second: %02d", second_bcd);
if (!time->is_24hours) { if (!time->is_24hours) {
if (time->is_pm) { if (time->is_pm) {
@ -144,10 +144,10 @@ SYSTEMCALL void rtc_set_time(p_time time) {
ctrl = *RTC_CTRL; ctrl = *RTC_CTRL;
*RTC_CTRL = ctrl | RTC_UTI; *RTC_CTRL = ctrl | RTC_UTI;
INFO("RTC Disabled"); INFO("RTC Disabled");
INFO("RTC Rates: %02x", *RTC_RATES); INFO1("RTC Rates: %02x", *RTC_RATES);
INFO("RTC Enables: %02x", *RTC_ENABLES); INFO1("RTC Enables: %02x", *RTC_ENABLES);
INFO("RTC Flags: %02x", *RTC_FLAGS); INFO1("RTC Flags: %02x", *RTC_FLAGS);
INFO("RTC Control: %02x", *RTC_CTRL); INFO1("RTC Control: %02x", *RTC_CTRL);
/* Set the time in the RTC */ /* Set the time in the RTC */
@ -168,13 +168,13 @@ SYSTEMCALL void rtc_set_time(p_time time) {
hour_bcd = *RTC_HOUR; hour_bcd = *RTC_HOUR;
minute_bcd = *RTC_MIN; minute_bcd = *RTC_MIN;
second_bcd = *RTC_SEC; second_bcd = *RTC_SEC;
INFO("REG Century: %02d", century_bcd); INFO1("REG Century: %02d", century_bcd);
INFO("REG Year: %02d", year_bcd); INFO1("REG Year: %02d", year_bcd);
INFO("REG Month: %02d", month_bcd); INFO1("REG Month: %02d", month_bcd);
INFO("REG Day: %02d", day_bcd); INFO1("REG Day: %02d", day_bcd);
INFO("REG Hour: %02d", hour_bcd); INFO1("REG Hour: %02d", hour_bcd);
INFO("REG Minute: %02d", minute_bcd); INFO1("REG Minute: %02d", minute_bcd);
INFO("REG Second: %02d", second_bcd); INFO1("REG Second: %02d", second_bcd);
/* Set the 24/12 hour control bit if needed */ /* Set the 24/12 hour control bit if needed */
if (time->is_24hours) { if (time->is_24hours) {
@ -184,10 +184,10 @@ SYSTEMCALL void rtc_set_time(p_time time) {
/* Re-enable updates to the clock */ /* Re-enable updates to the clock */
*RTC_CTRL = (ctrl & 0x07) | RTC_STOP; *RTC_CTRL = (ctrl & 0x07) | RTC_STOP;
INFO("RTC Enabled"); INFO("RTC Enabled");
INFO("RTC Rates: %02x", *RTC_RATES); INFO1("RTC Rates: %02x", *RTC_RATES);
INFO("RTC Enables: %02x", *RTC_ENABLES); INFO1("RTC Enables: %02x", *RTC_ENABLES);
INFO("RTC Flags: %02x", *RTC_FLAGS); INFO1("RTC Flags: %02x", *RTC_FLAGS);
INFO("RTC Control: %02x", *RTC_CTRL); INFO1("RTC Control: %02x", *RTC_CTRL);
} }
/* /*
@ -205,10 +205,10 @@ SYSTEMCALL void rtc_get_time(p_time time) {
ctrl = *RTC_CTRL; ctrl = *RTC_CTRL;
*RTC_CTRL = ctrl | RTC_UTI; *RTC_CTRL = ctrl | RTC_UTI;
INFO("RTC Disabled"); INFO("RTC Disabled");
INFO("RTC Rates: %02x", *RTC_RATES); INFO1("RTC Rates: %02x", *RTC_RATES);
INFO("RTC Enables: %02x", *RTC_ENABLES); INFO1("RTC Enables: %02x", *RTC_ENABLES);
INFO("RTC Flags: %02x", *RTC_FLAGS); INFO1("RTC Flags: %02x", *RTC_FLAGS);
INFO("RTC Control: %02x", *RTC_CTRL); INFO1("RTC Control: %02x", *RTC_CTRL);
if (*RTC_CTRL & RTC_2412) { if (*RTC_CTRL & RTC_2412) {
time->is_24hours = 1; time->is_24hours = 1;
@ -227,18 +227,18 @@ SYSTEMCALL void rtc_get_time(p_time time) {
/* Re-enable updates to the clock */ /* Re-enable updates to the clock */
*RTC_CTRL = (ctrl & 0x07) | RTC_STOP; *RTC_CTRL = (ctrl & 0x07) | RTC_STOP;
INFO("RTC Enabled"); INFO("RTC Enabled");
INFO("RTC Rates: %02x", *RTC_RATES); INFO1("RTC Rates: %02x", *RTC_RATES);
INFO("RTC Enables: %02x", *RTC_ENABLES); INFO1("RTC Enables: %02x", *RTC_ENABLES);
INFO("RTC Flags: %02x", *RTC_FLAGS); INFO1("RTC Flags: %02x", *RTC_FLAGS);
INFO("RTC Control: %02x", *RTC_CTRL); INFO1("RTC Control: %02x", *RTC_CTRL);
INFO("Century: %02d", century_bcd); INFO1("Century: %02d", century_bcd);
INFO("Year: %02d", year_bcd); INFO1("Year: %02d", year_bcd);
INFO("Month: %02d", month_bcd); INFO1("Month: %02d", month_bcd);
INFO("Day: %02d", day_bcd); INFO1("Day: %02d", day_bcd);
INFO("Hour: %02d", hour_bcd); INFO1("Hour: %02d", hour_bcd);
INFO("Minute: %02d", minute_bcd); INFO1("Minute: %02d", minute_bcd);
INFO("Second: %02d", second_bcd); INFO1("Second: %02d", second_bcd);
/* Fill out the time record */ /* Fill out the time record */

View file

@ -152,7 +152,7 @@ short sdc_init() {
short sdc_read(long lba, unsigned char * buffer, short size) { short sdc_read(long lba, unsigned char * buffer, short size) {
long adjusted_lba; long adjusted_lba;
TRACE("sdc_read(%ld,%p,%d)", lba, buffer, (int)size); TRACE3("sdc_read(%ld,%p,%d)", lba, buffer, (int)size);
// Check for presence of the card // Check for presence of the card
@ -218,7 +218,7 @@ short sdc_read(long lba, unsigned char * buffer, short size) {
ind_set(IND_SDC, IND_OFF); ind_set(IND_SDC, IND_OFF);
// Success: return the byte count // Success: return the byte count
TRACE("sdc_read: returning %d", count); TRACE1("sdc_read: returning %d", count);
return count; return count;
} }
} }
@ -326,7 +326,7 @@ short sdc_write(long lba, const unsigned char * buffer, short size) {
short sdc_status() { short sdc_status() {
short status = g_sdc_status; short status = g_sdc_status;
TRACE("sdc_status, status=0x%x",(int)status); TRACE1("sdc_status, status=0x%x",(int)status);
if (sdc_detected()) { if (sdc_detected()) {
// Add the PRESENT flag, if the card is inserted // Add the PRESENT flag, if the card is inserted
@ -338,7 +338,7 @@ short sdc_status() {
status |= SDC_STAT_PROTECTED; status |= SDC_STAT_PROTECTED;
} }
TRACE("sdc_status: %x", (short)status); TRACE1("sdc_status: %x", (short)status);
return status; return status;
} }

View file

@ -359,8 +359,8 @@ static short sdc_init(p_dev_block dev) {
sd->ctrl &= ~SDx_SLOW; // Bring back the Fast Mode - 25Mhz sd->ctrl &= ~SDx_SLOW; // Bring back the Fast Mode - 25Mhz
card->status = card->type ? 0 : SDC_STAT_NOINIT; card->status = card->type ? 0 : SDC_STAT_NOINIT;
INFO("SD0_CardType: %x", card->type); INFO1("SD0_CardType: %x", card->type);
INFO("SD0_Stat: %x", card->status); INFO1("SD0_Stat: %x", card->status);
SD0_deselect(sd); SD0_deselect(sd);

View file

@ -104,7 +104,7 @@ static void txt_c256_set_sizes() {
c256_visible_size.height = c256_max_size.height; c256_visible_size.height = c256_max_size.height;
} }
DEBUG("txt_c256_set_sizes max:%d,%d, visible:%d,%d", c256_max_size.width, c256_max_size.height, c256_visible_size.width, c256_visible_size.height); DEBUG4("txt_c256_set_sizes max:%d,%d, visible:%d,%d", c256_max_size.width, c256_max_size.height, c256_visible_size.width, c256_visible_size.height);
} }
} }
@ -327,7 +327,11 @@ static short txt_c256_get_region(p_rect region) {
region->size.width = c256_region.size.width; region->size.width = c256_region.size.width;
region->size.height = c256_region.size.height; region->size.height = c256_region.size.height;
DEBUG("txt_c256_get_region %p: x:%d, y:%d, w:%d, h:%d", region, region->origin.x, region->origin.y, region->size.width, region->size.height); {
char msg[80];
sprintf(msg,"txt_c256_get_region %p: x:%d, y:%d, w:%d, h:%d", region, region->origin.x, region->origin.y, region->size.width, region->size.height);
DEBUG(msg);
}
return 0; return 0;
} }

View file

@ -141,7 +141,7 @@ static void txt_evid_set_sizes() {
evid_visible_size.height = evid_max_size.height; evid_visible_size.height = evid_max_size.height;
} }
DEBUG("txt_evid_set_sizes max:%d,%d, visible:%d,%d", evid_max_size.width, evid_max_size.height, evid_visible_size.width, evid_visible_size.height); DEBUG4("txt_evid_set_sizes max:%d,%d, visible:%d,%d", evid_max_size.width, evid_max_size.height, evid_visible_size.width, evid_visible_size.height);
} }
} }

View file

@ -110,7 +110,7 @@ static void txt_f256_set_sizes() {
f256_visible_size.height = f256_max_size.height; f256_visible_size.height = f256_max_size.height;
} }
// DEBUG("txt_f256_set_sizes max:%d,%d, visible:%d,%d", f256_max_size.width, f256_max_size.height, f256_visible_size.width, f256_visible_size.height); // DEBUG4("txt_f256_set_sizes max:%d,%d, visible:%d,%d", f256_max_size.width, f256_max_size.height, f256_visible_size.width, f256_visible_size.height);
} }
} }
@ -177,7 +177,7 @@ static short txt_f256_set_mode(short mode) {
} }
*tvky_mstr_ctrl = mcr_shadow; *tvky_mstr_ctrl = mcr_shadow;
INFO("Setting Vicky MCR: 0x%04x", mcr_shadow); INFO1("Setting Vicky MCR: 0x%04x", mcr_shadow);
return 0; return 0;
} }
} }

View file

@ -47,7 +47,7 @@ void txt_init() {
* @return 0 on success, any other number is an error * @return 0 on success, any other number is an error
*/ */
short txt_register(p_txt_device device) { short txt_register(p_txt_device device) {
DEBUG("txt_register(%s)", device->name); DEBUG1("txt_register(%s)", device->name);
if (device->number < TXT_CNT_SCREENS) { if (device->number < TXT_CNT_SCREENS) {
int i = device->number; int i = device->number;
@ -95,7 +95,7 @@ p_txt_device txt_get_device(short screen) {
if (device->number == screen) { if (device->number == screen) {
return device; return device;
} else { } else {
ERROR("txt_get_device: number mismatch %d", screen); ERROR1("txt_get_device: number mismatch %d", screen);
} }
} }
@ -108,14 +108,14 @@ p_txt_device txt_get_device(short screen) {
* @param screen the number of the text device * @param screen the number of the text device
*/ */
void txt_init_screen(short screen) { void txt_init_screen(short screen) {
TRACE("txt_init_screen(%d)", (int)screen); TRACE1("txt_init_screen(%d)", (int)screen);
p_txt_device device = txt_get_device(screen); p_txt_device device = txt_get_device(screen);
if (device) { if (device) {
if (device->init) { if (device->init) {
device->init(); device->init();
} }
} else { } else {
ERROR("Could not find screen %d", screen); ERROR1("Could not find screen %d", screen);
} }
} }
@ -289,7 +289,7 @@ SYSTEMCALL void txt_set_cursor_visible(short screen, short enable) {
* @return 0 on success, any other number means the region was invalid * @return 0 on success, any other number means the region was invalid
*/ */
SYSTEMCALL short txt_get_region(short screen, p_rect region) { SYSTEMCALL short txt_get_region(short screen, p_rect region) {
DEBUG("txt_get_region screen:%d region:%p", screen, region); DEBUG2("txt_get_region screen:%d region:%p", screen, region);
p_txt_device device = txt_get_device(screen); p_txt_device device = txt_get_device(screen);
if (device) { if (device) {
if (device->get_region) { if (device->get_region) {
@ -309,7 +309,7 @@ SYSTEMCALL short txt_get_region(short screen, p_rect region) {
* @return 0 on success, any other number means the region was invalid * @return 0 on success, any other number means the region was invalid
*/ */
SYSTEMCALL short txt_set_region(short screen, p_rect region) { SYSTEMCALL short txt_set_region(short screen, p_rect region) {
TRACE("txt_set_region(%d,{x:%d; y:%d w:%d, h:%d})", (int)screen, (int)region->origin.x, (int)region->origin.y, (int)region->size.width, (int)region->size.height); TRACE5("txt_set_region(%d,{x:%d; y:%d w:%d, h:%d})", (int)screen, (int)region->origin.x, (int)region->origin.y, (int)region->size.width, (int)region->size.height);
p_txt_device device = txt_get_device(screen); p_txt_device device = txt_get_device(screen);
if (device) { if (device) {
if (device->set_region) { if (device->set_region) {
@ -327,7 +327,7 @@ SYSTEMCALL short txt_set_region(short screen, p_rect region) {
* @param background the Text LUT index of the new current background color (0 - 15) * @param background the Text LUT index of the new current background color (0 - 15)
*/ */
SYSTEMCALL short txt_set_color(short screen, unsigned char foreground, unsigned char background) { SYSTEMCALL short txt_set_color(short screen, unsigned char foreground, unsigned char background) {
TRACE("txt_get_color(%d,%d,%d)", (int)screen, (int)foreground, (int)background); TRACE3("txt_get_color(%d,%d,%d)", (int)screen, (int)foreground, (int)background);
p_txt_device device = txt_get_device(screen); p_txt_device device = txt_get_device(screen);
if (device) { if (device) {
if (device->set_color) { if (device->set_color) {
@ -346,7 +346,7 @@ SYSTEMCALL short txt_set_color(short screen, unsigned char foreground, unsigned
* background = pointer to the background color number * background = pointer to the background color number
*/ */
SYSTEMCALL void txt_get_color(short screen, unsigned char * foreground, unsigned char * background) { SYSTEMCALL void txt_get_color(short screen, unsigned char * foreground, unsigned char * background) {
TRACE("txt_get_color(%d,%p,%p)", (int)screen, foreground, background); TRACE3("txt_get_color(%d,%p,%p)", (int)screen, foreground, background);
p_txt_device device = txt_get_device(screen); p_txt_device device = txt_get_device(screen);
if (device) { if (device) {
if (device->get_color) { if (device->get_color) {
@ -366,7 +366,7 @@ SYSTEMCALL void txt_get_color(short screen, unsigned char * foreground, unsigned
* @param y the row for the cursor * @param y the row for the cursor
*/ */
SYSTEMCALL void txt_set_xy(short screen, short x, short y) { SYSTEMCALL void txt_set_xy(short screen, short x, short y) {
DEBUG("txt_set_xy(%d,%d,%d)", screen, (int)x, (int)y); DEBUG3("txt_set_xy(%d,%d,%d)", screen, (int)x, (int)y);
p_txt_device device = txt_get_device(screen); p_txt_device device = txt_get_device(screen);
if (device) { if (device) {
if (device->set_xy) { if (device->set_xy) {
@ -480,7 +480,7 @@ SYSTEMCALL void txt_print(short screen, const char * message) {
* @param vertical the number of rows to scroll (negative is down, positive is up) * @param vertical the number of rows to scroll (negative is down, positive is up)
*/ */
void txt_scroll(short screen, short horizontal, short vertical) { void txt_scroll(short screen, short horizontal, short vertical) {
TRACE("txt_scroll(%d,%d,%d)", screen, horizontal, vertical); TRACE3("txt_scroll(%d,%d,%d)", screen, horizontal, vertical);
p_txt_device device = txt_get_device(screen); p_txt_device device = txt_get_device(screen);
if (device) { if (device) {
if (device->scroll) { if (device->scroll) {
@ -517,7 +517,7 @@ void txt_clear(short screen, short mode) {
t_point cursor; t_point cursor;
t_rect old_region, region; t_rect old_region, region;
TRACE("txt_clear(%d,%d)", (int)screen, (int)mode); TRACE2("txt_clear(%d,%d)", (int)screen, (int)mode);
txt_get_xy(screen, &cursor); txt_get_xy(screen, &cursor);
txt_get_region(screen, &old_region); txt_get_region(screen, &old_region);
@ -592,7 +592,7 @@ void txt_clear_line(short screen, short mode) {
t_point cursor; t_point cursor;
t_rect old_region, region; t_rect old_region, region;
TRACE("txt_clear_line(%d,%d)", (int)screen, (int)mode); TRACE2("txt_clear_line(%d,%d)", (int)screen, (int)mode);
txt_get_xy(screen, &cursor); txt_get_xy(screen, &cursor);
txt_get_region(screen, &old_region); txt_get_region(screen, &old_region);
@ -657,7 +657,7 @@ void txt_insert(short screen, short count) {
t_point cursor; t_point cursor;
t_rect old_region, region; t_rect old_region, region;
TRACE("txt_clear_line(%d,%d)", (int)screen, (int)count); TRACE2("txt_clear_line(%d,%d)", (int)screen, (int)count);
if (count > 0) { if (count > 0) {
txt_get_xy(screen, &cursor); txt_get_xy(screen, &cursor);
@ -685,7 +685,7 @@ void txt_delete(short screen, short count) {
t_rect old_region, region; t_rect old_region, region;
short left; short left;
TRACE("txt_delete(%d,%d)", screen, count); TRACE2("txt_delete(%d,%d)", screen, count);
if (count > 0) { if (count > 0) {
txt_get_xy(screen, &cursor); txt_get_xy(screen, &cursor);

View file

@ -293,7 +293,7 @@ short uart_open(p_channel chan, const unsigned char * spec, short mode) {
uart_setbps(cdev_to_uart(chan->dev), bps_code); uart_setbps(cdev_to_uart(chan->dev), bps_code);
// Get the next token // Get the next token
token = strtok_r(NULL, ",", &saveptr); token = strtok_r(spec_copy, ",", &saveptr);
if (token) { if (token) {
// Parse the data bit count // Parse the data bit count
i = atoi(token); i = atoi(token);
@ -315,12 +315,12 @@ short uart_open(p_channel chan, const unsigned char * spec, short mode) {
break; break;
default: default:
ERROR("uart_open: Bad data word length"); log(LOG_ERROR, "uart_open: Bad data word length");
return ERR_BAD_ARGUMENT; return ERR_BAD_ARGUMENT;
} }
// Get the next token // Get the next token
token = strtok_r(NULL, ",", &saveptr); token = strtok_r(spec_copy, ",", &saveptr);
if (token) { if (token) {
// Parse the stop bit count (1 or 2) // Parse the stop bit count (1 or 2)
i = atoi(token); i = atoi(token);
@ -329,12 +329,12 @@ short uart_open(p_channel chan, const unsigned char * spec, short mode) {
} else if (i == 2) { } else if (i == 2) {
lcr_code |= LCR_STOPBIT_2; lcr_code |= LCR_STOPBIT_2;
} else { } else {
ERROR("uart_open: Bad stop bits"); log(LOG_ERROR, "uart_open: Bad stop bits");
return ERR_BAD_ARGUMENT; return ERR_BAD_ARGUMENT;
} }
// Get the next token // Get the next token
token = strtok_r(NULL, ",", &saveptr); token = strtok_r(spec_copy, ",", &saveptr);
if (token) { if (token) {
// NONE, ODD, EVEN, MARK, or SPACE // NONE, ODD, EVEN, MARK, or SPACE
if (strcmp(token, "NONE") == 0) { if (strcmp(token, "NONE") == 0) {
@ -348,7 +348,7 @@ short uart_open(p_channel chan, const unsigned char * spec, short mode) {
} else if (strcmp(token, "SPACE") == 0) { } else if (strcmp(token, "SPACE") == 0) {
lcr_code |= LCR_PARITY_SPACE; lcr_code |= LCR_PARITY_SPACE;
} else { } else {
ERROR("uart_open: Bad parity"); log(LOG_ERROR, "uart_open: Bad parity");
return ERR_BAD_ARGUMENT; return ERR_BAD_ARGUMENT;
} }
@ -357,19 +357,19 @@ short uart_open(p_channel chan, const unsigned char * spec, short mode) {
return 0; return 0;
} else { } else {
ERROR("uart_open: no parity token"); log(LOG_ERROR, "uart_open: no parity token");
return ERR_BAD_ARGUMENT; return ERR_BAD_ARGUMENT;
} }
} else { } else {
ERROR("uart_open: no stop bit token"); log(LOG_ERROR, "uart_open: no stop bit token");
return ERR_BAD_ARGUMENT; return ERR_BAD_ARGUMENT;
} }
} else { } else {
ERROR("uart_open: no data length token"); log(LOG_ERROR, "uart_open: no data length token");
return ERR_BAD_ARGUMENT; return ERR_BAD_ARGUMENT;
} }
} else { } else {
ERROR("uart_open: no BPS token"); log(LOG_ERROR, "uart_open: no BPS token");
return ERR_BAD_ARGUMENT; return ERR_BAD_ARGUMENT;
} }

View file

@ -54,7 +54,7 @@ DSTATUS disk_initialize(BYTE pdrv) {
DSTATUS disk_status(BYTE pdrv) { DSTATUS disk_status(BYTE pdrv) {
DSTATUS result = (DSTATUS)bdev_status(pdrv); DSTATUS result = (DSTATUS)bdev_status(pdrv);
INFO("disk_status: %02X", result); INFO1("disk_status: %02X", result);
return result; return result;
} }
@ -77,7 +77,7 @@ static void sector_dump(uint8_t * buffer, int count) {
DRESULT disk_read(BYTE pdrv, BYTE* buff, LBA_t sector, UINT count) { DRESULT disk_read(BYTE pdrv, BYTE* buff, LBA_t sector, UINT count) {
short result = bdev_read(pdrv, sector, buff, 512 * count); short result = bdev_read(pdrv, sector, buff, 512 * count);
INFO("disk_read: sector #%u result %d", sector, result); INFO2("disk_read: sector #%u result %d", sector, result);
// sector_dump(buff, 512); // sector_dump(buff, 512);
return bdev_to_fatfs(result); return bdev_to_fatfs(result);
@ -85,13 +85,13 @@ DRESULT disk_read(BYTE pdrv, BYTE* buff, LBA_t sector, UINT count) {
DRESULT disk_write(BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count) { DRESULT disk_write(BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count) {
short result = bdev_write(pdrv, sector, buff, 512 * count); short result = bdev_write(pdrv, sector, buff, 512 * count);
INFO("disk_write: sector #%u result %d", sector, result); INFO2("disk_write: sector #%u result %d", sector, result);
return bdev_to_fatfs(result); return bdev_to_fatfs(result);
} }
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void* buff) { DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void* buff) {
short result = bdev_ioctrl(pdrv, cmd, buff, 0); short result = bdev_ioctrl(pdrv, cmd, buff, 0);
INFO("disk_ioctl: %d", result); INFO1("disk_ioctl: %d", result);
return bdev_to_fatfs(result); return bdev_to_fatfs(result);
} }
@ -106,7 +106,7 @@ DWORD get_fattime(void) {
(DWORD)time.minute << 5 | (DWORD)time.minute << 5 |
(DWORD)time.second >> 1; (DWORD)time.second >> 1;
INFO("get_fattime %08lX", timestamp); INFO1("get_fattime %08lX", timestamp);
return timestamp; return timestamp;
} }

View file

@ -46,10 +46,6 @@
#define HAS_IEC 1 #define HAS_IEC 1
#endif #endif
#if MODEL == MODEL_FOENIX_F256K2 || MODEL == MODEL_FOENIX_F256K2E
#define HAS_OPTICAL_KBD_SUPPORT 1
#endif
/* Defaults -----------------------------------------------------------------*/ /* Defaults -----------------------------------------------------------------*/
@ -97,8 +93,4 @@
#define HAS_IEC 0 #define HAS_IEC 0
#endif #endif
#ifndef HAS_OPTICAL_KBD_SUPPORT
#define HAS_OPTICAL_KBD_SUPPORT 0
#endif
#endif #endif

View file

@ -47,7 +47,7 @@ void log_init(void) {
// if (log_channel == LOG_CHANNEL_UART0) { // if (log_channel == LOG_CHANNEL_UART0) {
uart_init(UART_COM1); uart_init(UART_COM1);
do_log = log_to_uart; do_log = log_to_uart;
INFO("FOENIX DEBUG OUTPUT------------"); log(LOG_INFO,"FOENIX DEBUG OUTPUT------------");
// } // }
// else { // else {
// do_log = log_to_screen; // do_log = log_to_screen;
@ -101,8 +101,6 @@ const char * err_messages[] = {
"media changed" "media changed"
}; };
#define LOG_BUFFER_SIZE 80
/* /*
* Return human readable message for an error number * Return human readable message for an error number
*/ */
@ -125,12 +123,12 @@ const char * err_message(short err_number) {
* err_number = the number of the error * err_number = the number of the error
*/ */
void err_print(short channel, const char * message, short err_number) { void err_print(short channel, const char * message, short err_number) {
char buffer[LOG_BUFFER_SIZE]; char buffer[80];
if ((err_number < 0) && (err_number > -40)) { if ((err_number < 0) && (err_number > -40)) {
snprintf(buffer, LOG_BUFFER_SIZE, "%s: %s\n", message, err_message(err_number)); sprintf(buffer, "%s: %s\n", message, err_message(err_number));
} else { } else {
snprintf(buffer, LOG_BUFFER_SIZE, "%s: #%d\n", message, err_number); sprintf(buffer, "%s: #%d\n", message, err_number);
} }
// TODO: bring back // TODO: bring back
@ -144,7 +142,7 @@ void err_print(short channel, const char * message, short err_number) {
* Display a panic screen * Display a panic screen
*/ */
void panic(void) { void panic(void) {
char buffer[LOG_BUFFER_SIZE]; char buffer[80];
short column = 2; short column = 2;
short row = 2; short row = 2;
short address_expected = 0; short address_expected = 0;
@ -216,11 +214,11 @@ TRACE("PANIC------------------------------------------");
if (address_expected) { if (address_expected) {
txt_set_xy(0, column, row++); txt_set_xy(0, column, row++);
snprintf(buffer, LOG_BUFFER_SIZE, "\xB3 PC: %08X Address: %08X \xB3", (unsigned int)panic_pc, (unsigned int)panic_address); sprintf(buffer, "\xB3 PC: %08X Address: %08X \xB3", (unsigned int)panic_pc, (unsigned int)panic_address);
txt_print(0, buffer); txt_print(0, buffer);
} else { } else {
txt_set_xy(0, column, row++); txt_set_xy(0, column, row++);
snprintf(buffer, LOG_BUFFER_SIZE, "\xB3 PC: %08X \xB3", (unsigned int)panic_pc); sprintf(buffer, "\xB3 PC: %08X \xB3", (unsigned int)panic_pc);
txt_print(0, buffer); txt_print(0, buffer);
} }
@ -268,17 +266,17 @@ static void log_to_screen(const char *message) {
* message/args = like printf. * message/args = like printf.
* *
* Caveat: * Caveat:
* The total length should not exceed 80 chars. * The total length should not exceed 512 chars.
*/ */
void log_msg(short level, const char * message, ...) { void log(short level, const char * message, ...) {
if (level > log_level) if (level > log_level)
return; return;
char buf[LOG_BUFFER_SIZE]; // Should hopefully be long enough ! char buf[80]; // Should hopefully be long enough !
va_list args; va_list args;
va_start(args, message); va_start(args, message);
vsnprintf(buf, LOG_BUFFER_SIZE, message, args); vsprintf(buf, message, args);
va_end(args); va_end(args);
(*do_log)(buf); (*do_log)(buf);
@ -286,6 +284,70 @@ void log_msg(short level, const char * message, ...) {
// txt_print(0, "\n"); // txt_print(0, "\n");
} }
void trace(const char * message, ...) {
if (LOG_TRACE > log_level)
return;
char buf[80]; // Should hopefully be long enough !
va_list args;
va_start(args, message);
vsprintf(buf, message, args);
va_end(args);
(*do_log)(buf);
}
/*
* Log a message to the console
*
* Inputs:
* level = the severity of the message... the logging level will filter messages displayed
* message1 = the first part of the message to log
* message2 = the second part of the message to log
*/
void log2(short level, const char * message1, const char * message2) {
if (level <= log_level) {
char line[80];
sprintf(line, "%s%s\n", message1, message2);
log(level, line);
}
}
/*
* Log a message to the console
*
* Inputs:
* level = the severity of the message... the logging level will filter messages displayed
* message1 = the first part of the message to log
* message2 = the second part of the message to log
* message3 = the third part of the message to log
*/
void log3(short level, const char * message1, const char * message2, const char * message3) {
if (level <= log_level) {
char line[80];
sprintf(line, "%s%s%s\n", message1, message2, message3);
log(level, line);
}
}
/*
* Log a message with a number
*
* Inputs:
* level = the severity of the message... the logging level will filter messages displayed
* message1 = the first part of the message to log
* n = the number to log
*/
void log_num(short level, char * message, int n) {
char line[80];
if (level <= log_level) {
sprintf(line, "%s%08X", message, n);
log(level, line);
}
}
/* /*
* Send a single character to the debugging channel * Send a single character to the debugging channel
*/ */
@ -293,5 +355,5 @@ void log_c(short level, char c) {
char line[2]; char line[2];
line[0] = c; line[0] = c;
line[1] = '\0'; line[1] = '\0';
log_msg(level, line); log(level, line);
} }

100
src/log.h
View file

@ -68,7 +68,38 @@ extern void log_setlevel(short level);
* level = the severity of the message... the logging level will filter messages displayed * level = the severity of the message... the logging level will filter messages displayed
* message = the message to log * message = the message to log
*/ */
extern void log_msg(short level, const char * message, ...); extern void log(short level, const char * message, ...);
extern void trace(const char * message, ...);
/*
* Log a message to the console
*
* Inputs:
* level = the severity of the message... the logging level will filter messages displayed
* message1 = the first part of the message to log
* message2 = the second part of the message to log
*/
extern void log2(short level, const char * message1, const char * message2);
/*
* Log a message to the console
*
* Inputs:
* level = the severity of the message... the logging level will filter messages displayed
* message1 = the first part of the message to log
* message2 = the second part of the message to log
* message3 = the third part of the message to log
*/
extern void log3(short level, const char * message1, const char * message2, const char * message3);
/*
* Log a message with a number
*
* Inputs:
* level = the severity of the message... the logging level will filter messages displayed
* message1 = the first part of the message to log
* n = the number to log
*/
extern void log_num(short level, char * message, int n);
/* /*
* Log a single character * Log a single character
@ -80,36 +111,73 @@ extern void log_c(short log_level, char c);
*/ */
#if DEFAULT_LOG_LEVEL >= LOG_ERROR #if DEFAULT_LOG_LEVEL >= LOG_ERROR
# define ERROR(m, ...) log_msg(LOG_ERROR, m, ##__VA_ARGS__) # define ERROR(m) log(LOG_ERROR, m)
# define ERROR1(a,b) log(LOG_ERROR, a, b)
# define ERROR2(a,b,c) log(LOG_ERROR, a, b, c)
# define ERROR3(a,b,c,d) log(LOG_ERROR, a, b, c, d)
# define ERROR4(a,b,c,d,e) log(LOG_ERROR, a, b, c, d, e)
# define ERROR5(a,b,c,d,e,f) log(LOG_ERROR, a, b, c, d, e, f)
#else #else
# define ERROR(m, ...) # define ERROR(m)
# define ERROR1(a,b)
# define ERROR2(a,b,c)
# define ERROR3(a,b,c,d)
# define ERROR4(a,b,c,d,e)
# define ERROR5(a,b,c,d,e,f)
#endif #endif
#if DEFAULT_LOG_LEVEL >= LOG_INFO #if DEFAULT_LOG_LEVEL >= LOG_INFO
# define INFO(m, ...) log_msg(LOG_INFO, m, ##__VA_ARGS__); # define INFO(m) log(LOG_INFO, m);
# define INFO1(a,b) log(LOG_INFO, a, b);
# define INFO2(a,b,c) log(LOG_INFO, a, b, c);
# define INFO3(a,b,c,d) log(LOG_INFO, a, b, c, d);
# define INFO4(a,b,c,d,e) log(LOG_INFO, a, b, c, d, e);
# define INFO5(a,b,c,d,e,f) log(LOG_INFO, a, b, c, d, e, f);
#else #else
# define INFO(m, ...) # define INFO(m)
# define INFO1(a,b)
# define INFO2(a,b,c)
# define INFO3(a,b,c,d)
# define INFO4(a,b,c,d,e)
# define INFO5(a,b,c,d,e,f)
#endif #endif
#if DEFAULT_LOG_LEVEL >= LOG_DEBUG #if DEFAULT_LOG_LEVEL >= LOG_DEBUG
# define DEBUG(m, ...) log_msg(LOG_DEBUG, m, ##__VA_ARGS__) # define DEBUG(m) log(LOG_DEBUG, m)
# define DEBUG1(a,b) log(LOG_DEBUG, a, b)
# define DEBUG2(a,b,c) log(LOG_DEBUG, a, b, c)
# define DEBUG3(a,b,c,d) log(LOG_DEBUG, a, b, c, d)
# define DEBUG4(a,b,c,d,e) log(LOG_DEBUG, a, b, c, d, e)
# define DEBUG5(a,b,c,d,e,f) log(LOG_DEBUG, a, b, c, d, e, f)
#else #else
# define DEBUG(m, ...) # define DEBUG(m)
# define DEBUG1(a,b)
# define DEBUG2(a,b,c)
# define DEBUG3(a,b,c,d)
# define DEBUG4(a,b,c,d,e)
# define DEBUG5(a,b,c,d,e,f)
#endif #endif
#if DEFAULT_LOG_LEVEL >= LOG_TRACE #if DEFAULT_LOG_LEVEL >= LOG_TRACE
# define TRACE(m, ...) log_msg(LOG_TRACE, m, ##__VA_ARGS__) # define TRACE(m) trace(m)
# define TRACE1(a,b) trace(a, b)
# define TRACE2(a,b,c) trace(a, b, c)
# define TRACE3(a,b,c,d) trace(a, b, c, d)
# define TRACE4(a,b,c,d,e) trace(a, b, c, d, e)
# define TRACE5(a,b,c,d,e,f) trace(a, b, c, d, e, f)
# define TRACE6(a,b,c,d,e,f,g) trace(a, b, c, d, e, f, g)
# define TRACE7(a,b,c,d,e,f,g,h) trace(a, b, c, d, e, f, g, h)
#else #else
# define TRACE(m, ...) # define TRACE(m)
# define TRACE1(a,b)
# define TRACE2(a,b,c)
# define TRACE3(a,b,c,d)
# define TRACE4(a,b,c,d,e)
# define TRACE5(a,b,c,d,e,f)
# define TRACE6(a,b,c,d,e,f,g)
# define TRACE7(a,b,c,d,e,f,g,h)
#endif #endif
#define TRACEC(c) log_c(LOG_TRACE, c); #define TRACEC(c) log_c(LOG_TRACE, c);
#if DEFAULT_LOG_LEVEL >= LOG_VERBOSE
# define VERBOSE(m, ...) log_msg(LOG_VERBOSE, m, ##__VA_ARGS__)
#else
# define VERBOSE(m, ...)
#endif
#define VERBOSEC(c) log_c(LOG_VERBOSE, c);
#endif #endif

View file

@ -49,8 +49,8 @@ void call_user(long start, long stack, int argc, char * argv[]) {
void proc_exec(long start, long stack, int argc, char * argv[]) { void proc_exec(long start, long stack, int argc, char * argv[]) {
TRACE("proc_exec"); TRACE("proc_exec");
INFO("proc_exec start: %d", start); log_num(LOG_INFO, "proc_exec start: ", start);
INFO("proc_exec stack: %d", stack); log_num(LOG_INFO, "proc_exec stack: ", stack);
g_proc_result = 0; g_proc_result = 0;
call_user(start, stack, argc, argv); call_user(start, stack, argc, argv);
@ -68,7 +68,7 @@ typedef void (*thunk)();
* Inputs: * Inputs:
*/ */
SYSTEMCALL void proc_exit(int result) { SYSTEMCALL void proc_exit(int result) {
INFO("proc_exit: %d", result); INFO1("proc_exit: %d", result);
g_proc_result = result; g_proc_result = result;
if (proc_shell_address != 0) { if (proc_shell_address != 0) {
INFO("proc_exit: Attempting to call into shell"); INFO("proc_exit: Attempting to call into shell");
@ -118,7 +118,7 @@ SYSTEMCALL int proc_get_result() {
*/ */
SYSTEMCALL short proc_run(const char * path, int argc, char * argv[]) { SYSTEMCALL short proc_run(const char * path, int argc, char * argv[]) {
TRACE("proc_run(\"%s\")", path); TRACE1("proc_run(\"%s\")", path);
/* TODO: allow for commands without extensions */ /* TODO: allow for commands without extensions */
/* TODO: allow for a search PATH */ /* TODO: allow for a search PATH */
@ -131,11 +131,11 @@ SYSTEMCALL short proc_run(const char * path, int argc, char * argv[]) {
proc_exec(start, k_default_stack, argc, argv); proc_exec(start, k_default_stack, argc, argv);
return 0; return 0;
} else { } else {
ERROR("Couldn't execute file: %d", result); ERROR1("Couldn't execute file: %d", result);
return ERR_NOT_EXECUTABLE; return ERR_NOT_EXECUTABLE;
} }
} else { } else {
ERROR("Couldn't load file: %d", result); ERROR1("Couldn't load file: %d", result);
return result; return result;
} }
} }

View file

@ -36,11 +36,11 @@ void print_c(short channel, char c) {
* message = the ASCII-Z string to print * message = the ASCII-Z string to print
*/ */
void print(short channel, const char * message) { void print(short channel, const char * message) {
TRACE("print(%d,..)", channel); TRACE1("print(%d,..)", channel);
short ret = sys_chan_write(channel, (const unsigned char *)message, strlen(message)); short ret = sys_chan_write(channel, (const unsigned char *)message, strlen(message));
if (ret < 0) if (ret < 0)
ERROR("Error while printing: %d", ret); ERROR1("Error while printing: %d", ret);
} }
/** /**

View file

@ -27,7 +27,7 @@ const char * sys_model_name[] = {
"F256 K2c", "F256 K2c",
"F256 K2", "F256 K2",
"F256 Ke", "F256 Ke",
"F256 K2e", // 20 "F256 K2e" // 20
"Reserved", "Reserved",
"Reserved", "Reserved",
"Reserved", "Reserved",

View file

@ -3,8 +3,8 @@
*/ */
#include "log_level.h" #include "log_level.h"
#define DEFAULT_LOG_LEVEL LOG_INFO #define DEFAULT_LOG_LEVEL LOG_ERROR
#define LOG_CHANNEL LOG_CHANNEL_UART0 #define LOG_CHANNEL LOG_CHANNEL_CHANNEL_A
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
@ -84,7 +84,7 @@ void initialize() {
/* Setup logging early */ /* Setup logging early */
log_init(); log_init();
log_setlevel(DEFAULT_LOG_LEVEL); log_setlevel(DEFAULT_LOG_LEVEL);
INFO("\n\rFoenix Toolbox v%d.%02d.%04d built on %s %s starting up...", VER_MAJOR, VER_MINOR, VER_BUILD, __DATE__, __TIME__); INFO3("\n\rFoenix Toolbox v%d.%02d.%04d starting up...", VER_MAJOR, VER_MINOR, VER_BUILD);
/* Fill out the system information */ /* Fill out the system information */
sys_get_information(&info); sys_get_information(&info);
@ -133,7 +133,7 @@ void initialize() {
INFO("Text system initialized."); INFO("Text system initialized.");
INFO("Top of memory: %lx", mem_get_ramtop()); INFO1("Top of memory: %lx", mem_get_ramtop());
/* Initialize the indicators */ /* Initialize the indicators */
ind_init(); ind_init();
@ -164,7 +164,7 @@ void initialize() {
INFO("Block device system ready."); INFO("Block device system ready.");
if ((res = con_install())) { if ((res = con_install())) {
ERROR("FAILED: Console installation: %d", res); log_num(LOG_ERROR, "FAILED: Console installation", res);
} else { } else {
INFO("Console installed."); INFO("Console installed.");
} }
@ -190,21 +190,21 @@ void initialize() {
#if HAS_PATA #if HAS_PATA
if ((res = pata_install())) { if ((res = pata_install())) {
ERROR("FAILED: PATA driver installation: %d", res); log_num(LOG_ERROR, "FAILED: PATA driver installation", res);
} else { } else {
INFO("PATA driver installed."); INFO("PATA driver installed.");
} }
#endif #endif
if ((res = sdc_install())) { if ((res = sdc_install())) {
ERROR("FAILED: SDC driver installation %d", res); ERROR1("FAILED: SDC driver installation %d", res);
} else { } else {
INFO("SDC driver installed."); INFO("SDC driver installed.");
} }
#if HAS_FLOPPY #if HAS_FLOPPY
if ((res = fdc_install())) { if ((res = fdc_install())) {
ERROR("FAILED: Floppy drive initialization %d", res); ERROR1("FAILED: Floppy drive initialization %d", res);
} else { } else {
INFO("Floppy drive initialized."); INFO("Floppy drive initialized.");
} }
@ -213,9 +213,9 @@ void initialize() {
// At this point, we should be able to call into to console to print to the screens // At this point, we should be able to call into to console to print to the screens
// if ((res = ps2_init())) { // if ((res = ps2_init())) {
// ERROR("FAILED: PS/2 keyboard initialization: %d", res); // ERROR1("FAILED: PS/2 keyboard initialization", res);
// } else { // } else {
// INFO("PS/2 keyboard initialized."); // log(LOG_INFO, "PS/2 keyboard initialized.");
// } // }
// Initialize the keyboard // Initialize the keyboard
@ -224,36 +224,36 @@ void initialize() {
#if MODEL == MODEL_FOENIX_A2560K #if MODEL == MODEL_FOENIX_A2560K
if ((res = kbdmo_init())) { if ((res = kbdmo_init())) {
ERROR("FAILED: A2560K built-in keyboard initialization: %d", res); log_num(LOG_ERROR, "FAILED: A2560K built-in keyboard initialization", res);
} else { } else {
INFO("A2560K built-in keyboard initialized."); log(LOG_INFO, "A2560K built-in keyboard initialized.");
} }
#endif #endif
#if HAS_PARALLEL_PORT #if HAS_PARALLEL_PORT
if ((res = lpt_install())) { if ((res = lpt_install())) {
ERROR("FAILED: LPT installation: %d", res); log_num(LOG_ERROR, "FAILED: LPT installation", res);
} else { } else {
INFO("LPT installed."); log(LOG_INFO, "LPT installed.");
} }
#endif #endif
#if HAS_MIDI_PORTS #if HAS_MIDI_PORTS
if ((res = midi_install())) { if ((res = midi_install())) {
ERROR("FAILED: MIDI installation: %d", res); log_num(LOG_ERROR, "FAILED: MIDI installation", res);
} else { } else {
INFO("MIDI installed."); log(LOG_INFO, "MIDI installed.");
} }
#endif #endif
if ((res = uart_install())) { // if (res = uart_install()) {
ERROR("FAILED: serial port initialization: %d", res); // log_num(LOG_ERROR, "FAILED: serial port initialization", res);
} else { // } else {
INFO("Serial ports initialized."); // log(LOG_INFO, "Serial ports initialized.");
} // }
if ((res = fsys_init())) { if ((res = fsys_init())) {
ERROR("FAILED: file system initialization: %d", res); log_num(LOG_ERROR, "FAILED: file system initialization", res);
} else { } else {
INFO("File system initialized."); INFO("File system initialized.");
} }

28
utils/srec2bin.py Executable file → Normal file
View file

@ -1,13 +1,10 @@
#!/usr/bin/env python
# #
# Convert Motorola SREC to binary ROM files (both a 512KB main file and 8KB sector files for non-empty sectors) # Convert Motorola SREC to binary ROM files (both a 512KB main file and 8KB sector files for non-empty sectors)
# #
# usage: python srec2bin.py # usage: python srec2bin.py
# #
import os
import re import re
import sys
def srec_add_data(rom, address, data): def srec_add_data(rom, address, data):
"""Add a line of data from an SREC file (hex digits) to the binary image at the given address""" """Add a line of data from an SREC file (hex digits) to the binary image at the given address"""
@ -47,22 +44,9 @@ def bank_has_data(rom, bank):
rom_size = 512 * 1024 rom_size = 512 * 1024
rom_base = 0xf80000 rom_base = 0xf80000
output_name_base = "toolbox"
if len(sys.argv) != 2: input_file = "toolbox.s37"
print("Usage: srec2bin.py [toolbox rom s37 file]") output_file = "toolbox.bin"
sys.exit()
input_file = sys.argv[1]
if not os.path.exists(input_file) or not os.path.isfile(input_file):
print("Cannot read input file: " + input_file)
sys.exit()
output_dir = os.path.dirname(input_file)
output_file = output_dir + os.path.sep + output_name_base + ".bin"
output_bank_name_format = output_dir + os.path.sep + output_name_base + "-{:02X}.bin"
output_csv_file = output_dir + os.path.sep + output_name_base + ".csv"
rom_image = bytearray(rom_size) rom_image = bytearray(rom_size)
for i in range(rom_size): for i in range(rom_size):
@ -72,13 +56,11 @@ with open(input_file, "r") as input:
for line in input: for line in input:
srec_process(rom_image, line) srec_process(rom_image, line)
with open(output_file, "wb") as output: with open("toolbox.bin", "wb") as output:
output.write(rom_image) output.write(rom_image)
with open(output_csv_file, "w") as csv:
for bank in range(0, 64): for bank in range(0, 64):
if bank_has_data(rom_image, bank): if bank_has_data(rom_image, bank):
output_bank_name = output_bank_name_format.format(bank) output_name = "toolbox-{:02X}.bin".format(bank)
with open(output_bank_name, "wb") as output: with open(output_name, "wb") as output:
output.write(rom_image[bank * 8192:bank * 8192 + 8192]) output.write(rom_image[bank * 8192:bank * 8192 + 8192])
csv.write('"{:02X}","{}-{:02X}.bin"\n'.format(bank, output_name_base, bank))