//==========================================================================
|
//==========================================================================
|
//
|
//
|
// redboot.h
|
// redboot.h
|
//
|
//
|
// Standard interfaces for RedBoot
|
// Standard interfaces for RedBoot
|
//
|
//
|
//==========================================================================
|
//==========================================================================
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
// -------------------------------------------
|
// -------------------------------------------
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
// Copyright (C) 2002 Gary Thomas
|
// Copyright (C) 2002 Gary Thomas
|
//
|
//
|
// eCos is free software; you can redistribute it and/or modify it under
|
// eCos is free software; you can redistribute it and/or modify it under
|
// the terms of the GNU General Public License as published by the Free
|
// the terms of the GNU General Public License as published by the Free
|
// Software Foundation; either version 2 or (at your option) any later version.
|
// Software Foundation; either version 2 or (at your option) any later version.
|
//
|
//
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// for more details.
|
// for more details.
|
//
|
//
|
// You should have received a copy of the GNU General Public License along
|
// You should have received a copy of the GNU General Public License along
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
//
|
//
|
// As a special exception, if other files instantiate templates or use macros
|
// As a special exception, if other files instantiate templates or use macros
|
// or inline functions from this file, or you compile this file and link it
|
// or inline functions from this file, or you compile this file and link it
|
// with other works to produce a work based on this file, this file does not
|
// with other works to produce a work based on this file, this file does not
|
// by itself cause the resulting work to be covered by the GNU General Public
|
// by itself cause the resulting work to be covered by the GNU General Public
|
// License. However the source code for this file must still be made available
|
// License. However the source code for this file must still be made available
|
// in accordance with section (3) of the GNU General Public License.
|
// in accordance with section (3) of the GNU General Public License.
|
//
|
//
|
// This exception does not invalidate any other reasons why a work based on
|
// This exception does not invalidate any other reasons why a work based on
|
// this file might be covered by the GNU General Public License.
|
// this file might be covered by the GNU General Public License.
|
//
|
//
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
// at http://sources.redhat.com/ecos/ecos-license/
|
// at http://sources.redhat.com/ecos/ecos-license/
|
// -------------------------------------------
|
// -------------------------------------------
|
//####ECOSGPLCOPYRIGHTEND####
|
//####ECOSGPLCOPYRIGHTEND####
|
//==========================================================================
|
//==========================================================================
|
//#####DESCRIPTIONBEGIN####
|
//#####DESCRIPTIONBEGIN####
|
//
|
//
|
// Author(s): gthomas
|
// Author(s): gthomas
|
// Contributors: gthomas, tkoeller
|
// Contributors: gthomas, tkoeller
|
// Date: 2000-07-14
|
// Date: 2000-07-14
|
// Purpose:
|
// Purpose:
|
// Description:
|
// Description:
|
//
|
//
|
// This code is part of RedBoot (tm).
|
// This code is part of RedBoot (tm).
|
//
|
//
|
//####DESCRIPTIONEND####
|
//####DESCRIPTIONEND####
|
//
|
//
|
//==========================================================================
|
//==========================================================================
|
|
|
#ifndef _REDBOOT_H_
|
#ifndef _REDBOOT_H_
|
#define _REDBOOT_H_
|
#define _REDBOOT_H_
|
|
|
#include <pkgconf/redboot.h>
|
#include <pkgconf/redboot.h>
|
#include <pkgconf/hal.h>
|
#include <pkgconf/hal.h>
|
#include <cyg/hal/hal_if.h>
|
#include <cyg/hal/hal_if.h>
|
#include <cyg/hal/hal_tables.h>
|
#include <cyg/hal/hal_tables.h>
|
#include <cyg/infra/diag.h>
|
#include <cyg/infra/diag.h>
|
#include <cyg/crc/crc.h>
|
#include <cyg/crc/crc.h>
|
#include <string.h>
|
#include <string.h>
|
|
|
#ifdef CYGPKG_REDBOOT_NETWORKING
|
#ifdef CYGPKG_REDBOOT_NETWORKING
|
#include <net/net.h>
|
#include <net/net.h>
|
#include <net/bootp.h>
|
#include <net/bootp.h>
|
// Determine an IP address for this node, using BOOTP
|
// Determine an IP address for this node, using BOOTP
|
extern int __bootp_find_local_ip(bootp_header_t *info);
|
extern int __bootp_find_local_ip(bootp_header_t *info);
|
#endif
|
#endif
|
|
|
#ifdef DEFINE_VARS
|
#ifdef DEFINE_VARS
|
#define EXTERN
|
#define EXTERN
|
#else
|
#else
|
#define EXTERN extern
|
#define EXTERN extern
|
#endif
|
#endif
|
|
|
// Global variables
|
// Global variables
|
EXTERN int argc;
|
EXTERN int argc;
|
#define MAX_ARGV 16
|
#define MAX_ARGV 16
|
EXTERN char *argv[MAX_ARGV];
|
EXTERN char *argv[MAX_ARGV];
|
EXTERN unsigned char *ram_start, *ram_end;
|
EXTERN unsigned char *ram_start, *ram_end;
|
EXTERN unsigned char *user_ram_start, *user_ram_end;
|
EXTERN unsigned char *user_ram_start, *user_ram_end;
|
EXTERN unsigned char *workspace_start, *workspace_end;
|
EXTERN unsigned char *workspace_start, *workspace_end;
|
EXTERN unsigned long workspace_size;
|
EXTERN unsigned long workspace_size;
|
|
|
// Data squirreled away after a load operation
|
// Data squirreled away after a load operation
|
EXTERN unsigned long entry_address;
|
EXTERN unsigned long entry_address;
|
EXTERN unsigned long load_address;
|
EXTERN unsigned long load_address;
|
EXTERN unsigned long load_address_end;
|
EXTERN unsigned long load_address_end;
|
|
|
|
|
#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
|
#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
|
EXTERN bool console_selected;
|
EXTERN bool console_selected;
|
#endif
|
#endif
|
EXTERN bool console_echo;
|
EXTERN bool console_echo;
|
EXTERN bool gdb_active;
|
EXTERN bool gdb_active;
|
#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
|
#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
|
EXTERN bool cmd_history;
|
EXTERN bool cmd_history;
|
#endif
|
#endif
|
|
|
#ifdef CYGPKG_REDBOOT_NETWORKING
|
#ifdef CYGPKG_REDBOOT_NETWORKING
|
EXTERN bool have_net, use_bootp;
|
EXTERN bool have_net, use_bootp;
|
EXTERN bootp_header_t my_bootp_info;
|
EXTERN bootp_header_t my_bootp_info;
|
EXTERN int gdb_port;
|
EXTERN int gdb_port;
|
EXTERN bool net_debug;
|
EXTERN bool net_debug;
|
#endif
|
#endif
|
|
|
#ifdef CYGFUN_REDBOOT_BOOT_SCRIPT
|
#ifdef CYGFUN_REDBOOT_BOOT_SCRIPT
|
EXTERN unsigned char *script;
|
EXTERN unsigned char *script;
|
EXTERN int script_timeout;
|
EXTERN int script_timeout;
|
#ifdef CYGSEM_REDBOOT_VARIABLE_BAUD_RATE
|
#ifdef CYGSEM_REDBOOT_VARIABLE_BAUD_RATE
|
EXTERN int console_baud_rate;
|
EXTERN int console_baud_rate;
|
#endif
|
#endif
|
#endif
|
#endif
|
|
|
#ifdef CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER
|
#ifdef CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER
|
EXTERN unsigned char *fis_zlib_common_buffer;
|
EXTERN unsigned char *fis_zlib_common_buffer;
|
#endif
|
#endif
|
|
|
// Prototypes
|
// Prototypes
|
typedef int _printf_fun(const char *fmt, ...);
|
typedef int _printf_fun(const char *fmt, ...);
|
externC int strcasecmp(const char *s1, const char *s2);
|
externC int strcasecmp(const char *s1, const char *s2);
|
externC int strncasecmp(const char *s1, const char *s2, size_t len);
|
externC int strncasecmp(const char *s1, const char *s2, size_t len);
|
|
|
externC void mon_write_char(char c);
|
externC void mon_write_char(char c);
|
externC bool verify_action(char *fmt, ...);
|
externC bool verify_action(char *fmt, ...);
|
externC bool verify_action_with_timeout(int timeout, char *fmt, ...);
|
externC bool verify_action_with_timeout(int timeout, char *fmt, ...);
|
|
|
// Read a single line of input from the console, possibly with timeout
|
// Read a single line of input from the console, possibly with timeout
|
externC int _rb_gets(char *line, int len, int timeout);
|
externC int _rb_gets(char *line, int len, int timeout);
|
// Just like _rb_gets(), except that the line buffer is assumed to contain
|
// Just like _rb_gets(), except that the line buffer is assumed to contain
|
// valid input data. This provides an easy mechanism for edit-in-place.
|
// valid input data. This provides an easy mechanism for edit-in-place.
|
externC int _rb_gets_preloaded(char *line, int len, int timeout);
|
externC int _rb_gets_preloaded(char *line, int len, int timeout);
|
// Result codes from 'gets()'
|
// Result codes from 'gets()'
|
#define _GETS_TIMEOUT -1
|
#define _GETS_TIMEOUT -1
|
#define _GETS_CTRLC -2
|
#define _GETS_CTRLC -2
|
#define _GETS_GDB 0
|
#define _GETS_GDB 0
|
#define _GETS_OK 1
|
#define _GETS_OK 1
|
|
|
// "console" selection
|
// "console" selection
|
externC int start_console(void);
|
externC int start_console(void);
|
externC void end_console(int old_console);
|
externC void end_console(int old_console);
|
|
|
// Alias functions
|
// Alias functions
|
#ifdef CYGSEM_REDBOOT_FLASH_ALIASES
|
#ifdef CYGSEM_REDBOOT_FLASH_ALIASES
|
externC char *flash_lookup_alias(char *alias, char *alias_buf);
|
externC char *flash_lookup_alias(char *alias, char *alias_buf);
|
#endif
|
#endif
|
externC void expand_aliases(char *line, int len);
|
externC void expand_aliases(char *line, int len);
|
|
|
//
|
//
|
// Stream I/O support
|
// Stream I/O support
|
//
|
//
|
|
|
typedef struct {
|
typedef struct {
|
char *filename;
|
char *filename;
|
int mode;
|
int mode;
|
int chan;
|
int chan;
|
#ifdef CYGPKG_REDBOOT_NETWORKING
|
#ifdef CYGPKG_REDBOOT_NETWORKING
|
struct sockaddr_in *server;
|
struct sockaddr_in *server;
|
#endif
|
#endif
|
} connection_info_t;
|
} connection_info_t;
|
|
|
typedef struct {
|
typedef struct {
|
int (*open)(connection_info_t *info, int *err);
|
int (*open)(connection_info_t *info, int *err);
|
void (*close)(int *err);
|
void (*close)(int *err);
|
void (*terminate)(bool abort, int (*getc)(void));
|
void (*terminate)(bool abort, int (*getc)(void));
|
int (*read)(char *buf, int size, int *err);
|
int (*read)(char *buf, int size, int *err);
|
char *(*error)(int err);
|
char *(*error)(int err);
|
} getc_io_funcs_t;
|
} getc_io_funcs_t;
|
|
|
#define GETC_IO_FUNCS(_label_, _open_, _close_, _terminate_, _read_, _error_) \
|
#define GETC_IO_FUNCS(_label_, _open_, _close_, _terminate_, _read_, _error_) \
|
getc_io_funcs_t _label_ = { \
|
getc_io_funcs_t _label_ = { \
|
_open_, _close_, _terminate_, _read_, _error_ \
|
_open_, _close_, _terminate_, _read_, _error_ \
|
};
|
};
|
|
|
struct load_io_entry {
|
struct load_io_entry {
|
char *name;
|
char *name;
|
getc_io_funcs_t *funcs;
|
getc_io_funcs_t *funcs;
|
bool can_verbose;
|
bool can_verbose;
|
bool need_filename;
|
bool need_filename;
|
int mode;
|
int mode;
|
} CYG_HAL_TABLE_TYPE;
|
} CYG_HAL_TABLE_TYPE;
|
#define _RedBoot_load(_name_,_funcs_,_verbose_,_filename_,_mode_) \
|
#define _RedBoot_load(_name_,_funcs_,_verbose_,_filename_,_mode_) \
|
struct load_io_entry _load_tab_##_funcs_##_name_ \
|
struct load_io_entry _load_tab_##_funcs_##_name_ \
|
CYG_HAL_TABLE_QUALIFIED_ENTRY(RedBoot_load,_funcs_##_name) = \
|
CYG_HAL_TABLE_QUALIFIED_ENTRY(RedBoot_load,_funcs_##_name) = \
|
{ #_name_, &_funcs_, _verbose_, _filename_, _mode_ };
|
{ #_name_, &_funcs_, _verbose_, _filename_, _mode_ };
|
#define RedBoot_load(_name_,_funcs_,_verbose_,_filename_, _mode_) \
|
#define RedBoot_load(_name_,_funcs_,_verbose_,_filename_, _mode_) \
|
_RedBoot_load(_name_,_funcs_,_verbose_,_filename_,_mode_)
|
_RedBoot_load(_name_,_funcs_,_verbose_,_filename_,_mode_)
|
|
|
#ifdef CYGPKG_COMPRESS_ZLIB
|
#ifdef CYGPKG_COMPRESS_ZLIB
|
// Decompression support
|
// Decompression support
|
typedef struct _pipe {
|
typedef struct _pipe {
|
unsigned char* in_buf; // only changed by producer
|
unsigned char* in_buf; // only changed by producer
|
int in_avail; // only changed by producer
|
int in_avail; // only changed by producer
|
unsigned char* out_buf; // only changed by consumer (init by producer)
|
unsigned char* out_buf; // only changed by consumer (init by producer)
|
int out_size; // only changed by consumer (init by producer)
|
int out_size; // only changed by consumer (init by producer)
|
int out_max; // set by producer
|
int out_max; // set by producer
|
const char* msg; // message from consumer
|
const char* msg; // message from consumer
|
void* priv; // handler's data
|
void* priv; // handler's data
|
} _pipe_t;
|
} _pipe_t;
|
|
|
typedef int _decompress_fun_init(_pipe_t*);
|
typedef int _decompress_fun_init(_pipe_t*);
|
typedef int _decompress_fun_inflate(_pipe_t*);
|
typedef int _decompress_fun_inflate(_pipe_t*);
|
typedef int _decompress_fun_close(_pipe_t*, int);
|
typedef int _decompress_fun_close(_pipe_t*, int);
|
|
|
externC _decompress_fun_init* _dc_init;
|
externC _decompress_fun_init* _dc_init;
|
externC _decompress_fun_inflate* _dc_inflate;
|
externC _decompress_fun_inflate* _dc_inflate;
|
externC _decompress_fun_close* _dc_close;
|
externC _decompress_fun_close* _dc_close;
|
#endif // CYGPKG_COMPRESS_ZLIB
|
#endif // CYGPKG_COMPRESS_ZLIB
|
|
|
// CLI support functions
|
// CLI support functions
|
externC bool parse_num(char *s, unsigned long *val, char **es, char *delim);
|
externC bool parse_num(char *s, unsigned long *val, char **es, char *delim);
|
externC bool parse_bool(char *s, bool *val);
|
externC bool parse_bool(char *s, bool *val);
|
|
|
typedef void cmd_fun(int argc, char *argv[]);
|
typedef void cmd_fun(int argc, char *argv[]);
|
struct cmd {
|
struct cmd {
|
char *str;
|
char *str;
|
char *help;
|
char *help;
|
char *usage;
|
char *usage;
|
cmd_fun *fun;
|
cmd_fun *fun;
|
struct cmd *sub_cmds, *sub_cmds_end;
|
struct cmd *sub_cmds, *sub_cmds_end;
|
} CYG_HAL_TABLE_TYPE;
|
} CYG_HAL_TABLE_TYPE;
|
externC struct cmd *cmd_search(struct cmd *tab, struct cmd *tabend, char *arg);
|
externC struct cmd *cmd_search(struct cmd *tab, struct cmd *tabend, char *arg);
|
externC void cmd_usage(struct cmd *tab, struct cmd *tabend, char *prefix);
|
externC void cmd_usage(struct cmd *tab, struct cmd *tabend, char *prefix);
|
#define RedBoot_cmd(_s_,_h_,_u_,_f_) cmd_entry(_s_,_h_,_u_,_f_,0,0,RedBoot_commands)
|
#define RedBoot_cmd(_s_,_h_,_u_,_f_) cmd_entry(_s_,_h_,_u_,_f_,0,0,RedBoot_commands)
|
#define RedBoot_nested_cmd(_s_,_h_,_u_,_f_,_subs_,_sube_) cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,RedBoot_commands)
|
#define RedBoot_nested_cmd(_s_,_h_,_u_,_f_,_subs_,_sube_) cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,RedBoot_commands)
|
#define _cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,_n_) \
|
#define _cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,_n_) \
|
cmd_fun _f_; \
|
cmd_fun _f_; \
|
struct cmd _cmd_tab_##_f_ CYG_HAL_TABLE_QUALIFIED_ENTRY(_n_,_f_) = {_s_, _h_, _u_, _f_, _subs_, _sube_};
|
struct cmd _cmd_tab_##_f_ CYG_HAL_TABLE_QUALIFIED_ENTRY(_n_,_f_) = {_s_, _h_, _u_, _f_, _subs_, _sube_};
|
#define cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,_n_) \
|
#define cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,_n_) \
|
extern _cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,_n_)
|
extern _cmd_entry(_s_,_h_,_u_,_f_,_subs_,_sube_,_n_)
|
#define local_cmd_entry(_s_,_h_,_u_,_f_,_n_) \
|
#define local_cmd_entry(_s_,_h_,_u_,_f_,_n_) \
|
static _cmd_entry(_s_,_h_,_u_,_f_,0,0,_n_)
|
static _cmd_entry(_s_,_h_,_u_,_f_,0,0,_n_)
|
|
|
// Initialization functions
|
// Initialization functions
|
#define RedBoot_INIT_FIRST 0000
|
#define RedBoot_INIT_FIRST 0000
|
// Specify a 3 digit numeric value for proper prioritizing
|
// Specify a 3 digit numeric value for proper prioritizing
|
#define RedBoot_INIT_PRIO(_n_) 1##_n_
|
#define RedBoot_INIT_PRIO(_n_) 1##_n_
|
#define RedBoot_INIT_LAST 9999
|
#define RedBoot_INIT_LAST 9999
|
typedef void void_fun(void);
|
typedef void void_fun(void);
|
typedef void_fun *void_fun_ptr;
|
typedef void_fun *void_fun_ptr;
|
struct init_tab_entry {
|
struct init_tab_entry {
|
void_fun_ptr fun;
|
void_fun_ptr fun;
|
} CYG_HAL_TABLE_TYPE;
|
} CYG_HAL_TABLE_TYPE;
|
#define _RedBoot_init(_f_,_p_) \
|
#define _RedBoot_init(_f_,_p_) \
|
struct init_tab_entry _init_tab_##_p_##_f_ \
|
struct init_tab_entry _init_tab_##_p_##_f_ \
|
CYG_HAL_TABLE_QUALIFIED_ENTRY(RedBoot_inits,_p_##_f_) = { _f_ };
|
CYG_HAL_TABLE_QUALIFIED_ENTRY(RedBoot_inits,_p_##_f_) = { _f_ };
|
#define RedBoot_init(_f_,_p_) _RedBoot_init(_f_,_p_)
|
#define RedBoot_init(_f_,_p_) _RedBoot_init(_f_,_p_)
|
|
|
// Main loop [idle] call-back functions
|
// Main loop [idle] call-back functions
|
#define RedBoot_IDLE_FIRST 0000
|
#define RedBoot_IDLE_FIRST 0000
|
#define RedBoot_IDLE_BEFORE_NETIO 3000
|
#define RedBoot_IDLE_BEFORE_NETIO 3000
|
#define RedBoot_IDLE_NETIO 5000
|
#define RedBoot_IDLE_NETIO 5000
|
#define RedBoot_IDLE_AFTER_NETIO 7000
|
#define RedBoot_IDLE_AFTER_NETIO 7000
|
#define RedBoot_IDLE_LAST 9999
|
#define RedBoot_IDLE_LAST 9999
|
typedef void idle_fun(bool);
|
typedef void idle_fun(bool);
|
typedef idle_fun *idle_fun_ptr;
|
typedef idle_fun *idle_fun_ptr;
|
struct idle_tab_entry {
|
struct idle_tab_entry {
|
idle_fun_ptr fun;
|
idle_fun_ptr fun;
|
} CYG_HAL_TABLE_TYPE;
|
} CYG_HAL_TABLE_TYPE;
|
#define _RedBoot_idle(_f_,_p_) \
|
#define _RedBoot_idle(_f_,_p_) \
|
struct idle_tab_entry _idle_tab_##_p_##_f_ \
|
struct idle_tab_entry _idle_tab_##_p_##_f_ \
|
CYG_HAL_TABLE_QUALIFIED_ENTRY(RedBoot_idle,_p_##_f_) = { _f_ };
|
CYG_HAL_TABLE_QUALIFIED_ENTRY(RedBoot_idle,_p_##_f_) = { _f_ };
|
#define RedBoot_idle(_f_,_p_) _RedBoot_idle(_f_,_p_)
|
#define RedBoot_idle(_f_,_p_) _RedBoot_idle(_f_,_p_)
|
|
|
// This function called when changing idle/not - mostly used by I/O
|
// This function called when changing idle/not - mostly used by I/O
|
// to support idle when timeout, etc.
|
// to support idle when timeout, etc.
|
void do_idle(bool state);
|
void do_idle(bool state);
|
|
|
// Option processing support
|
// Option processing support
|
|
|
struct option_info {
|
struct option_info {
|
char flag;
|
char flag;
|
bool takes_arg;
|
bool takes_arg;
|
int arg_type;
|
int arg_type;
|
void **arg;
|
void **arg;
|
bool *arg_set;
|
bool *arg_set;
|
char *name;
|
char *name;
|
};
|
};
|
|
|
#define OPTION_ARG_TYPE_NUM 0 // Numeric data
|
#define OPTION_ARG_TYPE_NUM 0 // Numeric data
|
#define OPTION_ARG_TYPE_STR 1 // Generic string
|
#define OPTION_ARG_TYPE_STR 1 // Generic string
|
#define OPTION_ARG_TYPE_FLG 2 // Flag only
|
#define OPTION_ARG_TYPE_FLG 2 // Flag only
|
|
|
// Command line parsing
|
// Command line parsing
|
externC struct cmd *parse(char **line, int *argc, char **argv);
|
externC struct cmd *parse(char **line, int *argc, char **argv);
|
|
|
externC void init_opts(struct option_info *opts, char flag, bool takes_arg,
|
externC void init_opts(struct option_info *opts, char flag, bool takes_arg,
|
int arg_type, void **arg, bool *arg_set, char *name);
|
int arg_type, void **arg, bool *arg_set, char *name);
|
externC bool scan_opts(int argc, char *argv[], int first,
|
externC bool scan_opts(int argc, char *argv[], int first,
|
struct option_info *opts, int num_opts,
|
struct option_info *opts, int num_opts,
|
void **def_arg, int def_arg_type, char *def_descr);
|
void **def_arg, int def_arg_type, char *def_descr);
|
|
|
#ifdef CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS
|
#ifdef CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS
|
#define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
|
#define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
|
(CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS+CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS)
|
(CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS+CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS)
|
#else
|
#else
|
#define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
|
#define CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS \
|
CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS
|
CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS
|
#endif
|
#endif
|
|
|
#ifdef CYGPKG_REDBOOT_NETWORKING
|
#ifdef CYGPKG_REDBOOT_NETWORKING
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
// DNS wrapper
|
// DNS wrapper
|
#ifdef CYGPKG_REDBOOT_NETWORKING_DNS
|
#ifdef CYGPKG_REDBOOT_NETWORKING_DNS
|
|
|
// I would really like if we could just pull in cyg/ns/dns/dns.h, but
|
// I would really like if we could just pull in cyg/ns/dns/dns.h, but
|
// that would require adding dummy <network.h> and <netinet/in.h> files.
|
// that would require adding dummy <network.h> and <netinet/in.h> files.
|
|
|
// Host name / IP mapping
|
// Host name / IP mapping
|
struct hostent {
|
struct hostent {
|
char *h_name; /* official name of host */
|
char *h_name; /* official name of host */
|
char **h_aliases; /* alias list */
|
char **h_aliases; /* alias list */
|
int h_addrtype; /* host address type */
|
int h_addrtype; /* host address type */
|
int h_length; /* length of address */
|
int h_length; /* length of address */
|
char **h_addr_list; /* list of addresses */
|
char **h_addr_list; /* list of addresses */
|
};
|
};
|
#define h_addr h_addr_list[0] /* for backward compatibility */
|
#define h_addr h_addr_list[0] /* for backward compatibility */
|
|
|
externC int redboot_dns_res_init(void);
|
externC int redboot_dns_res_init(void);
|
externC void set_dns(char* new_ip);
|
externC void set_dns(char* new_ip);
|
externC void show_dns(void);
|
externC void show_dns(void);
|
externC struct hostent *gethostbyname(const char *host);
|
externC struct hostent *gethostbyname(const char *host);
|
|
|
// Error reporting
|
// Error reporting
|
externC int h_errno;
|
externC int h_errno;
|
|
|
#define DNS_SUCCESS 0
|
#define DNS_SUCCESS 0
|
#define HOST_NOT_FOUND 1
|
#define HOST_NOT_FOUND 1
|
#define TRY_AGAIN 2
|
#define TRY_AGAIN 2
|
#define NO_RECOVERY 3
|
#define NO_RECOVERY 3
|
#define NO_DATA 4
|
#define NO_DATA 4
|
|
|
static inline bool
|
static inline bool
|
_gethostbyname(const char* name, in_addr_t* host)
|
_gethostbyname(const char* name, in_addr_t* host)
|
{
|
{
|
struct hostent* hent = gethostbyname(name);
|
struct hostent* hent = gethostbyname(name);
|
if (hent) {
|
if (hent) {
|
memcpy(host, hent->h_addr_list[0], sizeof(in_addr_t));
|
memcpy(host, hent->h_addr_list[0], sizeof(in_addr_t));
|
return true;
|
return true;
|
}
|
}
|
// Fall back to inet_aton - gethostbyname may already have tried
|
// Fall back to inet_aton - gethostbyname may already have tried
|
// it, but we can't know for sure (the DNS IP may not have been
|
// it, but we can't know for sure (the DNS IP may not have been
|
// valid, preventing the inet_aton).
|
// valid, preventing the inet_aton).
|
return inet_aton(name, host);
|
return inet_aton(name, host);
|
}
|
}
|
#else
|
#else
|
static inline bool
|
static inline bool
|
_gethostbyname(const char* name, in_addr_t* host)
|
_gethostbyname(const char* name, in_addr_t* host)
|
{
|
{
|
return inet_aton(name, host);
|
return inet_aton(name, host);
|
}
|
}
|
#endif // CYGPKG_REDBOOT_NETWORKING_DNS
|
#endif // CYGPKG_REDBOOT_NETWORKING_DNS
|
#endif // CYGPKG_REDBOOT_NETWORKING
|
#endif // CYGPKG_REDBOOT_NETWORKING
|
|
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
// String functions. Some of these are duplicates of the same functions in
|
// String functions. Some of these are duplicates of the same functions in
|
// the I18N package.
|
// the I18N package.
|
|
|
// Validate a hex character
|
// Validate a hex character
|
__inline__ static bool
|
__inline__ static bool
|
_is_hex(char c)
|
_is_hex(char c)
|
{
|
{
|
return (((c >= '0') && (c <= '9')) ||
|
return (((c >= '0') && (c <= '9')) ||
|
((c >= 'A') && (c <= 'F')) ||
|
((c >= 'A') && (c <= 'F')) ||
|
((c >= 'a') && (c <= 'f')));
|
((c >= 'a') && (c <= 'f')));
|
}
|
}
|
|
|
// Convert a single hex nibble
|
// Convert a single hex nibble
|
__inline__ static int
|
__inline__ static int
|
_from_hex(char c)
|
_from_hex(char c)
|
{
|
{
|
int ret = 0;
|
int ret = 0;
|
|
|
if ((c >= '0') && (c <= '9')) {
|
if ((c >= '0') && (c <= '9')) {
|
ret = (c - '0');
|
ret = (c - '0');
|
} else if ((c >= 'a') && (c <= 'f')) {
|
} else if ((c >= 'a') && (c <= 'f')) {
|
ret = (c - 'a' + 0x0a);
|
ret = (c - 'a' + 0x0a);
|
} else if ((c >= 'A') && (c <= 'F')) {
|
} else if ((c >= 'A') && (c <= 'F')) {
|
ret = (c - 'A' + 0x0A);
|
ret = (c - 'A' + 0x0A);
|
}
|
}
|
return ret;
|
return ret;
|
}
|
}
|
|
|
// Convert a character to lower case
|
// Convert a character to lower case
|
__inline__ static char
|
__inline__ static char
|
_tolower(char c)
|
_tolower(char c)
|
{
|
{
|
if ((c >= 'A') && (c <= 'Z')) {
|
if ((c >= 'A') && (c <= 'Z')) {
|
c = (c - 'A') + 'a';
|
c = (c - 'A') + 'a';
|
}
|
}
|
return c;
|
return c;
|
}
|
}
|
|
|
// Validate alpha
|
// Validate alpha
|
__inline__ static bool
|
__inline__ static bool
|
isalpha(int c)
|
isalpha(int c)
|
{
|
{
|
return (((c >= 'a') && (c <= 'z')) ||
|
return (((c >= 'a') && (c <= 'z')) ||
|
((c >= 'A') && (c <= 'Z')));
|
((c >= 'A') && (c <= 'Z')));
|
}
|
}
|
|
|
// Validate digit
|
// Validate digit
|
__inline__ static bool
|
__inline__ static bool
|
isdigit(int c)
|
isdigit(int c)
|
{
|
{
|
return ((c >= '0') && (c <= '9'));
|
return ((c >= '0') && (c <= '9'));
|
}
|
}
|
|
|
// Validate alphanum
|
// Validate alphanum
|
__inline__ static bool
|
__inline__ static bool
|
isalnum(int c)
|
isalnum(int c)
|
{
|
{
|
return (isalpha(c) || isdigit(c));
|
return (isalpha(c) || isdigit(c));
|
}
|
}
|
|
|
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
// syscall values
|
// syscall values
|
#if defined(CYGSEM_REDBOOT_BSP_SYSCALLS)
|
#if defined(CYGSEM_REDBOOT_BSP_SYSCALLS)
|
|
|
// These are required by the ANSI C part of newlib (excluding system() of
|
// These are required by the ANSI C part of newlib (excluding system() of
|
// course).
|
// course).
|
#define SYS_exit 1
|
#define SYS_exit 1
|
#define SYS_open 2
|
#define SYS_open 2
|
#define SYS_close 3
|
#define SYS_close 3
|
#define SYS_read 4
|
#define SYS_read 4
|
#define SYS_write 5
|
#define SYS_write 5
|
#define SYS_lseek 6
|
#define SYS_lseek 6
|
#define SYS_unlink 7
|
#define SYS_unlink 7
|
#define SYS_getpid 8
|
#define SYS_getpid 8
|
#define SYS_kill 9
|
#define SYS_kill 9
|
#define SYS_fstat 10
|
#define SYS_fstat 10
|
//#define SYS_sbrk 11 - not currently a system call, but reserved.
|
//#define SYS_sbrk 11 - not currently a system call, but reserved.
|
|
|
// ARGV support.
|
// ARGV support.
|
#define SYS_argvlen 12
|
#define SYS_argvlen 12
|
#define SYS_argv 13
|
#define SYS_argv 13
|
|
|
// These are extras added for one reason or another.
|
// These are extras added for one reason or another.
|
#define SYS_chdir 14
|
#define SYS_chdir 14
|
#define SYS_stat 15
|
#define SYS_stat 15
|
#define SYS_chmod 16
|
#define SYS_chmod 16
|
#define SYS_utime 17
|
#define SYS_utime 17
|
#define SYS_time 18
|
#define SYS_time 18
|
#define SYS_gettimeofday 19
|
#define SYS_gettimeofday 19
|
#define SYS_times 20
|
#define SYS_times 20
|
|
|
#define SYS_interrupt 1000
|
#define SYS_interrupt 1000
|
#define SYS_meminfo 1001
|
#define SYS_meminfo 1001
|
|
|
#define __GET_SHARED 0xbaad // 47789 decimal
|
#define __GET_SHARED 0xbaad // 47789 decimal
|
|
|
#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
|
#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
|
|
|
#define SYS_timer_call_back 2001
|
#define SYS_timer_call_back 2001
|
#define SYS_timer_frequency 2002
|
#define SYS_timer_frequency 2002
|
#define SYS_timer_reset 2003
|
#define SYS_timer_reset 2003
|
|
|
#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
|
#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
|
#define SYS_rename 3001
|
#define SYS_rename 3001
|
#define SYS_isatty 3002
|
#define SYS_isatty 3002
|
#define SYS_system 3003
|
#define SYS_system 3003
|
|
|
#endif // CYGSEM_REDBOOT_BSP_SYSCALLS
|
#endif // CYGSEM_REDBOOT_BSP_SYSCALLS
|
|
|
#endif // _REDBOOT_H_
|
#endif // _REDBOOT_H_
|
|
|