]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/term/serial.c: Add option for enabling/disabling
authorVladimir Serbinenko <phcoder@gmail.com>
Fri, 8 Nov 2013 17:20:20 +0000 (18:20 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Fri, 8 Nov 2013 17:20:20 +0000 (18:20 +0100)
RTS/CTS flow control.

ChangeLog
grub-core/bus/usb/serial/ftdi.c
grub-core/bus/usb/serial/pl2303.c
grub-core/term/efi/serial.c
grub-core/term/ns8250.c
grub-core/term/serial.c
include/grub/efi/api.h
include/grub/serial.h

index 84c65799e9ea0aafc31284cc016fb89c6cc43aa2..ae852e1565cca8b4bba630530801f9bec2b9d102 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-08  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * b/grub-core/term/serial.c: Add option for enabling/disabling
+       RTS/CTS flow control.
+
 2013-11-08  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/lib/libgcrypt/cipher/idea.c (mul_inv): Remove signed
index 25c1d6f328ccc34024be0bccb41dfc4ac1f45331..1a99cba173361216495593c32656e67ccfc87bf5 100644 (file)
@@ -91,11 +91,13 @@ real_config (struct grub_serial_port *port)
 
   grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
                        GRUB_FTDI_MODEM_CTRL,
-                       GRUB_FTDI_MODEM_CTRL_DTRRTS, 0, 0, 0);
+                       port->config.rtscts ? GRUB_FTDI_MODEM_CTRL_DTRRTS : 0,
+                       0, 0, 0);
 
   grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
                        GRUB_FTDI_FLOW_CTRL,
-                       GRUB_FTDI_FLOW_CTRL_DTRRTS, 0, 0, 0);
+                       port->config.rtscts ? GRUB_FTDI_FLOW_CTRL_DTRRTS : 0,
+                       0, 0, 0);
 
   divisor = get_divisor (port->config.speed);
   grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
index 92b00efa8be5ef89b79ee6b3d6d43dd1c7beb7f5..08095622ae22f163a8266cb246dcdbe1fed6c857 100644 (file)
@@ -125,7 +125,7 @@ real_config (struct grub_serial_port *port)
                        0x22, 3, 0, 0, 0);
 
   grub_usb_control_msg (port->usbdev, GRUB_USB_REQTYPE_VENDOR_OUT,
-                       1, 0, 0x61, 0, 0);
+                       1, 0, port->config.rtscts ? 0x61 : 0, 0, 0);
   port->configured = 1;
 }
 
index dc5f33b4084e662ac291e297c55f880815cfad28..c0911ad7b8a9acc49bdf6736fd18e24f3236a35f 100644 (file)
@@ -58,6 +58,10 @@ do_real_config (struct grub_serial_port *port)
                       stop_bits[port->config.stop_bits]);
   if (status != GRUB_EFI_SUCCESS)
     port->broken = 1;
+
+  status = efi_call_2 (port->interface->set_control_bits, port->interface,
+                      port->config.rtscts ? 0x4002 : 0x2);
+
   port->configured = 1;
 }
 
index b428235cc8bf8480423b8103ea54698b5dbd65da..2959632a95aa82fc29b9cdacb18f83adfdc6959e 100644 (file)
@@ -107,20 +107,22 @@ do_real_config (struct grub_serial_port *port)
             | stop_bits[port->config.stop_bits]);
   grub_outb (status, port->port + UART_LCR);
 
-  /* On Loongson machines serial port has only 3 wires.  */
-#ifndef GRUB_MACHINE_MIPS_LOONGSON
-  /* Enable the FIFO.  */
-  grub_outb (UART_ENABLE_FIFO_TRIGGER1, port->port + UART_FCR);
+  if (port->config.rtscts)
+    {
+      /* Enable the FIFO.  */
+      grub_outb (UART_ENABLE_FIFO_TRIGGER1, port->port + UART_FCR);
 
-  /* Turn on DTR and RTS.  */
-  grub_outb (UART_ENABLE_DTRRTS, port->port + UART_MCR);
-#else
-  /* Enable the FIFO.  */
-  grub_outb (UART_ENABLE_FIFO_TRIGGER14, port->port + UART_FCR);
+      /* Turn on DTR and RTS.  */
+      grub_outb (UART_ENABLE_DTRRTS, port->port + UART_MCR);
+    }
+  else
+    {
+      /* Enable the FIFO.  */
+      grub_outb (UART_ENABLE_FIFO_TRIGGER14, port->port + UART_FCR);
 
-  /* Turn on DTR, RTS, and OUT2.  */
-  grub_outb (UART_ENABLE_DTRRTS | UART_ENABLE_OUT2, port->port + UART_MCR);
-#endif
+      /* Turn on DTR, RTS, and OUT2.  */
+      grub_outb (UART_ENABLE_DTRRTS | UART_ENABLE_OUT2, port->port + UART_MCR);
+    }
 
   /* Drain the input buffer.  */
   endtime = grub_get_time_ms () + 1000;
index 2b97fcc6d685d9f70f35748dd8dfd3df34eb1da6..eac665c855dacc72b06f8c874d192af6d20dc897 100644 (file)
@@ -47,7 +47,8 @@ enum
     OPTION_WORD,
     OPTION_PARITY,
     OPTION_STOP,
-    OPTION_BASE_CLOCK
+    OPTION_BASE_CLOCK,
+    OPTION_RTSCTS
   };
 
 /* Argument options.  */
@@ -60,6 +61,7 @@ static const struct grub_arg_option options[] =
   {"parity", 'r', 0, N_("Set the serial port parity."),      0, ARG_TYPE_STRING},
   {"stop",   't', 0, N_("Set the serial port stop bits."),   0, ARG_TYPE_INT},
   {"base-clock",   'b', 0, N_("Set the base clock."),   0, ARG_TYPE_STRING},
+  {"rtscts",   'f', 0, N_("Enable/disable RTS/CTS."),   "on|off", ARG_TYPE_STRING},
   {0, 0, 0, 0, 0, 0}
 };
 
@@ -237,6 +239,17 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args)
                           N_("unsupported serial port parity"));
     }
 
+  if (state[OPTION_RTSCTS].set)
+    {
+      if (grub_strcmp (state[OPTION_PARITY].arg, "on") == 0)
+       config.rtscts = 1;
+      if (grub_strcmp (state[OPTION_PARITY].arg, "off") == 0)
+       config.rtscts = 0;
+      else
+       return grub_error (GRUB_ERR_BAD_ARGUMENT,
+                          N_("unsupported serial port flow"));
+    }
+
   if (state[OPTION_STOP].set)
     {
       if (! grub_strcmp (state[OPTION_STOP].arg, "1"))
index 69bcd0ccf8f0a62ac9910747f1be556539791d2d..f7503406c0c8ceca2b8ab6e89f62f01f270acfd6 100644 (file)
@@ -1244,7 +1244,8 @@ struct grub_efi_serial_io_interface
                                       grub_efi_parity_type_t parity,
                                       grub_uint8_t word_len,
                                       grub_efi_stop_bits_t stop_bits);
-  void (*set_control_bits) (void);
+  grub_efi_status_t (*set_control_bits) (struct grub_efi_serial_io_interface *this,
+                                        grub_efi_uint32_t flags);
   void (*get_control_bits) (void);
   grub_efi_status_t (*write) (struct grub_efi_serial_io_interface *this,
                              grub_efi_uintn_t *buf_size,
index 7d981f927f2f3365065ffb5f683bd4cf1dc02062..67379de45dd1fef846e062cb9959d541bf5c3b31 100644 (file)
@@ -68,6 +68,7 @@ struct grub_serial_config
   grub_serial_parity_t parity;
   grub_serial_stop_bits_t stop_bits;
   grub_uint64_t base_clock;
+  int rtscts;
 };
 
 struct grub_serial_port
@@ -159,8 +160,11 @@ grub_serial_config_defaults (struct grub_serial_port *port)
     {
 #ifdef GRUB_MACHINE_MIPS_LOONGSON
       .speed = 115200,
+      /* On Loongson machines serial port has only 3 wires.  */
+      .rtscts = 0,
 #else
       .speed = 9600,
+      .rtscts = 1,
 #endif
       .word_len = 8,
       .parity = GRUB_SERIAL_PARITY_NONE,