* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <getopt.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <time.h>
-#include <sys/time.h>
-#include <malloc.h>
-#include <termios.h>
-#include <sys/poll.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <netinet/in.h>
-
-#include "cpu.h"
#include "vl.h"
//#define DEBUG_SERIAL
s->lsr &= ~UART_LSR_THRE;
serial_update_irq(s);
- ch = val;
- do {
- ret = write(s->out_fd, &ch, 1);
- } while (ret != 1);
+ if (s->out_fd >= 0) {
+ ch = val;
+ do {
+ ret = write(s->out_fd, &ch, 1);
+ } while (ret != 1);
+ }
s->thr_ipending = 1;
s->lsr |= UART_LSR_THRE;
s->lsr |= UART_LSR_TEMT;
register_ioport_write(base, 8, 1, serial_ioport_write, s);
register_ioport_read(base, 8, 1, serial_ioport_read, s);
- if (fd != 0) {
+ if (fd < 0) {
+ /* no associated device */
+ s->out_fd = -1;
+ } else if (fd != 0) {
qemu_add_fd_read_handler(fd, serial_can_receive1, serial_receive1, s);
s->out_fd = fd;
} else {