--- ./src/host/common/Makefile.orig 2006-01-16 17:36:48.000000000 +0000 +++ ./src/host/common/Makefile 2006-01-16 17:36:58.000000000 +0000 @@ -10,7 +10,7 @@ # Suggested CFLAGS for optimization: #CFLAGS :=-Wall -O2 -fomit-frame-pointer -fstrength-reduce -SRCS := crc.c download.c eth.c ethutil.c flash.c main.c memmap.c \ +SRCS := crc.c download.c ethutil.c flash.c main.c memmap.c \ options.c region.c serial.c target.c util.c console.c OBJS := $(SRCS:.c=.o) DEPS := $(SRCS:.c=.d) @@ -62,5 +62,5 @@ rm -f $(DEPS) .PHONY: distclean distclean: scrub - rm -f *~ \ No newline at end of file + rm -f *~ --- ./src/host/common/serial.c.orig 2006-01-16 17:38:06.000000000 +0000 +++ ./src/host/common/serial.c 2006-01-16 19:34:44.000000000 +0000 @@ -51,7 +51,11 @@ /* open serial port */ #ifndef WIN32 +#if defined(__NetBSD__) + if ((portfd = open(portname, O_RDWR|O_NOCTTY|O_NONBLOCK)) < 0) +#else if ((portfd = open(portname, O_RDWR|O_NOCTTY)) < 0) +#endif perror_xe("open serial port"); #else if ((portfd = CreateFile(portname, GENERIC_READ|GENERIC_WRITE, @@ -67,7 +71,11 @@ /* configure new values */ cfmakeraw(&newtios); /* see man page */ newtios.c_iflag |= IGNPAR; /* ignore parity on input */ +#if defined(__NetBSD__) + newtios.c_oflag &= ~(OPOST|ONLCR|OCRNL|ONOCR|ONLRET); +#else newtios.c_oflag &= ~(OPOST|ONLCR|OLCUC|OCRNL|ONOCR|ONLRET|OFILL); +#endif newtios.c_cflag = CS8|CLOCAL|CREAD; newtios.c_cc[VMIN] = 1; /* block until 1 char received */ newtios.c_cc[VTIME] = 0; /* no inter-character timer */ @@ -89,7 +97,14 @@ saved_portfd = portfd; tcflush(portfd, TCIFLUSH); tcsetattr(portfd, TCSADRAIN, &newtios); +#if defined(__NetBSD__) + portfd = open(portname, O_RDWR|O_NOCTTY); + if ( portfd>=0 ){ + close(saved_portfd); + saved_portfd = portfd; + } +#endif #else timeouts.ReadIntervalTimeout = 0; timeouts.ReadTotalTimeoutMultiplier = 10; --- ./src/host/common/main.c.orig 2006-01-16 17:43:00.000000000 +0000 +++ ./src/host/common/main.c 2006-01-16 19:41:07.000000000 +0000 @@ -71,12 +71,13 @@ mem_map_read(tc); } flags |= REQ_MEM_MAP; - +#if !defined(__NetBSD__) } else if (flags & REQ_LOCAL_MAC) { const char zeroes [6] = { 0, }; assert(opt_ethernet); assert(memcmp(tc->local_mac, zeroes, 6)); flags |= REQ_LOCAL_MAC; +#endif } /* XXX need to handle more than one request! */ @@ -110,22 +111,26 @@ /* open raw ethernet socket if desired, then drop root */ #if !defined(WIN32) +#if !defined(__NetBSD__) if (opt_ethernet) eth_raw_socket(); #endif +#endif drop_root(); /* miscellaneous initialization */ init_crc32(); - /* open a connection to the target */ +#if !defined(__NetBSD__) + if (!(tc = target_open(opt_port, NULL))){ +#else if (!(tc = target_open(opt_port, opt_ethernet ? opt_netif : NULL))){ +#endif panic("couldn't open connection to target"); return -1; } - while (cmd) { command_t *tmp; --- ./src/host/common/target.c.orig 2006-01-16 17:49:44.000000000 +0000 +++ ./src/host/common/target.c 2006-01-16 20:15:01.000000000 +0000 @@ -65,9 +65,11 @@ #endif #ifndef WIN32 +#if !defined(__NetBSD__) static void target_write_ethernet(target_context_t *tc, const void *data, size_t count); #endif +#endif static void target_write_serial(target_context_t *tc, const void *data, size_t count); @@ -98,9 +100,11 @@ #endif #ifndef WIN32 +#if !defined(__NetBSD__) if (netif && (eth_open(tc, netif) < 0)) goto failure; #endif +#endif return tc; failure: @@ -245,8 +249,10 @@ if (!strcmp(medium, TM_ETHERNET)) { tc->mtu = ETHERNET_MTU; #ifndef WIN32 +#if !defined(__NetBSD__) tc->write = target_write_ethernet; #endif +#endif } else if (!strcmp(medium, TM_SERIAL)) { tc->mtu = SERIAL_MTU; tc->write = target_write_serial; @@ -467,6 +473,7 @@ } #ifndef WIN32 +#if !defined(__NetBSD__) static void target_write_ethernet(target_context_t *tc, const void *data, size_t count) { @@ -487,7 +494,8 @@ } } #endif +#endif static void target_write_serial(target_context_t *tc, const void *data, size_t count) --- ./src/host/common/options.c.orig 2006-01-16 17:55:02.000000000 +0000 +++ ./src/host/common/options.c 2006-01-16 17:58:03.000000000 +0000 @@ -32,7 +32,11 @@ const char *opt_memory_map_path; const char *opt_netif = "eth0"; +#if defined(__NetBSD__) +const char *opt_port = "/dev/tty00"; +#else const char *opt_port = "/dev/ttyS0"; +#endif const char *opt_remote_mac; unsigned char opt_remote_mac_bytes [6]; @@ -270,11 +274,19 @@ #endif "Multiple commands may be given.\n" "General options (defaults) [environment]:\n" +#if !defined(__NetBSD__) " -e, --ethernet\n" +#endif " -i, --input-file \n" +#if !defined(__NetBSD__) " --netif (eth0) [HERMIT_NETIF]\n" +#endif " --memory-map \n" +#if !defined(__NetBSD__) + " --port (/dev/tty00) [HERMIT_PORT]\n" +#else " --port (/dev/ttyS0) [HERMIT_PORT]\n" +#endif " -o, --output-file \n" " --remote-mac \n" " -v, --verbose\n"