diff --git a/src/devices/disk/zip.c b/src/devices/disk/zip.c index 0195135..a258a07 100644 --- a/src/devices/disk/zip.c +++ b/src/devices/disk/zip.c @@ -9,7 +9,7 @@ * Implementation of the Iomega ZIP drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)zip.c 1.0.24 2018/10/27 + * Version: @(#)zip.c 1.0.25 2018/11/02 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -2106,6 +2106,11 @@ phase_data_out(zip_t *dev) pos = hdr_len + block_desc_len; while(1) { + if (pos >= dev->current_cdb[4]) { + DEBUG("ZIP %i: Buffer has only block descriptor\n", dev->id); + break; + } + page = dev->buffer[pos] & 0x3F; page_len = dev->buffer[pos + 1]; diff --git a/src/devices/input/keyboard_xt.c b/src/devices/input/keyboard_xt.c index d346c0e..1213900 100644 --- a/src/devices/input/keyboard_xt.c +++ b/src/devices/input/keyboard_xt.c @@ -8,7 +8,7 @@ * * Implementation of the XT-style keyboard. * - * Version: @(#)keyboard_xt.c 1.0.8 2018/10/05 + * Version: @(#)keyboard_xt.c 1.0.9 2018/11/02 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -424,7 +424,7 @@ kbd_adddata_process(uint16_t val, void (*adddata)(uint16_t val)) } -void +static void kbd_adddata_ex(uint16_t val) { kbd_adddata_process(val, kbd_adddata); diff --git a/src/devices/network/net_pcap.c b/src/devices/network/net_pcap.c index e30ce93..48d9122 100644 --- a/src/devices/network/net_pcap.c +++ b/src/devices/network/net_pcap.c @@ -8,7 +8,7 @@ * * Handle WinPcap library processing. * - * Version: @(#)net_pcap.c 1.0.7 2018/10/05 + * Version: @(#)net_pcap.c 1.0.8 2018/10/28 * * Author: Fred N. van Kempen, * @@ -53,9 +53,6 @@ # define WIN32 #endif #include -#ifdef ERROR -# undef ERROR -#endif #define dbglog network_log #include "../../emu.h" #include "../../device.h" @@ -63,6 +60,13 @@ #include "network.h" +#ifdef _WIN32 +# define PCAP_DLL_PATH "wpcap.dll" +#else +# define PCAP_DLL_PATH "libpcap.so" +#endif + + static volatile void *pcap_handle; /* handle to WinPcap DLL */ static volatile pcap_t *pcap; /* handle to WinPcap library */ static volatile thread_t *poll_tid; @@ -71,26 +75,26 @@ static event_t *poll_state; /* Pointers to the real functions. */ -static char *const (*f_pcap_lib_version)(void); -static int (*f_pcap_findalldevs)(pcap_if_t **,char *); -static void (*f_pcap_freealldevs)(pcap_if_t *); -static pcap_t *(*f_pcap_open_live)(const char *,int,int,int,char *); -static int (*f_pcap_compile)(pcap_t *,struct bpf_program *, +static char *const (*PCAP_lib_version)(void); +static int (*PCAP_findalldevs)(pcap_if_t **,char *); +static void (*PCAP_freealldevs)(pcap_if_t *); +static pcap_t *(*PCAP_open_live)(const char *,int,int,int,char *); +static int (*PCAP_compile)(pcap_t *,struct bpf_program *, const char *,int,bpf_u_int32); -static int (*f_pcap_setfilter)(pcap_t *,struct bpf_program *); -static u_char *const (*f_pcap_next)(pcap_t *,struct pcap_pkthdr *); -static int (*f_pcap_sendpacket)(pcap_t *,const u_char *,int); -static void (*f_pcap_close)(pcap_t *); +static int (*PCAP_setfilter)(pcap_t *,struct bpf_program *); +static u_char *const (*PCAP_next)(pcap_t *,struct pcap_pkthdr *); +static int (*PCAP_sendpacket)(pcap_t *,const u_char *,int); +static void (*PCAP_close)(pcap_t *); static const dllimp_t pcap_imports[] = { - { "pcap_lib_version", &f_pcap_lib_version }, - { "pcap_findalldevs", &f_pcap_findalldevs }, - { "pcap_freealldevs", &f_pcap_freealldevs }, - { "pcap_open_live", &f_pcap_open_live }, - { "pcap_compile", &f_pcap_compile }, - { "pcap_setfilter", &f_pcap_setfilter }, - { "pcap_next", &f_pcap_next }, - { "pcap_sendpacket", &f_pcap_sendpacket }, - { "pcap_close", &f_pcap_close }, + { "pcap_lib_version", &PCAP_lib_version }, + { "pcap_findalldevs", &PCAP_findalldevs }, + { "pcap_freealldevs", &PCAP_freealldevs }, + { "pcap_open_live", &PCAP_open_live }, + { "pcap_compile", &PCAP_compile }, + { "pcap_setfilter", &PCAP_setfilter }, + { "pcap_next", &PCAP_next }, + { "pcap_sendpacket", &PCAP_sendpacket }, + { "pcap_close", &PCAP_close }, { NULL, NULL }, }; @@ -123,7 +127,7 @@ poll_thread(void *arg) if (pcap == NULL) break; /* Wait for the next packet to arrive. */ - data = (uint8_t *)f_pcap_next((pcap_t *)pcap, &h); + data = (uint8_t *)PCAP_next((pcap_t *)pcap, &h); if (data != NULL) { /* Received MAC. */ mac_cmp32[0] = *(uint32_t *)(data+6); @@ -177,15 +181,11 @@ net_pcap_prepare(netdev_t *list) pcap = NULL; /* Try loading the DLL. */ -#ifdef _WIN32 - pcap_handle = dynld_module("wpcap.dll", pcap_imports); -#else - pcap_handle = dynld_module("libpcap.so", pcap_imports); -#endif + pcap_handle = dynld_module(PCAP_DLL_PATH, pcap_imports); if (pcap_handle == NULL) return(-1); /* Retrieve the device list from the local machine */ - if (f_pcap_findalldevs(&devlist, errbuf) == -1) { + if (PCAP_findalldevs(&devlist, errbuf) == -1) { ERRLOG("PCAP: error in pcap_findalldevs: %s\n", errbuf); return(-1); } @@ -200,7 +200,7 @@ net_pcap_prepare(netdev_t *list) } /* Release the memory. */ - f_pcap_freealldevs(devlist); + PCAP_freealldevs(devlist); return(i); } @@ -223,7 +223,7 @@ net_pcap_init(void) if (pcap_handle == NULL) return(-1); /* Get the PCAP library name and version. */ - strcpy(errbuf, f_pcap_lib_version()); + strcpy(errbuf, PCAP_lib_version()); str = strchr(errbuf, '('); if (str != NULL) *(str-1) = '\0'; INFO("PCAP: initializing, %s\n", errbuf); @@ -271,7 +271,7 @@ net_pcap_close(void) } /* OK, now shut down Pcap itself. */ - f_pcap_close(pc); + PCAP_close(pc); pcap = NULL; INFO("PCAP: closed.\n"); @@ -297,11 +297,11 @@ net_pcap_reset(const netcard_t *card, uint8_t *mac) struct bpf_program fp; /* Open a PCAP live channel. */ - if ((pcap = f_pcap_open_live(network_host, /* interface name */ - 1518, /* max packet size */ - 1, /* promiscuous mode? */ - 10, /* timeout in msec */ - errbuf)) == NULL) { /* error buffer */ + if ((pcap = PCAP_open_live(network_host, /* interface name */ + 1518, /* max packet size */ + 1, /* promiscuous mode? */ + 10, /* timeout in msec */ + errbuf)) == NULL) { /* error buffer */ ERRLOG(" Unable to open device: %s!\n", network_host); return(-1); } @@ -314,15 +314,15 @@ net_pcap_reset(const netcard_t *card, uint8_t *mac) "( ((ether dst ff:ff:ff:ff:ff:ff) or (ether dst %02x:%02x:%02x:%02x:%02x:%02x)) and not (ether src %02x:%02x:%02x:%02x:%02x:%02x) )", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - if (f_pcap_compile((pcap_t *)pcap, &fp, filter_exp, 0, 0xffffffff) != -1) { - if (f_pcap_setfilter((pcap_t *)pcap, &fp) != 0) { + if (PCAP_compile((pcap_t *)pcap, &fp, filter_exp, 0, 0xffffffff) != -1) { + if (PCAP_setfilter((pcap_t *)pcap, &fp) != 0) { ERRLOG("PCAP: error installing filter (%s) !\n", filter_exp); - f_pcap_close((pcap_t *)pcap); + PCAP_close((pcap_t *)pcap); return(-1); } } else { ERRLOG("PCAP: could not compile filter (%s) !\n", filter_exp); - f_pcap_close((pcap_t *)pcap); + PCAP_close((pcap_t *)pcap); return(-1); } @@ -345,7 +345,7 @@ net_pcap_in(uint8_t *bufp, int len) network_busy(1); - f_pcap_sendpacket((pcap_t *)pcap, bufp, len); + PCAP_sendpacket((pcap_t *)pcap, bufp, len); network_busy(0); } diff --git a/src/devices/network/network.c b/src/devices/network/network.c index 16736cf..9888015 100644 --- a/src/devices/network/network.c +++ b/src/devices/network/network.c @@ -54,7 +54,7 @@ #include #include #include -#ifdef ENABLE_NETWORK_DUMP +#ifdef _DEBUG # include #endif #define HAVE_STDARG_H @@ -112,12 +112,12 @@ static struct { } poll_data; -#ifdef ENABLE_NETWORK_DUMP +#ifdef _DEBUG # define is_print(c) (isalnum((int)(c)) || ((c) == ' ')) /* Dump a buffer in hex to output buffer. */ -static void +void hexdump_p(char *ptr, uint8_t *bufp, int len) { char asci[20]; diff --git a/src/devices/network/slirp/VERSION.txt b/src/devices/network/slirp/VERSION.txt deleted file mode 100644 index 0dd1c2b..0000000 --- a/src/devices/network/slirp/VERSION.txt +++ /dev/null @@ -1 +0,0 @@ -qemu 0.9.0 (2007/02/05) \ No newline at end of file diff --git a/src/devices/network/slirp/slirp_config.h b/src/devices/network/slirp/slirp_config.h deleted file mode 100644 index 7d775a0..0000000 --- a/src/devices/network/slirp/slirp_config.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * User definable configuration options - */ - -/* Undefine if you don't want talk emulation */ -#undef EMULATE_TALK - -/* Define if you want the connection to be probed */ -/* XXX Not working yet, so ignore this for now */ -#undef PROBE_CONN - -/* Define to 1 if you want KEEPALIVE timers */ -#define DO_KEEPALIVE 0 - -/* Define to MAX interfaces you expect to use at once */ -/* MAX_INTERFACES determines the max. TOTAL number of interfaces (SLIP and PPP) */ -/* MAX_PPP_INTERFACES determines max. number of PPP interfaces */ -#define MAX_INTERFACES 1 -#define MAX_PPP_INTERFACES 1 - -/* Define if you want slirp's socket in /tmp */ -/* XXXXXX Do this in ./configure */ -#undef USE_TMPSOCKET - -/* Define if you want slirp to use cfsetXspeed() on the terminal */ -#undef DO_CFSETSPEED - -/* Define this if you want slirp to write to the tty as fast as it can */ -/* This should only be set if you are using load-balancing, slirp does a */ -/* pretty good job on single modems already, and seting this will make */ -/* interactive sessions less responsive */ -/* XXXXX Talk about having fast modem as unit 0 */ -#undef FULL_BOLT - -/* - * Define if you want slirp to use less CPU - * You will notice a small lag in interactive sessions, but it's not that bad - * Things like Netscape/ftp/etc. are completely unaffected - * This is mainly for sysadmins who have many slirp users - */ -#undef USE_LOWCPU - -/* Define this if your compiler doesn't like prototypes */ -#ifndef __STDC__ -#define NO_PROTOTYPES -#endif - -/*********************************************************/ -/* - * Autoconf defined configuration options - * You shouldn't need to touch any of these - */ - -/* Ignore this */ -#undef DUMMY_PPP - -/* XXX: Define according to how time.h should be included */ -#undef TIME_WITH_SYS_TIME -#define TIME_WITH_SYS_TIME 0 -#undef HAVE_SYS_TIME_H - -/* Define if your sprintf returns char * instead of int */ -#undef BAD_SPRINTF - -/* Define if you have readv */ -#undef HAVE_READV - -/* Define if iovec needs to be declared */ -#undef DECLARE_IOVEC -#ifdef _WIN32 -#define DECLARE_IOVEC -#endif - -/* Define if a declaration of sprintf/fprintf is needed */ -#undef DECLARE_SPRINTF - -/* Define if you have sys/stropts.h */ -#undef HAVE_SYS_STROPTS_H - -/* Define if your compiler doesn't like prototypes */ -#undef NO_PROTOTYPES - -/* Define if you don't have u_int32_t etc. typedef'd */ -#undef NEED_TYPEDEFS -#ifdef __sun__ -#define NEED_TYPEDEFS -#endif - -/* Define to sizeof(char *) */ -#ifdef SIZEOF_VOID_P -# define SIZEOF_CHAR_P SIZEOF_VOID_P -#else -# define SIZEOF_CHAR_P 4 /*FIXME: sizeof() does not work in cpp!*/ -#endif - -/* Define if you have random() */ -#undef HAVE_RANDOM - -/* Define if you have srandom() */ -#undef HAVE_SRANDOM - -/* Define if you have setenv */ -#undef HAVE_SETENV - -/* Define if you have index() */ -#undef HAVE_INDEX - -/* Define if you have bcmp() */ -#undef HAVE_BCMP - -/* Define if you have drand48 */ -#undef HAVE_DRAND48 - -/* Define if you have memmove */ -#define HAVE_MEMMOVE - -/* Define if you have gethostid */ -#undef HAVE_GETHOSTID - -/* Define if you DON'T have unix-domain sockets */ -#undef NO_UNIX_SOCKETS -#ifdef _WIN32 -#define NO_UNIX_SOCKETS -#endif - -/* Define if gettimeofday only takes one argument */ -#undef GETTIMEOFDAY_ONE_ARG - -/* Define if you have revoke() */ -#undef HAVE_REVOKE - -/* Define if you have the sysv method of opening pty's (/dev/ptmx, etc.) */ -#undef HAVE_GRANTPT - -/* Define if you have fchmod */ -#undef HAVE_FCHMOD - -/* Define if you have */ -#undef HAVE_SYS_TYPES32_H diff --git a/src/devices/network/slirp/tftp.c b/src/devices/network/slirp/tftp.c deleted file mode 100644 index b7b1ffb..0000000 --- a/src/devices/network/slirp/tftp.c +++ /dev/null @@ -1,332 +0,0 @@ -/* - * tftp.c - a simple, read-only tftp server for qemu - * - * Copyright (c) 2004 Magnus Damm - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "slirp.h" -#include "../ibm.h" - -struct tftp_session { - int in_use; - char filename[TFTP_FILENAME_MAX]; - - struct in_addr client_ip; - u_int16_t client_port; - - int timestamp; -}; - -struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX]; - -const char *tftp_prefix; - -static void tftp_session_update(struct tftp_session *spt) -{ - spt->timestamp = curtime; - spt->in_use = 1; -} - -static void tftp_session_terminate(struct tftp_session *spt) -{ - spt->in_use = 0; -} - -static int tftp_session_allocate(struct tftp_t *tp) -{ - struct tftp_session *spt; - int k; - - for (k = 0; k < TFTP_SESSIONS_MAX; k++) { - spt = &tftp_sessions[k]; - - if (!spt->in_use) - goto found; - - /* sessions time out after 5 inactive seconds */ - if ((int)(curtime - spt->timestamp) > 5000) - goto found; - } - - return -1; - - found: - memset(spt, 0, sizeof(*spt)); - memcpy(&spt->client_ip, &tp->ip.ip_src, sizeof(spt->client_ip)); - spt->client_port = tp->udp.uh_sport; - - tftp_session_update(spt); - - return k; -} - -static int tftp_session_find(struct tftp_t *tp) -{ - struct tftp_session *spt; - int k; - - for (k = 0; k < TFTP_SESSIONS_MAX; k++) { - spt = &tftp_sessions[k]; - - if (spt->in_use) { - if (!memcmp(&spt->client_ip, &tp->ip.ip_src, sizeof(spt->client_ip))) { - if (spt->client_port == tp->udp.uh_sport) { - return k; - } - } - } - } - - return -1; -} - -static int tftp_read_data(struct tftp_session *spt, u_int16_t block_nr, - u_int8_t *buf, int len) -{ - int fd; - int bytes_read = 0; - - char file_path[sizeof(pcempath) + 5 + sizeof(spt->filename)]; - strcpy(file_path, pcempath); - strcat(file_path, "tftp/"); - strcat(file_path, spt->filename); - - fd = open(file_path, O_RDONLY | O_BINARY); - - if (fd < 0) { - return -1; - } - - if (len) { - lseek(fd, block_nr * 512, SEEK_SET); - - bytes_read = read(fd, buf, len); - } - - close(fd); - - return bytes_read; -} - -static int tftp_send_error(struct tftp_session *spt, - u_int16_t errorcode, const char *msg, - struct tftp_t *recv_tp) -{ - struct sockaddr_in saddr, daddr; - struct SLIRPmbuf *m; - struct tftp_t *tp; - int nobytes; - - m = m_get(); - - if (!m) { - return -1; - } - - memset(m->m_data, 0, m->m_size); - - m->m_data += if_maxlinkhdr; - tp = (void *)m->m_data; - m->m_data += sizeof(struct udpiphdr); - - tp->tp_op = htons(TFTP_ERROR); - tp->x.tp_error.tp_error_code = htons(errorcode); - strncpy((char *)tp->x.tp_error.tp_msg, msg, sizeof(tp->x.tp_error.tp_msg)); - tp->x.tp_error.tp_msg[sizeof(tp->x.tp_error.tp_msg)-1] = 0; - - saddr.sin_addr = recv_tp->ip.ip_dst; - saddr.sin_port = recv_tp->udp.uh_dport; - - daddr.sin_addr = spt->client_ip; - daddr.sin_port = spt->client_port; - - nobytes = 2; - - m->m_len = sizeof(struct tftp_t) - 514 + 3 + strlen(msg) - - sizeof(struct ip) - sizeof(struct udphdr); - - udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY); - - tftp_session_terminate(spt); - - return 0; -} - -static int tftp_send_data(struct tftp_session *spt, - u_int16_t block_nr, - struct tftp_t *recv_tp) -{ - struct sockaddr_in saddr, daddr; - struct SLIRPmbuf *m; - struct tftp_t *tp; - int nobytes; - - if (block_nr < 1) { - return -1; - } - - m = m_get(); - - if (!m) { - return -1; - } - - memset(m->m_data, 0, m->m_size); - - m->m_data += if_maxlinkhdr; - tp = (void *)m->m_data; - m->m_data += sizeof(struct udpiphdr); - - tp->tp_op = htons(TFTP_DATA); - tp->x.tp_data.tp_block_nr = htons(block_nr); - - saddr.sin_addr = recv_tp->ip.ip_dst; - saddr.sin_port = recv_tp->udp.uh_dport; - - daddr.sin_addr = spt->client_ip; - daddr.sin_port = spt->client_port; - - nobytes = tftp_read_data(spt, block_nr - 1, tp->x.tp_data.tp_buf, 512); - - if (nobytes < 0) { - m_free(m); - - /* send "file not found" error back */ - - tftp_send_error(spt, 1, "File not found", tp); - - return -1; - } - - m->m_len = sizeof(struct tftp_t) - (512 - nobytes) - - sizeof(struct ip) - sizeof(struct udphdr); - - udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY); - - if (nobytes == 512) { - tftp_session_update(spt); - } - else { - tftp_session_terminate(spt); - } - - return 0; -} - -static void tftp_handle_rrq(struct tftp_t *tp, int pktlen) -{ - struct tftp_session *spt; - int s, k, n; - u_int8_t *src, *dst; - - s = tftp_session_allocate(tp); - - if (s < 0) { - return; - } - - spt = &tftp_sessions[s]; - - src = tp->x.tp_buf; - dst = (u_int8_t *)spt->filename; - n = pktlen - ((uint8_t *)&tp->x.tp_buf[0] - (uint8_t *)tp); - - /* get name */ - - for (k = 0; k < n; k++) { - if (k < TFTP_FILENAME_MAX) { - dst[k] = src[k]; - } - else { - return; - } - - if (src[k] == '\0') { - break; - } - } - - if (k >= n) { - return; - } - - k++; - - /* check mode */ - if ((n - k) < 6) { - return; - } - - if (memcmp(&src[k], "octet\0", 6) != 0) { - tftp_send_error(spt, 4, "Unsupported transfer mode", tp); - return; - } - - pclog("tftp request: %s\n", spt->filename); - - /* do sanity checks on the filename */ - - if (strstr(spt->filename, "../") || strstr(spt->filename, "..\\")) { - tftp_send_error(spt, 2, "Access violation", tp); - return; - } - - /* check if the file exists */ - - if (tftp_read_data(spt, 0, (u_int8_t *)spt->filename, 0) < 0) { - tftp_send_error(spt, 1, "File not found", tp); - return; - } - - tftp_send_data(spt, 1, tp); -} - -static void tftp_handle_ack(struct tftp_t *tp, int pktlen) -{ - int s; - - s = tftp_session_find(tp); - - if (s < 0) { - return; - } - - if (tftp_send_data(&tftp_sessions[s], - ntohs(tp->x.tp_data.tp_block_nr) + 1, - tp) < 0) { - return; - } -} - -void tftp_input(struct SLIRPmbuf *m) -{ - struct tftp_t *tp = (struct tftp_t *)m->m_data; - - switch(ntohs(tp->tp_op)) { - case TFTP_RRQ: - tftp_handle_rrq(tp, m->m_len); - break; - - case TFTP_ACK: - tftp_handle_ack(tp, m->m_len); - break; - } -} diff --git a/src/devices/network/slirp/tftp.h b/src/devices/network/slirp/tftp.h deleted file mode 100644 index ba41741..0000000 --- a/src/devices/network/slirp/tftp.h +++ /dev/null @@ -1,40 +0,0 @@ -/* tftp defines */ - -#define TFTP_SESSIONS_MAX 3 - -#define TFTP_SERVER 69 - -#define TFTP_RRQ 1 -#define TFTP_WRQ 2 -#define TFTP_DATA 3 -#define TFTP_ACK 4 -#define TFTP_ERROR 5 - -#define TFTP_FILENAME_MAX 512 - -#ifdef PRAGMA_PACK_SUPPORTED -#pragma pack(1) -#endif - -struct tftp_t { - struct ip ip; - struct udphdr udp; - u_int16_t tp_op; - union { - struct { - u_int16_t tp_block_nr; - u_int8_t tp_buf[512]; - } tp_data; - struct { - u_int16_t tp_error_code; - u_int8_t tp_msg[512]; - } tp_error; - u_int8_t tp_buf[512 + 2]; - } x; -} PACKED__; - -#ifdef PRAGMA_PACK_SUPPORTED -#pragma pack(PACK_END) -#endif - -void tftp_input(struct SLIRPmbuf *m); diff --git a/src/devices/scsi/scsi_cdrom.c b/src/devices/scsi/scsi_cdrom.c index 1907125..ff2faa2 100644 --- a/src/devices/scsi/scsi_cdrom.c +++ b/src/devices/scsi/scsi_cdrom.c @@ -8,7 +8,7 @@ * * Emulation of SCSI (and ATAPI) CD-ROM drives. * - * Version: @(#)scsi_cdrom.c 1.0.10 2018/10/27 + * Version: @(#)scsi_cdrom.c 1.0.11 2018/11/02 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -393,6 +393,7 @@ current_mode(scsi_cdrom_t *dev) } +#if 1 /* will be moved to IDE layer */ /* Translates ATAPI status (ERR_STAT flag) to SCSI status. */ static int err_stat_to_scsi(void *priv) @@ -404,6 +405,7 @@ err_stat_to_scsi(void *priv) return SCSI_STATUS_OK; } +#endif /* Translates ATAPI phase (DRQ, I/O, C/D) to SCSI phase (MSG, C/D, I/O). */ @@ -2601,13 +2603,18 @@ phase_data_out(scsi_cdrom_t *dev) pos = hdr_len + block_desc_len; while(1) { + if (pos >= dev->current_cdb[4]) { + DEBUG("CD-ROM %i: Buffer has only block descriptor\n", dev->id); + break; + } + page = dev->buffer[pos] & 0x3F; page_len = dev->buffer[pos + 1]; pos += 2; if (!(mode_sense_page_flags & (1LL << ((uint64_t) page)))) { - DEBUG("Unimplemented page %02X\n", page); + DEBUG("CD-ROM %i: Unimplemented page %02X\n", dev->id, page); error |= 1; } else { for (i = 0; i < page_len; i++) { @@ -2618,7 +2625,7 @@ phase_data_out(scsi_cdrom_t *dev) if (ch) dev->ms_pages_saved.pages[page][i + 2] = val; else { - DEBUG("Unchangeable value on position %02X on page %02X\n", i + 2, page); + DEBUG("CD-ROM %i: Unchangeable value on position %02X on page %02X\n", dev->id, i + 2, page); error |= 1; } } @@ -3246,7 +3253,9 @@ scsi_cdrom_drive_reset(int c) sd->p = dev; sd->command = do_command; sd->callback = do_callback; +#if 1 /* Will be moved to IDE layer */ sd->err_stat_to_scsi = err_stat_to_scsi; +#endif sd->request_sense = request_sense_scsi; sd->reset = do_reset; sd->read_capacity = read_capacity; diff --git a/src/devices/scsi/scsi_disk.c b/src/devices/scsi/scsi_disk.c index 9bada9c..e48c8b2 100644 --- a/src/devices/scsi/scsi_disk.c +++ b/src/devices/scsi/scsi_disk.c @@ -8,7 +8,7 @@ * * Emulation of SCSI fixed disks. * - * Version: @(#)scsi_disk.c 1.0.21 2018/10/27 + * Version: @(#)scsi_disk.c 1.0.22 2018/11/02 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1217,6 +1217,11 @@ phase_data_out(scsi_disk_t *dev) pos = hdr_len + block_desc_len; while(1) { + if (pos >= dev->current_cdb[4]) { + DEBUG("SCSI DISK %i: Buffer has only block descriptor\n", dev->id); + break; + } + page = hdbufferb[pos] & 0x3F; page_len = hdbufferb[pos + 1]; diff --git a/src/machines/m_pcjr.c b/src/machines/m_pcjr.c index 4d7dc6b..8836c1f 100644 --- a/src/machines/m_pcjr.c +++ b/src/machines/m_pcjr.c @@ -8,7 +8,7 @@ * * Emulation of the IBM PCjr. * - * Version: @(#)m_pcjr.c 1.0.9 2018/10/05 + * Version: @(#)m_pcjr.c 1.0.10 2018/11/02 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -43,6 +43,7 @@ #include #include #include "../emu.h" +#include "../cpu/cpu.h" #include "../io.h" #include "../mem.h" #include "../timer.h" @@ -765,6 +766,14 @@ machine_pcjr_init(const machine_t *model, UNUSED(void *arg)) pit_init(); pit_set_out_func(&pit, 0, pit_irq0_timer_pcjr); + cpu_set(); + + if (machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].cpu_type >= +CPU_286) + setrtcconst((float)machine_speed()); + else + setrtcconst(14318184.0); + if (serial_enabled[0]) { serial_setup(1, 0x2f8, 3); device_add(&serial_1_pcjr_device); @@ -782,6 +791,7 @@ machine_pcjr_init(const machine_t *model, UNUSED(void *arg)) (const video_timings_t *)&m_pcjr_device.vid_timing); /* Initialize the keyboard. */ + keyboard_scan = 1; key_queue_start = key_queue_end = 0; io_sethandler(0x0060, 4, kbd_read, NULL, NULL, kbd_write, NULL, NULL, pcjr); diff --git a/src/nvr.c b/src/nvr.c index d6deee2..2091773 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -8,7 +8,7 @@ * * Implement a generic NVRAM/CMOS/RTC device. * - * Version: @(#)nvr.c 1.0.12 2018/10/05 + * Version: @(#)nvr.c 1.0.13 2018/11/01 * * Author: Fred N. van Kempen, * @@ -102,7 +102,6 @@ rtc_tick(void) if (++intclk.tm_mday == (nvr_get_days(intclk.tm_mon, intclk.tm_year) + 1)) { intclk.tm_mday = 1; - intclk.tm_mon++; if (++intclk.tm_mon == 13) { intclk.tm_mon = 1; intclk.tm_year++; @@ -295,7 +294,7 @@ nvr_period_recalc(void) /* Make sure we have been initialized. */ if (saved_nvr == NULL) return; - if (saved_nvr->size != 0) + if (saved_nvr->recalc && (saved_nvr->size != 0)) saved_nvr->recalc(saved_nvr); } diff --git a/src/ui/lang/VARCem-NO.str b/src/ui/lang/VARCem-NO.str index 76fa420..e60ca39 100644 --- a/src/ui/lang/VARCem-NO.str +++ b/src/ui/lang/VARCem-NO.str @@ -8,7 +8,7 @@ * * String definitions for "Norwegian (Norway)" language. * - * Version: @(#)VARCem-NO.str 1.0.6 2018/10/25 + * Version: @(#)VARCem-NO.str 1.0.6 2018/11/01 * * Author: Fred N. van Kempen, * Tore Sinding Bekkedal, * Fred N. van Kempen, @@ -48,7 +48,7 @@ */ /* Main application strings (2000) - DO NOT TRANSLATE! */ -#define STR_VERSION 1,0,2 +#define STR_VERSION 1,0,3 #define STR_AUTHOR "Ola Trzeciak" #define STR_EMAIL "otrzeciak@varcem@gmail.com" #define STR_NAME "VARCem" @@ -234,7 +234,7 @@ #define STR_3476 "Kontroler dysku twardego:" #define STR_3477 "Trzecie IDE" #define STR_3478 "Czwarte IDE" -#define STR_3479 "karta ISABugger" +#define STR_3479 "Karta ISABugger" #define STR_3480 "Karta rozszerzenia pamięci na złącze ISA" #define STR_3481 "Karta zegara czasu rzeczywistego na złącze ISA" diff --git a/src/win/mingw/Makefile.MinGW b/src/win/mingw/Makefile.MinGW index 48fb9ca..6b1b345 100644 --- a/src/win/mingw/Makefile.MinGW +++ b/src/win/mingw/Makefile.MinGW @@ -8,7 +8,7 @@ # # Makefile for Windows systems using the MinGW32 environment. # -# Version: @(#)Makefile.mingw 1.0.64 2018/10/24 +# Version: @(#)Makefile.mingw 1.0.66 2018/10/30 # # Author: Fred N. van Kempen, # @@ -370,7 +370,7 @@ endif LIBS := -mwindows \ -lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 \ -lversion -lcomctl32 -lwinmm -LIBS += -lwsock32 -liphlpapi -lpsapi +LIBS += -lws2_32 -lwsock32 -liphlpapi -lpsapi LIBS += -static -lstdc++ -lgcc #ifneq ($(X64), y) # LIBS += -Wl,--large-address-aware @@ -667,10 +667,12 @@ SCSIOBJ := scsi.o \ NETOBJ := network.o \ net_pcap.o \ net_slirp.o \ - bootp.o ip_icmp.o slirp_misc.o socket.o tcp_timer.o \ - cksum.o ip_input.o queue.o tcp_input.o debug.o \ - ip_output.o sbuf.o tcp_output.o udp.o if.o mbuf.o \ - slirp.o tcp_subr.o \ + slirp.o slirp_misc.o \ + cksum.o debug.o if.o mbuf.o queue.o sbuf.o socket.o \ + arp.o bootp.o \ + ip_icmp.o ip_input.o ip_output.o \ + tcp_input.o tcp_output.o tcp_subr.o tcp_timer.o \ + udp.o \ net_dp8390.o \ net_ne2000.o net_wd80x3.o net_3c503.o diff --git a/src/win/msvc/Makefile.VC b/src/win/msvc/Makefile.VC index 5ddb671..b4829a0 100644 --- a/src/win/msvc/Makefile.VC +++ b/src/win/msvc/Makefile.VC @@ -8,7 +8,7 @@ # # Makefile for Windows using Visual Studio 2015. # -# Version: @(#)Makefile.VC 1.0.51 2018/10/24 +# Version: @(#)Makefile.VC 1.0.52 2018/10/30 # # Author: Fred N. van Kempen, # @@ -350,7 +350,7 @@ endif LIBS := ddraw.lib dinput8.lib dxguid.lib d3d9.lib d3dx9.lib \ version.lib comctl32.lib winmm.lib comdlg32.lib \ advapi32.lib gdi32.lib shell32.lib user32.lib \ - wsock32.lib iphlpapi.lib psapi.lib + ws2_32.lib wsock32.lib iphlpapi.lib psapi.lib ifeq ($(DEBUG), y) LIBS += libcmtd.lib libvcruntimed.lib libucrtd.lib endif @@ -641,11 +641,13 @@ SCSIOBJ := scsi.obj \ NETOBJ := network.obj \ net_pcap.obj \ net_slirp.obj \ - bootp.obj ip_icmp.obj slirp_misc.obj socket.obj \ - tcp_timer.obj cksum.obj ip_input.obj queue.obj \ - tcp_input.obj debug.obj ip_output.obj sbuf.obj \ - tcp_output.obj udp.obj if.obj mbuf.obj slirp.obj \ - tcp_subr.obj \ + slirp.obj slirp_misc.obj \ + cksum.obj debug.obj if.obj mbuf.obj queue.obj sbuf.obj \ + socket.obj \ + arp.obj bootp.obj \ + ip_icmp.obj ip_input.obj ip_output.obj \ + tcp_input.obj tcp_output.obj tcp_subr.obj tcp_timer.obj \ + udp.obj \ net_dp8390.obj \ net_ne2000.obj net_wd80x3.obj net_3c503.obj diff --git a/src/win/win_settings_video.h b/src/win/win_settings_video.h index 92e2cfa..b11dccd 100644 --- a/src/win/win_settings_video.h +++ b/src/win/win_settings_video.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_video.h 1.0.9 2018/10/24 + * Version: @(#)win_settings_video.h 1.0.10 2018/10/28 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -68,7 +68,7 @@ video_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) /* Populate the video cards combo. */ c = d = 0; - while (1) { + for (;;) { stransi = video_get_internal_name(c); if (stransi == NULL) break; @@ -110,7 +110,7 @@ video_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) vid = vid_to_list[temp_video_card]; if (vid < d) { SendMessage(h, CB_SETCURSEL, vid, 0); - if (video_card_has_config(vid)) { + if (video_card_has_config(temp_video_card)) { h = GetDlgItem(hdlg, IDC_CONFIGURE_VIDEO); EnableWindow(h, TRUE); }