Compare commits

..

14 commits

Author SHA1 Message Date
Gered 2abb0ee743 replace other usages of sprintf with snprintf
kind of nitpicky in some of these cases, but generally a good idea
2025-02-09 18:23:14 -05:00
Gered 6fddecb577 various logging cleanups
- remove all the INFOx, ERRORn, etc style faux-variadic logging macros
  and replace with real variadic macro equivalents
- switch all direct usages of trace(), log2(), log3() and log_num() to
  use the equivalent logging macros instead. i guess that these logging
  macros were added later on at some point but not all code was switched
  over to use them at that time?
- remove trace(), log2(), log3() and lognum() functions
- some formatting cleanups
- rename log() to log_msg() so as to not ever risk conflicting with
  log() from math.h
- use snprintf() instead of sprintf() in log.c
2025-02-09 18:23:14 -05:00
Gered 44bf82cfb1 missing comma 2025-02-09 18:02:44 -05:00
Gered 60e7c34a85 fix spaces/tabs issues in Makefile 2025-02-09 14:02:13 -05:00
Gered 3ea6ec9d8a fix compiler-generated dependencies file usage in Makefile
was unintentionally dropping part of the file extension so the deps
files weren't actually being used. oops.
2025-02-09 13:53:35 -05:00
Gered b35e5efd01 change build output location. make srec2bin.py more flexible
the Makefile now builds all artifacts, including final output s37 and
bin files under "build" so as to not clutter up the root directory
and making it easier to gitignore all build artifacts now and into the
future.

as well, the Makefile now has a new target to invoke srec2bin.py for us
to build ready-to-flash artifacts

srec2bin.py has been updated to be more flexible and do some minimal
argument error checking. it now also will output a CSV file for use
with FoenixMgr's flash-bulk option. this is useful as the number of
8k bin files can and will vary now and into the future, especially if
you are building with -O2 optimizations for size, etc.
2025-02-09 13:02:02 -05:00
Gered 47e3489141 fix cold bootup keyboard issue on the f256k
KBD_OPTICAL (0xf01dc0) is only "valid" on F256K2 hardware. i would
assume that this value is unknown on non-F256K2 hardware, thus sometimes
you might read some garbage value from here perhaps?

what i observed on my f256k was that always on cold bootup (that is,
booting from flash) the keyboard would never work. hitting reset or
booting from a ram build would not exhibit the same problem.

sometimes (somewhat more rarely) kbd_init() would lock up at some
point, presumably when it was trying to initialize/scan the non-existent
optical keyboard.

so far this also *seems* to resolve intermittent issues with reads to
the SD card on my f256k locking up. best not to read from those new
F256K2 registers on non-K2 devices!
2025-02-09 12:47:19 -05:00
Gered e16eaca30c add build date/time to startup log output 2025-02-08 22:25:38 -05:00
Gered 3c96d30f7a update gitignore 2025-02-07 16:37:24 -05:00
Gered dcec60f478 re-enable uart debug output by default
at least for now
2025-02-07 16:36:55 -05:00
Gered 50cc3c333c re-enable uart channel device driver installation
i'm not really sure why this was commented out to begin with. possibly
due to the broken parsing of the channel path string in uart_open, but
i am unsure exactly.
2025-02-07 16:36:41 -05:00
Gered 42d8a985e5 fix uart_open's incorrect use of strtok_r, fixing uart device init 2025-02-07 16:36:32 -05:00
Gered 8e50c61349 update gitignore 2025-02-02 15:32:22 -05:00
Gered 7704756b72 add new Makefile
i am really not a big fan of the current "Makefile in each directory"
build system in this project. sorry.

i don't have any C256 devices, so i've not kept anything for them in
this new Makefile. to the best of my knowledge, you can't get any of
these devices anymore anyway, so i don't particular care. sorry again.
2025-02-02 15:32:05 -05:00
26 changed files with 424 additions and 374 deletions

8
.gitignore vendored
View file

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

142
Makefile Normal file
View file

@ -0,0 +1,142 @@
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++) {
if (bootable[i]) {
sprintf(message, "\e[93mF%d\e[37m-%s\n", i+1, boot_source_name(boot_chain[i]));
snprintf(message, 80, "\e[93mF%d\e[37m-%s\n", i+1, boot_source_name(boot_chain[i]));
chan_write(0, (uint8_t *)message, strlen(message));
}
}
}
sprintf(message, "\nPress \e[93mSPACE\e[37m for default.\n");
snprintf(message, 80, "\nPress \e[93mSPACE\e[37m for default.\n");
chan_write(0, (uint8_t *)message, strlen(message));
// 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) {
short dev;
TRACE1("bdev_register(%s)", device->name);
TRACE("bdev_register(%s)", device->name);
dev = device->number;
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
//
short bdev_init(short dev) {
TRACE1("bdev_init(%d)", (int)dev);
TRACE("bdev_init(%d)", (int)dev);
short ret = DEV_ERR_BADDEV;
@ -79,7 +79,7 @@ short bdev_init(short dev) {
}
}
TRACE1("bdev_init returning %d", (int)ret);
TRACE("bdev_init returning %d", (int)ret);
return ret;
}
@ -96,7 +96,7 @@ short bdev_init(short dev) {
// number of bytes read, any negative number is an error code
//
SYSTEMCALL short bdev_read(short dev, long lba, unsigned char * buffer, short size) {
TRACE4("bdev_read(%d,%ld,%p,%d)", (int)dev, lba, buffer, (int)size);
TRACE("bdev_read(%d,%ld,%p,%d)", (int)dev, lba, buffer, (int)size);
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);
}
TRACE1("bdev_read returning %d", (int)ret);
TRACE("bdev_read returning %d", (int)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
//
SYSTEMCALL short bdev_write(short dev, long lba, const unsigned char * buffer, short size) {
TRACE4("bdev_write(%d,%ld,%p,%d)", (int)dev, lba, buffer, (int)size);
TRACE("bdev_write(%d,%ld,%p,%d)", (int)dev, lba, buffer, (int)size);
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);
}
TRACE1("bdev_write returning %d", (int)ret);
TRACE("bdev_write returning %d", (int)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
//
SYSTEMCALL short bdev_status(short dev) {
TRACE1("bdev_status(%d)", dev);
TRACE("bdev_status(%d)", dev);
short ret = DEV_ERR_BADDEV;
@ -157,7 +157,7 @@ SYSTEMCALL short bdev_status(short dev) {
ret = bdev->status(bdev);
}
TRACE1("bdev_status returning %d", (int)ret);
TRACE("bdev_status returning %d", (int)ret);
return ret;
}
@ -171,7 +171,7 @@ SYSTEMCALL short bdev_status(short dev) {
// 0 on success, any negative number is an error code
//
SYSTEMCALL short bdev_flush(short dev) {
TRACE1("bdev_flush(%d)", (int)dev);
TRACE("bdev_flush(%d)", (int)dev);
short ret = DEV_ERR_BADDEV;
@ -181,7 +181,7 @@ SYSTEMCALL short bdev_flush(short dev) {
return bdev->flush(bdev);
}
TRACE1("bdev_flush returning %d", (int)ret);
TRACE("bdev_flush returning %d", (int)ret);
return ret;
}
@ -198,7 +198,7 @@ SYSTEMCALL short bdev_flush(short dev) {
// 0 on success, any negative number is an error code
//
SYSTEMCALL short bdev_ioctrl(short dev, short command, unsigned char * buffer, short size) {
TRACE4("bdev_ioctrl(%d, %d, %p, %d)", (int)dev, command, buffer, (int)size);
TRACE("bdev_ioctrl(%d, %d, %p, %d)", (int)dev, command, buffer, (int)size);
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);
}
TRACE1("bdev_ioctrl returning %d", (int)ret);
TRACE("bdev_ioctrl returning %d", (int)ret);
return ret;
}

View file

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

View file

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

View file

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

View file

@ -14,6 +14,7 @@
#include <stdint.h>
#include <stdio.h>
#include "features.h"
#include "interrupt.h"
#include "log.h"
#include "ring_buffer.h"
@ -330,11 +331,20 @@ bool kbd_break() {
*
*/
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) {
is_optical = false;
} else {
is_optical = true;
}
#else
is_optical = false;
#endif
// Initialize VIA0 -- we'll just read from PB7
via0->ddra = 0x00;

View file

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

View file

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

View file

@ -152,7 +152,7 @@ short sdc_init() {
short sdc_read(long lba, unsigned char * buffer, short size) {
long adjusted_lba;
TRACE3("sdc_read(%ld,%p,%d)", lba, buffer, (int)size);
TRACE("sdc_read(%ld,%p,%d)", lba, buffer, (int)size);
// 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);
// Success: return the byte count
TRACE1("sdc_read: returning %d", count);
TRACE("sdc_read: returning %d", count);
return count;
}
}
@ -326,7 +326,7 @@ short sdc_write(long lba, const unsigned char * buffer, short size) {
short sdc_status() {
short status = g_sdc_status;
TRACE1("sdc_status, status=0x%x",(int)status);
TRACE("sdc_status, status=0x%x",(int)status);
if (sdc_detected()) {
// Add the PRESENT flag, if the card is inserted
@ -338,7 +338,7 @@ short sdc_status() {
status |= SDC_STAT_PROTECTED;
}
TRACE1("sdc_status: %x", (short)status);
TRACE("sdc_status: %x", (short)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
card->status = card->type ? 0 : SDC_STAT_NOINIT;
INFO1("SD0_CardType: %x", card->type);
INFO1("SD0_Stat: %x", card->status);
INFO("SD0_CardType: %x", card->type);
INFO("SD0_Stat: %x", card->status);
SD0_deselect(sd);

View file

@ -104,7 +104,7 @@ static void txt_c256_set_sizes() {
c256_visible_size.height = c256_max_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);
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);
}
}
@ -327,11 +327,7 @@ static short txt_c256_get_region(p_rect region) {
region->size.width = c256_region.size.width;
region->size.height = c256_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);
}
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);
return 0;
}

View file

@ -141,7 +141,7 @@ static void txt_evid_set_sizes() {
evid_visible_size.height = evid_max_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);
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);
}
}

View file

@ -110,7 +110,7 @@ static void txt_f256_set_sizes() {
f256_visible_size.height = f256_max_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);
// 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);
}
}
@ -177,7 +177,7 @@ static short txt_f256_set_mode(short mode) {
}
*tvky_mstr_ctrl = mcr_shadow;
INFO1("Setting Vicky MCR: 0x%04x", mcr_shadow);
INFO("Setting Vicky MCR: 0x%04x", mcr_shadow);
return 0;
}
}

View file

@ -47,7 +47,7 @@ void txt_init() {
* @return 0 on success, any other number is an error
*/
short txt_register(p_txt_device device) {
DEBUG1("txt_register(%s)", device->name);
DEBUG("txt_register(%s)", device->name);
if (device->number < TXT_CNT_SCREENS) {
int i = device->number;
@ -95,7 +95,7 @@ p_txt_device txt_get_device(short screen) {
if (device->number == screen) {
return device;
} else {
ERROR1("txt_get_device: number mismatch %d", screen);
ERROR("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
*/
void txt_init_screen(short screen) {
TRACE1("txt_init_screen(%d)", (int)screen);
TRACE("txt_init_screen(%d)", (int)screen);
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->init) {
device->init();
}
} else {
ERROR1("Could not find screen %d", screen);
ERROR("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
*/
SYSTEMCALL short txt_get_region(short screen, p_rect region) {
DEBUG2("txt_get_region screen:%d region:%p", screen, region);
DEBUG("txt_get_region screen:%d region:%p", screen, region);
p_txt_device device = txt_get_device(screen);
if (device) {
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
*/
SYSTEMCALL short txt_set_region(short screen, p_rect region) {
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);
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);
p_txt_device device = txt_get_device(screen);
if (device) {
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)
*/
SYSTEMCALL short txt_set_color(short screen, unsigned char foreground, unsigned char background) {
TRACE3("txt_get_color(%d,%d,%d)", (int)screen, (int)foreground, (int)background);
TRACE("txt_get_color(%d,%d,%d)", (int)screen, (int)foreground, (int)background);
p_txt_device device = txt_get_device(screen);
if (device) {
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
*/
SYSTEMCALL void txt_get_color(short screen, unsigned char * foreground, unsigned char * background) {
TRACE3("txt_get_color(%d,%p,%p)", (int)screen, foreground, background);
TRACE("txt_get_color(%d,%p,%p)", (int)screen, foreground, background);
p_txt_device device = txt_get_device(screen);
if (device) {
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
*/
SYSTEMCALL void txt_set_xy(short screen, short x, short y) {
DEBUG3("txt_set_xy(%d,%d,%d)", screen, (int)x, (int)y);
DEBUG("txt_set_xy(%d,%d,%d)", screen, (int)x, (int)y);
p_txt_device device = txt_get_device(screen);
if (device) {
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)
*/
void txt_scroll(short screen, short horizontal, short vertical) {
TRACE3("txt_scroll(%d,%d,%d)", screen, horizontal, vertical);
TRACE("txt_scroll(%d,%d,%d)", screen, horizontal, vertical);
p_txt_device device = txt_get_device(screen);
if (device) {
if (device->scroll) {
@ -517,7 +517,7 @@ void txt_clear(short screen, short mode) {
t_point cursor;
t_rect old_region, region;
TRACE2("txt_clear(%d,%d)", (int)screen, (int)mode);
TRACE("txt_clear(%d,%d)", (int)screen, (int)mode);
txt_get_xy(screen, &cursor);
txt_get_region(screen, &old_region);
@ -592,7 +592,7 @@ void txt_clear_line(short screen, short mode) {
t_point cursor;
t_rect old_region, region;
TRACE2("txt_clear_line(%d,%d)", (int)screen, (int)mode);
TRACE("txt_clear_line(%d,%d)", (int)screen, (int)mode);
txt_get_xy(screen, &cursor);
txt_get_region(screen, &old_region);
@ -657,7 +657,7 @@ void txt_insert(short screen, short count) {
t_point cursor;
t_rect old_region, region;
TRACE2("txt_clear_line(%d,%d)", (int)screen, (int)count);
TRACE("txt_clear_line(%d,%d)", (int)screen, (int)count);
if (count > 0) {
txt_get_xy(screen, &cursor);
@ -685,7 +685,7 @@ void txt_delete(short screen, short count) {
t_rect old_region, region;
short left;
TRACE2("txt_delete(%d,%d)", screen, count);
TRACE("txt_delete(%d,%d)", screen, count);
if (count > 0) {
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);
// Get the next token
token = strtok_r(spec_copy, ",", &saveptr);
token = strtok_r(NULL, ",", &saveptr);
if (token) {
// Parse the data bit count
i = atoi(token);
@ -315,12 +315,12 @@ short uart_open(p_channel chan, const unsigned char * spec, short mode) {
break;
default:
log(LOG_ERROR, "uart_open: Bad data word length");
ERROR("uart_open: Bad data word length");
return ERR_BAD_ARGUMENT;
}
// Get the next token
token = strtok_r(spec_copy, ",", &saveptr);
token = strtok_r(NULL, ",", &saveptr);
if (token) {
// Parse the stop bit count (1 or 2)
i = atoi(token);
@ -329,12 +329,12 @@ short uart_open(p_channel chan, const unsigned char * spec, short mode) {
} else if (i == 2) {
lcr_code |= LCR_STOPBIT_2;
} else {
log(LOG_ERROR, "uart_open: Bad stop bits");
ERROR("uart_open: Bad stop bits");
return ERR_BAD_ARGUMENT;
}
// Get the next token
token = strtok_r(spec_copy, ",", &saveptr);
token = strtok_r(NULL, ",", &saveptr);
if (token) {
// NONE, ODD, EVEN, MARK, or SPACE
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) {
lcr_code |= LCR_PARITY_SPACE;
} else {
log(LOG_ERROR, "uart_open: Bad parity");
ERROR("uart_open: Bad parity");
return ERR_BAD_ARGUMENT;
}
@ -357,19 +357,19 @@ short uart_open(p_channel chan, const unsigned char * spec, short mode) {
return 0;
} else {
log(LOG_ERROR, "uart_open: no parity token");
ERROR("uart_open: no parity token");
return ERR_BAD_ARGUMENT;
}
} else {
log(LOG_ERROR, "uart_open: no stop bit token");
ERROR("uart_open: no stop bit token");
return ERR_BAD_ARGUMENT;
}
} else {
log(LOG_ERROR, "uart_open: no data length token");
ERROR("uart_open: no data length token");
return ERR_BAD_ARGUMENT;
}
} else {
log(LOG_ERROR, "uart_open: no BPS token");
ERROR("uart_open: no BPS token");
return ERR_BAD_ARGUMENT;
}

View file

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

View file

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

View file

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

100
src/log.h
View file

@ -68,38 +68,7 @@ extern void log_setlevel(short level);
* level = the severity of the message... the logging level will filter messages displayed
* message = the message to log
*/
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);
extern void log_msg(short level, const char * message, ...);
/*
* Log a single character
@ -111,73 +80,36 @@ extern void log_c(short log_level, char c);
*/
#if DEFAULT_LOG_LEVEL >= LOG_ERROR
# 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)
# define ERROR(m, ...) log_msg(LOG_ERROR, m, ##__VA_ARGS__)
#else
# 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)
# define ERROR(m, ...)
#endif
#if DEFAULT_LOG_LEVEL >= LOG_INFO
# 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);
# define INFO(m, ...) log_msg(LOG_INFO, m, ##__VA_ARGS__);
#else
# 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)
# define INFO(m, ...)
#endif
#if DEFAULT_LOG_LEVEL >= LOG_DEBUG
# 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)
# define DEBUG(m, ...) log_msg(LOG_DEBUG, m, ##__VA_ARGS__)
#else
# 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)
# define DEBUG(m, ...)
#endif
#if DEFAULT_LOG_LEVEL >= LOG_TRACE
# 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)
# define TRACE(m, ...) log_msg(LOG_TRACE, m, ##__VA_ARGS__)
#else
# 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)
# define TRACE(m, ...)
#endif
#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

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[]) {
TRACE("proc_exec");
log_num(LOG_INFO, "proc_exec start: ", start);
log_num(LOG_INFO, "proc_exec stack: ", stack);
INFO("proc_exec start: %d", start);
INFO("proc_exec stack: %d", stack);
g_proc_result = 0;
call_user(start, stack, argc, argv);
@ -68,7 +68,7 @@ typedef void (*thunk)();
* Inputs:
*/
SYSTEMCALL void proc_exit(int result) {
INFO1("proc_exit: %d", result);
INFO("proc_exit: %d", result);
g_proc_result = result;
if (proc_shell_address != 0) {
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[]) {
TRACE1("proc_run(\"%s\")", path);
TRACE("proc_run(\"%s\")", path);
/* TODO: allow for commands without extensions */
/* 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);
return 0;
} else {
ERROR1("Couldn't execute file: %d", result);
ERROR("Couldn't execute file: %d", result);
return ERR_NOT_EXECUTABLE;
}
} else {
ERROR1("Couldn't load file: %d", result);
ERROR("Couldn't load file: %d", result);
return result;
}
}

View file

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

View file

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

View file

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

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

@ -1,10 +1,13 @@
#!/usr/bin/env python
#
# Convert Motorola SREC to binary ROM files (both a 512KB main file and 8KB sector files for non-empty sectors)
#
# usage: python srec2bin.py
#
import os
import re
import sys
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"""
@ -44,9 +47,22 @@ def bank_has_data(rom, bank):
rom_size = 512 * 1024
rom_base = 0xf80000
output_name_base = "toolbox"
input_file = "toolbox.s37"
output_file = "toolbox.bin"
if len(sys.argv) != 2:
print("Usage: srec2bin.py [toolbox rom s37 file]")
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)
for i in range(rom_size):
@ -56,11 +72,13 @@ with open(input_file, "r") as input:
for line in input:
srec_process(rom_image, line)
with open("toolbox.bin", "wb") as output:
with open(output_file, "wb") as output:
output.write(rom_image)
for bank in range(0, 64):
with open(output_csv_file, "w") as csv:
for bank in range(0, 64):
if bank_has_data(rom_image, bank):
output_name = "toolbox-{:02X}.bin".format(bank)
with open(output_name, "wb") as output:
output_bank_name = output_bank_name_format.format(bank)
with open(output_bank_name, "wb") as output:
output.write(rom_image[bank * 8192:bank * 8192 + 8192])
csv.write('"{:02X}","{}-{:02X}.bin"\n'.format(bank, output_name_base, bank))