diff -urN hermit-at-1.0.2.orig/src/host/common/Makefile hermit-at-1.0.2/src/host/common/Makefile --- hermit-at-1.0.2.orig/src/host/common/Makefile 2005-11-24 15:22:14.000000000 +0900 +++ hermit-at-1.0.2/src/host/common/Makefile 2007-11-18 16:20:22.000000000 +0900 @@ -6,11 +6,11 @@ # uncomment the followiing line CFLAGS_EXTRA := -DAJ_FIRMUPDATE_SUPPORT -CFLAGS := -Wall -g -I../../../include $(CFLAGS_EXTRA) -D_CONSOLE +CFLAGS := -Wall -g -I../../../include $(CFLAGS_EXTRA) -D_CONSOLE -DMACOSX # 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,4 +62,4 @@ rm -f $(DEPS) .PHONY: distclean distclean: scrub - rm -f *~ \ No newline at end of file + rm -f *~ diff -urN hermit-at-1.0.2.orig/src/host/common/download.c hermit-at-1.0.2/src/host/common/download.c --- hermit-at-1.0.2.orig/src/host/common/download.c 2005-12-02 20:58:19.000000000 +0900 +++ hermit-at-1.0.2/src/host/common/download.c 2007-11-18 16:23:20.000000000 +0900 @@ -241,8 +241,13 @@ offset = addr - mr->vma; nbytes = download_data(tc, src->data, remain, mr, offset); if (!nbytes) { +#ifndef MACOSX warn("download_to_addr: no data downloaded\n"); +#else + warnq("download_to_addr: no data downloaded\n"); +#endif return -1; + } addr += nbytes; remain -= nbytes; @@ -274,7 +279,11 @@ } ret = download_data(tc, src->data, src->size, mr, 0); if(ret == 0){ - warn("download_to_region: no data downloaded\n"); +#ifndef MACOSX + warn("download_to_region: no data downloaded\n"); +#else + warnq("download_to_region: no data downloaded\n"); +#endif return -1; }else if(ret == -1){ return -1; @@ -425,7 +434,11 @@ return -1; } if (!firmupdate_data(tc, src->data, src->size, mr, 0)) { - warn("download_to_region: no data downloaded\n"); +#ifndef MACOSX + warn("download_to_region: no data downloaded\n"); +#else + warnq("download_to_region: no data downloaded\n"); +#endif return -1; } return 0; diff -urN hermit-at-1.0.2.orig/src/host/common/main.c hermit-at-1.0.2/src/host/common/main.c --- hermit-at-1.0.2.orig/src/host/common/main.c 2005-12-02 21:01:42.000000000 +0900 +++ hermit-at-1.0.2/src/host/common/main.c 2007-11-18 16:45:02.000000000 +0900 @@ -71,12 +71,13 @@ mem_map_read(tc); } flags |= REQ_MEM_MAP; - +#ifndef MACOSX } 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,9 +111,11 @@ /* open raw ethernet socket if desired, then drop root */ #if !defined(WIN32) +#ifndef MACOSX if (opt_ethernet) eth_raw_socket(); #endif +#endif drop_root(); /* miscellaneous initialization */ @@ -120,7 +123,11 @@ init_crc32(); /* open a connection to the target */ +#ifndef MACOSX if (!(tc = target_open(opt_port, opt_ethernet ? opt_netif : NULL))){ +#else + if (!(tc = target_open(opt_port, NULL))){ +#endif panic("couldn't open connection to target"); return -1; } @@ -158,7 +165,11 @@ else if (cmd->info.download.have_address) download_to_addr(tc, mr, cmd->addr); else{ +#ifndef MACOSX warn("download: must specify address or region\n"); +#else + warnq("download: must specify address or region\n"); +#endif return -1; } break; @@ -180,7 +191,11 @@ return 0; default: +#ifndef MACOSX warn("unsupported command\n"); +#else + warnq("unsupported command\n"); +#endif return -1; } diff -urN hermit-at-1.0.2.orig/src/host/common/options.c hermit-at-1.0.2/src/host/common/options.c --- hermit-at-1.0.2.orig/src/host/common/options.c 2005-12-02 20:41:17.000000000 +0900 +++ hermit-at-1.0.2/src/host/common/options.c 2007-11-18 16:32:05.000000000 +0900 @@ -32,7 +32,11 @@ const char *opt_memory_map_path; const char *opt_netif = "eth0"; +#ifndef MACOSX const char *opt_port = "/dev/ttyS0"; +#else +const char *opt_port = "/dev/cu.usbserial"; +#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" +#ifndef MACOSX " -e, --ethernet\n" +#endif " -i, --input-file \n" +#ifndef MACOSX " --netif (eth0) [HERMIT_NETIF]\n" +#endif " --memory-map \n" +#ifndef MACOSX " --port (/dev/ttyS0) [HERMIT_PORT]\n" +#else + " --port (/dev/cu.usbserial) [HERMIT_PORT]\n" +#endif " -o, --output-file \n" " --remote-mac \n" " -v, --verbose\n" diff -urN hermit-at-1.0.2.orig/src/host/common/serial.c hermit-at-1.0.2/src/host/common/serial.c --- hermit-at-1.0.2.orig/src/host/common/serial.c 2005-11-24 15:22:14.000000000 +0900 +++ hermit-at-1.0.2/src/host/common/serial.c 2007-11-18 16:35:03.000000000 +0900 @@ -51,7 +51,11 @@ /* open serial port */ #ifndef WIN32 +#ifndef MACOSX if ((portfd = open(portname, O_RDWR|O_NOCTTY)) < 0) +#else + if ((portfd = open(portname, O_RDWR|O_NOCTTY|O_NONBLOCK)) < 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 */ - newtios.c_oflag &= ~(OPOST|ONLCR|OLCUC|OCRNL|ONOCR|ONLRET|OFILL); +#ifndef MACOSX + newtios.c_oflag &= ~(OPOST|ONLCR|OLCUC|OCRNL|ONOCR|ONLRET|OFILL); +#else + newtios.c_oflag &= ~(OPOST|ONLCR|OCRNL|ONOCR|ONLRET); +#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,6 +97,14 @@ saved_portfd = portfd; tcflush(portfd, TCIFLUSH); tcsetattr(portfd, TCSADRAIN, &newtios); + +#ifdef MACOSX + portfd = open(portname, O_RDWR|O_NOCTTY); + if ( portfd>=0 ){ + close(saved_portfd); + saved_portfd = portfd; + } +#endif #else timeouts.ReadIntervalTimeout = 0; timeouts.ReadTotalTimeoutMultiplier = 10; diff -urN hermit-at-1.0.2.orig/src/host/common/target.c hermit-at-1.0.2/src/host/common/target.c --- hermit-at-1.0.2.orig/src/host/common/target.c 2005-12-02 21:02:16.000000000 +0900 +++ hermit-at-1.0.2/src/host/common/target.c 2007-11-18 16:41:09.000000000 +0900 @@ -65,9 +65,11 @@ #endif #ifndef WIN32 +#ifndef MACOSX 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 +#ifndef MACOSX if (netif && (eth_open(tc, netif) < 0)) goto failure; #endif +#endif return tc; failure: @@ -129,6 +133,7 @@ } #if !defined(WIN32) +#ifndef MACOSX /* switch to ethernet if possible and desired */ if (opt_ethernet){ if(target_set_medium(tc, "ethernet") == -1){ @@ -136,6 +141,7 @@ } } #endif +#endif return 0; } @@ -245,8 +251,10 @@ if (!strcmp(medium, TM_ETHERNET)) { tc->mtu = ETHERNET_MTU; #ifndef WIN32 +#ifndef MACOSX tc->write = target_write_ethernet; #endif +#endif } else if (!strcmp(medium, TM_SERIAL)) { tc->mtu = SERIAL_MTU; tc->write = target_write_serial; @@ -281,7 +289,11 @@ break; case 0: #ifndef WIN32 +#ifndef MACOSX warn("target didn't respond with +OK or -NG\n"); +#else + warnq("target didn't respond with +OK or -NG\n"); +#endif warnf("unknown response `%s'\n", buf); #endif return -1; @@ -467,6 +479,7 @@ } #ifndef WIN32 +#ifndef MACOSX static void target_write_ethernet(target_context_t *tc, const void *data, size_t count) { @@ -487,6 +500,7 @@ } } #endif +#endif static void target_write_serial(target_context_t *tc, const void *data, size_t count) diff -urN hermit-at-1.0.2.orig/src/host/common/util.c hermit-at-1.0.2/src/host/common/util.c --- hermit-at-1.0.2.orig/src/host/common/util.c 2005-11-24 15:22:14.000000000 +0900 +++ hermit-at-1.0.2/src/host/common/util.c 2007-11-18 16:30:33.000000000 +0900 @@ -127,7 +127,11 @@ #endif } +#ifndef MACOSX int warn(const char *message) +#else +int warnq(const char *message) +#endif { char str[1024];