| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- #ifndef _ARCH_UNIX_H_
- #define _ARCH_UNIX_H_
- /*
- * Copyright (C) 2000-2004 by ETH Zurich
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holders nor the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY ETH ZURICH AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ETH ZURICH
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * For additional information see http://www.ethernut.de/
- *
- */
- /*
- * unix.h.c - types and defines for unix emulation
- *
- * 2004.04.01 Matthias Ringwald <matthias.ringwald@inf.ethz.ch>
- *
- */
- #if !defined(__linux__) && !defined(__APPLE__) && !defined(__CYGWIN__)
- #error "Nut/OS emulation currently runs only on Linux and MAC OS X systems."
- #endif
- /* -------------------------------------------------------------------------
- * map some AVR types/defines to something else
- * ------------------------------------------------------------------------- */
- #define CONST const
- #define INLINE inline
- #define PSTR(p) (p)
- #define PRG_RDB(p) (*((const char *)(p)))
- #define prog_char const char
- #define PGM_P prog_char *
- /* -------------------------------------------------------------------------
- * now we can include types (and time.h)
- * ------------------------------------------------------------------------- */
- #include <sys/types.h>
- #include <dev/mweeprom.h>
- #include <termios.h>
- #include <unistd_orig.h>
- /* -------------------------------------------------------------------------
- * redefine main
- * ------------------------------------------------------------------------- */
- #define main(...) NutAppMain(__VA_ARGS__)
- /* -------------------------------------------------------------------------
- * map harvard specific calls to normal ones
- * ------------------------------------------------------------------------- */
- #define strlen_P(x) strlen(x)
- #define strcpy_P(x,y) strcpy(x,y)
- #define strcmp_P(x, y) strcmp(x, y)
- #define memcpy_P(x, y, z) memcpy(x, y, z)
- /* -------------------------------------------------------------------------
- * emulated IRQs
- * ------------------------------------------------------------------------- */
- enum {
- IRQ_TIMER0,
- IRQ_UART0_RX,
- IRQ_UART1_RX,
- IRQ_UART2_RX,
- IRQ_MAX
- };
- /* -------------------------------------------------------------------------
- * emulated heap
- * ------------------------------------------------------------------------- */
- /* RAMSTART could be zero, but RAMSTART < 3 leads to a crash in freopen (stdout) */
- #define RAMSTART ((void *)0x00100)
- /* on linux our malloc function makes the init section crash, so we better rename it */
- #define malloc(...) NUT_malloc(__VA_ARGS__)
- #define free(...) NUT_free(__VA_ARGS__)
- /* -------------------------------------------------------------------------
- * parsing of command line options
- * ------------------------------------------------------------------------- */
- /*
- * options of one uart
- * usbnum: a negative usbnum is used to indicate that device name is used
- */
- typedef struct {
- char *device;
- u_long bautrate;
- u_char flowcontrol;
- signed char usbnum;
- } uart_options_t;
- /*
- * all command line options
- */
- typedef struct {
- // debug output
- int verbose;
- uart_options_t uart_options[3];
- struct termios saved_termios;
- } emulation_options_t;
- /* the command line options are stored here */
- extern emulation_options_t emulation_options;
- /* -------------------------------------------------------------------------
- * function declarations
- * ------------------------------------------------------------------------- */
- void emulation_options_parse(int argc, char *argv[]);
- /** \name Backwards compatibility defines */
- #define eeprom_rb(addr) eeprom_read_byte ((u_char *)(u_long) (addr))
- #define eeprom_rw(addr) eeprom_read_word ((u_short *)(u_long) (addr))
- #define eeprom_wb(addr, val) eeprom_write_byte ((u_char *)(u_long) (addr), (val))
- // fake ATmega128 has 0xfff eeprom
- #define E2END 0x0FFF
- /** \def eeprom_is_ready
- \ingroup unix_eeprom
- always returns 1, as eeprom = unix_file is always ready */
- #define eeprom_is_ready() TRUE
- #endif /* #ifndef _CPU_UNIX_H_ */
|