memtest86plus/parity-bits.diff

98 lines
2.5 KiB
Diff

Index: memtest86+-1.70/lib.c
===================================================================
--- memtest86+-1.70.orig/lib.c
+++ memtest86+-1.70/lib.c
@@ -23,6 +23,9 @@ const short serial_base_ports[] = {0x3f8
#endif
int serial_baud_rate = SERIAL_BAUD_RATE;
+unsigned char serial_parity = 0;
+unsigned char serial_bits = 8;
+
char buf[18];
struct ascii_map_str {
@@ -722,6 +725,7 @@ void ttyprint(int y, int x, const char *
void serial_echo_init(void)
{
int comstat, hi, lo, serial_div;
+ unsigned char lcr;
/* read the Divisor Latch */
comstat = serial_echo_inb(UART_LCR);
@@ -731,12 +735,13 @@ void serial_echo_init(void)
serial_echo_outb(comstat, UART_LCR);
/* now do hardwired init */
- serial_echo_outb(0x03, UART_LCR); /* No parity, 8 data bits, 1 stop */
+ lcr = serial_parity | (serial_bits - 5);
+ serial_echo_outb(lcr, UART_LCR); /* No parity, 8 data bits, 1 stop */
serial_div = 115200 / serial_baud_rate;
- serial_echo_outb(0x83, UART_LCR); /* Access divisor latch */
+ serial_echo_outb(0x80|lcr, UART_LCR); /* Access divisor latch */
serial_echo_outb(serial_div & 0xff, UART_DLL); /* baud rate divisor */
serial_echo_outb((serial_div >> 8) & 0xff, UART_DLM);
- serial_echo_outb(0x03, UART_LCR); /* Done with divisor */
+ serial_echo_outb(lcr, UART_LCR); /* Done with divisor */
/* Prior to disabling interrupts, read the LSR and RBR
* registers */
@@ -969,12 +974,14 @@ void wait_keyup( void ) {
* ttyS0
* ttyS1
* ttyS0,115200
+ * ttyS0,9600e8
*/
void serial_console_setup(char *param)
{
char *option, *end;
unsigned long tty;
unsigned long baud_rate;
+ unsigned char parity, bits;
if (strncmp(param, "ttyS", 4))
return; /* not a serial port */
@@ -1005,9 +1012,42 @@ void serial_console_setup(char *param)
if (baud_rate == 0 || (115200 % baud_rate) != 0)
return; /* wrong baud rate */
+ if (*end == '\0')
+ goto save_baud_rate; /* no more options given */
+
+ switch (toupper(*end)) {
+ case 'N':
+ parity = 0;
+ break;
+ case 'O':
+ parity = UART_LCR_PARITY;
+ break;
+ case 'E':
+ parity = UART_LCR_PARITY | UART_LCR_EPAR;
+ break;
+ default:
+ /* Unknown parity */
+ return;
+ }
+
+ end++;
+ if (*end == '\0')
+ goto save_parity;
+
+ /* word length (bits) */
+ if (*end < '7' || *end > '8')
+ return; /* invalid number of bits */
+
+ bits = *end - '0';
+
+ end++;
if (*end != '\0')
return; /* garbage at the end */
+ serial_bits = bits;
+save_parity:
+ serial_parity = parity;
+save_baud_rate:
serial_baud_rate = (int) baud_rate;
save_tty:
serial_tty = (short) tty;