Compare commits

...

5 commits

Author SHA1 Message Date
Gered e45a899c43 updates to boot source selection process
this is i suppose a fairly subjective change, but basically:
- i did not like the timeout to default selection at all. possibly i
  might want to make it so that the timeout is disabled only when the
  "boot from ram" dip switch is enabled?
- i wanted a bit more feedback from the UI when keys are hit, even if
  there is no valid boot source. kind of reassuring to know that things
  are working, even if there's nothing to boot from.
- having the ability to manually trigger a boot source detection
  refresh (even if it is, for now, implemented in a slightly-hacky way
  by just resetting the device) is really nice

i also didn't like that after you made a selection, it either worked
and booted from whatever you picked, or it told you "no bootable device
is present" and then just blocked at that point, forcing you to reset
manually. calling `boot_from` inside the while-loop seems nicer to me
just in case you fat-finger the boot device and choose an invalid one.
2025-02-02 16:49:36 -05:00
Gered 337da365c0 clarify message 2025-02-02 15:43:25 -05:00
Gered a447776078 fix ceil_div_short
the existing implementation causes issues for some reason, at least on
my F256K anyway?
2025-02-02 15:42:26 -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
4 changed files with 162 additions and 13 deletions

7
.gitignore vendored
View file

@ -52,3 +52,10 @@ Mkfile.old
dkms.conf dkms.conf
.vscode/settings.json .vscode/settings.json
/misc/F256xE_Kernal_Code /misc/F256xE_Kernal_Code
obj/
/foenixmgr.ini
/*.s37
/*.raw
/*.bin
/*.lst

135
Makefile Normal file
View file

@ -0,0 +1,135 @@
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))
OBJ_DIR = obj
OBJ_FILES = $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(SRC_FILES)))
DEPS_DIR = $(OBJ_DIR)
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
rom: $(TARGET_ROM).s37
ram: $(TARGET_RAM).s37
clean:
rm -f *.s37
rm -f *.lst
rm -rf $(OBJ_DIR)
$(TARGET_ROM).s37: $(OBJ_FILES)
$(LD) -o $@ $^ $(LDFLAGS_FOR_ROM) --output-format=s37 --list-file=$@.lst
$(TARGET_RAM).s37: $(OBJ_FILES)
$(LD) -o $@ $^ $(LDFLAGS_FOR_RAM) --output-format=s37 --list-file=$@.lst
$(OBJ_DIR)/%.c.o: %.c
@mkdir -p $(dir $@)
$(CC) -MMD -MP -MF$(DEPS_DIR)/$*.d $(CFLAGS) -o $@ $<
$(OBJ_DIR)/%.s.o: %.s
@mkdir -p $(dir $@)
$(AS) $(AFLAGS) -o $@ $<
-include $(DEPENDS)

View file

@ -25,6 +25,7 @@
#include "vicky_general.h" #include "vicky_general.h"
#include "rsrc/sprites/boot_sprites.h" #include "rsrc/sprites/boot_sprites.h"
#include "rsrc/tiles/boot_tiles.h" #include "rsrc/tiles/boot_tiles.h"
#include "syscalls.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -562,34 +563,36 @@ void boot_screen() {
} }
} }
sprintf(message, "\nPress \e[93mSPACE\e[37m for default.\n"); sprintf(message, "\nPress \e[93mSPACE\e[37m to boot from default source.\nPress \e[93m<=\e[37m to rescan for boot sources.\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 // Let the user select a boot source
// If the time expires, boot the default source (earliest in the boot chain)
jiffies_target = timers_jiffies() + 60 * 15; while (true) {
while (jiffies_target > timers_jiffies()) {
unsigned short scancode = kbd_get_scancode(); unsigned short scancode = kbd_get_scancode();
if (scancode > 0) { if (scancode > 0) {
if (scancode == 1) {
printf("Rebooting ...\n");
sys_reboot();
}
short selected = sc_to_function(scancode); short selected = sc_to_function(scancode);
if (selected == 0x20) { if (selected == 0x20) {
printf("Booting from default ...\n");
// SPACE was pressed... just boot the default // SPACE was pressed... just boot the default
break; boot_from(boot_source, boot_record[0]);
} else if (selected > 0) { } else if (selected > 0) {
printf("Booting from %d ...\n", selected);
if (bootable[selected - 1]) { if (bootable[selected - 1]) {
boot_position = selected - 1; boot_position = selected - 1;
boot_source = boot_chain[boot_position]; boot_source = boot_chain[boot_position];
break; boot_from(boot_source, boot_record[boot_position]);
} else {
printf("Nothing bootable at device %d.\n", selected);
} }
} }
} }
} }
// And launch the system
boot_from(boot_source, boot_record[boot_position]);
} }

View file

@ -15,7 +15,11 @@
* @return the smallest short c such that c >= a / b * @return the smallest short c such that c >= a / b
*/ */
short ceil_div_short(short a, short b) { short ceil_div_short(short a, short b) {
return (a + (b - 1)) / b; if (a % b) {
return (a / b) + 1;
} else {
return a / b;
}
} }
/** /**