diff options
author | Leo C | 2014-08-21 11:36:14 +0200 |
---|---|---|
committer | Leo C | 2014-08-21 11:36:14 +0200 |
commit | 21a24f90c5aaaaf13f91716208b32cde163c5918 (patch) | |
tree | efc6f9ebab5f84d3af20493821444f220b957962 /avr | |
parent | dea9a31523216caa153c589426b175d52aa43634 (diff) | |
download | z180-stamp-21a24f90c5aaaaf13f91716208b32cde163c5918.zip |
Create include directory
Diffstat (limited to 'avr')
-rw-r--r-- | avr/Tupfile | 6 | ||||
-rw-r--r-- | avr/background.h | 10 | ||||
-rw-r--r-- | avr/cli.h | 64 | ||||
-rw-r--r-- | avr/cli_readline.h | 50 | ||||
-rw-r--r-- | avr/cmd_mem.h | 30 | ||||
-rw-r--r-- | avr/command.h | 158 | ||||
-rw-r--r-- | avr/common.h | 61 | ||||
-rw-r--r-- | avr/con-utils.h | 22 | ||||
-rw-r--r-- | avr/config.h | 29 | ||||
-rw-r--r-- | avr/crc.h | 12 | ||||
-rw-r--r-- | avr/debug.h | 38 | ||||
-rw-r--r-- | avr/env.h | 10 | ||||
-rw-r--r-- | avr/ring.h | 74 | ||||
-rw-r--r-- | avr/serial.h | 9 | ||||
-rw-r--r-- | avr/timer.h | 7 | ||||
-rw-r--r-- | avr/xmalloc.h | 8 | ||||
-rw-r--r-- | avr/z80-if.h | 46 |
17 files changed, 4 insertions, 630 deletions
diff --git a/avr/Tupfile b/avr/Tupfile index 8d36e0b..60022d6 100644 --- a/avr/Tupfile +++ b/avr/Tupfile @@ -16,7 +16,9 @@ MCU_TARGET = atmega1281 F_CPU = 18432000UL DEFS = -DF_CPU=$(F_CPU) -DBAUD=115200UL -#INCLUDES += ../z180 +INCLUDES += -I$(TOP)/include + +#INCLUDES += -I../z180 ############################################################################### @@ -56,7 +58,7 @@ CFLAGS += -fshort-enums #CFLAGS += -save-temps -#CFLAGS += -I $(INCLUDES) +CFLAGS += $(INCLUDES) CPPFLAGS += $(DEFS) diff --git a/avr/background.h b/avr/background.h deleted file mode 100644 index a624dbb..0000000 --- a/avr/background.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef BACKGROUND_H -#define BACKGROUND_H - -typedef int (*bg_func)(int); - -int bg_register(bg_func f); -void bg_shed(void); - -#endif /* BACKGROUND_H */ - diff --git a/avr/cli.h b/avr/cli.h deleted file mode 100644 index 67ff63b..0000000 --- a/avr/cli.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef CLI_H -#define CLI_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, int 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, int 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[]); - -int run_command_list(const char *cmd, int len); - - -#endif /* CLI_H */ - diff --git a/avr/cli_readline.h b/avr/cli_readline.h deleted file mode 100644 index 5b25762..0000000 --- a/avr/cli_readline.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (C) Copyright 2014 Google, Inc - * Simon Glass <sjg@chromium.org> - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#ifndef CLI_READLINE_H -#define CLI_READLINE_H - -extern char console_buffer[]; /* console I/O buffer */ - -/** - * cli_readline() - read a line into the console_buffer - * - * This is a convenience function which calls cli_readline_into_buffer(). - * - * @prompt: Prompt to display - * @return command line length excluding terminator, or -ve on error - */ -int cli_readline(const FLASH char *const prompt); - -/** - * readline_into_buffer() - read a line into a buffer - * - * Display the prompt, then read a command line into @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 if - * CONFIG_CMDLINE_EDITING is defined. Tab auto-complete is supported if - * CONFIG_AUTO_COMPLETE is defined. If CONFIG_BOOT_RETRY_TIME is defined, - * then a timeout will be applied. - * - * If CONFIG_BOOT_RETRY_TIME is defined and retry_time >= 0, - * time out when time goes past endtime (timebase time in ticks). - * - * @prompt: Prompt to display - * @buffer: Place to put the line that is entered - * @timeout: Timeout in milliseconds, 0 if none - * @return command line length excluding terminator, or -ve on error: of the - * timeout is exceeded (either CONFIG_BOOT_RETRY_TIME or the timeout - * parameter), then -2 is returned. If a break is detected (Ctrl-C) then - * -1 is returned. - */ -//int cli_readline_into_buffer(const char *const prompt, char *buffer, int timeout); - - -#endif /* CLI_READLINE_H */ - diff --git a/avr/cmd_mem.h b/avr/cmd_mem.h deleted file mode 100644 index cf379ce..0000000 --- a/avr/cmd_mem.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef CMD_MEM_H -#define CMD_MEM_H - -//#include "common.h" - -#include "command.h" -#include "cmd_mem.h" - - -extern command_ret_t do_mem_md(cmd_tbl_t *, int, int, char * const []); -extern command_ret_t do_mem_mm(cmd_tbl_t *, int, int, char * const []); -extern command_ret_t do_mem_nm(cmd_tbl_t *, int, int, char * const []); -extern command_ret_t do_mem_mw(cmd_tbl_t *, int, int, char * const []); -extern command_ret_t do_mem_cp(cmd_tbl_t *, int, int, char * const []); -extern command_ret_t do_mem_cmp(cmd_tbl_t *, int, int, char * const []); -extern command_ret_t do_mem_base(cmd_tbl_t *, int, int, char * const []); -extern command_ret_t do_mem_loop(cmd_tbl_t *, int, int, char * const []); -#ifdef CONFIG_LOOPW -extern command_ret_t do_mem_loopw(cmd_tbl_t *, int, int, char * const []); -#endif -#ifdef CONFIG_CMD_MEMTEST -extern command_ret_t do_mem_mtest(cmd_tbl_t *, int, int, char * const []); -#endif -#ifdef CONFIG_MX_CYCLIC -extern command_ret_t do_mem_mdc(cmd_tbl_t *, int, int, char * const []); -extern command_ret_t do_mem_mwc(cmd_tbl_t *, int, int, char * const []); -#endif /* CONFIG_MX_CYCLIC */ - -#endif /* CMD_MEM_H */ - diff --git a/avr/command.h b/avr/command.h deleted file mode 100644 index 2fd20a0..0000000 --- a/avr/command.h +++ /dev/null @@ -1,158 +0,0 @@ - -/* - * Definitions for Command Processor - */ -#ifndef __COMMAND_H -#define __COMMAND_H - -#include "common.h" -#include "config.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 - */ - -struct cmd_tbl_s { - const FLASH char *name; /* Command Name */ - int maxargs; /* maximum number of arguments */ - int repeatable; /* autorepeat allowed? */ - /* Implementation function */ - command_ret_t (*cmd)(const FLASH struct cmd_tbl_s *, int, int, char * const []); - const FLASH char *usage; /* Usage message (short) */ -#ifdef CONFIG_SYS_LONGHELP - const FLASH char *help; /* Help message (long) */ -#endif -#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 -}; - -typedef const FLASH struct cmd_tbl_s cmd_tbl_t; - -extern command_ret_t do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); - -/** - * 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(int flag, int argc, char * const argv[], uint_fast8_t *repeatable); - - -/* command.c */ -command_ret_t _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int - flag, int argc, char * const argv[]); -cmd_tbl_t *find_cmd(const char *cmd); -cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len); - -int cmd_tbl_item_count(void); -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); - -/* - * Monitor Command - * - * All commands use a common argument format: - * - * void function (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); - */ - - -#ifdef CONFIG_CMD_BOOTD -extern command_ret_t do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); -#endif -#ifdef CONFIG_CMD_BOOTM -extern command_ret_t do_bootm(cmd_tbl_t *cmdtp, int 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, const char *cmd) -{ - (void) cmdtp; (void) cmd; - - return 0; -} -#endif - -extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, - char *const argv[]); - -extern command_ret_t do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); - -/* - * Command Flags: - */ -#define CMD_FLAG_REPEAT 0x0001 /* repeat last command */ -#define CMD_FLAG_BOOTD 0x0002 /* command is from bootd */ - -#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_COMPLETE(_name, _maxargs, _rep, _cmd, \ - _usage, _help, _comp) \ - { FSTR(#_name), _maxargs, _rep, _cmd, FSTR(_usage), \ - _CMD_HELP(FSTR(_help)) _CMD_COMPLETE(_comp) } - -#define CMD_TBL_ITEM(_name, _maxargs, _rep, _cmd, _usage, _help) \ - CMD_TBL_ITEM_COMPLETE(_name, _maxargs, _rep, _cmd, \ - _usage, _help, NULL) - -typedef command_ret_t (*do_cmd_t)(cmd_tbl_t *, int, int, char * const []); - -extern cmd_tbl_t cmd_tbl[]; - - -#endif /* __COMMAND_H */ diff --git a/avr/common.h b/avr/common.h deleted file mode 100644 index a92f62c..0000000 --- a/avr/common.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef COMMON_H -#define COMMON_H - -#ifdef __AVR__ -#include <avr/io.h> - -//TODO: -// Known to work: 4.8.4, 4.9.1 -// Known to fail: 4.8.3, 4.9.0 -#define GCC_BUG_61443 1 - -#else -// TODO: stm32 -#endif /* __AVR__ */ - -#include <stdio.h> - -#ifdef __FLASH -#define FLASH __flash -#else -#define FLASH -#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])) - - -#ifdef __AVR__ -#define Stat GPIOR0 -#else -extern volatile uint_least8_t Stat; -#endif /* __AVR__ */ - -#define S_10MS_TO (1<<0) -#define S_Z180_RUNNING (2<<0) - -static inline -void my_puts(const char *s) -{ - fputs(s, stdout); -} - -#ifdef __AVR__ -static inline -void my_puts_P(const char *s) -{ - fputs_P(s, stdout); -} - -#else -static inline -void my_puts_P(const char *s) -{ - fputs(s, stdout); -} -#endif /* __AVR__ */ -#endif /* COMMON_H */ - diff --git a/avr/con-utils.h b/avr/con-utils.h deleted file mode 100644 index f03dfb3..0000000 --- a/avr/con-utils.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef CON_UTILS_H -#define CON_UTILS_H - -uint_fast8_t tstc(void); - -int my_getchar(void); - -/* 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/avr/config.h b/avr/config.h deleted file mode 100644 index 08d97bd..0000000 --- a/avr/config.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -#define CONFIG_ENV_SIZE 1600 -#define CONFIG_ENV_OFFSET 0 -#define CONFIG_ENVVAR_MAX 20 - -#define CONFIG_BOOTDELAY 4 -//#define CONFIG_ZERO_BOOTDELAY_CHECK 1 - -//#define CONFIG_LOOPW -//#define CONFIG_CMD_MEMTEST -//#define CONFIG_MX_CYCLIC - -#define CONFIG_SYS_CBSIZE 250 -#define CONFIG_SYS_ENV_NAMELEN 16 -#define CONFIG_SYS_MAXARGS 8 - -#define CONFIG_SYS_PROMPT "=> " - - -/* TODO: */ -//#define CONFIG_CMDLINE_EDITING 1 -//#define CONFIG_AUTO_COMPLETE 1 - -#define CONFIG_SYS_LONGHELP 1 - -#endif /* CONFIG_H */ - diff --git a/avr/crc.h b/avr/crc.h deleted file mode 100644 index c38bae4..0000000 --- a/avr/crc.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef CRC_H -#define CRC_H - -#include <util/crc16.h> - -static inline -uint16_t crc16(uint16_t crc, uint8_t data) -{ - return _crc_ccitt_update(crc, data); -} - -#endif /* CRC_H */ diff --git a/avr/debug.h b/avr/debug.h deleted file mode 100644 index 7c19e40..0000000 --- a/avr/debug.h +++ /dev/null @@ -1,38 +0,0 @@ - -#ifndef DEBUG_H_ -#define DEBUG_H_ - -#include "common.h" -#include <avr/pgmspace.h> - -#ifdef DEBUG -#define _DEBUG 1 -#else -#define _DEBUG 0 -#endif - -#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 */ - - -void printfreelist(const char * title); - - -#endif /* DEBUG_H_ */ - diff --git a/avr/env.h b/avr/env.h deleted file mode 100644 index 9d55273..0000000 --- a/avr/env.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef ENV_H -#define ENV_H - -int env_init(void); - -char *getenv(const char *name); -int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf); - -#endif /* ENV_H */ - diff --git a/avr/ring.h b/avr/ring.h deleted file mode 100644 index d57f9aa..0000000 --- a/avr/ring.h +++ /dev/null @@ -1,74 +0,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/avr/serial.h b/avr/serial.h deleted file mode 100644 index 7414ef1..0000000 --- a/avr/serial.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef SERIAL_H -#define SERIAL_H - -void serial_setup(void); -void serial_putc(char); -int serial_getc(void); -uint_fast8_t serial_tstc(void); - -#endif /* SERIAL_H */ diff --git a/avr/timer.h b/avr/timer.h deleted file mode 100644 index bed3eb0..0000000 --- a/avr/timer.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef TIMER_H -#define TIMER_H - -uint32_t get_timer(uint32_t); - -#endif /* TIMER_H */ - diff --git a/avr/xmalloc.h b/avr/xmalloc.h deleted file mode 100644 index cb0019f..0000000 --- a/avr/xmalloc.h +++ /dev/null @@ -1,8 +0,0 @@ - -#ifndef XMALLOC_H -#define XMALLOC_H - -void* xmalloc(size_t size); -void* xrealloc(void *p, size_t size); - -#endif /* XMALLOC_H */ diff --git a/avr/z80-if.h b/avr/z80-if.h deleted file mode 100644 index b02fe23..0000000 --- a/avr/z80-if.h +++ /dev/null @@ -1,46 +0,0 @@ - -#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; - -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); -//void z80_busreq(level_t level); -int z80_stat_halt(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(const FLASH uint8_t *src, uint32_t dest, uint32_t length); - - -typedef enum fifo_t {fifo_in, fifo_out, 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); -uint8_t z80_memfifo_getc(const fifo_t f); -void z80_memfifo_putc(fifo_t f, uint8_t val); - -void z80_setup_msg_fifo(void); -void z80_init_msg_fifo(uint32_t addr); -int z80_msg_fifo_getc(void); |