Started client samples. Fixed some UNIT errors in makefiles

This commit is contained in:
Peter Weingartner 2024-09-06 16:03:42 -04:00
parent 43a9d48cfc
commit ccbcc7303b
51 changed files with 4512 additions and 30 deletions

8
client-64tass/Makefile Normal file
View file

@ -0,0 +1,8 @@
AS = 64tass
ASFLAGS = --nostart --flat --s-record
# Build the object files from assembly
hello.s37: hello.s
$(AS) $(ASFLAGS) --list=hello.lst -o hello.s37 hello.s

View file

@ -0,0 +1,33 @@
###
### Generate client bindings for the Toolbox (64TASS version)
###
# with open("toolbox_bindings.s", "w") as output:
table_entry_size = 4
table_address = 0xffe000
syscalls = {}
with open("..\src\C256\syscalls.txt", "r") as input:
for line in input:
# Remove comments
index = line.find("#")
if index == 0:
line = ""
elif index > 0:
line = line[index - 1:]
line = line.strip()
if line != "":
name = "sys_{}".format(line)
syscalls[name] = table_address
table_address += table_entry_size
with open("bindings.s", "w") as output:
output.write(";;;\n;;; Bindings for the Foenix Toolbox public calls\n;;;\n\n")
for name in syscalls.keys():
address = syscalls[name]
output.write("{0} = ${1:06X}\n".format(name, address))

46
client-64tass/hello.s Normal file
View file

@ -0,0 +1,46 @@
;;;
;;; A simple client program for the Foenix Toolbox using 64TASS
;;;
.cpu "65816"
.include "macros.s"
.include "toolbox.s"
.include "tb_params.s"
* = $10000
header: .byte $f8, $16 ; Signature
.byte 0 ; Version
.dword start ; Starting address
.dword 0 ; Icon address
.dword 0 ; Icon palette address
.null "hello" ; Name of the file
start: clc
xce
setdbr `start
setaxl
alloc 6 ; Set aside parameter space for sys_chan_write
lda #33 ; Size of the message
sta tb.chan_write.size
lda #`message ; Pointer to the message
sta tb.chan_write.buffer+2
lda #<>message
sta tb.chan_write.buffer
lda #0 ; Channel #0
jsl sys_chan_write ; sys_chan_write(0, message, strlen(message))
free 6 ; Reclaim parameter space from sys_chan_write
loop: nop
bra loop
message: .null "Hello, Foenix Toolbox (64TASS)!",13,10

68
client-64tass/macros.s Normal file
View file

@ -0,0 +1,68 @@
; Set 8-bit accumulator
setaxs .macro
SEP #$30 ; set A&X short
.as
.xs
.endm
; Set 16-bit accumulator
setaxl .macro
REP #$30 ; set A&X long
.al
.xl
.endm
; Set 8-bit accumulator
setas .macro
SEP #$20 ; set A short
.as
.endm
; Set 16-bit accumulator
setal .macro
REP #$20 ; set A long
.al
.endm
; Set 8 bit index registers
setxs .macro
SEP #$10 ; set X short
.xs
.endm
; Set 16-bit index registers
setxl .macro
REP #$10 ; set X long
.xl
.endm
; Set the direct page.
; Note: This uses the accumulator and leaves A set to 16 bits.
setdp .macro
PEA #\1 ; set DP to page 0
PLD
.dpage \1
.endm
setdbr .macro ; Set the B (Data bank) register
PEA #((\1) * 256) + (\1)
PLB
PLB
.databank \1
.endm
TRACE .macro message
; PHA
; PHX
; PHY
; PEA #`txt_message
; PEA #<>txt_message
; JSL ITRACE
; BRA continue
; txt_message .null 13,\message
; continue PLY
; PLX
; PLA
.endm

124
client-64tass/tb_params.s Normal file
View file

@ -0,0 +1,124 @@
;
; Allocate a number of bytes onto the stack for parameters
;
alloc .macro count
.switch \count
.case 0
.case 2
pea #0 ; 5
.case 4
pea #0 ; 10
pea #0
.case 6
pea #0 ; 15
pea #0
pea #0
.default
sta #0,d
tsc
sec
sbc #\count
tcs
lda #0,d
.endswitch
.endm
;
; Remove a number of bytes from the stack (previously alloc'ed)
;
free .macro count
.switch \count
.case 0
.case 2
ply ; 5
.case 4
ply ; 10
ply
.case 6
ply ; 15
ply
ply
.default
sta #0,d ; 4
tsc ; 2
clc ; 2
adc #\count ; 3
tcs ; 2
lda #0,d ; 4 (17 total)
.endswitch
.endm
tb .namespace
int_register .namespace
.virtual #1,s
handler: .dword ?
.endv
.endn
;
; Channel Parameters
;
chan_read .namespace
.virtual #1,s
size: .word ?
buffer .dword ?
.endv
.endn
chan_readline .namespace
.virtual #1,s
size .word ?
buffer .dword ?
.endv
.endn
chan_write_b .namespace
.virtual #1,s
b: .byte ?
.endv
.endn
chan_write .namespace
.virtual #1,s
buffer .dword ?
size .word ?
.endv
.endn
chan_seek .namespace
.virtual #1,s
base .word ?
position .dword ?
.endv
.endn
chan_ioctrl .namespace
.virtual #1,s
size .word ?
buffer .dword ?
command .word ?
.endv
.endn
chan_open .namespace
.virtual #1,s
mode .word ?
path .dword ?
.endv
.endn
chan_swap .namespace
.virtual #1,s
channel2 .word ?
.endv
.endn
.endn

59
client-64tass/toolbox.s Normal file
View file

@ -0,0 +1,59 @@
;;;
;;; Bindings for the Foenix Toolbox public calls
;;;
sys_proc_exit = $FFE000
sys_chan_read_b = $FFE004
sys_chan_read = $FFE008
sys_chan_readline = $FFE00C
sys_chan_write_b = $FFE010
sys_chan_write = $FFE014
sys_chan_status = $FFE018
sys_chan_flush = $FFE01C
sys_chan_seek = $FFE020
sys_chan_ioctrl = $FFE024
sys_chan_open = $FFE028
sys_chan_close = $FFE02C
sys_chan_swap = $FFE030
sys_chan_device = $FFE034
sys_bdev_register = $FFE038
sys_bdev_read = $FFE03C
sys_bdev_write = $FFE040
sys_bdev_status = $FFE044
sys_bdev_flush = $FFE048
sys_bdev_ioctrl = $FFE04C
sys_fsys_open = $FFE050
sys_fsys_close = $FFE054
sys_fsys_opendir = $FFE058
sys_fsys_closedir = $FFE05C
sys_fsys_readdir = $FFE060
sys_fsys_findfirst = $FFE064
sys_fsys_findnext = $FFE068
sys_fsys_mkdir = $FFE06C
sys_fsys_delete = $FFE070
sys_fsys_rename = $FFE074
sys_fsys_set_cwd = $FFE078
sys_fsys_get_cwd = $FFE07C
sys_fsys_load = $FFE080
sys_fsys_register_loader = $FFE084
sys_fsys_stat = $FFE088
sys_mem_get_ramtop = $FFE08C
sys_mem_reserve = $FFE090
sys_err_message = $FFE094
sys_proc_run = $FFE098
sys_txt_get_capabilities = $FFE09C
sys_txt_set_mode = $FFE0A0
sys_txt_setsizes = $FFE0A4
sys_txt_set_xy = $FFE0A8
sys_txt_get_xy = $FFE0AC
sys_txt_get_region = $FFE0B0
sys_txt_set_region = $FFE0B4
sys_txt_set_color = $FFE0B8
sys_txt_get_color = $FFE0BC
sys_txt_set_cursor_visible = $FFE0C0
sys_txt_set_font = $FFE0C4
sys_txt_get_sizes = $FFE0C8
sys_txt_set_border = $FFE0CC
sys_txt_set_border_color = $FFE0D0
sys_txt_put = $FFE0D4
sys_txt_print = $FFE0D8

68
client/src/Makefile Normal file
View file

@ -0,0 +1,68 @@
# VPATH=.:../../module/Calypsi-remote-debug/src
DEBUGGER=../module/Calypsi-remote-debug/src
UNIT := F256K
MEMORY := RAM
# Define OS-dependent variables
ifeq ($(OS),Windows_NT)
RM = del /F/Q
else
RM = rm -f
endif
# Define model-specific variables, including tools, source files, compiler flags, etc.
ifeq ($(UNIT),F256K)
CPU=w65816
C_SRCS_DEBUGGER=$(DEBUGGER)/agent.c $(DEBUGGER)/c256-uart.c $(DEBUGGER)/low_level_WDC65816.s
SRCS_FOR_UNIT=
CFLAGS_FOR_UNIT=-DMODEL=17 -DCPU=255 --code-model large --data-model large
ifeq ($(MEMORY),ROM)
LDFLAGS_FOR_UNIT=C256/f256-flash.scm clib-lc-ld.a --rtattr printf=medium --cstartup=f256
else
LDFLAGS_FOR_UNIT=C256/f256-ld_lc.scm clib-lc-ld.a --rtattr printf=medium --cstartup=f256
endif
endif
ifeq ($(CPU),w65816)
CC=cc65816
AS=as65816
LD=ln65816
AR=nlib
endif
INCLUDES=-I. -I./include
CFLAGS=$(INCLUDES) $(CFLAGS_FOR_UNIT) -l # -l -D_CALYPSI_MCP_DEBUGGER
ASFLAGS=$(INCLUDES) --data-model large --code-model large
ifeq ($(MEMORY),ROM)
LDFLAGS=--rom-code $(LDFLAGS_FOR_UNIT) --list-file toolbox.map
else
LDFLAGS=$(LDFLAGS_FOR_UNIT) --list-file toolbox.map
endif
SRCS = stubs.c bindings.s $(SRCS_FOR_UNIT) # $(C_SRCS_DEBUGGER)
OBJS = $(patsubst %.s,%.o,$(patsubst %.c,%.o,$(SRCS)))
OBJS4RM = $(subst /,\\,$(OBJS))
LIBS =
.PHONY: clean
toolbox.a: $(OBJS)
$(AR) toolbox.a $(OBJS)
# Build the object files from C
%.o: %.c
$(CC) $(CFLAGS) -o $@ $^
# Build the object files from assembly
%.o: %.s
$(AS) $(ASFLAGS) -o $@ $^
# Clean up after a build
clean:
$(RM) $(OBJS4RM) *.o *.a *.lst

115
client/src/bindings.s Normal file
View file

@ -0,0 +1,115 @@
;;;
;;; Bindings for the Foenix Toolbox public calls
;;;
.public sys_proc_exit
.public sys_chan_read_b
.public sys_chan_read
.public sys_chan_readline
.public sys_chan_write_b
.public sys_chan_write
.public sys_chan_status
.public sys_chan_flush
.public sys_chan_seek
.public sys_chan_ioctrl
.public sys_chan_open
.public sys_chan_close
.public sys_chan_swap
.public sys_chan_device
.public sys_bdev_register
.public sys_bdev_read
.public sys_bdev_write
.public sys_bdev_status
.public sys_bdev_flush
.public sys_bdev_ioctrl
.public sys_fsys_open
.public sys_fsys_close
.public sys_fsys_opendir
.public sys_fsys_closedir
.public sys_fsys_readdir
.public sys_fsys_findfirst
.public sys_fsys_findnext
.public sys_fsys_mkdir
.public sys_fsys_delete
.public sys_fsys_rename
.public sys_fsys_set_cwd
.public sys_fsys_get_cwd
.public sys_fsys_load
.public sys_fsys_register_loader
.public sys_fsys_stat
.public sys_mem_get_ramtop
.public sys_mem_reserve
.public sys_err_message
.public sys_proc_run
.public sys_txt_get_capabilities
.public sys_txt_set_mode
.public sys_txt_setsizes
.public sys_txt_set_xy
.public sys_txt_get_xy
.public sys_txt_get_region
.public sys_txt_set_region
.public sys_txt_set_color
.public sys_txt_get_color
.public sys_txt_set_cursor_visible
.public sys_txt_set_font
.public sys_txt_get_sizes
.public sys_txt_set_border
.public sys_txt_set_border_color
.public sys_txt_put
.public sys_txt_print
sys_proc_exit: .equlab 0xFFE000
sys_chan_read_b: .equlab 0xFFE004
sys_chan_read: .equlab 0xFFE008
sys_chan_readline: .equlab 0xFFE00C
sys_chan_write_b: .equlab 0xFFE010
sys_chan_write: .equlab 0xFFE014
sys_chan_status: .equlab 0xFFE018
sys_chan_flush: .equlab 0xFFE01C
sys_chan_seek: .equlab 0xFFE020
sys_chan_ioctrl: .equlab 0xFFE024
sys_chan_open: .equlab 0xFFE028
sys_chan_close: .equlab 0xFFE02C
sys_chan_swap: .equlab 0xFFE030
sys_chan_device: .equlab 0xFFE034
sys_bdev_register: .equlab 0xFFE038
sys_bdev_read: .equlab 0xFFE03C
sys_bdev_write: .equlab 0xFFE040
sys_bdev_status: .equlab 0xFFE044
sys_bdev_flush: .equlab 0xFFE048
sys_bdev_ioctrl: .equlab 0xFFE04C
sys_fsys_open: .equlab 0xFFE050
sys_fsys_close: .equlab 0xFFE054
sys_fsys_opendir: .equlab 0xFFE058
sys_fsys_closedir: .equlab 0xFFE05C
sys_fsys_readdir: .equlab 0xFFE060
sys_fsys_findfirst: .equlab 0xFFE064
sys_fsys_findnext: .equlab 0xFFE068
sys_fsys_mkdir: .equlab 0xFFE06C
sys_fsys_delete: .equlab 0xFFE070
sys_fsys_rename: .equlab 0xFFE074
sys_fsys_set_cwd: .equlab 0xFFE078
sys_fsys_get_cwd: .equlab 0xFFE07C
sys_fsys_load: .equlab 0xFFE080
sys_fsys_register_loader: .equlab 0xFFE084
sys_fsys_stat: .equlab 0xFFE088
sys_mem_get_ramtop: .equlab 0xFFE08C
sys_mem_reserve: .equlab 0xFFE090
sys_err_message: .equlab 0xFFE094
sys_proc_run: .equlab 0xFFE098
sys_txt_get_capabilities: .equlab 0xFFE09C
sys_txt_set_mode: .equlab 0xFFE0A0
sys_txt_setsizes: .equlab 0xFFE0A4
sys_txt_set_xy: .equlab 0xFFE0A8
sys_txt_get_xy: .equlab 0xFFE0AC
sys_txt_get_region: .equlab 0xFFE0B0
sys_txt_set_region: .equlab 0xFFE0B4
sys_txt_set_color: .equlab 0xFFE0B8
sys_txt_get_color: .equlab 0xFFE0BC
sys_txt_set_cursor_visible: .equlab 0xFFE0C0
sys_txt_set_font: .equlab 0xFFE0C4
sys_txt_get_sizes: .equlab 0xFFE0C8
sys_txt_set_border: .equlab 0xFFE0CC
sys_txt_set_border_color: .equlab 0xFFE0D0
sys_txt_put: .equlab 0xFFE0D4
sys_txt_print: .equlab 0xFFE0D8

38
client/src/genbinding.py Normal file
View file

@ -0,0 +1,38 @@
###
### Generate client bindings for the Toolbox
###
# with open("toolbox_bindings.s", "w") as output:
table_entry_size = 4
table_address = 0xffe000
syscalls = {}
with open("..\src\C256\syscalls.txt", "r") as input:
for line in input:
# Remove comments
index = line.find("#")
if index == 0:
line = ""
elif index > 0:
line = line[index - 1:]
line = line.strip()
if line != "":
name = "sys_{}".format(line)
syscalls[name] = table_address
table_address += table_entry_size
with open("bindings.s", "w") as output:
output.write(";;;\n;;; Bindings for the Foenix Toolbox public calls\n;;;\n\n")
for name in syscalls.keys():
output.write("\t.public {}\n".format(name))
output.write("\n")
for name in syscalls.keys():
address = syscalls[name]
output.write("{0}:\t.equlab\t0x{1:06X}\n".format(name, address))

View file

@ -0,0 +1,79 @@
/**
* @file constants.h
* @brief Define the major public-facing constants for the Foenix Toolbox
* @version 0.1
* @date 2024-09-02
*
* @copyright Copyright (c) 2024
*
*/
#ifndef __CONSTANTS_H
#define __CONSTANTS_H
/*
* Miscellaneous definitions
*/
#define FSYS_SECTOR_SZ 512 /* Size of a sector */
#define MAX_PATH_LEN 256 /* Maximum length of a file path */
/*
* Definitions of special characters
*/
#define CHAR_ESC '\x1B' /* Escape character */
#define CHAR_TAB '\t' /* Vertical tab */
#define CHAR_CR '\x0D' /* Carriage return */
#define CHAR_NL '\x0A' /* Linefeed */
#define CHAR_BS '\b' /* Backspace */
/*
* File access mode and open method flags
*/
#define FSYS_READ 0x01
#define FSYS_WRITE 0x02
#define FSYS_OPEN_EXISTING 0x00
#define FSYS_CREATE_NEW 0x04
#define FSYS_CREATE_ALWAYS 0x08
#define FSYS_OPEN_ALWAYS 0x10
#define FSYS_OPEN_APPEND 0x30
/*
* File attribute bits for directory entry
*/
#define FSYS_AM_RDO 0x01 /* Read only */
#define FSYS_AM_HID 0x02 /* Hidden */
#define FSYS_AM_SYS 0x04 /* System */
#define FSYS_AM_DIR 0x10 /* Directory */
#define FSYS_AM_ARC 0x20 /* Archive */
/*
* Block devices
*/
#define BDEV_SD0 0 /* External SDC */
#define BDEV_SD1 1 /* Internal SDC */
/*
* Channel devices
*/
#define CDEV_CONSOLE 0
#define CDEV_EVID 1
#define CDEV_COM1 2
#define CDEV_COM2 3
#define CDEV_LPT 4
#define CDEV_MIDI 5
#define CDEV_FILE 6
/*
* Block Device IOCRTRL commands
*/
#define IOCTRL_CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */
#define IOCTRL_GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */
#define IOCTRL_GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
#define IOCTRL_GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */
#endif

View file

@ -0,0 +1,60 @@
/**
* @file errors.h
* @brief Error codes returned by Foenix Toolbox calls
* @version 0.1
* @date 2024-09-02
*
* @copyright Copyright (c) 2024
*
*/
#ifndef __ERRORS_H
#define __ERRORS_H
// #define MAX_ERROR_NUMBER 16 // Largest (absolute value) of the error number
#define E_OK 0 // Success, no error
#define ERR_GENERAL -1 // A general error condition
#define DEV_ERR_BADDEV -2 // Device number is bad (too big or no device assigned)
#define DEV_TIMEOUT -3 // The block device function timed out
#define DEV_CANNOT_INIT -4 // The block device could not initilize
#define DEV_CANNOT_READ -5 // The device cannot complete the READ
#define DEV_CANNOT_WRITE -6 // The device cannot complete the WRITE
#define DEV_BOUNDS_ERR -7 // The buffer provided is not big enough
#define DEV_NOMEDIA -8 // There is no media present for that device
#define DEV_WRITEPROT -9 // The media is write protected
#define ERR_BADCHANNEL -10 // The channel number was bad
#define ERR_OUT_OF_HANDLES -11 // There are no available handles for channels files etc.
#define ERR_BAD_HANDLE -12 // The handle passed was not valid
#define ERR_BAD_EXTENSION -13 // The path to load did not have an extension that matched registered loaders
#define ERR_OUT_OF_MEMORY -14 // Unable to allocate more memory
#define ERR_BAD_BINARY -15 // Bad binary file format... i.e. binary format does not match expectations
#define ERR_NOT_EXECUTABLE -16 // Binary file format does not have a starting address
#define ERR_NOT_FOUND -17 // Resource not found
#define FSYS_ERR_DISK_ERR -18 /* (1) A hard error occurred in the low level disk I/O layer */
#define FSYS_ERR_INT_ERR -19 /* (2) Assertion failed */
#define FSYS_ERR_NOT_READY -20 /* (3) The physical drive cannot work */
#define FSYS_ERR_NO_FILE -21 /* (4) Could not find the file */
#define FSYS_ERR_NO_PATH -22 /* (5) Could not find the path */
#define FSYS_ERR_INVALID_NAME -23 /* (6) The path name format is invalid */
#define FSYS_ERR_DENIED -24 /* (7) Access denied due to prohibited access or directory full */
#define FSYS_ERR_EXIST -25 /* (8) Access denied due to prohibited access */
#define FSYS_ERR_INVALID_OBJECT -26 /* (9) The file/directory object is invalid */
#define FSYS_ERR_WRITE_PROTECTED -27 /* (10) The physical drive is write protected */
#define FSYS_ERR_INVALID_DRIVE -28 /* (11) The logical drive number is invalid */
#define FSYS_ERR_NOT_ENABLED -29 /* (12) The volume has no work area */
#define FSYS_ERR_NO_FILESYSTEM -30 /* (13) There is no valid FAT volume */
#define FSYS_ERR_MKFS_ABORTED -31 /* (14) The f_mkfs() aborted due to any problem */
#define FSYS_ERR_TIMEOUT -32 /* (15) Could not get a grant to access the volume within defined period */
#define FSYS_ERR_LOCKED -33 /* (16) The operation is rejected according to the file sharing policy */
#define FSYS_ERR_NOT_ENOUGH_CORE -34 /* (17) LFN working buffer could not be allocated */
#define FSYS_ERR_TOO_MANY_OPEN_FILES -35 /* (18) Number of open files > FF_FS_LOCK */
#define FSYS_ERR_INVALID_PARAMETER -36 /* (19) Given parameter is invalid */
#define ERR_NOT_SUPPORTED -37 /* Device does not support the file or operation */
#define ERR_BAD_ARGUMENT -38 /* An invalid argument was provided */
#define ERR_MEDIA_CHANGE -39 /* Removable media has changed */
#define ERR_NOT_READY -40 /* Media device is not ready */
#endif

View file

@ -0,0 +1,28 @@
/**
* @file sys_macros.h
* @brief Macros needed for the Foenix Toolbox
* @version 0.1
* @date 2024-09-02
*
* @copyright Copyright (c) 2024
*
*/
#ifndef _sys_macros_h_
#define _sys_macros_h_
/*
* Define the machine-specific system call function prefix
*/
#ifdef __CALYPSI_CORE_65816__
//
// System calls on the 65816 pass parameters primarily on stack using the Calypsi
// simple call convention and save/restore the direct page and data bank registers.
//
#define SYSTEMCALL __attribute__((simple_call)) __attribute__((saveds))
#else
#define SYSTEMCALL
#endif
#endif

View file

@ -0,0 +1,163 @@
/**
* @file sys_types.h
* @brief Public-facing ypes used by the Foenix Toolbox
* @version 0.1
* @date 2024-09-02
*
* @copyright Copyright (c) 2024
*
*/
#ifndef _sys_types_h_
#define _sys_types_h_
#include <stdbool.h>
#include <stdint.h>
#include "constants.h"
/**
* @struct s_extent
*
* An extent or size of a rectangular area
*/
typedef struct s_extent {
short width; /**< The width of the region */
short height; /**< The height of the region */
} t_extent, *p_extent;
/**
* @struct s_point
*
* A point on a plane
*/
typedef struct s_point {
short x; /**< The column of the point */
short y; /**< The row of the point */
} t_point, *p_point;
/**
* @struct s_rect
*
* A rectangle on the screen
*/
typedef struct s_rect {
t_point origin; /**< The upper-left corner of the rectangle */
t_extent size; /**< The size of the rectangle */
} t_rect, *p_rect;
//
// A color (BGR)
//
typedef struct s_color3 {
uint8_t blue;
uint8_t green;
uint8_t red;
} t_color3;
//
// A color entry for a color lookup table (BGRA)
//
typedef struct s_color4 {
uint8_t blue;
uint8_t green;
uint8_t red;
uint8_t alpha;
} t_color4;
/*
* Type declaration for an interrupt handler
*/
typedef void (*p_int_handler)();
/*
* Structure to describe the hardware
*/
typedef struct s_sys_info {
uint16_t mcp_version; /* Current version of the MCP kernel */
uint16_t mcp_rev; /* Current revision, or sub-version of the MCP kernel */
uint16_t mcp_build; /* Current vuild # of the MCP kernel */
uint16_t model; /* Code to say what model of machine this is */
uint16_t sub_model; /* 0x00 = PB, 0x01 = LB, 0x02 = CUBE */
const char * model_name; /* Human readable name of the model of the computer */
uint16_t cpu; /* Code to say which CPU is running */
const char * cpu_name; /* Human readable name for the CPU */
uint32_t cpu_clock_khz; /* Speed of the CPU clock in KHz */
unsigned long fpga_date; /* YYYYMMDD */
uint16_t fpga_model; /* FPGA model number */
uint16_t fpga_version; /* FPGA version */
uint16_t fpga_subver; /* FPGA sub-version */
uint32_t system_ram_size; /* The number of bytes of system RAM on the board */
bool has_floppy; /* TRUE if the board has a floppy drive installed */
bool has_hard_drive; /* TRUE if the board has a PATA device installed */
bool has_expansion_card; /* TRUE if an expansion card is installed on the device */
bool has_ethernet; /* TRUE if an ethernet port is present */
uint16_t screens; /* How many screens are on this computer */
} t_sys_info, *p_sys_info;
/*
* Structure defining a block device's functions
*/
typedef struct s_dev_block {
short number; // The number of the device (assigned by registration)
char * name; // The name of the device
void * data; // Device-specific data block
short (*init)(struct s_dev_block *); // Initialize the device
short (*read)(struct s_dev_block *, long lba, uint8_t * buffer, short size); // Read a block from the device
short (*write)(struct s_dev_block *, long lba, const uint8_t * buffer, short size); // Write a block to the device
short (*status)(struct s_dev_block *); // Get the status of the device
short (*flush)(struct s_dev_block *); // Ensure that any pending writes to the device have been completed
short (*ioctrl)(struct s_dev_block *, short command, unsigned char * buffer, short size); // Issue a control command to the device
} t_dev_block, *p_dev_block;
/*
* Type for directory information about a file
*/
typedef struct s_file_info {
long size;
unsigned short date;
unsigned short time;
unsigned char attributes;
char name[MAX_PATH_LEN];
} t_file_info, * p_file_info;
/*
* Pointer type for file loaders
*
* short loader(short chan, destination, start);
*/
typedef short (*p_file_loader)(short chan, long destination, long * start);
/*
* Type to describe the current time
*/
typedef struct s_time {
short year;
short month;
short day;
short hour;
short minute;
short second;
short is_pm;
short is_24hours;
} t_time, *p_time;
/*
* A description of a screen's capabilities
*/
typedef struct s_txt_capabilities {
short number; /**< The unique ID of the screen */
short supported_modes; /**< The display modes supported on this screen */
short font_size_count; /**< The number of supported font sizes */
p_extent font_sizes; /**< Pointer to a list of t_extent listing all supported font sizes */
short resolution_count; /**< The number of supported display resolutions */
p_extent resolutions; /**< Pointer to a list of t_extent listing all supported display resolutions (in pixels) */
} t_txt_capabilities, *p_txt_capabilities;
#endif

View file

@ -0,0 +1,818 @@
/**
* @file toolbox.h
* @brief Public-facing calls for the Foenix Toolbox
* @version 0.1
* @date 2024-09-02
*
* @copyright Copyright (c) 2024
*
*/
#ifndef __toolbox_h__
#define __toolbox_h__
#include <stdbool.h>
#include <stdint.h>
#include "constants.h"
#include "sys_macros.h"
#include "sys_types.h"
/*
* Quit the current user process
*
* NOTE: at the moment, this relaunches the CLI. In the future, this
* may cause execution to return to the program that started
* the user process.
*
* Inputs:
* result = the code to return to the kernel
*/
extern SYSTEMCALL void sys_exit(short result);
/*
* Enable all interrupts
*
* NOTE: this is actually provided in the low level assembly
*/
extern SYSTEMCALL void sys_int_enable_all();
/*
* Disable all interrupts
*
* NOTE: this is actually provided in the low level assembly
*/
extern SYSTEMCALL void sys_int_disable_all();
/*
* Disable an interrupt by masking it
*
* Inputs:
* n = the number of the interrupt: n[7..4] = group number, n[3..0] = individual number.
*/
extern SYSTEMCALL void sys_int_disable(unsigned short n);
/*
* Enable an interrupt
*
* Inputs:
* n = the number of the interrupt
*/
extern SYSTEMCALL void sys_int_enable(unsigned short n);
/*
* Register a handler for a given interrupt.
*
* Inputs:
* n = the number of the interrupt
* handler = pointer to the interrupt handler to register
*
* Returns:
* the pointer to the previous interrupt handler
*/
extern SYSTEMCALL p_int_handler sys_int_register(unsigned short n, p_int_handler handler);
/*
* Return true (non-zero) if an interrupt is pending for the given interrupt
*
* Inputs:
* n = the number of the interrupt: n[7..4] = group number, n[3..0] = individual number.
*
* Returns:
* non-zero if interrupt n is pending, 0 if not
*/
extern SYSTEMCALL short sys_int_pending(unsigned short n);
/*
* Fill out a s_sys_info structure with the information about the current system
*
* Inputs:
* info = pointer to a s_sys_info structure to fill out
*/
extern SYSTEMCALL void sys_get_info(p_sys_info info);
/*
* Acknowledge an interrupt (clear out its pending flag)
*
* Inputs:
* n = the number of the interrupt: n[7..4] = group number, n[3..0] = individual number.
*/
extern SYSTEMCALL void sys_int_clear(unsigned short n);
/***
*** Channel system calls
***/
/*
* Read a single byte from the channel
*
* Inputs:
* channel = the number of the channel
*
* Returns:
* the value read (if negative, error)
*/
extern SYSTEMCALL short sys_chan_read_b(short channel);
/*
* Read bytes from the channel
*
* Inputs:
* channel = the number of the channel
* buffer = the buffer into which to copy the channel data
* size = the size of the buffer.
*
* Returns:
* number of bytes read, any negative number is an error code
*/
extern SYSTEMCALL short sys_chan_read(short channel, unsigned char * buffer, short size);
/*
* Read a line of text from the channel
*
* Inputs:
* channel = the number of the channel
* buffer = the buffer into which to copy the channel data
* size = the size of the buffer
*
* Returns:
* number of bytes read, any negative number is an error code
*/
extern SYSTEMCALL short sys_chan_readline(short channel, unsigned char * buffer, short size);
/*
* Write a single byte to the device
*
* Inputs:
* channel = the number of the channel
* b = the byte to write
*
* Returns:
* 0 on success, a negative value on error
*/
extern SYSTEMCALL short sys_chan_write_b(short channel, uint8_t b);
/*
* Write a byte to the channel
*
* Inputs:
* channel = the number of the channel
* b = the byte to write
*
* Returns:
* number of bytes written, any negative number is an error code
*/
extern SYSTEMCALL short sys_chan_write(short channel, const uint8_t * buffer, short size);
/*
* Return the status of the channel device
*
* Inputs:
* channel = the number of the channel
*
* Returns:
* the status of the device
*/
extern SYSTEMCALL short sys_chan_status(short channel);
/*
* Ensure that any pending writes to teh device have been completed
*
* Inputs:
* channel = the number of the channel
*
* Returns:
* 0 on success, any negative number is an error code
*/
extern SYSTEMCALL short sys_chan_flush(short channel);
/*
* Attempt to set the position of the channel cursor (if supported)
*
* Inputs:
* channel = the number of the channel
* position = the position of the cursor
* base = whether the position is absolute or relative to the current position
*
* Returns:
* 0 = success, a negative number is an error.
*/
extern SYSTEMCALL short sys_chan_seek(short channel, long position, short base);
/*
* Issue a control command to the device
*
* Inputs:
* channel = the number of the channel
* command = the number of the command to send
* buffer = pointer to bytes of additional data for the command
* size = the size of the buffer
*
* Returns:
* 0 on success, any negative number is an error code
*/
extern SYSTEMCALL short sys_chan_ioctrl(short channel, short command, uint8_t * buffer, short size);
/*
* Open a channel
*
* Inputs:
* dev = the device number to have a channel opened
* path = a "path" describing how the device is to be open
* mode = is the device to be read, written, both? (0x01 = READ flag, 0x02 = WRITE flag, 0x03 = READ and WRITE)
*
* Returns:
* the number of the channel opened, negative number on error
*/
extern SYSTEMCALL short sys_chan_open(short dev, const char * path, short mode);
/*
* Close a channel
*
* Inputs:
* chan = the number of the channel to close
*
* Returns:
* nothing useful
*/
extern SYSTEMCALL short sys_chan_close(short chan);
/**
* Swap the channel ID assignments for two channels
*
* Before call: channel1 = "Channel A", channel2 = "Channel B"
* After call: channel1 = "Channel B", channel2 = "Channel A"
*
* @param channel1 the ID of one of the channels
* @param channel2 the ID of the other channel
* @return 0 on success, any other number is an error
*/
extern SYSTEMCALL short sys_chan_swap(short channel1, short channel2);
/**
* Return the device associated with the channel
*
* @param channel the ID of the channel to query
* @return the ID of the device associated with the channel, negative number for error
*/
extern SYSTEMCALL short sys_chan_device(short channel);
/*
* Compute the size information for the text screen based on the current settings in VICKY
* These settings are needed to correctly position text on the screen.
*
* Inputs:
* screen = the screen number 0 for channel A, 1 for channel B
*/
extern SYSTEMCALL void sys_text_setsizes(short chan);
/***
*** Block device system calls
***/
//
// Register a block device driver
//
extern SYSTEMCALL short sys_bdev_register(p_dev_block device);
//
// Read a block from the device
//
// Inputs:
// dev = the number of the device
// lba = the logical block address of the block to read
// buffer = the buffer into which to copy the block data
// size = the size of the buffer.
//
// Returns:
// number of bytes read, any negative number is an error code
//
extern SYSTEMCALL short sys_bdev_read(short dev, long lba, uint8_t * buffer, short size);
//
// Write a block from the device
//
// Inputs:
// dev = the number of the device
// lba = the logical block address of the block to write
// buffer = the buffer containing the data to write
// size = the size of the buffer.
//
// Returns:
// number of bytes written, any negative number is an error code
//
extern SYSTEMCALL short sys_bdev_write(short dev, long lba, const uint8_t * buffer, short size);
//
// Return the status of the block device
//
// Inputs:
// dev = the number of the device
//
// Returns:
// the status of the device
//
extern SYSTEMCALL short sys_bdev_status(short dev);
//
// Ensure that any pending writes to teh device have been completed
//
// Inputs:
// dev = the number of the device
//
// Returns:
// 0 on success, any negative number is an error code
//
extern SYSTEMCALL short sys_bdev_flush(short dev);
//
// Issue a control command to the device
//
// Inputs:
// dev = the number of the device
// command = the number of the command to send
// buffer = pointer to bytes of additional data for the command
// size = the size of the buffer
//
// Returns:
// 0 on success, any negative number is an error code
//
extern SYSTEMCALL short sys_bdev_ioctrl(short dev, short command, uint8_t * buffer, short size);
/*
* File System Calls
*/
/**
* Attempt to open a file given the path to the file and the mode.
*
* Inputs:
* path = the ASCIIZ string containing the path to the file.
* mode = the mode (e.g. r/w/create)
*
* Returns:
* the channel ID for the open file (negative if error)
*/
extern SYSTEMCALL short sys_fsys_open(const char * path, short mode);
/**
* Close access to a previously open file.
*
* Inputs:
* fd = the channel ID for the file
*
* Returns:
* 0 on success, negative number on failure
*/
extern SYSTEMCALL short sys_fsys_close(short fd);
/**
* Attempt to open a directory for scanning
*
* Inputs:
* path = the path to the directory to open
*
* Returns:
* the handle to the directory if >= 0. An error if < 0
*/
extern SYSTEMCALL short sys_fsys_opendir(const char * path);
/**
* Close access to a previously open file.
*
* Inputs:
* fd = the channel ID for the file
*
* Returns:
* 0 on success, negative number on failure
*/
extern SYSTEMCALL short sys_fsys_close(short fd);
/**
* Attempt to open a directory for scanning
*
* Inputs:
* path = the path to the directory to open
*
* Returns:
* the handle to the directory if >= 0. An error if < 0
*/
extern SYSTEMCALL short sys_fsys_opendir(const char * path);
/**
* Close a previously open directory
*
* Inputs:
* dir = the directory handle to close
*
* Returns:
* 0 on success, negative number on error
*/
extern SYSTEMCALL short sys_fsys_closedir(short dir);
/**
* Attempt to read an entry from an open directory
*
* Inputs:
* dir = the handle of the open directory
* file = pointer to the t_file_info structure to fill out.
*
* Returns:
* 0 on success, negative number on failure
*/
extern SYSTEMCALL short sys_fsys_readdir(short dir, p_file_info file);
/**
* Open a directory given the path and search for the first file matching the pattern.
*
* Inputs:
* path = the path to the directory to search
* pattern = the file name pattern to search for
* file = pointer to the t_file_info structure to fill out
*
* Returns:
* the directory handle to use for subsequent calls if >= 0, error if negative
*/
extern SYSTEMCALL short sys_fsys_findfirst(const char * path, const char * pattern, p_file_info file);
/**
* Open a directory given the path and search for the first file matching the pattern.
*
* Inputs:
* dir = the handle to the directory (returned by fsys_findfirst) to search
* file = pointer to the t_file_info structure to fill out
*
* Returns:
* 0 on success, error if negative
*/
extern SYSTEMCALL short sys_fsys_findnext(short dir, p_file_info file);
/*
* Get the label for the drive holding the path
*
* Inputs:
* path = path to the drive
* label = buffer that will hold the label... should be at least 35 bytes
*/
extern SYSTEMCALL short sys_fsys_get_label(const char * path, char * label);
/*
* Set the label for the drive holding the path
*
* Inputs:
* drive = drive number
* label = buffer that holds the label
*/
extern SYSTEMCALL short sys_fsys_set_label(short drive, const char * label);
/**
* Create a directory
*
* Inputs:
* path = the path of the directory to create.
*
* Returns:
* 0 on success, negative number on failure.
*/
extern SYSTEMCALL short sys_fsys_mkdir(const char * path);
/**
* Delete a file or directory
*
* Inputs:
* path = the path of the file or directory to delete.
*
* Returns:
* 0 on success, negative number on failure.
*/
extern SYSTEMCALL short sys_fsys_delete(const char * path);
/**
* Rename a file or directory
*
* Inputs:
* old_path = the current path to the file
* new_path = the new path for the file
*
* Returns:
* 0 on success, negative number on failure.
*/
extern SYSTEMCALL short sys_fsys_rename(const char * old_path, const char * new_path);
/**
* Change the current working directory (and drive)
*
* Inputs:
* path = the path that should be the new current
*
* Returns:
* 0 on success, negative number on failure.
*/
extern SYSTEMCALL short sys_fsys_set_cwd(const char * path);
/**
* Get the current working drive and directory
*
* Inputs:
* path = the buffer in which to store the directory
* size = the size of the buffer in bytes
*
* Returns:
* 0 on success, negative number on failure.
*/
extern SYSTEMCALL short sys_fsys_get_cwd(char * path, short size);
/*
* Load a file into memory at the designated destination address.
*
* If destination = 0, the file must be in a recognized binary format
* that specifies its own loading address.
*
* Inputs:
* path = the path to the file to load
* destination = the destination address (0 for use file's address)
* start = pointer to the long variable to fill with the starting address
* (0 if not an executable, any other number if file is executable
* with a known starting address)
*
* Returns:
* 0 on success, negative number on error
*/
extern SYSTEMCALL short sys_fsys_load(const char * path, uint32_t destination, uint32_t * start);
/*
* Register a file loading routine
*
* A file loader, takes a channel number to load from and returns a
* short that is the status of the load.
*
* Inputs:
* extension = the file extension to map to
* loader = pointer to the file load routine to add
*
* Returns:
* 0 on success, negative number on error
*/
extern SYSTEMCALL short sys_fsys_register_loader(const char * extension, p_file_loader loader);
/**
* Check to see if the file is present.
* If it is not, return a file not found error.
* If it is, populate the file info record
*
* @param path the path to the file to check
* @param file pointer to a file info record to fill in, if the file is found.
* @return 0 on success, negative number on error
*/
extern SYSTEMCALL short sys_fsys_stat(const char * path, p_file_info file);
/**
* Memory
*/
/**
* Return the top of system RAM... the user program must not use any
* system memory from this address and above.
*
* @return the address of the first byte of reserved system RAM (one above the last byte the user program can use)
*/
extern SYSTEMCALL uint32_t sys_mem_get_ramtop();
/**
* Reserve a block of memory at the top of system RAM.
*
* @param bytes the number of bytes to reserve
* @return address of the first byte of the reserved block
*/
extern SYSTEMCALL uint32_t sys_mem_reserve(uint32_t bytes);
/*
* Miscellaneous
*/
/*
* Get the number of jiffies since the system last booted.
*
* NOTE: a jiffie is 1/60 of a second. This timer will not be
* 100% precise, so it should be used for timeout purposes
* where precision is not critical.
*
* Returns:
* the number of jiffies since the last reset
*/
extern SYSTEMCALL uint32_t sys_time_jiffies();
/*
* Set the time on the RTC
*
* Inputs:
* time = pointer to a t_time record containing the correct time
*/
extern SYSTEMCALL void sys_rtc_set_time(p_time time);
/*
* Get the time on the RTC
*
* Inputs:
* time = pointer to a t_time record in which to put the current time
*/
extern SYSTEMCALL void sys_rtc_get_time(p_time time);
/*
* Return the next scan code from the keyboard... 0 if nothing pending
*/
extern SYSTEMCALL uint16_t sys_kbd_scancode();
/*
* Return an error message given an error number
*/
extern SYSTEMCALL const char * sys_err_message(short err_number);
/*
* Set the keyboard translation tables
*
* The translation tables provided to the keyboard consist of eight
* consecutive tables of 128 characters each. Each table maps from
* the MAKE scan code of a key to its appropriate 8-bit character code.
*
* The tables included must include, in order:
* - UNMODIFIED: Used when no modifier keys are pressed or active
* - SHIFT: Used when the SHIFT modifier is pressed
* - CTRL: Used when the CTRL modifier is pressed
* - CTRL-SHIFT: Used when both CTRL and SHIFT are pressed
* - CAPSLOCK: Used when CAPSLOCK is down but SHIFT is not pressed
* - CAPSLOCK-SHIFT: Used when CAPSLOCK is down and SHIFT is pressed
* - ALT: Used when only ALT is presse
* - ALT-SHIFT: Used when ALT is pressed and either CAPSLOCK is down
* or SHIFT is pressed (but not both)
*
* Inputs:
* tables = pointer to the keyboard translation tables
*/
extern SYSTEMCALL short sys_kbd_layout(const char * tables);
/**
* Load and execute an executable file
*
* @param path the path to the executable file
* @param argc the number of arguments passed
* @param argv the array of string arguments
* @return the return result of the program
*/
extern SYSTEMCALL short sys_proc_run(const char * path, int argc, char * argv[]);
//
// Text screen calls
//
/**
* Gets the description of a screen's capabilities
*
* @param screen the number of the text device
*
* @return a pointer to the read-only description (0 on error)
*/
extern SYSTEMCALL const p_txt_capabilities sys_txt_get_capabilities(short screen);
/**
* Set the display mode for the screen
*
* @param screen the number of the text device
* @param mode a bitfield of desired display mode options
*
* @return 0 on success, any other number means the mode is invalid for the screen
*/
extern SYSTEMCALL short sys_txt_set_mode(short screen, short mode);
/**
* Set the position of the cursor to (x, y) relative to the current region
* If the (x, y) coordinate is outside the region, it will be clipped to the region.
* If y is greater than the height of the region, the region will scroll until that relative
* position would be within view.
*
* @param screen the number of the text device
* @param x the column for the cursor
* @param y the row for the cursor
*/
extern SYSTEMCALL void sys_txt_set_xy(short screen, short x, short y);
/**
* Get the position of the cursor (x, y) relative to the current region
*
* @param screen the number of the text device
* @param position pointer to a t_point record to fill out
*/
extern SYSTEMCALL void sys_txt_get_xy(short screen, p_point position);
/**
* Get the current region.
*
* @param screen the number of the text device
* @param region pointer to a t_rect describing the rectangular region (using character cells for size and size)
*
* @return 0 on success, any other number means the region was invalid
*/
extern SYSTEMCALL short sys_txt_get_region(short screen, p_rect region);
/**
* Set a region to restrict further character display, scrolling, etc.
* Note that a region of zero size will reset the region to the full size of the screen.
*
* @param screen the number of the text device
* @param region pointer to a t_rect describing the rectangular region (using character cells for size and size)
*
* @return 0 on success, any other number means the region was invalid
*/
extern SYSTEMCALL short sys_txt_set_region(short screen, p_rect region);
/**
* Set the default foreground and background colors for printing
*
* @param screen the number of the text device
* @param foreground the Text LUT index of the new current foreground color (0 - 15)
* @param background the Text LUT index of the new current background color (0 - 15)
*/
extern SYSTEMCALL void sys_txt_set_color(short screen, unsigned char foreground, unsigned char background);
/*
* Get the foreground and background color for printing
*
* Inputs:
* screen = the screen number 0 for channel A, 1 for channel B
* foreground = pointer to the foreground color number
* background = pointer to the background color number
*/
extern SYSTEMCALL void sys_txt_get_color(short screen, unsigned char * foreground, unsigned char * background);
/**
* Set if the cursor is visible or not
*
* @param screen the screen number 0 for channel A, 1 for channel B
* @param is_visible TRUE if the cursor should be visible, FALSE (0) otherwise
*/
extern SYSTEMCALL void sys_txt_set_cursor_visible(short screen, short is_visible);
/**
* Load a font as the current font for the screen
*
* @param screen the number of the text device
* @param width width of a character in pixels
* @param height of a character in pixels
* @param data pointer to the raw font data to be loaded
*/
extern SYSTEMCALL short sys_txt_set_font(short screen, short width, short height, unsigned char * data);
/**
* Get the display resolutions
*
* @param screen the screen number 0 for channel A, 1 for channel B
* @param text_size the size of the screen in visible characters (may be null)
* @param pixel_size the size of the screen in pixels (may be null)
*/
extern SYSTEMCALL void sys_txt_get_sizes(short screen, p_extent text_size, p_extent pixel_size);
/**
* Set the size of the border of the screen (if supported)
*
* @param screen the number of the text device
* @param width the horizontal size of one side of the border (0 - 32 pixels)
* @param height the vertical size of one side of the border (0 - 32 pixels)
*/
extern SYSTEMCALL void sys_txt_set_border(short screen, short width, short height);
/**
* Set the size of the border of the screen (if supported)
*
* @param screen the number of the text device
* @param red the red component of the color (0 - 255)
* @param green the green component of the color (0 - 255)
* @param blue the blue component of the color (0 - 255)
*/
extern SYSTEMCALL void sys_txt_set_border_color(short screen, unsigned char red, unsigned char green, unsigned char blue);
/**
* Print a character to the current cursor position in the current color
*
* Most character codes will result in a glyph being displayed at the current
* cursor position, advancing the cursor one spot. There are some exceptions that
* will be treated as control codes:
*
* 0x08 - BS - Move the cursor back one position, erasing the character underneath
* 0x09 - HT - Move forward to the next TAB stop
* 0x0A - LF - Move the cursor down one line (line feed)
* 0x0D - CR - Move the cursor to column 0 (carriage return)
*
* @param screen the number of the text device
* @param c the character to print
*/
extern SYSTEMCALL void sys_txt_put(short screen, char c);
/**
* Print an ASCII Z string to the screen
*
* @param screen the number of the text device
* @param c the ASCII Z string to print
*/
extern SYSTEMCALL void sys_txt_print(short screen, const char * message);
#endif

224
client/src/stubs.c Normal file
View file

@ -0,0 +1,224 @@
/**
* @file stubs.c
* @brief Stubs for Calypsi I/O routines
* @version 0.1
* @date 2024-09-02
*
* @copyright Copyright (c) 2024
*
*/
#include "include/toolbox.h"
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdint.h>
#include <stubs.h>
#define MAX_FD 16
struct s_file_descriptor {
bool is_open;
int public_fd;
short toolbox_fd;
};
static bool is_inited = false;
static struct s_file_descriptor file_descriptor[MAX_FD];
static void init() {
if (!is_inited) {
is_inited = true;
// Define stdin
file_descriptor[0].is_open = true;
file_descriptor[0].public_fd = 0;
file_descriptor[0].toolbox_fd = 0;
// Define stdout
file_descriptor[1].is_open = true;
file_descriptor[1].public_fd = 0;
file_descriptor[1].toolbox_fd = 0;
// Define stderr
file_descriptor[2].is_open = true;
file_descriptor[2].public_fd = 0;
file_descriptor[2].toolbox_fd = 0;
for (int i = 3; i < MAX_FD; i++) {
file_descriptor[i].is_open = false;
file_descriptor[i].public_fd = 0;
file_descriptor[i].toolbox_fd = 0;
}
}
}
/**
* @brief Find a free file descriptor
*
* @return int the index of the available (closed) file descriptor (-1 for error)
*/
static int find_fd() {
for (int i = 3; i < MAX_FD; i++) {
if (!file_descriptor[i].is_open) {
// Found one that is closed... return it's public ID
return file_descriptor[i].public_fd;
}
}
// Return an error
return -1;
}
/****************************************************************************
* Name: _Stub_open
*
* Description:
* Open a file.
* The oflag argument are POSIX style mode flags, e.g O_RDONLY which
* are defined in fcntl.h.
* This function is variadic as it optionally can take a mode_t that
* are permissions, e.g 0666. If the file system does not handle
* permissions you can ignore that this function is variadic.
* The return file descriptor shall be a positive number, larger
* than 2 (as 0-2 are used for stdin, stdout and stderr).
* The actual number does not matter and they need not to be
* consequtive, multiple numeric series with gaps between can be used.
*
* Return the obtained file descriptor or EOF (-1) on failure and set
* errno according to the error.
*
****************************************************************************/
int _Stub_open(const char *path, int oflag, ...) {
int fd = find_fd();
if (fd >= 0) {
int mode = 0;
if ((oflag & O_RDONLY) == O_RDONLY) {
mode = FSYS_READ | FSYS_OPEN_EXISTING;
}
if ((oflag & O_WRONLY) == O_WRONLY) {
mode = FSYS_WRITE;
}
if ((oflag & O_RDWR) == O_RDWR) {
mode = FSYS_READ | FSYS_WRITE;
}
if ((oflag & O_CREAT) == O_CREAT) {
mode |= FSYS_CREATE_NEW | FSYS_CREATE_ALWAYS;
}
short toolbox_fd = sys_fsys_open(path, mode);
if (toolbox_fd >= 0) {
file_descriptor[fd].is_open = true;
file_descriptor[fd].toolbox_fd = toolbox_fd;
return fd;
} else {
return -1;
}
} else {
errno = ENFILE;
return -1;
}
}
/****************************************************************************
* Name: _Stub_close
*
* Description:
* Close a file
*
* Return 0 if operation was OK, EOF otherwise and set errno according to
* the error.
* Note: This will only be invoked for streams opened by _Stub_open(),
* there is no need to check for the standard descriptor 0-2.
*
****************************************************************************/
int _Stub_close(int fd) {
if (file_descriptor[fd].is_open) {
sys_fsys_close(file_descriptor[fd].toolbox_fd);
file_descriptor[fd].toolbox_fd = 0;
file_descriptor[fd].is_open = false;
}
return 0;
}
/****************************************************************************
* Name: _Stub_read
*
* Description:
* Read from a file
*
* Returns the number of characters read. Return -1 on failure and set
* errno according to the error.
*
****************************************************************************/
size_t _Stub_read(int fd, void *buf, size_t count) {
if (file_descriptor[fd].is_open) {
short n = sys_chan_read(file_descriptor[fd].toolbox_fd, (unsigned char *)buf, (short)count);
return n;
} else {
return -1;
}
}
/****************************************************************************
* Name: _Stub_write
*
* Description:
* Write to a file
*
* Returns the number of characters actually written. Return -1 on failure and
* set errno according to the error.
*
****************************************************************************/
size_t _Stub_write(int fd, const void *buf, size_t count) {
if (file_descriptor[fd].is_open) {
short n = sys_chan_write(file_descriptor[fd].toolbox_fd, (unsigned char *)buf, (short)count);
return n;
} else {
return -1;
}
}
/****************************************************************************
* Name: _Stub_rename
*
* Description:
* Rename a file or directory
*
* Return 0 on success, -1 otherwise and set errno according to the
* error.
*
****************************************************************************/
int _Stub_rename(const char *oldpath, const char *newpath) {
short result = sys_fsys_rename(oldpath, newpath);
return result;
}
/****************************************************************************
* Name: _Stub_remove
*
* Description:
* Remove a file or directory
*
* Return 0 on success, -1 otherwise and set errno according to the
* error.
*
****************************************************************************/
int _Stub_remove(const char *path) {
short result = sys_fsys_delete(path);
return result;
}

12
roms/f256jr/README.md Normal file
View file

@ -0,0 +1,12 @@
# ROM Files for the F256jr
This directory contains BIN files for programming the F256jr flash memory with the Foenix Toolbox.
## How to Install
Currently, the toolbox must be installed by bulk programming the flash memory.
Using the FoenixMgr Python script, this can be done with the following command (substitute the device path or name for your F256K's USB debug port):
```
python FoenixMgr.zip --port {debug device name} --flash-bulk toolbox.csv
```

BIN
roms/f256jr/toolbox-20.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-21.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-22.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-23.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-24.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-25.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-26.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-27.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-28.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-29.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-2A.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-2B.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-2C.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-2D.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-2E.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-2F.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-30.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-31.bin Normal file

Binary file not shown.

BIN
roms/f256jr/toolbox-3F.bin Normal file

Binary file not shown.

2182
roms/f256jr/toolbox.bin Normal file

File diff suppressed because one or more lines are too long

19
roms/f256jr/toolbox.csv Normal file
View file

@ -0,0 +1,19 @@
"20","toolbox-20.bin"
"21","toolbox-21.bin"
"22","toolbox-22.bin"
"23","toolbox-23.bin"
"24","toolbox-24.bin"
"25","toolbox-25.bin"
"26","toolbox-26.bin"
"27","toolbox-27.bin"
"28","toolbox-28.bin"
"29","toolbox-29.bin"
"2A","toolbox-2A.bin"
"2B","toolbox-2B.bin"
"2C","toolbox-2C.bin"
"2D","toolbox-2D.bin"
"2E","toolbox-2E.bin"
"2F","toolbox-2F.bin"
"30","toolbox-30.bin"
"31","toolbox-31.bin"
"3F","toolbox-3F.bin"
1 20 toolbox-20.bin
2 21 toolbox-21.bin
3 22 toolbox-22.bin
4 23 toolbox-23.bin
5 24 toolbox-24.bin
6 25 toolbox-25.bin
7 26 toolbox-26.bin
8 27 toolbox-27.bin
9 28 toolbox-28.bin
10 29 toolbox-29.bin
11 2A toolbox-2A.bin
12 2B toolbox-2B.bin
13 2C toolbox-2C.bin
14 2D toolbox-2D.bin
15 2E toolbox-2E.bin
16 2F toolbox-2F.bin
17 30 toolbox-30.bin
18 31 toolbox-31.bin
19 3F toolbox-3F.bin

Binary file not shown.

68
samples/hello/Makefile Normal file
View file

@ -0,0 +1,68 @@
# VPATH=.:../../module/Calypsi-remote-debug/src
DEBUGGER=../module/Calypsi-remote-debug/src
UNIT := F256K
MEMORY := RAM
# Define OS-dependent variables
ifeq ($(OS),Windows_NT)
RM = del /F/Q
else
RM = rm -f
endif
# Define model-specific variables, including tools, source files, compiler flags, etc.
ifeq ($(UNIT),F256K)
CPU=w65816
C_SRCS_DEBUGGER=$(DEBUGGER)/agent.c $(DEBUGGER)/c256-uart.c $(DEBUGGER)/low_level_WDC65816.s
SRCS_FOR_UNIT=
CFLAGS_FOR_UNIT=-DMODEL=17 -DCPU=255 --code-model large --data-model large --target f256
ifeq ($(MEMORY),ROM)
LDFLAGS_FOR_UNIT=clib-lc-ld.a --rtattr printf=medium --cstartup=f256 # C256/f256-flash.scm
else
LDFLAGS_FOR_UNIT=f256-plain.scm clib-lc-ld.a --rtattr printf=medium --cstartup=f256
endif
endif
ifeq ($(CPU),w65816)
CC=cc65816
AS=as65816
LD=ln65816
AR=nlib
endif
INCLUDES=-I. -I./include
CFLAGS=$(INCLUDES) $(CFLAGS_FOR_UNIT) -l # -l -D_CALYPSI_MCP_DEBUGGER
ASFLAGS=$(INCLUDES) --data-model large --code-model large
ifeq ($(MEMORY),ROM)
LDFLAGS=--rom-code $(LDFLAGS_FOR_UNIT) --list-file toolbox.map
else
LDFLAGS=$(LDFLAGS_FOR_UNIT) --list-file toolbox.map
endif
SRCS = hello.c header.s $(SRCS_FOR_UNIT) # $(C_SRCS_DEBUGGER)
OBJS = $(patsubst %.s,%.o,$(patsubst %.c,%.o,$(SRCS)))
OBJS4RM = $(subst /,\\,$(OBJS))
LIBS = ../../client/src/toolbox.a
.PHONY: clean
hello.s37: $(OBJS) $(LIBS)
$(LD) $(LDFLAGS) --output-format s37 -o $@ $^
# Build the object files from C
%.o: %.c
$(CC) $(CFLAGS) -o $@ $^
# Build the object files from assembly
%.o: %.s
$(AS) $(ASFLAGS) -o $@ $^
# Clean up after a build
clean:
$(RM) $(OBJS4RM) *.s37 *.o *.a *.lst

View file

@ -0,0 +1,19 @@
(define memories
'(
(memory LoMem
(address (#x0000 . #xbfff))
(type ANY))
(memory Vector (address (#xffe4 . #xffff)))
(memory Banks
(address (#x10000 . #x7ffff))
(type ANY)
(section (header #x10000)))
(memory DirectPage
(address (#x00c000 . #x00c0ff))
(section (registers ztiny)))
(block stack (size #x1000))
(block heap (size #x1000))
(base-address _DirectPageStart DirectPage 0)
(base-address _NearBaseAddress LoMem 0)
))

10
samples/hello/header.s Normal file
View file

@ -0,0 +1,10 @@
.extern __program_start
.section header
signature: .byte 0xf8, 0x16
version: .byte 0
start: .long __program_start
icon: .long 0
clut: .long 0
name: .asciz "hello"

10
samples/hello/hello.c Normal file
View file

@ -0,0 +1,10 @@
#include "../../client/src/include/toolbox.h"
#include <string.h>
int main(int c, char * argv[]) {
char * message = "Hello, Foenix Toolbox!\n";
sys_chan_write(0, (uint8_t *)message, strlen(message));
while (1) ;
}

72
samples/hello/hello.lst Normal file
View file

@ -0,0 +1,72 @@
###############################################################################
# #
# Calypsi ISO C compiler for 65816 version 5.5 #
# 03/Sep/2024 22:57:21 #
# Command line: -I. -I./include -DMODEL=17 -DCPU=255 --code-model large #
# --data-model large --target f256 -l -o hello.o hello.c #
# #
###############################################################################
\ 000000 .rtmodel version,"1"
\ 000000 .rtmodel codeModel,"large"
\ 000000 .rtmodel dataModel,"large"
\ 000000 .rtmodel core,"65816"
\ 000000 .rtmodel huge,"0"
\ 000000 .rtmodel target,"f256"
\ 000000 .extern _Dp
\ 000000 .extern _Vfp
\ 000000 .extern strlen
\ 000000 .extern sys_chan_write
0001 #include "../../client/src/include/toolbox.h"
0002
0003 #include <string.h>
0004
0005 int main(int c, char * argv[]) {
\ 000000 .section farcode,text
\ 000000 .public main
\ 000000 main:
\ 000000 d4.. pei dp:.tiny (_Dp+8)
\ 000002 d4.. pei dp:.tiny (_Dp+10)
0006 char * message = "Hello, Foenix Toolbox!\n";
\ 000004 a9.... lda ##.word0 `_StringLiteral_[72,101,108,108,111,44,32,70,111,101,110,105,120,32,84,111,111,108,98,111,120,33,10]`
\ 000007 85.. sta dp:.tiny (_Dp+8)
\ 000009 a9.... lda ##.word2 `_StringLiteral_[72,101,108,108,111,44,32,70,111,101,110,105,120,32,84,111,111,108,98,111,120,33,10]`
\ 00000c 85.. sta dp:.tiny (_Dp+10)
0007 sys_chan_write(0, (uint8_t *)message, strlen(message));
\ 00000e a5.. lda dp:.tiny (_Dp+8)
\ 000010 85.. sta dp:.tiny _Dp
\ 000012 a5.. lda dp:.tiny (_Dp+10)
\ 000014 85.. sta dp:.tiny (_Dp+2)
\ 000016 22...... jsl long:strlen
\ 00001a 48 pha
\ 00001b a5.. lda dp:.tiny (_Dp+10)
\ 00001d 48 pha
\ 00001e a5.. lda dp:.tiny (_Dp+8)
\ 000020 48 pha
\ 000021 a90000 lda ##0
\ 000024 22...... jsl long:sys_chan_write
0008
0009 while (1) ;
\ 000028 68 pla
\ 000029 68 pla
\ 00002a 68 pla
\ 00002b 80fe `?L4`: bra `?L4`
\ 000000 .section cfar,rodata
\ 000000 .pubweak `_StringLiteral_[72,101,108,108,111,44,32,70,111,101,110,105,120,32,84,111,111,108,98,111,120,33,10]`
\ 000000 `_StringLiteral_[72,101,108,108,111,44,32,70,111,101,110,105,120,32,84,111,111,108,98,111,120,33,10]`:
\ 000000 48656c6c .byte 72,101,108,108,111,44,32,70,111,101,110,105,120,32,84,111,111,108,98,111,120,33,10,0
\ 000004 6f2c2046
\ 000008 6f656e69
\ 00000c 7820546f
\ 000010 6f6c626f
\ 000014 78210a00
0010 }
##########################
# #
# Memory sizes (decimal) #
# #
##########################
Executable (Text): 45 bytes
Constant __far : 24 bytes

139
samples/hello/hello.s37 Normal file
View file

@ -0,0 +1,139 @@
S02700000000484452202D2047656E6572617465642062792043616C79707369206C6E36353831360A
S31E0000000018FBC238A259209AA900C05BA900006412EB48ABAB221102017D
S31D00000019A902008506A909008504A902008502A90000850022230701AB
S32300000031A900008506A95A008504A901008502A98F008500A20000A90010225B0A011A
S3100000004FA9000022BA02015C31050185
S3070000FFFC0000FD
S31A00010000F8160000000000000000000000000068656C6C6F00C2
S31D0001001548656C6C6F2C20466F656E697820546F6F6C626F78210A00F1
S30600010210DB0B
S306000102116B7A
S30A00010212221002016B40
S30E00010217A602A5002270E0FF6BAE
S31000010220B704850A8888B70485086BBF
S3130001022BA8E220A50A48C220A5083A48986B09
S31400010239A40C8400A40E840218A500690A006BA8
S31800010248A50648A50448A602A5002274E0FFAA68688A6B87
S31B0001025B7A100EA90000AA38E500A88AE502AA986BA500A6026B00
S31B00010271A01000B70C85028888B70C850038A500A00600F70C6B2D
S31E00010287A5008504A5028506A70429FF00D00638A504E5006BE60480EFC4
S31F000102A0AAA90200860038E500500349008010068A223906016BA900006BA8
S325000102BAD408D40AA915008508A90100850AA5088500A50A85022287020148A50A48A508DF
S312000102DA48A900002214E0FF68686880FE54
S325000102E7AF290101C92000B020AF2901010A0AAAA5009F2B0101A5029F2D0101AF29010105
S312000103071A8F290101A900006BA901006BE5
S32500010314D406A40485046406A9000048488A4A900FAA18A30165048301A303650683038A2D
S31500010334F0060604260680E668FA84047A84066BC7
S325000103445A5AAAA900008301E000809005A90B00801D8A4A4A4A4AA8A301A201008400E4B8
S3170001036400B00C1A8301984A8303A8A30180EB7A7A6BA8
S32500010376A5000502D010A9AB018500A90100850222AB06018007A90100226F0B01AA8600F7
S31D00010396A5001010860038A90000E5008F0E0201A9FFFF6BA900006B71
S325000103AED408D40A5A5A5A8301A5008508A502850AA5048305A3058303A3053A8305A90002
S325000103CE00C303B016A5088504A50A8506E608E220A3018704C220A30580DAA602A5007A42
S30E000103EE7A7A7A840A7A84086B92
S325000103F75A8301A301A2060022140301AABF2D0001F035A50448A50248A50048A92D008597
S3250001041700A901008502A307A2060022140301850418A50065048500A00400B7002208E068
S31200010437FFAA6868688A8003A9FFFF7A6B37
S325000104445A8301A301A2060022140301AABF2D0001F035A50448A50248A50048A92D008549
S3250001046400A901008502A307A2060022140301850418A50065048500A00400B7002214E00F
S31200010484FFAA6868688A8003A9FFFF7A6BEA
S32500010491D408D40AD40CD40E5A8301A5008508A502850AA301A301A83AAA640CA50C840CFD
S325000104B1C50CB019A508850CA50A850EE608A704E604E220870CC2208A830180D8A602A55D
S314000104D1007A7A840E7A840C7A840A7A84086B0C
S325000104E0A901008F0702018FDC01011A8FEE01018FC301018FD50101A9F1018FAB0101A972
S3250001050001008FAD0101A9D8018FAF0101A901008FB10101A9BF018FB30101A901008FB54C
S316000105200101A9DD058F0A0201A901008F0C02016BE7
S32500010531D408D40A5A5A8301AF0A02010F0C0201F010AF0C0201850AAF0A02018508222BF4
S325000105510201AF2901013A8303A303100FA301221202017A7A7A840A7A84086B0A0AAABF5C
S31B000105712D0101850ABF2B01018508222B0201A3033A830380D32D
S325000105875AA903008301A3018301A30138E9100050034900803005A9FFFF8031A301A206D1
S325000105A70022140301AABF2D0001D023A92D008500A901008502A301A206002214030185D2
S31B000105C70418A50065048500A00200B7007A6BA3011A830180B4B4
S325000105DDD408D40AA900008500850222760301AFB90101850AAFB701018508A508050AD072
S325000105FD1FAFF5010122A00201AFDC010122A00201AFC3010122A002017A840A7A84086B49
S3210001061DA00400B70822390601A00200B7088502A70885008508A502850A80BFD7
S325000106395A8301A301A2060022140301AABF2D0001F05AA92D008500A901008502A301A283
S32500010659060022140301850418A50065048500A00400B7002254E0FFA22D008600A201005E
S325000106798602A301A2060022140301850418A50065048500A90000A004009700A301A206E8
S317000106990022140301AAA900009F2D0001A900007A6B60
S325000106ABD408D40A5A5AA900008301A5000502F05CA00E00B700850A8888B7008508A301A9
S325000106CB8303A508050AD004A3038043A90200A016003708F01AA5088500A50A85022276DF
S325000106EB03018301A3013004A3038301A3018004A3038301A00200B7088502A7088500A34D
S31D0001070B018303A5008508A502850A80B5A3017A7A7A840A7A84086B9A
S32500010723D408D40AD40CD40EA5048508A506850AA500850CA502850EA50C8500A50E8502E3
S32500010743A500C508A502E50AB04CA00400B70CC8C8170CF01FB70C85068888B70C85048830
S3250001076388B70C8502A70C8500A00800B70C229104018018C8C8B70C8504A00200B70C85E4
S3250001078302A70C8500A9000022AE030118A50C690A00850C80A27A840E7A840C7A840A7A11
S308000107A384086B55
S325000107A6D408D40AD40CD40E5AA500850CA502850EA5048508A506850AA70822440301A8B5
S325000107C6980A0A8301AAA3010A83018A1863018301A60EA50C18690A0018630186028500FD
S325000107E6980A0A8301AAA3010A83018A186301830118A50C690A00850C18A50C6301850CCB
S32500010806A00600B70C85068888B70C8504A5040506F02BA704F027A704AAA708850CE40C65
S32500010826B01CA5048500A5068502C8C8B704850E8888B704850C8504A50E850680CFA50882
S325000108469700A50AC8C89700A500C8C89708A502C8C89708A504A004009708A506C8C897B6
S3250001086608A5040506F00CA508C8C89704A50AC8C897047A7A840E7A840C7A840A7A840863
S306000108866BFF
S32500010887D408D40AD40CD40E5AA8A506AAA50418690F009001E8860A8508A50A29FFFFAA28
S325000108A7A50829F0FF860A850898A20000186504488A6506AA6886068504A50629FFFFAAAD
S325000108C7A50429F0FF860E850CA50C38E50883011867008700A60AA508A0020097008AC8DC
S325000108E7C89700B70085068888B7008504A904008704A8B70085068888B7008504A900805E
S325000109079704A60AA508186904009001E886068504A30138E908008704A904009704A60E6A
S32500010927A50C38E90400B001CAA0060097008AC8C89700B700850A8888B7008508A9040023
S325000109478708A90080070448C8C8B700850A8888B700850868A00200970822A60701A90131
S30B00010967007A5CC40A01DE
S3250001096DD408D40A5A5A5A8303A5008508A502850A228705018305A30510034C470AA90075
S3250001098D008301A901002303C90100D00BA901008301A30183018004A3018301A90200237A
S325000109AD03C90200D00BA902008301A30183018004A3018301A903002303C90300D00BA955
S325000109CD03008301A30183018004A3018301A904002303C90400D00DA90C0003018301A34B
S325000109ED0183018004A3018301A30148A60AA5082250E0FFAA688A8301A3013038A305A2A2
S32500010A0D060022140301AAA901009F2D0001A22D008600A201008602A305A2060022140358
S32500010A2D01850418A50065048500A301A004009700A305800FA9FFFF800AA917008F0E02C7
S31300010A4D01A9FFFF7A7A7A7A840A7A84086B05
S32500010A5BD408D40AD40CD40EA83B38E90A001B988301A500850CA502850EA5048508A50662
S32500010A7B850AA90000870CA290008604A50C8500A50E8502224102018500A9000022AE03F6
S32500010A9B01A901008309A309C90C009029A5088504A50A8506A50C8500A50E8502A301221D
S32500010ABB8708013B18690A001B7A840E7A840C7A840A7A84086B3A0A0A83058303A3050A06
S32500010ADB83051863038303A3090A0A83078305A3070A83071863058305A60EA50C18690A60
S32500010AFB00186305DA4822390201850018A5006307850068FAA0040097008AC8C89700A3B2
S32500010B1B090A0A83058303A3050A83051863038303A3093A0A0A8305AAA3050A83058A1842
S32500010B3B63058305A60EA50C18690A00186305DA4822390201850018A5006307850068FA20
S31900010B5BA0080097008AC8C89700A3091A8303A3034C9F0AA8
S32500010B6FD408D40AD40CD40E5A5A8301A500850CA502850EA00400B70C850010034CB80C2C
S32500010B8FA90200A01600370CD0034CB80CA00600B70CC8C8170CD006A900004CBB0CA00E5C
S32500010BAF00B70CA00600D70CD00FA01000B70CA00800D70CD0034CAD0CA01200B70CA00603
S32500010BCF00D70CF0034CB30CA01400B70CA00800D70CF0034CB30C22710201AAC8C8B70C8B
S32500010BEF85028888B70C85008508A502850A8A8303A3038504A5088500A50A8502A00400F2
S32500010C0FB70C22440401AAE0FFFFD013A01800E220A902170C970CC220A9FFFF4CBB0CA5B9
S32500010C2F088500A50A8502860418A50065048500A303860438E504AAA301F015A5008508D0
S32500010C4FA502850A8A83036404A5048604C50490A0A00600B70CA00E00970CA00800B70C7F
S32500010C6FA01000970CE8CAF035B70C85068888B70C8504C8C8B70C850A8888B70C8508E662
S32500010C8F08A508970CA50AC8C8970CA700E600E2208704C2208A3A8301A301AA80C7227198
S32000010CAF02018008A900008003A9F7FF7A7A7A840E7A840C7A840A7A84086B4A
S32500010CCAD408D40AD40CD40E5A5A5A5AA5008305A5028307A98F008301A901008303A3052D
S32500010CEA0307D0034C190EA307AAA30538E9040086028500A9FF7FA0020037009700A50029
S32500010D0A8504A502850618A50467008504B70485083066A5048508A506850A18A5086704D8
S32500010D2A8508A00A00B704850E8888B704850CA00400B704970CC8C8B704970C8888B70406
S32500010D4AC8C81704F017B704850E8888B704850CA00800B704970CC8C8B704970CA704186F
S32500010D6A67008700A90080A00200370807009708A60AA50883058A8006A5048305A5068370
S32500010D8A07A5008504A502850638A504F7008504B7048508305DA00A0022200201A0040012
S32500010DAAB7049708C8C8B70497088888B704C8C81704F01122200201A00800B7049708C858
S32500010DCAC8B7049708A7001867048704A3078502A3058500A90080A002003700070448A3D5
S32500010DEA098502A3078500689700A606A50483058A8006A5008305A5028307A3078506A301
S32500010E0A058504A3038502A301850022A607017A7A7A7A7A840E7A840C7A840A7A84086B96
S32500010E2AD408D40AD40CD40E3B38E90E001BA5008508A502850AA9000083018303A21600CD
S32500010E4AA888A508050AD0034CBA0F981A83051A1A9B3708F018A5088500A50A850222765D
S32500010E6A0301AAAF0E02018305830B8A80058A830BA305830DAFAB0101C508D008AFAD0120
S32500010E8A01C50AF020AFAF0101C508D008AFB10101C50AF010AFB30101C508D013AFB501B2
S32500010EAA01C50AD00BA30B8305A30D83014CC20FA9AB018500A901008502A00E00B70085FA
S32500010ECA068888B7008504A303A5040506F065A508C504F0034C980FA50AC506F0034C984F
S32500010EEA0FA00C00B700C504D01AC8C8B700C506D012A70488889700A00200B704A00E006B
S32500010F0A97008013A303850EA301850CA704870CA00200B704970CA01000B700C504D014D6
S32500010F2AC8C8B700C506D00CA30188889700A303C8C89700A00400B70822A002018301A34B
S32500010F4A0DD00CA301AAAF0E020183058A8006A30B8305A30D8301A00600B708C8C8170873
S32500010F6AF01C98A01800370829FF00D011A00800B70885028888B708850022CA0C01A508D4
S32500010F8A8500A50A850222CA0C01A3018028A5048301A5068303A00200B704850EA70485C2
S32500010FAA0C8307A50E83098506A30785044CD30E8A8305988301A301A301F00BA3058F0EAA
S32400010FCA0201A9FFFF8003A90000A83B18690E001B987A840E7A840C7A840A7A84086B77
S30F000200002D00010000000000E301DC
S503008874
S70500000000FA

View file

@ -40,19 +40,19 @@ else ifeq ($(UNIT),C256_FMX)
else ifeq ($(UNIT),F256)
CPU=w65816
C_SRCS_DEBUGGER=$(DEBUGGER)/agent.c $(DEBUGGER)/c256-uart.c $(DEBUGGER)/low_level_WDC65816.s
SRCS_FOR_UNIT=C256/jumptable.s C256/io_stubs.c C256/extras.s C256/iecll.s
CFLAGS_FOR_UNIT=-DMODEL=2 -DCPU=255 --code-model large --data-model large
SRCS_FOR_UNIT=cartridge.c C256/jumptable.s C256/io_stubs.c C256/extras.s C256/iecll.s C256/interrupts.s C256/f256-cstartup.s
CFLAGS_FOR_UNIT=-DMODEL=2 -DCPU=255 --code-model large --data-model large --target f256
ifeq ($(MEMORY),ROM)
LDFLAGS_FOR_UNIT=C256/f256-flash.scm clib-lc-ld.a --rtattr printf=medium
LDFLAGS_FOR_UNIT=C256/f256-flash.scm clib-lc-ld.a --rtattr printf=medium --cstartup=f256
else
LDFLAGS_FOR_UNIT=C256/f256-ld_lc.scm clib-lc-ld.a --rtattr printf=medium
LDFLAGS_FOR_UNIT=C256/f256-ld_lc.scm clib-lc-ld.a --rtattr printf=medium --cstartup=f256
endif
else ifeq ($(UNIT),F256K)
CPU=w65816
C_SRCS_DEBUGGER=$(DEBUGGER)/agent.c $(DEBUGGER)/c256-uart.c $(DEBUGGER)/low_level_WDC65816.s
SRCS_FOR_UNIT=cartridge.c C256/jumptable.s C256/io_stubs.c C256/extras.s C256/iecll.s C256/interrupts.s C256/f256-cstartup.s
CFLAGS_FOR_UNIT=-DMODEL=17 -DCPU=255 --code-model large --data-model large
CFLAGS_FOR_UNIT=-DMODEL=17 -DCPU=255 --code-model large --data-model large --target f256
ifeq ($(MEMORY),ROM)
LDFLAGS_FOR_UNIT=C256/f256-flash.scm clib-lc-ld.a --rtattr printf=medium --cstartup=f256
@ -92,13 +92,13 @@ toolbox.raw: $(OBJS) $(LIBS)
$(LD) $(LDFLAGS) --raw-multiple-memories --output-format raw -o $@ $^
dev/devices.a:
$(MAKE) --directory=dev
$(MAKE) UNIT=$(UNIT) --directory=dev
snd/sound.a:
$(MAKE) --directory=snd
$(MAKE) UNIT=$(UNIT) --directory=snd
fatfs/fatfs.a:
$(MAKE) --directory=fatfs
$(MAKE) UNIT=$(UNIT) --directory=fatfs
# Build the object files from C
%.o: %.c

View file

@ -16,7 +16,7 @@
#include "dev/fsys.h"
#include "dev/channel.h"
#include "dev/console.h"
#include "dev/kbd_f256k.h"
#include "dev/kbd_f256.h"
#include "dev/txt_screen.h"
#include "dev/sprites.h"
#include "dev/tiles.h"
@ -501,6 +501,7 @@ void boot_screen() {
jiffies_target = timers_jiffies() + 60 * 15;
while (jiffies_target > timers_jiffies()) {
// kbd_handle_irq();
unsigned short scancode = kbd_get_scancode();
if (scancode > 0) {
short selected = sc_to_function(scancode);

View file

@ -38,14 +38,14 @@ else ifeq ($(UNIT),F256)
AR=nlib
SRCS_FOR_UNIT=txt_f256.c kbd_f256.c kbd_f256jr.c indicators_c256.c interrupts_f256.c sdc_f256.c iec.c # timers_c256.c
CFLAGS_FOR_UNIT=-DMODEL=2 -DCPU=255 --code-model large --data-model large # --target Foenix
CFLAGS_FOR_UNIT=-DMODEL=2 -DCPU=255 --code-model large --data-model large --target f256
else ifeq ($(UNIT),F256K)
CC=cc65816
AS=as65816
AR=nlib
SRCS_FOR_UNIT=txt_f256.c kbd_f256.c kbd_f256k.c indicators_c256.c interrupts_f256.c sdc_f256.c iec.c # timers_c256.c
CFLAGS_FOR_UNIT=-DMODEL=2 -DCPU=255 --code-model large --data-model large --target f256
CFLAGS_FOR_UNIT=-DMODEL=17 -DCPU=255 --code-model large --data-model large --target f256
endif
INCLUDES=-I.. -I../include

View file

@ -29,7 +29,17 @@ else ifeq ($(UNIT),C256_FMX)
else ifeq ($(UNIT),F256)
CPU=w65816
SRCS_FOR_UNIT=toolbox_bdev.c
CFLAGS_FOR_UNIT=-DMODEL=0 -DCPU=255 --code-model large --data-model large
CFLAGS_FOR_UNIT=-DMODEL=2 -DCPU=255 --code-model large --data-model large --target f256
ifeq ($(MEMORY),ROM)
LDFLAGS_FOR_UNIT=C256/flash-f256.scm clib-lc-ld.a --rtattr printf=medium
else
LDFLAGS_FOR_UNIT=C256/ld_lc_f256.scm clib-lc-ld.a --rtattr printf=medium
endif
else ifeq ($(UNIT),F256K)
CPU=w65816
SRCS_FOR_UNIT=toolbox_bdev.c
CFLAGS_FOR_UNIT=-DMODEL=17 -DCPU=255 --code-model large --data-model large --target f256
ifeq ($(MEMORY),ROM)
LDFLAGS_FOR_UNIT=C256/flash-f256.scm clib-lc-ld.a --rtattr printf=medium

View file

@ -38,7 +38,14 @@ else ifeq ($(UNIT),F256)
AR=nlib
SRCS_FOR_UNIT=psg.c codec_c256.c sid.c
CFLAGS_FOR_UNIT=-DMODEL=2 -DCPU=255 --code-model large --data-model large
CFLAGS_FOR_UNIT=-DMODEL=2 -DCPU=255 --code-model large --data-model large --target f256
else ifeq ($(UNIT),F256K)
CC=cc65816
AS=as65816
AR=nlib
SRCS_FOR_UNIT=psg.c codec_c256.c sid.c
CFLAGS_FOR_UNIT=-DMODEL=17 -DCPU=255 --code-model large --data-model large --target f256
endif
INCLUDES=-I.. -I../include

View file

@ -1,17 +1,19 @@
"00","toolbox-00.bin"
"01","toolbox-01.bin"
"02","toolbox-02.bin"
"03","toolbox-03.bin"
"04","toolbox-04.bin"
"05","toolbox-05.bin"
"06","toolbox-06.bin"
"07","toolbox-07.bin"
"08","toolbox-08.bin"
"09","toolbox-09.bin"
"0A","toolbox-0A.bin"
"0B","toolbox-0B.bin"
"0C","toolbox-0C.bin"
"0D","toolbox-0D.bin"
"0E","toolbox-0E.bin"
"0F","toolbox-0F.bin"
"20","toolbox-20.bin"
"21","toolbox-21.bin"
"22","toolbox-22.bin"
"23","toolbox-23.bin"
"24","toolbox-24.bin"
"25","toolbox-25.bin"
"26","toolbox-26.bin"
"27","toolbox-27.bin"
"28","toolbox-28.bin"
"29","toolbox-29.bin"
"2A","toolbox-2A.bin"
"2B","toolbox-2B.bin"
"2C","toolbox-2C.bin"
"2D","toolbox-2D.bin"
"2E","toolbox-2E.bin"
"2F","toolbox-2F.bin"
"30","toolbox-30.bin"
"31","toolbox-31.bin"
"3F","toolbox-3F.bin"

1 00 20 toolbox-00.bin toolbox-20.bin
2 01 21 toolbox-01.bin toolbox-21.bin
3 02 22 toolbox-02.bin toolbox-22.bin
4 03 23 toolbox-03.bin toolbox-23.bin
5 04 24 toolbox-04.bin toolbox-24.bin
6 05 25 toolbox-05.bin toolbox-25.bin
7 06 26 toolbox-06.bin toolbox-26.bin
8 07 27 toolbox-07.bin toolbox-27.bin
9 08 28 toolbox-08.bin toolbox-28.bin
10 09 29 toolbox-09.bin toolbox-29.bin
11 0A 2A toolbox-0A.bin toolbox-2A.bin
12 0B 2B toolbox-0B.bin toolbox-2B.bin
13 0C 2C toolbox-0C.bin toolbox-2C.bin
14 0D 2D toolbox-0D.bin toolbox-2D.bin
15 0E 2E toolbox-0E.bin toolbox-2E.bin
16 0F 2F toolbox-0F.bin toolbox-2F.bin
17 30 toolbox-30.bin
18 31 toolbox-31.bin
19 3F 3F toolbox-3F.bin toolbox-3F.bin

View file

@ -7,6 +7,6 @@
#define VER_MAJOR 1
#define VER_MINOR 0
#define VER_BUILD 12
#define VER_BUILD 15
#endif