summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/avr/ffconf.h289
-rw-r--r--include/background.h17
-rw-r--r--include/bcd.h13
-rw-r--r--include/cli.h83
-rw-r--r--include/cli_readline.h34
-rw-r--r--include/cmd_attach.h14
-rw-r--r--include/cmd_boot.h22
-rw-r--r--include/cmd_cpu.h16
-rw-r--r--include/cmd_date.h14
-rw-r--r--include/cmd_fat.h20
-rw-r--r--include/cmd_gpio.h15
-rw-r--r--include/cmd_loadcpm3.h14
-rw-r--r--include/cmd_loadihex.h14
-rw-r--r--include/cmd_mem.h29
-rw-r--r--include/cmd_misc.h16
-rw-r--r--include/cmd_run.h17
-rw-r--r--include/cmd_sd.h16
-rw-r--r--include/command.h185
-rw-r--r--include/common.h105
-rw-r--r--include/con-utils.h30
-rw-r--r--include/config.h87
-rw-r--r--include/crc.h21
-rw-r--r--include/debug.h57
-rw-r--r--include/diskio.h88
-rw-r--r--include/env.h27
-rw-r--r--include/errnum.h30
-rw-r--r--include/eval_arg.h19
l---------include/ff.h1
-rw-r--r--include/ffconf.h5
-rw-r--r--include/getopt-min.h12
-rw-r--r--include/gpio.h22
-rw-r--r--include/i2c.h65
-rw-r--r--include/integer.h38
-rw-r--r--include/print-utils.h24
-rw-r--r--include/ring.h79
-rw-r--r--include/rtc.h13
-rw-r--r--include/serial.h15
-rw-r--r--include/spi.h54
-rw-r--r--include/strerror.h14
-rw-r--r--include/timer.h16
-rw-r--r--include/z180-serv.h46
-rw-r--r--include/z80-if.h67
42 files changed, 1763 insertions, 0 deletions
diff --git a/include/avr/ffconf.h b/include/avr/ffconf.h
new file mode 100644
index 0000000..b6485be
--- /dev/null
+++ b/include/avr/ffconf.h
@@ -0,0 +1,289 @@
+/*---------------------------------------------------------------------------/
+/ FatFs - Configuration file
+/---------------------------------------------------------------------------*/
+
+#define FFCONF_DEF 63463 /* Revision ID */
+
+/*---------------------------------------------------------------------------/
+/ Function Configurations
+/---------------------------------------------------------------------------*/
+
+#define FF_FS_READONLY 0
+/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
+/ Read-only configuration removes writing API functions, f_write(), f_sync(),
+/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
+/ and optional writing functions as well. */
+
+
+#define FF_FS_MINIMIZE 0
+/* This option defines minimization level to remove some basic API functions.
+/
+/ 0: Basic functions are fully enabled.
+/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()
+/ are removed.
+/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
+/ 3: f_lseek() function is removed in addition to 2. */
+
+
+#define FF_USE_STRFUNC 2
+/* This option switches string functions, f_gets(), f_putc(), f_puts() and f_printf().
+/
+/ 0: Disable string functions.
+/ 1: Enable without LF-CRLF conversion.
+/ 2: Enable with LF-CRLF conversion. */
+
+
+#define FF_USE_FIND 0
+/* This option switches filtered directory read functions, f_findfirst() and
+/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
+
+
+#define FF_USE_MKFS 0
+/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
+
+
+#define FF_USE_FASTSEEK 0
+/* This option switches fast seek function. (0:Disable or 1:Enable) */
+
+
+#define FF_USE_EXPAND 0
+/* This option switches f_expand function. (0:Disable or 1:Enable) */
+
+
+#define FF_USE_CHMOD 0
+/* This option switches attribute manipulation functions, f_chmod() and f_utime().
+/ (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */
+
+
+#define FF_USE_LABEL 1
+/* This option switches volume label functions, f_getlabel() and f_setlabel().
+/ (0:Disable or 1:Enable) */
+
+
+#define FF_USE_FORWARD 0
+/* This option switches f_forward() function. (0:Disable or 1:Enable) */
+
+
+/*---------------------------------------------------------------------------/
+/ Locale and Namespace Configurations
+/---------------------------------------------------------------------------*/
+
+#define FF_CODE_PAGE 850
+/* This option specifies the OEM code page to be used on the target system.
+/ Incorrect code page setting can cause a file open failure.
+/
+/ 437 - U.S.
+/ 720 - Arabic
+/ 737 - Greek
+/ 771 - KBL
+/ 775 - Baltic
+/ 850 - Latin 1
+/ 852 - Latin 2
+/ 855 - Cyrillic
+/ 857 - Turkish
+/ 860 - Portuguese
+/ 861 - Icelandic
+/ 862 - Hebrew
+/ 863 - Canadian French
+/ 864 - Arabic
+/ 865 - Nordic
+/ 866 - Russian
+/ 869 - Greek 2
+/ 932 - Japanese (DBCS)
+/ 936 - Simplified Chinese (DBCS)
+/ 949 - Korean (DBCS)
+/ 950 - Traditional Chinese (DBCS)
+/ 0 - Include all code pages above and configured by f_setcp()
+*/
+
+
+#define FF_USE_LFN 1
+#define FF_MAX_LFN 128
+/* The FF_USE_LFN switches the support for LFN (long file name).
+/
+/ 0: Disable LFN. FF_MAX_LFN has no effect.
+/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
+/ 2: Enable LFN with dynamic working buffer on the STACK.
+/ 3: Enable LFN with dynamic working buffer on the HEAP.
+/
+/ To enable the LFN, ffunicode.c needs to be added to the project. The LFN function
+/ requiers certain internal working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and
+/ additional (FF_MAX_LFN + 44) / 15 * 32 bytes when exFAT is enabled.
+/ The FF_MAX_LFN defines size of the working buffer in UTF-16 code unit and it can
+/ be in range of 12 to 255. It is recommended to be set 255 to fully support LFN
+/ specification.
+/ When use stack for the working buffer, take care on stack overflow. When use heap
+/ memory for the working buffer, memory management functions, ff_memalloc() and
+/ ff_memfree() in ffsystem.c, need to be added to the project. */
+
+
+#define FF_LFN_UNICODE 0
+/* This option switches the character encoding on the API when LFN is enabled.
+/
+/ 0: ANSI/OEM in current CP (TCHAR = char)
+/ 1: Unicode in UTF-16 (TCHAR = WCHAR)
+/ 2: Unicode in UTF-8 (TCHAR = char)
+/ 3: Unicode in UTF-32 (TCHAR = DWORD)
+/
+/ Also behavior of string I/O functions will be affected by this option.
+/ When LFN is not enabled, this option has no effect. */
+
+
+#define FF_LFN_BUF 128
+#define FF_SFN_BUF 12
+/* This set of options defines size of file name members in the FILINFO structure
+/ which is used to read out directory items. These values should be suffcient for
+/ the file names to read. The maximum possible length of the read file name depends
+/ on character encoding. When LFN is not enabled, these options have no effect. */
+
+
+#define FF_STRF_ENCODE 3
+/* When FF_LFN_UNICODE >= 1 with LFN enabled, string I/O functions, f_gets(),
+/ f_putc(), f_puts and f_printf() convert the character encoding in it.
+/ This option selects assumption of character encoding ON THE FILE to be
+/ read/written via those functions.
+/
+/ 0: ANSI/OEM in current CP
+/ 1: Unicode in UTF-16LE
+/ 2: Unicode in UTF-16BE
+/ 3: Unicode in UTF-8
+*/
+
+
+#define FF_FS_RPATH 2
+/* This option configures support for relative path.
+/
+/ 0: Disable relative path and remove related functions.
+/ 1: Enable relative path. f_chdir() and f_chdrive() are available.
+/ 2: f_getcwd() function is available in addition to 1.
+*/
+
+
+/*---------------------------------------------------------------------------/
+/ Drive/Volume Configurations
+/---------------------------------------------------------------------------*/
+
+#define FF_VOLUMES 2
+/* Number of volumes (logical drives) to be used. (1-10) */
+
+
+#define FF_STR_VOLUME_ID 0
+#define FF_VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3"
+/* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.
+/ When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive
+/ number in the path name. FF_VOLUME_STRS defines the volume ID strings for each
+/ logical drives. Number of items must not be less than FF_VOLUMES. Valid
+/ characters for the volume ID strings are A-Z, a-z and 0-9, however, they are
+/ compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is
+/ not defined, a user defined volume string table needs to be defined as:
+/
+/ const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",...
+*/
+
+
+#define FF_MULTI_PARTITION 0
+/* This option switches support for multiple volumes on the physical drive.
+/ By default (0), each logical drive number is bound to the same physical drive
+/ number and only an FAT volume found on the physical drive will be mounted.
+/ When this function is enabled (1), each logical drive number can be bound to
+/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
+/ funciton will be available. */
+
+
+#define FF_MIN_SS 512
+#define FF_MAX_SS 512
+/* This set of options configures the range of sector size to be supported. (512,
+/ 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
+/ harddisk. But a larger value may be required for on-board flash memory and some
+/ type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured
+/ for variable sector size mode and disk_ioctl() function needs to implement
+/ GET_SECTOR_SIZE command. */
+
+
+#define FF_USE_TRIM 0
+/* This option switches support for ATA-TRIM. (0:Disable or 1:Enable)
+/ To enable Trim function, also CTRL_TRIM command should be implemented to the
+/ disk_ioctl() function. */
+
+
+#define FF_FS_NOFSINFO 0
+/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
+/ option, and f_getfree() function at first time after volume mount will force
+/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
+/
+/ bit0=0: Use free cluster count in the FSINFO if available.
+/ bit0=1: Do not trust free cluster count in the FSINFO.
+/ bit1=0: Use last allocated cluster number in the FSINFO if available.
+/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
+*/
+
+
+
+/*---------------------------------------------------------------------------/
+/ System Configurations
+/---------------------------------------------------------------------------*/
+
+#define FF_FS_TINY 1
+/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
+/ At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.
+/ Instead of private sector buffer eliminated from the file object, common sector
+/ buffer in the filesystem object (FATFS) is used for the file data transfer. */
+
+
+#define FF_FS_EXFAT 0
+/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
+/ To enable exFAT, also LFN needs to be enabled.
+/ Note that enabling exFAT discards ANSI C (C89) compatibility. */
+
+
+#define FF_FS_NORTC 0
+#define FF_NORTC_MON 1
+#define FF_NORTC_MDAY 1
+#define FF_NORTC_YEAR 2018
+/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have
+/ any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable
+/ the timestamp function. Every object modified by FatFs will have a fixed timestamp
+/ defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.
+/ To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be
+/ added to the project to read current time form real-time clock. FF_NORTC_MON,
+/ FF_NORTC_MDAY and FF_NORTC_YEAR have no effect.
+/ These options have no effect at read-only configuration (FF_FS_READONLY = 1). */
+
+
+#define FF_FS_LOCK 0
+/* The option FF_FS_LOCK switches file lock function to control duplicated file open
+/ and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
+/ is 1.
+/
+/ 0: Disable file lock function. To avoid volume corruption, application program
+/ should avoid illegal open, remove and rename to the open objects.
+/ >0: Enable file lock function. The value defines how many files/sub-directories
+/ can be opened simultaneously under file lock control. Note that the file
+/ lock control is independent of re-entrancy. */
+
+
+#define FF_FS_REENTRANT 0
+#define FF_FS_TIMEOUT 1000
+#define FF_SYNC_t HANDLE
+/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
+/ module itself. Note that regardless of this option, file access to different
+/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
+/ and f_fdisk() function, are always not re-entrant. Only file/directory access
+/ to the same volume is under control of this function.
+/
+/ 0: Disable re-entrancy. FF_FS_TIMEOUT and FF_SYNC_t have no effect.
+/ 1: Enable re-entrancy. Also user provided synchronization handlers,
+/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
+/ function, must be added to the project. Samples are available in
+/ option/syscall.c.
+/
+/ The FF_FS_TIMEOUT defines timeout period in unit of time tick.
+/ The FF_SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
+/ SemaphoreHandle_t and etc. A header file for O/S definitions needs to be
+/ included somewhere in the scope of ff.h. */
+
+/* #include <windows.h> // O/S definitions */
+
+
+
+/*--- End of configuration options ---*/
diff --git a/include/background.h b/include/background.h
new file mode 100644
index 0000000..87e95e5
--- /dev/null
+++ b/include/background.h
@@ -0,0 +1,17 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef BACKGROUND_H
+#define BACKGROUND_H
+
+typedef int (*bg_func)(int);
+
+int bg_register(bg_func f, int initval);
+int bg_setstat(int handle, int val);
+int bg_getstat(int handle);
+void bg_shed(void);
+
+#endif /* BACKGROUND_H */
diff --git a/include/bcd.h b/include/bcd.h
new file mode 100644
index 0000000..efbebcc
--- /dev/null
+++ b/include/bcd.h
@@ -0,0 +1,13 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef BCD_H
+#define BCD_H
+
+uint_fast8_t bcd2bin(uint8_t val);
+uint8_t bin2bcd (uint_fast8_t val);
+
+#endif /* BCD_H */
diff --git a/include/cli.h b/include/cli.h
new file mode 100644
index 0000000..e6df408
--- /dev/null
+++ b/include/cli.h
@@ -0,0 +1,83 @@
+/*
+ * (C) Copyright 2014-2016 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * (C) Copyright 2014 Google, Inc
+ * Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CLI_H
+#define CLI_H
+
+#include "common.h"
+
+/**
+ * Go into the command loop
+ *
+ * This will return if we get a timeout waiting for a command, but only for
+ * the simple parser (not hush). See CONFIG_BOOT_RETRY_TIME.
+ */
+void cli_loop(void);
+
+/**
+ * cli_simple_run_command() - Execute a command with the simple CLI
+ *
+ * @cmd: String containing the command to execute
+ * @flag Flag value - see CMD_FLAG_...
+ * @return 1 - command executed, repeatable
+ * 0 - command executed but not repeatable, interrupted commands are
+ * always considered not repeatable
+ * -1 - not executed (unrecognized, bootd recursion or too many args)
+ * (If cmd is NULL or "" or longer than CONFIG_SYS_CBSIZE-1 it is
+ * considered unrecognized)
+ */
+//int cli_simple_run_command(const char *cmd, uint_fast8_t flag);
+
+/**
+ * cli_simple_run_command_list() - Execute a list of command
+ *
+ * The commands should be separated by ; or \n and will be executed
+ * by the built-in parser.
+ *
+ * This function cannot take a const char * for the command, since if it
+ * finds newlines in the string, it replaces them with \0.
+ *
+ * @param cmd String containing list of commands
+ * @param flag Execution flags (CMD_FLAG_...)
+ * @return 0 on success, or != 0 on error.
+ */
+//int cli_simple_run_command_list(char *cmd, uint_fast8_t flag);
+
+/**
+ * parse_line() - split a command line down into separate arguments
+ *
+ * The argv[] array is filled with pointers into @line, and each argument
+ * is terminated by \0 (i.e. @line is changed in the process unless there
+ * is only one argument).
+ *
+ * #argv is terminated by a NULL after the last argument pointer.
+ *
+ * At most CONFIG_SYS_MAXARGS arguments are permited - if there are more
+ * than that then an error is printed, and this function returns
+ * CONFIG_SYS_MAXARGS, with argv[] set up to that point.
+ *
+ * @line: Command line to parse
+ * @args: Array to hold arguments
+ * @return number of arguments
+ */
+//int cli_simple_parse_line(char *line, char *argv[]);
+
+/*
+ * Run a command.
+ *
+ * @param cmd Command to run
+ * @param flag Execution flags (CMD_FLAG_...)
+ * @return 0 on success, or != 0 on error.
+ */
+int run_command(const char *cmd, uint_fast8_t flag);
+
+int run_command_list(const char *cmd, int len);
+
+
+#endif /* CLI_H */
diff --git a/include/cli_readline.h b/include/cli_readline.h
new file mode 100644
index 0000000..f326106
--- /dev/null
+++ b/include/cli_readline.h
@@ -0,0 +1,34 @@
+/*
+ * (C) Copyright 2014-2016 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * (C) Copyright 2014 Google, Inc
+ * Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CLI_READLINE_H
+#define CLI_READLINE_H
+
+#include "common.h"
+#include <stdbool.h>
+
+extern char console_buffer[]; /* console I/O buffer */
+
+/**
+ * cli_readline() - read a line into the console_buffer
+ *
+ * Display the prompt, then read a command line into console_buffer. The
+ * maximum line length is CONFIG_SYS_CBSIZE including a \0 terminator, which
+ * will always be added.
+ *
+ * The command is echoed as it is typed. Command editing is supported.
+ * Tab auto-complete is supported if CONFIG_AUTO_COMPLETE is defined.
+ *
+ * @prompt: Prompt to display
+ * @enable_history: Use history buffer if true
+ * @return command line length excluding terminator, or -ve on error
+ */
+int cli_readline(const FLASH char *const prompt, bool enable_history);
+
+#endif /* CLI_READLINE_H */
diff --git a/include/cmd_attach.h b/include/cmd_attach.h
new file mode 100644
index 0000000..2bd7363
--- /dev/null
+++ b/include/cmd_attach.h
@@ -0,0 +1,14 @@
+/*
+ * (C) Copyright 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CMD_ATTACH_H
+#define CMD_ATTACH_H
+
+#include "command.h"
+
+command_ret_t do_attach(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+
+#endif /* CMD_ATTACH_H */
diff --git a/include/cmd_boot.h b/include/cmd_boot.h
new file mode 100644
index 0000000..015a215
--- /dev/null
+++ b/include/cmd_boot.h
@@ -0,0 +1,22 @@
+/*
+ * (C) Copyright 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CMD_BOOT_H
+#define CMD_BOOT_H
+
+#include "command.h"
+
+command_ret_t do_loadf(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_bootcf(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_busreq_pulse(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_go(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_restart(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_reset(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
+command_ret_t do_console(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+
+
+
+#endif /* CMD_BOOT_H */
diff --git a/include/cmd_cpu.h b/include/cmd_cpu.h
new file mode 100644
index 0000000..f6f1fb9
--- /dev/null
+++ b/include/cmd_cpu.h
@@ -0,0 +1,16 @@
+/*
+ * (C) Copyright 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CMD_CPU_H
+#define CMD_CPU_H
+
+#include "command.h"
+
+extern cmd_tbl_t cmd_tbl_cpu[];
+
+command_ret_t do_cpu(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+
+#endif /* CMD_CPU_H */
diff --git a/include/cmd_date.h b/include/cmd_date.h
new file mode 100644
index 0000000..cd98f2a
--- /dev/null
+++ b/include/cmd_date.h
@@ -0,0 +1,14 @@
+/*
+ * (C) Copyright 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CMD_DATE_H
+#define CMD_DATE_H
+
+#include "command.h"
+
+command_ret_t do_date(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+
+#endif /* CMD_DATE_H */
diff --git a/include/cmd_fat.h b/include/cmd_fat.h
new file mode 100644
index 0000000..222b14c
--- /dev/null
+++ b/include/cmd_fat.h
@@ -0,0 +1,20 @@
+/*
+ * (C) Copyright 2014-2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CMD_FAT_H
+#define CMD_FAT_H
+
+#include "command.h"
+#include "ff.h"
+
+extern cmd_tbl_t cmd_tbl_fat[];
+
+const FLASH char * fat_rctostr(FRESULT rc);
+command_ret_t do_fat(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+
+void setup_fatfs(void);
+
+#endif /* CMD_FAT_H */
diff --git a/include/cmd_gpio.h b/include/cmd_gpio.h
new file mode 100644
index 0000000..d2f211d
--- /dev/null
+++ b/include/cmd_gpio.h
@@ -0,0 +1,15 @@
+/*
+ * (C) Copyright 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CMD_GPIO_H
+#define CMD_GPIO_H
+
+#include "command.h"
+
+command_ret_t do_gpio(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+
+
+#endif /* CMD_GPIO_H */
diff --git a/include/cmd_loadcpm3.h b/include/cmd_loadcpm3.h
new file mode 100644
index 0000000..5ef2a9d
--- /dev/null
+++ b/include/cmd_loadcpm3.h
@@ -0,0 +1,14 @@
+/*
+ * (C) Copyright 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CMD_LOADCPM3_H
+#define CMD_LOADCPM3_H
+
+#include "command.h"
+
+command_ret_t do_loadcpm3(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+
+#endif /* CMD_LOADCPM3_H */
diff --git a/include/cmd_loadihex.h b/include/cmd_loadihex.h
new file mode 100644
index 0000000..7ca53cf
--- /dev/null
+++ b/include/cmd_loadihex.h
@@ -0,0 +1,14 @@
+/*
+ * (C) Copyright 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CMD_LOADIHEX_H
+#define CMD_LOADIHEX_H
+
+#include "command.h"
+
+command_ret_t do_loadihex(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+
+#endif /* CMD_LOADIHEX_H */
diff --git a/include/cmd_mem.h b/include/cmd_mem.h
new file mode 100644
index 0000000..4b370cc
--- /dev/null
+++ b/include/cmd_mem.h
@@ -0,0 +1,29 @@
+/*
+ * (C) Copyright 2014,2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CMD_MEM_H
+#define CMD_MEM_H
+
+#include "command.h"
+
+command_ret_t do_mem_size(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_mem_md(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_mem_mm(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_mem_nm(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_mem_mw(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_mem_cp(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_mem_cmp(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_mem_base(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_mem_loop(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_mem_loopw(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+#ifdef CONFIG_CMD_MEMTEST
+command_ret_t do_mem_mtest(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+#endif
+#ifdef CONFIG_MX_CYCLIC
+command_ret_t do_mem_mdc(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+#endif /* CONFIG_MX_CYCLIC */
+
+#endif /* CMD_MEM_H */
diff --git a/include/cmd_misc.h b/include/cmd_misc.h
new file mode 100644
index 0000000..8dd7d56
--- /dev/null
+++ b/include/cmd_misc.h
@@ -0,0 +1,16 @@
+/*
+ * (C) Copyright 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CMD_MISC_H
+#define CMD_MISC_H
+
+#include "command.h"
+
+command_ret_t do_echo(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
+command_ret_t do_sleep(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
+command_ret_t do_time(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
+
+#endif /* CMD_MISC_H */
diff --git a/include/cmd_run.h b/include/cmd_run.h
new file mode 100644
index 0000000..fc81267
--- /dev/null
+++ b/include/cmd_run.h
@@ -0,0 +1,17 @@
+/*
+ * (C) Copyright 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CMD_RUN_H
+#define CMD_RUN_H
+
+#include "command.h"
+
+command_ret_t do_bootd(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_source(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_run(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+
+
+#endif /* CMD_RUN_H */
diff --git a/include/cmd_sd.h b/include/cmd_sd.h
new file mode 100644
index 0000000..0a5f5e5
--- /dev/null
+++ b/include/cmd_sd.h
@@ -0,0 +1,16 @@
+/*
+ * (C) Copyright 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CMD_SD_H
+#define CMD_SD_H
+
+#include "command.h"
+
+extern cmd_tbl_t cmd_tbl_sd[];
+
+command_ret_t do_sd(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+
+#endif /* CMD_SD_H */
diff --git a/include/command.h b/include/command.h
new file mode 100644
index 0000000..6109f9f
--- /dev/null
+++ b/include/command.h
@@ -0,0 +1,185 @@
+/*
+ * (C) Copyright 2014-2016, 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+/*
+ * Definitions for Command Processor
+ */
+#ifndef __COMMAND_H
+#define __COMMAND_H
+
+#include "common.h"
+#include "config.h"
+#include <setjmp.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+/* Default to a width of 8 characters for help message command width */
+#ifndef CONFIG_SYS_HELP_CMD_WIDTH
+#define CONFIG_SYS_HELP_CMD_WIDTH 8
+#endif
+
+/*
+ * Error codes that commands return to cmd_process(). We use the standard 0
+ * and 1 for success and failure, but add one more case - failure with a
+ * request to call cmd_usage(). But the cmd_process() function handles
+ * CMD_RET_USAGE itself and after calling cmd_usage() it will return 1.
+ * This is just a convenience for commands to avoid them having to call
+ * cmd_usage() all over the place.
+ */
+typedef enum {
+ CMD_RET_SUCCESS = 0, /* Success */
+ CMD_RET_FAILURE = 1, /* Failure */
+ CMD_RET_USAGE = -1, /* Failure, please report 'usage' error */
+} command_ret_t;
+
+/*
+ * Monitor Command Table
+ */
+
+typedef const FLASH struct cmd_tbl_s cmd_tbl_t;
+struct cmd_tbl_s {
+ const FLASH char *name; /* Command Name */
+ uint8_t maxargs; /* maximum number of arguments */
+ uint8_t flags; /* autorepeat allowed? */
+ /* Implementation function */
+ command_ret_t (*cmd)(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+ const FLASH char *usage; /* Usage message (short) */
+#ifdef CONFIG_SYS_LONGHELP
+ const FLASH char *help; /* Help message (long) */
+#endif
+ cmd_tbl_t *subcmd;
+#ifdef CONFIG_AUTO_COMPLETE
+ /* do auto completion on the arguments */
+ int (*complete)(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]);
+#endif
+};
+
+/**
+ * Process a command with arguments. We look up the command and execute it
+ * if valid. Otherwise we print a usage message.
+ *
+ * @param flag Some flags normally 0 (see CMD_FLAG_.. above)
+ * @param argc Number of arguments (arg 0 must be the command text)
+ * @param argv Arguments
+ * @param repeatable This function sets this to 0 if the command is not
+ * repeatable. If the command is repeatable, the value
+ * is left unchanged.
+ * @return 0 if the command succeeded, 1 if it failed
+ */
+command_ret_t
+cmd_process(uint_fast8_t flag, int argc, char * const argv[], uint_fast8_t *repeatable);
+
+
+/* command.c */
+command_ret_t do_help(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
+
+command_ret_t cmd_usage(cmd_tbl_t *cmdtp);
+
+#ifdef CONFIG_AUTO_COMPLETE
+extern int var_complete(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]);
+extern int cmd_auto_complete(const FLASH char *const prompt, char *buf, int *np, int *colp);
+#endif
+
+/**
+ * cmd_process_error() - report and process a possible error
+ *
+ * @cmdtp: Command which caused the error
+ * @err: Error code (0 if none, -ve for error, like -EIO)
+ * @return 0 if there is not error, 1 (CMD_RET_FAILURE) if an error is found
+ */
+int cmd_process_error(cmd_tbl_t *cmdtp, int err);
+
+/**
+ * cmd_error() - print error message
+ *
+ * @fmt:
+ */
+void cmd_error(int status, int errnum, const char *fmt, ...);
+
+/*
+ * Monitor Command
+ *
+ * All commands use a common argument format:
+ *
+ * void function (cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
+ */
+
+
+#ifdef CONFIG_CMD_BOOTD
+extern command_ret_t do_bootd(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
+#endif
+#ifdef CONFIG_CMD_BOOTM
+extern command_ret_t do_bootm(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
+extern int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd);
+#else
+static inline int bootm_maybe_autostart(cmd_tbl_t *cmdtp UNUSED, const char *cmd UNUSED)
+{
+ return 0;
+}
+#endif
+
+extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
+ char *const argv[]);
+
+/*
+ * Command Flags:
+ */
+#define CMD_FLAG_REPEAT 0x01 /* repeat last command */
+#define CMD_FLAG_BOOTD 0x02 /* command is from bootd */
+
+/*
+ * Flags for command table:
+ */
+#define CTBL_RPT 0x01 /* command is repeatable */
+#define CTBL_SUBCMD 0x02 /* command has subcommands */
+#define CTBL_SUBCMDAUTO 0x04 /* execute subcommands whithout prefix */
+#define CTBL_DBG 0x08 /* command is only for debugging */
+
+#ifdef CONFIG_AUTO_COMPLETE
+# define _CMD_COMPLETE(x) x,
+#else
+# define _CMD_COMPLETE(x)
+#endif
+#ifdef CONFIG_SYS_LONGHELP
+# define _CMD_HELP(x) x,
+#else
+# define _CMD_HELP(x)
+#endif
+
+
+#define CMD_TBL_ITEM_FULL(_name, _maxargs, _rep, _cmd, \
+ _usage, _help, _subtbl, _comp) \
+ { FSTR(#_name), _maxargs, _rep, _cmd, FSTR(_usage), \
+ _CMD_HELP(FSTR(_help)) _subtbl, _CMD_COMPLETE(_comp) }
+
+#define CMD_TBL_ITEM_COMPLETE(_name, _maxargs, _rep, _cmd, \
+ _usage, _help, _comp) \
+ { FSTR(#_name), _maxargs, _rep, _cmd, FSTR(_usage), \
+ _CMD_HELP(FSTR(_help)) NULL, _CMD_COMPLETE(_comp) }
+
+#define CMD_TBL_ITEM(_name, _maxargs, _rep, _cmd, _usage, _help) \
+ CMD_TBL_ITEM_FULL(_name, _maxargs, _rep, _cmd, \
+ _usage, _help, NULL, NULL)
+
+#define CMD_TBL_ITEM_TOP(_name, _maxargs, _rep, _cmd, _usage, _help, _subtbl) \
+ CMD_TBL_ITEM_FULL(_name, _maxargs, _rep, _cmd, \
+ _usage, _help, _subtbl, NULL)
+
+#define CMD_TBL_END(_table_start) { .subcmd = _table_start }
+
+typedef command_ret_t (*do_cmd_t)(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+
+extern cmd_tbl_t cmd_tbl[];
+
+extern jmp_buf cmd_jbuf;
+
+
+#endif /* __COMMAND_H */
diff --git a/include/common.h b/include/common.h
new file mode 100644
index 0000000..e89b91f
--- /dev/null
+++ b/include/common.h
@@ -0,0 +1,105 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef COMMON_H
+#define COMMON_H
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <ctype.h>
+#include <string.h>
+#include <stdlib.h>
+#include "errnum.h"
+
+#define GCC_VERSION (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
+
+#define USED __attribute__((used))
+#define UNUSED __attribute__((unused))
+
+#ifdef __AVR__
+#include <avr/io.h>
+#include <avr/pgmspace.h>
+#include <util/delay.h>
+
+#define udelay(n) _delay_us(n)
+
+struct bits {
+ uint8_t b0:1;
+ uint8_t b1:1;
+ uint8_t b2:1;
+ uint8_t b3:1;
+ uint8_t b4:1;
+ uint8_t b5:1;
+ uint8_t b6:1;
+ uint8_t b7:1;
+} __attribute__((__packed__));
+
+#define SBIT(port,pin) ((*(volatile struct bits*)&port).b##pin)
+
+//GCC bug PR61443
+// Known to work: 4.8.4, 4.9.1
+// Known to fail: 4.8.3, 4.9.0
+
+#if (GCC_VERSION < 40804) || (GCC_VERSION == 40900)
+#define GCC_BUG_61443 1
+#endif /* PR61443 */
+
+#define DEVICE_NAME __AVR_DEVICE_NAME__
+
+#else
+// TODO: stm32
+#endif /* __AVR__ */
+
+#ifdef __FLASH
+#define FLASH __flash
+#define MEMX __memx
+#else
+#define FLASH
+#define MEMX
+#endif
+
+#define stringify(s) tostring(s)
+#define tostring(s) #s
+
+#define FSTR(X) ((const FLASH char[]) { X } )
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+#define MIN(a,b) ({ typeof (a) _a = (a); \
+ typeof (b) _b = (b); \
+ _a < _b ? _a : _b; })
+#define MAX(a,b) ({ typeof (a) _a = (a); \
+ typeof (b) _b = (b); \
+ _a > _b ? _a : _b; })
+
+#ifdef __AVR__
+#define Stat GPIOR0
+#else
+extern volatile uint_least8_t Stat;
+#endif /* __AVR__ */
+
+#define S_10MS_TO (1<<0)
+#define S_MSG_PENDING (1<<1)
+#define S_CON_PENDING (1<<3)
+#define S_RESET_POLARITY (1<<4)
+
+static inline
+int my_puts(const char *s)
+{
+ return fputs(s, stdout);
+}
+
+static inline
+int my_puts_P(const char *s)
+{
+#ifdef __AVR__
+ return fputs_P(s, stdout);
+#else
+ return fputs(s, stdout);
+#endif /* __AVR__ */
+}
+
+#endif /* COMMON_H */
diff --git a/include/con-utils.h b/include/con-utils.h
new file mode 100644
index 0000000..86c0df0
--- /dev/null
+++ b/include/con-utils.h
@@ -0,0 +1,30 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/*
+ * Console utilities
+ */
+
+#ifndef CON_UTILS_H
+#define CON_UTILS_H
+
+uint_fast8_t tstc(void);
+
+int my_getchar(uint_fast8_t waitforchar);
+
+/* test if ctrl-c was pressed */
+uint_fast8_t ctrlc(void);
+
+
+/* pass 1 to disable ctrlc() checking, 0 to enable.
+ * returns previous state
+ */
+uint_fast8_t disable_ctrlc(uint_fast8_t disable);
+
+uint_fast8_t had_ctrlc (void);
+void clear_ctrlc(void);
+
+#endif /* CON_UTILS_H */
diff --git a/include/config.h b/include/config.h
new file mode 100644
index 0000000..1a82123
--- /dev/null
+++ b/include/config.h
@@ -0,0 +1,87 @@
+/*
+ * (C) Copyright 2014-2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+/* Version */
+#define VERSION "0.6.8.3"
+
+/* Environment variables */
+
+#define ENV_FMON "fmon"
+#define ENV_BAUDRATE "baudrate"
+#define ENV_BOOTDELAY "bootdelay"
+#define ENV_BOOTCMD "bootcmd"
+
+#define ENV_CPU_FREQ "fcpu"
+#define ENV_CPU "CPU"
+
+#define ENV_CPM3_SYSFILE "cpm3_file"
+#define ENV_CPM3_COMMON_BASE "cpm3_commonbase"
+#define ENV_CPM3_BANKED_BASE "cpm3_bankedbase"
+#define ENV_CPM3_SCB "cpm3_scb"
+
+#define ENV_PINALIAS "pin_alias"
+#define ENV_STARTADDRESS "startaddress"
+#define ENV_ESC_CHAR "esc_char"
+
+#define ENV_HOME "HOME"
+#define ENV_SINGLESTEP "singlestep"
+
+#define CONFIG_ENV_SIZE 1600
+#define CONFIG_ENV_OFFSET 0
+#define CONFIG_ENVVAR_MAX 40
+
+#define CONFIG_BAUDRATE 115200
+#define CONFIG_PWRON_DELAY 2000 /* ms to wait after power on */
+#define CONFIG_BOOTDELAY 4
+
+#define CONFIG_CPM3_SYSFILE "0:/cpm3.sys"
+#define CONFIG_CPM3_COMMON_BASE 0xF000
+#define CONFIG_CPM3_BANKED_BASE 0x0
+//#define CONFIG_CPM3_COMMON_BASE_STR "F000"
+#define CONFIG_CPM3_BANKED_BASE_STR "0"
+
+#define CONFIG_CPM_MAX_DRIVE 8
+#define CONFIG_CPM_MAX_DRNR_STR "7"
+#define CONFIG_CPM_BASE_DRIVE 'A'
+#define CONFIG_CPM_BLOCK_SIZE 512
+
+#define CONFIG_CMD_MEMTEST
+#define CONFIG_MX_CYCLIC
+#define CONFIG_SYS_RAMSIZE_MAX (1l<<19) /* max. addressable memory */
+
+#define CONFIG_CMD_DATE 1
+
+
+//#define CONFIG_CMD_LOADB
+
+
+#define CONFIG_SYS_I2C_RTC_ADDR 0x50
+#define CONFIG_SYS_I2C_BUFSIZE 64
+#define CONFIG_SYS_I2C_CLOCK 100000L /* SCL clock frequency in Hz */
+
+#define CONFIG_SYS_CBSIZE 250
+#define CONFIG_SYS_HIST_MAX 20
+#define CONFIG_SYS_MAXARGS 20
+#define CONFIG_SYS_ENV_NAMELEN 16
+#define CONFIG_SYS_HISTSIZE (CONFIG_SYS_CBSIZE*2)
+#define CONFIG_SYS_MAX_PATHLEN 200
+#define CONFIG_SYS_MALLOC_MARGIN 256
+
+#define CONFIG_SYS_PROMPT "-> "
+#define CONFIG_SYS_PROMPT_REPEAT "=> "
+#define CONFIG_ESC_CHAR ('^'-0x40)
+
+#define CONFIG_SYS_FBOOTSIG "Peda"
+
+/* TODO: */
+//#define CONFIG_AUTO_COMPLETE 1
+
+#define CONFIG_SYS_LONGHELP 1
+
+#endif /* CONFIG_H */
diff --git a/include/crc.h b/include/crc.h
new file mode 100644
index 0000000..89cde1f
--- /dev/null
+++ b/include/crc.h
@@ -0,0 +1,21 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef CRC_H
+#define CRC_H
+
+#ifdef __AVR__
+#include <util/crc16.h>
+static inline
+uint16_t crc16(uint16_t crc, uint8_t data)
+{
+ return _crc_ccitt_update(crc, data);
+}
+#else /* !__AVR__ */
+ /* TODO */
+#endif /* __AVR__ */
+
+#endif /* CRC_H */
diff --git a/include/debug.h b/include/debug.h
new file mode 100644
index 0000000..659fd70
--- /dev/null
+++ b/include/debug.h
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+
+#ifndef DEBUG_H_
+#define DEBUG_H_
+
+#include "command.h"
+
+command_ret_t do_dump_mem(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_mem_mm_avr(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_mem_nm_avr(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_eep_cp(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_pr_free_avr(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+command_ret_t do_pr_heap_avr(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+
+void printfreelist(const char * title);
+void dump_heap(void);
+
+
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
+
+/*
+ * Output a debug text when condition "cond" is met. The "cond" should be
+ * computed by a preprocessor in the best case, allowing for the best
+ * optimization.
+ */
+#define debug_cond(cond, fmt, args...) \
+ do { \
+ if (cond) \
+ printf_P(PSTR(fmt), ##args); \
+ } while (0)
+
+#define debug(fmt, args...) \
+ debug_cond(_DEBUG, fmt, ##args)
+
+
+#if 1
+#ifdef DEBUG
+#define DBG_P(lvl, format, ...) if (DEBUG>=lvl) \
+ fprintf_P( stdout, PSTR(format), ##__VA_ARGS__ )
+#else
+#define DBG_P(lvl, ...)
+#endif
+#endif /* 0 */
+
+#endif /* DEBUG_H_ */
diff --git a/include/diskio.h b/include/diskio.h
new file mode 100644
index 0000000..fee87a5
--- /dev/null
+++ b/include/diskio.h
@@ -0,0 +1,88 @@
+/*-----------------------------------------------------------------------
+/ Low level disk interface modlue include file R0.07 (C)ChaN, 2009
+/-----------------------------------------------------------------------*/
+
+#ifndef _DISKIO_H
+#define _DISKIO_H
+
+#define _USE_WRITE 1 /* 1: Enable disk_write function */
+#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
+
+#include "integer.h"
+
+
+/* Status of Disk Functions */
+typedef BYTE DSTATUS;
+
+/* Results of Disk Functions */
+typedef enum {
+ RES_OK = 0, /* 0: Successful */
+ RES_ERROR, /* 1: R/W Error */
+ RES_WRPRT, /* 2: Write Protected */
+ RES_NOTRDY, /* 3: Not Ready */
+ RES_PARERR /* 4: Invalid Parameter */
+} DRESULT;
+
+
+/*---------------------------------------*/
+/* Prototypes for disk control functions */
+
+DSTATUS disk_initialize (BYTE drv);
+DSTATUS disk_status (BYTE drv);
+DRESULT disk_read (BYTE drv, BYTE* buff, DWORD sector, UINT count);
+#if _USE_WRITE
+DRESULT disk_write (BYTE drv, const BYTE* buff, DWORD sector, UINT count);
+#endif
+#if _USE_IOCTL
+DRESULT disk_ioctl (BYTE drv, BYTE cmd, void* buff);
+#endif
+void disk_timerproc (void);
+
+
+
+/* Disk Status Bits (DSTATUS) */
+
+#define STA_NOINIT 0x01 /* Drive not initialized */
+#define STA_NODISK 0x02 /* No medium in the drive */
+#define STA_PROTECT 0x04 /* Write protected */
+#define STA_FAST 0x08 /* Fast SPI clock */
+#define STAT_MASK (STA_NOINIT | STA_NODISK | STA_PROTECT)
+
+
+/* Command code for disk_ioctrl() */
+
+/* Generic command (Used by FatFs) */
+#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
+#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
+#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
+#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
+#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
+
+/* Generic command (Not used by FatFs) */
+#define CTRL_FORMAT 5 /* Create physical format on the media */
+#define CTRL_POWER_IDLE 6 /* Put the device idle state */
+#define CTRL_POWER_OFF 7 /* Put the device off state */
+#define CTRL_LOCK 8 /* Lock media removal */
+#define CTRL_UNLOCK 9 /* Unlock media removal */
+#define CTRL_EJECT 10 /* Eject media */
+
+/* MMC/SDC specific command (Not used by FatFs) */
+#define MMC_GET_TYPE 50 /* Get card type */
+#define MMC_GET_CSD 51 /* Get CSD */
+#define MMC_GET_CID 52 /* Get CID */
+#define MMC_GET_OCR 53 /* Get OCR */
+#define MMC_GET_SDSTAT 54 /* Get SD status */
+
+/* ATA/CF specific command (Not used by FatFs) */
+#define ATA_GET_REV 60 /* Get F/W revision */
+#define ATA_GET_MODEL 61 /* Get model name */
+#define ATA_GET_SN 62 /* Get serial number */
+
+/* MMC card type flags (MMC_GET_TYPE) */
+#define CT_MMC 0x01 /* MMC ver 3 */
+#define CT_SD1 0x02 /* SD ver 1 */
+#define CT_SD2 0x04 /* SD ver 2 */
+#define CT_SDC (CT_SD1|CT_SD2) /* SD */
+#define CT_BLOCK 0x08 /* Block addressing */
+
+#endif /* _DISKIO_H */
diff --git a/include/env.h b/include/env.h
new file mode 100644
index 0000000..71bc98c
--- /dev/null
+++ b/include/env.h
@@ -0,0 +1,27 @@
+/*
+ * (C) Copyright 2014, 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef ENV_H
+#define ENV_H
+
+#include "command.h"
+
+extern cmd_tbl_t cmd_tbl_env[];
+
+command_ret_t do_env(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+int env_init(void);
+char *getenv_str(const MEMX char *name);
+unsigned long getenv_ulong(const MEMX char *name, int base, unsigned long default_val);
+bool getenv_yesno(const MEMX char *name);
+int setenv(const MEMX char *varname, const char *varvalue);
+int setenv_ulong(const MEMX char *varname, unsigned long value);
+int setenv_hex(const MEMX char *varname, unsigned long value);
+
+#if defined(CONFIG_AUTO_COMPLETE)
+int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf);
+#endif
+
+#endif /* ENV_H */
diff --git a/include/errnum.h b/include/errnum.h
new file mode 100644
index 0000000..5faa65c
--- /dev/null
+++ b/include/errnum.h
@@ -0,0 +1,30 @@
+/*
+ * (C) Copyright 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef ERRNUM_H
+#define ERRNUM_H
+
+#include "errnum.h"
+
+typedef enum {
+ ESUCCESS = 0,
+ // Unknown error
+ ENOMEM = 101, // Not enough memory
+ EINTR, // Interrupt
+ EBUSTO, // Bus timeout
+ EUNEXPARG, // Unexpected argument
+ EATRANGE, // Invalid disk number
+ EATALRDY, // Disk already attached
+ EATNOT, // Disk not attached
+ EATOPEN, // Error opening file
+ EATOTHER, // File already attached to other drive
+ ERUNNING, // CPU is running
+ EINVAL, // Invalid argument
+ EEOF, // Unexpected EOF
+
+} ERRNUM;
+
+#endif /* ERRNUM_H */
diff --git a/include/eval_arg.h b/include/eval_arg.h
new file mode 100644
index 0000000..a86b0d5
--- /dev/null
+++ b/include/eval_arg.h
@@ -0,0 +1,19 @@
+/*
+ * (C) Copyright 2016 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef EVAL_ARG_H
+#define EVAL_ARG_H
+
+/**
+ * eval_arg() - evaluate a command argument expression
+ *
+ * @arg: pointer to argument (usually argv[i])
+ * @end_ptr: pointer to position, where evaluation stopped. Points to '\0' if no error.
+ * @return evaluated argument
+ */
+long eval_arg(char *arg, char **end_ptr);
+
+#endif /* EVAL_ARG_H */
diff --git a/include/ff.h b/include/ff.h
new file mode 120000
index 0000000..6dd8d56
--- /dev/null
+++ b/include/ff.h
@@ -0,0 +1 @@
+../fatfs/source/ff.h \ No newline at end of file
diff --git a/include/ffconf.h b/include/ffconf.h
new file mode 100644
index 0000000..9841d5b
--- /dev/null
+++ b/include/ffconf.h
@@ -0,0 +1,5 @@
+#ifdef __AVR__
+#include "avr/ffconf.h"
+#else
+ /* TODO */
+#endif
diff --git a/include/getopt-min.h b/include/getopt-min.h
new file mode 100644
index 0000000..e42aa78
--- /dev/null
+++ b/include/getopt-min.h
@@ -0,0 +1,12 @@
+#ifndef GETOPT_MIN_H
+#define GETOPT_MIN_H
+
+int getopt( /* returns letter, '?', EOF */
+ int argc, /* argument count from main */
+ char *const argv[], /* argument vector from main */
+ const FLASH char * optstring ); /* allowed args, e.g. "ab:c" */
+
+extern int optind;
+extern char *optarg;
+
+#endif /* GETOPT_MIN_H */
diff --git a/include/gpio.h b/include/gpio.h
new file mode 100644
index 0000000..1e0346d
--- /dev/null
+++ b/include/gpio.h
@@ -0,0 +1,22 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef GPIO_H
+#define GPIO_H
+
+/* Number of user configurable I/O pins */
+#define GPIO_MAX 11
+
+typedef enum {NONE, INPUT, INPUT_PULLUP, OUTPUT, OUTPUT_TIMER} gpiomode_t;
+
+int gpio_config(int pin, gpiomode_t mode);
+gpiomode_t gpio_config_get(int pin);
+int gpio_read(int pin);
+void gpio_write(int pin, uint8_t val);
+int gpio_clockdiv_set(int pin, unsigned long divider);
+long gpio_clockdiv_get(int pin);
+
+#endif /* GPIO_H */
diff --git a/include/i2c.h b/include/i2c.h
new file mode 100644
index 0000000..f39fa1d
--- /dev/null
+++ b/include/i2c.h
@@ -0,0 +1,65 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * Copyright (C) 2009 Sergey Kubushyn <ksi@koi8.net>
+ * Copyright (C) 2009 - 2013 Heiko Schocher <hs@denx.de>
+ * Changes for multibus/multiadapter I2C support.
+ *
+ * (C) Copyright 2001
+ * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * The original I2C interface was
+ * (C) 2000 by Paolo Scaffardi (arsenio@tin.it)
+ * AIRVENT SAM s.p.a - RIMINI(ITALY)
+ * but has been changed substantially.
+ */
+
+#ifndef _I2C_H_
+#define _I2C_H_
+
+/*
+ * Configuration items.
+ */
+/* TODO: config.h? */
+#define I2C_RXTX_LEN 128 /* maximum tx/rx buffer length */
+
+
+/*
+ * Initialization, must be called once on start up, may be called
+ * repeatedly to change the speed.
+ */
+void i2c_init(uint32_t speed);
+
+/*
+ * Probe the given I2C chip address. Returns 0 if a chip responded,
+ * not 0 on failure.
+ */
+int i2c_probe(uint8_t chip);
+
+/*
+ * Read/Write interface:
+ * chip: I2C chip address, range 0..127
+ * addr: Memory (register) address within the chip
+ * alen: Number of bytes to use for addr (typically 1, 2 for larger
+ * memories, 0 for register type devices with only one
+ * register)
+ * buffer: Where to read/write the data
+ * len: How many bytes to read/write
+ *
+ * Returns: 0 on success, not 0 on failure
+ */
+int i2c_read(uint8_t chip, unsigned int addr, uint_fast8_t alen,
+ uint8_t *buffer, uint_fast8_t len);
+int i2c_write(uint8_t chip, unsigned int addr, uint_fast8_t alen,
+ uint8_t *buffer, uint_fast8_t len);
+
+/*
+ * Utility routines to read/write registers.
+ */
+uint8_t i2c_reg_read(uint8_t addr, uint8_t reg);
+
+void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val);
+
+#endif /* _I2C_H_*/
diff --git a/include/integer.h b/include/integer.h
new file mode 100644
index 0000000..4660ed6
--- /dev/null
+++ b/include/integer.h
@@ -0,0 +1,38 @@
+/*-------------------------------------------*/
+/* Integer type definitions for FatFs module */
+/*-------------------------------------------*/
+
+#ifndef _FF_INTEGER
+#define _FF_INTEGER
+
+#ifdef _WIN32 /* FatFs development platform */
+
+#include <windows.h>
+#include <tchar.h>
+typedef unsigned __int64 QWORD;
+
+
+#else /* Embedded platform */
+
+/* These types MUST be 16-bit or 32-bit */
+typedef int INT;
+typedef unsigned int UINT;
+
+/* This type MUST be 8-bit */
+typedef unsigned char BYTE;
+
+/* These types MUST be 16-bit */
+typedef short SHORT;
+typedef unsigned short WORD;
+typedef unsigned short WCHAR;
+
+/* These types MUST be 32-bit */
+typedef long LONG;
+typedef unsigned long DWORD;
+
+/* This type MUST be 64-bit (Remove this for C89 compatibility) */
+typedef unsigned long long QWORD;
+
+#endif
+
+#endif
diff --git a/include/print-utils.h b/include/print-utils.h
new file mode 100644
index 0000000..38de111
--- /dev/null
+++ b/include/print-utils.h
@@ -0,0 +1,24 @@
+/*
+ * (C) Copyright 2014, 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef PRINT_UTILS_H
+#define PRINT_UTILS_H
+
+#include "common.h"
+#include <avr/eeprom.h>
+
+void print_blanks(uint_fast8_t count);
+ERRNUM dump_mem(uint32_t address, uint32_t offset, uint32_t len,
+ ERRNUM (*readfkt)(uint8_t *, uint32_t, uint8_t), char *title);
+
+void dump_eep(uint32_t addr, unsigned int len, char *title);
+void dump_ram(uint8_t *addr, size_t offset, unsigned int len, char *title);
+
+ERRNUM eeprom_read_buf(uint8_t *buf, uint32_t addr, uint8_t count);
+ERRNUM ram_read_buf(uint8_t *buf, uint32_t addr, uint8_t count);
+ERRNUM flash_read_buf(uint8_t *buf, uint32_t addr, uint8_t count);
+
+#endif /* PRINT_UTILS_H */
diff --git a/include/ring.h b/include/ring.h
new file mode 100644
index 0000000..b64f462
--- /dev/null
+++ b/include/ring.h
@@ -0,0 +1,79 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef RING_H
+#define RING_H
+
+struct ring {
+ uint8_t *data;
+ uint_fast8_t mask;
+ volatile uint_fast8_t begin;
+ volatile uint_fast8_t end;
+};
+
+
+static inline
+void ring_init(struct ring *ring, uint8_t *buf, int size)
+{
+ ring->data = buf;
+ ring->mask = (size-1) & 0xff;
+ ring->begin = 0;
+ ring->end = 0;
+}
+
+static inline
+int ring_write_ch(struct ring *ring, uint8_t ch)
+{
+ uint_fast8_t ep = ring->end;
+
+ ring->data[ep] = ch;
+ ep = (ep + 1) & ring->mask;
+
+ if ((ep) != ring->begin) {
+ ring->end = ep;
+ return 1;
+ }
+
+ return -1;
+}
+
+#if 0
+static inline
+int ring_write(struct ring *ring, uint8_t *data, int size)
+{
+ int i;
+
+ for (i = 0; i < size; i++) {
+ if (ring_write_ch(ring, data[i]) < 0)
+ return -i;
+ }
+
+ return i;
+}
+#endif
+
+static inline
+int ring_read_ch(struct ring *ring)
+{
+ int ret = -1;
+ uint_fast8_t bp = ring->begin;
+
+ if (bp != ring->end) {
+ ret = ring->data[bp];
+ ring->begin = (bp + 1) & ring->mask;
+ }
+
+ return ret;
+}
+
+
+static inline
+int_fast8_t ring_is_empty(struct ring *ring)
+{
+ return ring->begin == ring->end;
+}
+
+#endif /* RING_H */
diff --git a/include/rtc.h b/include/rtc.h
new file mode 100644
index 0000000..ca4c068
--- /dev/null
+++ b/include/rtc.h
@@ -0,0 +1,13 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef _RTC_H_
+#define _RTC_H_
+
+int rtc_get (struct tm *);
+int rtc_set (struct tm *);
+
+#endif /* _RTC_H_ */
diff --git a/include/serial.h b/include/serial.h
new file mode 100644
index 0000000..54c7211
--- /dev/null
+++ b/include/serial.h
@@ -0,0 +1,15 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef SERIAL_H
+#define SERIAL_H
+
+void serial_setup(unsigned long baud);
+void serial_putc(char);
+int serial_getc(void);
+uint_fast8_t serial_tstc(void);
+
+#endif /* SERIAL_H */
diff --git a/include/spi.h b/include/spi.h
new file mode 100644
index 0000000..9dac375
--- /dev/null
+++ b/include/spi.h
@@ -0,0 +1,54 @@
+/*
+ * (C) Copyright 2009,2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef SPI_H_
+#define SPI_H_
+
+#define SPI_PORT PORTB /* SPI Connection port */
+#define SPI_DDR DDRB /* SPI Direction port */
+#define SPI_SS 0
+#define SPI_SCK 1
+#define SPI_MOSI 2
+#define SPI_MISO 3
+
+
+/* SPI macros */
+
+#define SPI_SET_SPEED_F_2 do {SPCR = (1<<SPE) | (1<<MSTR) | (0<<SPR1) | (0<<SPR0); SPSR = (1<<SPI2X); } while(0)
+#define SPI_SET_SPEED_F_4 do {SPCR = (1<<SPE) | (1<<MSTR) | (0<<SPR1) | (0<<SPR0); SPSR = (0<<SPI2X); } while(0)
+#define SPI_SET_SPEED_F_8 do {SPCR = (1<<SPE) | (1<<MSTR) | (0<<SPR1) | (1<<SPR0); SPSR = (1<<SPI2X); } while(0)
+#define SPI_SET_SPEED_F_16 do {SPCR = (1<<SPE) | (1<<MSTR) | (0<<SPR1) | (1<<SPR0); SPSR = (0<<SPI2X); } while(0)
+#define SPI_SET_SPEED_F_32 do {SPCR = (1<<SPE) | (1<<MSTR) | (1<<SPR1) | (0<<SPR0); SPSR = (1<<SPI2X); } while(0)
+#define SPI_SET_SPEED_F_64 do {SPCR = (1<<SPE) | (1<<MSTR) | (1<<SPR1) | (0<<SPR0); SPSR = (0<<SPI2X); } while(0)
+#define SPI_SET_SPEED_F_128 do {SPCR = (1<<SPE) | (1<<MSTR) | (1<<SPR1) | (1<<SPR0); SPSR = (0<<SPI2X); } while(0)
+
+/** switch to fast SPI Clock */
+#define SPISetFastClock() SPI_SET_SPEED_F_2
+#define SPISetSlowClock() SPI_SET_SPEED_F_8
+#define SPISetMMCInitClock() SPI_SET_SPEED_F_64
+
+#define SPI_OFF() do { SPCR = 0; } while(0)
+
+static inline __attribute__((always_inline)) void spi_wait(void) {
+ loop_until_bit_is_set(SPSR,SPIF);
+}
+
+static inline __attribute__((always_inline)) void spi_write(uint8_t a) {
+ SPDR = a;
+}
+
+static inline void spi_xmit(uint8_t a){
+ spi_write(a);
+ spi_wait();
+}
+
+static inline uint8_t spi_rcvr(void) {
+ SPDR = 0xFF;
+ spi_wait();
+ return SPDR;
+}
+
+#endif /* SPI_H_ */
diff --git a/include/strerror.h b/include/strerror.h
new file mode 100644
index 0000000..0457316
--- /dev/null
+++ b/include/strerror.h
@@ -0,0 +1,14 @@
+/*
+ * (C) Copyright 2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef STRERROR_H
+#define STRERROR_H
+
+#include "errnum.h"
+
+const FLASH char * my_strerror_P(ERRNUM errnum);
+
+#endif /* STRERROR_H */
diff --git a/include/timer.h b/include/timer.h
new file mode 100644
index 0000000..d604008
--- /dev/null
+++ b/include/timer.h
@@ -0,0 +1,16 @@
+/*
+ * (C) Copyright 2014,2018 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef TIMER_H
+#define TIMER_H
+
+#include "common.h"
+
+void setup_timer(void);
+
+uint32_t get_timer(uint32_t);
+
+#endif /* TIMER_H */
diff --git a/include/z180-serv.h b/include/z180-serv.h
new file mode 100644
index 0000000..760fa04
--- /dev/null
+++ b/include/z180-serv.h
@@ -0,0 +1,46 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef Z180_SERV_H
+#define Z180_SERV_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "ff.h"
+
+void setup_z180_serv(void);
+void restart_z180_serv(void);
+
+
+/* CP/M drive interface */
+
+/* TODO: Variable Disk Format */
+#define CONFIG_CPM_DISKSIZE (8*1024*1024L)
+
+typedef uint8_t drv_opt_t;
+
+#define DRV_OPT_RO (1<<0) /* Drive is write protected */
+#define DRV_OPT_DEBUG (1<<1) /* Debug this drive */
+#define DRV_OPT_REATTATCH (1<<7) /* Change existing attachment */
+
+typedef uint8_t drv_flag_t;
+#define DRV_FLG_OPEN (1<<0) /* Drive is logged in from CP/M */
+#define DRV_FLG_DIRTY (2<<0) /* Unwritten data */
+
+struct cpm_drive_s {
+ drv_opt_t opt;
+ drv_flag_t flags;
+ uint32_t dph;
+ char *img_name;
+ FIL fd;
+};
+
+
+int drv_list(void);
+int drv_detach(uint8_t drv);
+int drv_attach(uint8_t drv, const char *filename, drv_opt_t options);
+
+#endif /* Z180_SERV_H */
diff --git a/include/z80-if.h b/include/z80-if.h
new file mode 100644
index 0000000..c83c7de
--- /dev/null
+++ b/include/z80-if.h
@@ -0,0 +1,67 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
+#include "common.h"
+
+#define ZST_ACQUIRED 0x01
+#define ZST_RUNNING 0x02
+
+typedef enum {
+ RESET = 0x00,
+ RESET_AQRD = ZST_ACQUIRED,
+ RUNNING = ZST_RUNNING,
+ RUNNING_AQRD = ZST_RUNNING | ZST_ACQUIRED,
+} zstate_t;
+
+typedef enum {
+ Reset,
+ Request,
+ Release,
+ Run,
+ Restart,
+ M_Cycle
+} bus_cmd_t;
+
+typedef enum {LOW, HIGH} level_t;
+
+
+void z80_bus_request_or_exit(void);
+
+uint32_t z80_get_busreq_cycles(void);
+zstate_t z80_bus_state(void);
+zstate_t z80_bus_cmd(bus_cmd_t cmd);
+void z80_setup_bus(void);
+int z80_stat_reset(void);
+int z80_stat_halt(void);
+void z80_toggle_reset(void);
+void z80_toggle_busreq(void);
+
+
+int32_t z80_memsize_detect(void);
+void z80_write(uint32_t addr, uint8_t data);
+uint8_t z80_read(uint32_t addr);
+void z80_memset(uint32_t addr, uint8_t data, uint32_t length);
+void z80_write_block_P(const FLASH uint8_t *src, uint32_t dest, uint32_t length);
+void z80_write_block(const uint8_t *src, uint32_t dest, uint32_t length);
+void z80_read_block (uint8_t *dest, uint32_t src, size_t length);
+
+
+typedef enum fifo_t {
+ fifo_msgin, fifo_msgout,
+ fifo_conin, fifo_conout,
+ NUM_FIFOS
+ } fifo_t;
+
+void z80_memfifo_init(const fifo_t f, uint32_t adr);
+int z80_memfifo_is_empty(const fifo_t f);
+int z80_memfifo_is_full(const fifo_t f);
+int z80_memfifo_getc(const fifo_t f);
+uint8_t z80_memfifo_getc_wait(const fifo_t f);
+void z80_memfifo_putc(fifo_t f, uint8_t val);
+
+void z80_load_mem(int_fast8_t verbosity, const FLASH unsigned char data[],
+ const FLASH unsigned long *sections,
+ const FLASH unsigned long address[],
+ const FLASH unsigned long length_of_sections[]);