From 98b1a59547584bd823ed0aa3db0a65c6af56e0d6 Mon Sep 17 00:00:00 2001 From: aiju Date: Sat, 17 Jun 2017 23:30:23 +0000 Subject: [PATCH] vmx(1): don't zero all memory, don't abandon uart on eof, sleep before transmitting uart data --- sys/src/cmd/vmx/io.c | 15 +++++++++++---- sys/src/cmd/vmx/vmx.c | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/src/cmd/vmx/io.c b/sys/src/cmd/vmx/io.c index ad18e1af8..507dda972 100644 --- a/sys/src/cmd/vmx/io.c +++ b/sys/src/cmd/vmx/io.c @@ -1020,9 +1020,11 @@ uartrxproc(void *uv) UART *u; char buf[128], *p; int rc; + int eofctr; threadsetname("uart rx"); u = uv; + eofctr = 0; for(;;){ rc = read(u->infd, buf, sizeof(buf)); if(rc < 0){ @@ -1030,9 +1032,12 @@ uartrxproc(void *uv) threadexits("read: %r"); } if(rc == 0){ - vmerror("read(uartrx): eof"); - threadexits("read: eof"); - } + if(++eofctr == 100){ /* keep trying but give up eventually */ + vmerror("read(uartrx): eof"); + threadexits("read: eof"); + } + continue; + }else eofctr = 0; for(p = buf; p < buf + rc; p++){ send(u->inch, p); sendnotif((void(*)(void*))uartkick, u); @@ -1052,6 +1057,8 @@ uarttxproc(void *uv) p = buf; recv(u->outch, p); p++; + sendnotif((void(*)(void*))uartkick, u); + sleep(1); while(sendnotif((void(*)(void*))uartkick, u), p < buf+sizeof(buf) && nbrecv(u->outch, p) > 0) p++; if(write(u->outfd, buf, p - buf) < p - buf) @@ -1216,7 +1223,7 @@ IOHandler handlers[] = { 0x084, 0x084, nopio, nil, /* dma -- used by openbsd for delay by dummy read */ 0x100, 0x110, nopio, nil, /* elnk3 */ 0x240, 0x25f, nopio, nil, /* ne2000 */ - 0x279, 0x279, nopio, nil, /* isa pnp */ + 0x278, 0x27a, nopio, nil, /* LPT1 / ISA PNP */ 0x280, 0x29f, nopio, nil, /* ne2000 */ 0x2e8, 0x2ef, nopio, nil, /* COM4 */ 0x300, 0x31f, nopio, nil, /* ne2000 */ diff --git a/sys/src/cmd/vmx/vmx.c b/sys/src/cmd/vmx/vmx.c index 8e5cd6e18..e868d7266 100644 --- a/sys/src/cmd/vmx/vmx.c +++ b/sys/src/cmd/vmx/vmx.c @@ -304,7 +304,7 @@ mksegment(char *sn) gmem = segattach(0, sn, nil, sz); if(gmem == (void*)-1) sysfatal("segattach: %r"); } - memset(gmem, 0, sz); + memset(gmem, 0, sz > 1>>24 ? 1>>24 : sz); p = gmem; for(r = mmap; r != nil; r = r->next){ if(r->segname == nil) continue;