From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27012 invoked by alias); 14 Jul 2006 19:53:06 -0000 Received: (qmail 27000 invoked by uid 22791); 14 Jul 2006 19:53:05 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 14 Jul 2006 19:53:01 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k6EJqwKA005932 for ; Fri, 14 Jul 2006 15:52:58 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx1.corp.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k6EJqvne011042 for ; Fri, 14 Jul 2006 15:52:58 -0400 Received: from [172.16.50.154] (vpn50-154.rdu.redhat.com [172.16.50.154]) by potter.sfbay.redhat.com (8.12.8/8.12.8) with ESMTP id k6EJqsHS007702 for ; Fri, 14 Jul 2006 15:52:55 -0400 Message-ID: <44B7F619.7040404@redhat.com> Date: Fri, 14 Jul 2006 19:53:00 -0000 From: Dave Brolley User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) MIME-Version: 1.0 To: sid@sources.redhat.com Subject: [patch][commit] EOF Handling for sid-io-stdio Content-Type: multipart/mixed; boundary="------------090702020606040104070308" X-IsSubscribed: yes Mailing-List: contact sid-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: sid-owner@sourceware.org X-SW-Source: 2006-q3/txt/msg00019.txt.bz2 This is a multi-part message in MIME format. --------------090702020606040104070308 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 485 Hi, I've committed this patch which corrects a problem with sid-io-stdio. Currently, when there is no data available to be read, the gloss component cannot distinguish this from EOF. This causes eof to be reported by do_sys_read prematurely in some instances. I've committed this patch which adds an eof pin to the sid-io-stdio compoenent which is now checked by do_sys_read when no data is returned to ensure that it really is eof. Let me know if you find any problems. Dave --------------090702020606040104070308 Content-Type: text/plain; name="sid-stdio.ChangeLog" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sid-stdio.ChangeLog" Content-length: 656 2006-06-21 Dave Brolley * stdio.cxx (stdioConsole): Initialize eof_p. Add "eof" pin. (read): Remove 'value'. Check eof_p. Drive eof_pin and set eof_p as needed. * components.h (eof_pin): New member of stdioConsole. (eof_p): Likewise. * sid-io-stdio.xml: Document eof pin. * sid-io-stdio.txt: Regenerated. 2006-06-21 Dave Brolley * gloss.h (rx_eof_pin): New member of gloss32. * gloss.cxx (gloss32): Add debug-rx-eof pin. (read): Check rx_eof_pin. 2006-06-21 Dave Brolley * commonCfg.cxx (BoardCfg::write_config): Connect stdio_obj's eof pin to gloss' debug-rx-eof pin. --------------090702020606040104070308 Content-Type: text/plain; name="sid-stdio.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sid-stdio.patch.txt" Content-length: 9474 Index: sid/component/consoles/components.h =================================================================== RCS file: /cvs/src/src/sid/component/consoles/components.h,v retrieving revision 1.5 diff -c -p -r1.5 components.h *** sid/component/consoles/components.h 19 Aug 2005 19:43:09 -0000 1.5 --- sid/component/consoles/components.h 14 Jul 2006 19:16:02 -0000 *************** *** 1,7 **** // file.cxx - Joint header file for nearby component classes. // -*- C++ -*- ! // Copyright (C) 1999, 2000, 2003, 2005 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. --- 1,7 ---- // file.cxx - Joint header file for nearby component classes. // -*- C++ -*- ! // Copyright (C) 1999, 2000, 2003, 2005, 2006 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. *************** private: *** 106,111 **** --- 106,114 ---- callback_pin activity_pin; callback_pin stdout_pin; output_pin stdin_pin; + output_pin eof_pin; + + bool eof_p; // save & restore state string save_state ( ); Index: sid/component/consoles/sid-io-stdio.xml =================================================================== RCS file: /cvs/src/src/sid/component/consoles/sid-io-stdio.xml,v retrieving revision 1.2 diff -c -p -r1.2 sid-io-stdio.xml *** sid/component/consoles/sid-io-stdio.xml 10 Jun 2003 18:28:19 -0000 1.2 --- sid/component/consoles/sid-io-stdio.xml 14 Jul 2006 19:16:02 -0000 *************** *** 8,13 **** --- 8,14 ---- + *************** *** 45,53 **** When the poll pin is driven, the stdin stream is checked for ! unread input, without blocking. All available input is consumed, and transmitted individually by driving the stdin pin with each ! byte, in sequence. --- 46,57 ---- When the poll pin is driven, the stdin stream is checked for ! unread input, without blocking. If end of file has not been detected, the eof ! pin is driven with the value 0. All available input is consumed, and transmitted individually by driving the stdin pin with each ! byte, in sequence. When end of file is detected, the eof is driven with ! a value of 1 and no data is transmitted via the stdin pin. ! Index: sid/component/consoles/stdio.cxx =================================================================== RCS file: /cvs/src/src/sid/component/consoles/stdio.cxx,v retrieving revision 1.3 diff -c -p -r1.3 stdio.cxx *** sid/component/consoles/stdio.cxx 14 Jul 2003 18:42:14 -0000 1.3 --- sid/component/consoles/stdio.cxx 14 Jul 2006 19:16:02 -0000 *************** *** 1,7 **** // stdio.cxx - A simple console that uses standard I/O for // enunciation. -*- C++ -*- ! // Copyright (C) 1999, 2000, 2003 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. --- 1,7 ---- // stdio.cxx - A simple console that uses standard I/O for // enunciation. -*- C++ -*- ! // Copyright (C) 1999, 2000, 2003, 2006 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. *************** namespace console_stuff *** 13,23 **** stdioConsole::stdioConsole() :activity_pin(this, & stdioConsole::read), ! stdout_pin(this, & stdioConsole::write) { add_pin("poll", &activity_pin); add_pin("stdin", &stdin_pin); add_pin("stdout", &stdout_pin); add_attribute_virtual ("state-snapshot", this, & stdioConsole::save_state, & stdioConsole::restore_state); --- 13,25 ---- stdioConsole::stdioConsole() :activity_pin(this, & stdioConsole::read), ! stdout_pin(this, & stdioConsole::write), ! eof_p (false) { add_pin("poll", &activity_pin); add_pin("stdin", &stdin_pin); add_pin("stdout", &stdout_pin); + add_pin("eof", &eof_pin); add_attribute_virtual ("state-snapshot", this, & stdioConsole::save_state, & stdioConsole::restore_state); *************** stdioConsole::write(host_int_4 value) *** 32,52 **** void stdioConsole::read(host_int_4) { unsigned char buf[1000]; int len; - host_int_4 value; - // Switch to non-blocking input. long flags = fcntl(0, F_GETFL); fcntl(0, F_SETFL, flags | O_NONBLOCK); if ((len = ::read(0, buf, 1000)) > 0) { for (int i = 0; i < len; ++i) { stdin_pin.drive(buf[i]); } } // Restore flags. fcntl(0, F_SETFL, flags); --- 34,62 ---- void stdioConsole::read(host_int_4) { + // Check for EOF + if (eof_p) + return; + unsigned char buf[1000]; int len; // Switch to non-blocking input. long flags = fcntl(0, F_GETFL); fcntl(0, F_SETFL, flags | O_NONBLOCK); if ((len = ::read(0, buf, 1000)) > 0) { + eof_pin.drive (0); for (int i = 0; i < len; ++i) { stdin_pin.drive(buf[i]); } } + else if (len == 0) + { + eof_p = true; + eof_pin.drive (1); + } // Restore flags. fcntl(0, F_SETFL, flags); Index: sid/component/gloss/gloss.cxx =================================================================== RCS file: /cvs/src/src/sid/component/gloss/gloss.cxx,v retrieving revision 1.20 diff -c -p -r1.20 gloss.cxx *** sid/component/gloss/gloss.cxx 19 Aug 2005 19:44:46 -0000 1.20 --- sid/component/gloss/gloss.cxx 14 Jul 2006 19:16:03 -0000 *************** *** 1,6 **** // gloss.cxx - Gloss routines. -*- C++ -*- ! // Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. --- 1,6 ---- // gloss.cxx - Gloss routines. -*- C++ -*- ! // Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. *************** gloss32::gloss32() : *** 63,68 **** --- 65,71 ---- add_pin("debug-tx", &this->tx_pin); add_pin("debug-rx", &this->rx_pin); + add_pin("debug-rx-eof", &this->rx_eof_pin); add_attribute_ro_value ("tk tty", string("hw-visual-tty"), "gui"); add_uni_relation("cpu", &this->cpu); *************** gloss32::read (int fd, address32 addr, s *** 1543,1548 **** --- 1645,1655 ---- strbuf += c; } } + else if (rx_eof_pin.sense () != 0) + { + len_read = 0; + return true; + } else { this->blocked_p = true; Index: sid/component/gloss/gloss.h =================================================================== RCS file: /cvs/src/src/sid/component/gloss/gloss.h,v retrieving revision 1.12 diff -c -p -r1.12 gloss.h *** sid/component/gloss/gloss.h 19 Aug 2005 19:44:46 -0000 1.12 --- sid/component/gloss/gloss.h 14 Jul 2006 19:16:03 -0000 *************** *** 1,7 **** // gloss.h - Basic process emulation plus ROM monitor support. // -*- C++ -*- ! // Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. --- 1,7 ---- // gloss.h - Basic process emulation plus ROM monitor support. // -*- C++ -*- ! // Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. *************** protected: *** 119,124 **** --- 119,125 ---- callback_pin rx_pin; void rx_handler(host_int_4 byte); vector rx_buffer; + input_pin rx_eof_pin; output_pin tx_pin; // ABI-specifics, for getting syscall arguments and setting results. Index: sid/main/dynamic/commonCfg.cxx =================================================================== RCS file: /cvs/src/src/sid/main/dynamic/commonCfg.cxx,v retrieving revision 1.15 diff -c -p -r1.15 commonCfg.cxx *** sid/main/dynamic/commonCfg.cxx 26 Jun 2006 21:03:00 -0000 1.15 --- sid/main/dynamic/commonCfg.cxx 14 Jul 2006 19:16:05 -0000 *************** void BoardCfg::write_config (Writer &w) *** 1285,1290 **** --- 1285,1291 ---- assert (sess->stdio_obj); PinConnection (gloss, "debug-tx", sess->stdio_obj, "stdout").write_to(w); PinConnection (gloss, "debug-rx", sess->stdio_obj, "stdin", dst_to_src).write_to(w); + PinConnection (gloss, "debug-rx-eof", sess->stdio_obj, "eof", dst_to_src).write_to(w); PinConnection (gloss, "process-signal", sess->main_obj, "stop!").write_to(w); PinConnection (gloss, "process-signal", sess->yield_net, "input").write_to(w); } --------------090702020606040104070308--