[PATCH] Display serial errors and allow word write to modem status register

2 views
Skip to first unread message

Erik van der Kouwe

unread,
Jan 11, 2011, 5:56:56 AM1/11/11
to V3VEE Development, Jack Lange
Dear all,

Several error conditions in serial.c trigger a PrintDebug rather than
PrintError. The result is that, if debug output is disabled, a failure
may terminate Palacios without an error message. This patch causes
PrintError to be used wherever this situation may occur.

In addition, this patch allows word writes to the modem status register,
causing the second byte to be written into the scratch register. Windows
XP does this for some reason.

With kind regards,
Erik

Jack Lange

unread,
Jan 11, 2011, 4:25:44 PM1/11/11
to v3vee-de...@googlegroups.com
Hey Erik,

It looks like the patch didn't make it. Would you mind resending?

--Jack

> --
> You received this message because you are subscribed to the Google Groups
> "V3VEE Development" group.
> To post to this group, send email to v3vee-de...@googlegroups.com.
> To unsubscribe from this group, send email to
> v3vee-developm...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/v3vee-development?hl=en.
>
>

Erik van der Kouwe

unread,
Jan 11, 2011, 4:37:30 PM1/11/11
to V3VEE Development
Hi,

> It looks like the patch didn't make it. Would you mind resending?

Patch has been sent by e-mail in the hope that it will arrive this
way. For any others who may be interested I included the patch text
below.

With kind regargs,
Erik



--- git/palacios/src/devices/serial.c 2011-01-11 11:03:36.755919400
+0100
+++ minix/palacios/src/devices/serial.c 2011-01-11 11:50:35.863163100
+0100
@@ -460,7 +460,7 @@
PrintDebug("Write to Data Port 0x%x (val=%x)\n", port, *val);

if (length != 1) {
- PrintDebug("Invalid length(%d) in write to 0x%x\n", length, port);
+ PrintError("Invalid length(%d) in write to 0x%x\n", length, port);
return -1;
}

@@ -473,7 +473,7 @@
com_port = get_com_from_port(state, port);

if (com_port == NULL) {
- PrintDebug("UART:read from NOBODY");
+ PrintError("UART:read from NOBODY");
return -1;
}

@@ -506,7 +506,7 @@
PrintDebug("Read from Data Port 0x%x\n", port);

if (length != 1) {
- PrintDebug("Invalid length(%d) in write to 0x%x\n", length, port);
+ PrintError("Invalid length(%d) in write to 0x%x\n", length, port);
return -1;
}

@@ -519,7 +519,7 @@
com_port = get_com_from_port(state, port);

if (com_port == NULL) {
- PrintDebug("UART:read from NOBODY");
+ PrintError("UART:read from NOBODY");
return -1;
}

@@ -589,7 +589,7 @@
PrintDebug("UART:Write to Control Port (val=%x)\n", val);

if (length != 1) {
- PrintDebug("UART:Invalid Write length to control port%d\n", port);
+ PrintError("UART:Invalid Write length to control port%d\n", port);
return -1;
}

@@ -653,7 +653,7 @@
break;
}
default:
- PrintDebug("UART:Write to NOBODY, ERROR");
+ PrintError("UART:Write to NOBODY, ERROR");
return -1;
}

@@ -673,7 +673,7 @@
PrintDebug("Read from Control Port\n");

if (length != 1) {
- PrintDebug("Invalid Read length to control port\n");
+ PrintError("Invalid Read length to control port\n");
return -1;
}

@@ -733,7 +733,7 @@
break;

default:
- PrintDebug("UART:read from NOBODY");
+ PrintError("UART:read from NOBODY");
return -1;
}

@@ -750,7 +750,7 @@
PrintDebug("Write to Status Port (val=%x)\n", val);

if (length != 1) {
- PrintDebug("Invalid Write length to status port %d\n", port);
+ PrintError("Invalid Write length to status port %d\n", port);
return -1;
}

@@ -779,7 +779,7 @@
break;

default:
- PrintDebug("UART:write to NOBODY");
+ PrintError("UART:write to NOBODY");
return -1;
}

@@ -794,11 +794,6 @@

PrintDebug("Read from Status Port 0x%x\n", port);

- if (length != 1) {
- PrintDebug("Invalid Read length to control port\n");
- return -1;
- }
-
com_port = get_com_from_port(state, port);

if (com_port == NULL) {
@@ -811,6 +806,11 @@
case COM2_LINE_STATUS_PORT:
case COM3_LINE_STATUS_PORT:
case COM4_LINE_STATUS_PORT:
+ if (length != 1) {
+ PrintError("Invalid Read length to LSR port\n");
+ return -1;
+ }
+
PrintDebug("UART:read from LSR");

*val = com_port->lsr.val;
@@ -822,12 +822,29 @@
case COM2_MODEM_STATUS_PORT:
case COM3_MODEM_STATUS_PORT:
case COM4_MODEM_STATUS_PORT:
- PrintDebug("UART:read from COM4 MSR");
- *val = com_port->msr.val;
+ switch (length) {
+ case 2:
+ /* Windows XP expects to be able to read this register and the next
in one go */
+ PrintDebug("UART:word read from COM4 MSR");
+ if (read_ctrl_port(core, port + 1, val + 1, 1, priv_data) < 0)
return -1;
+ /* fall through */
+ case 1:
+ PrintDebug("UART:read from COM4 MSR");
+ *val = com_port->msr.val;
+ break;
+ default:
+ PrintError("Invalid Read length to MSR port\n");
+ return -1;
+ }
break;

default:
- PrintDebug("UART:read from NOBODY");
+ if (length != 1) {
+ PrintError("Invalid Read length to status port\n");
+ return -1;
+ }
+
+ PrintError("UART:read from NOBODY");
return -1;
}

Reply all
Reply to author
Forward
0 new messages