Bus Pirate support needs serial communication. Serprog already has such
functionality, so it makes sense to share that.
TODO: Factor out serial communication into a separate file, have that
code be available even if serprog is not selected and make it portable
(it is very Linux-centric right now).

Signed-off-by: Carl-Daniel Hailfinger <[email protected]>
Acked-by: Stefan Reinauer <[email protected]>

Index: flashrom-serprog_share/flash.h
===================================================================
--- flashrom-serprog_share/flash.h      (Revision 767)
+++ flashrom-serprog_share/flash.h      (Arbeitskopie)
@@ -736,5 +736,8 @@
 uint8_t serprog_chip_readb(const chipaddr addr);
 void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
 void serprog_delay(int delay);
+void sp_flush_incoming(void);
+int sp_openserport(char *dev, unsigned int baud);
+extern int sp_fd;
 
 #endif                         /* !__FLASH_H__ */
Index: flashrom-serprog_share/serprog.c
===================================================================
--- flashrom-serprog_share/serprog.c    (Revision 767)
+++ flashrom-serprog_share/serprog.c    (Arbeitskopie)
@@ -61,7 +61,7 @@
 #define S_CMD_Q_RDNMAXLEN      0x11    /* Query read-n maximum length          
        */
 #define S_CMD_S_BUSTYPE                0x12    /* Set used bustype(s).         
                */
 
-static int sp_fd;
+int sp_fd;
 
 static uint16_t sp_device_serbuf_size = 16;
 static uint16_t sp_device_opbuf_size = 300;
@@ -185,7 +185,7 @@
        {0, 0}                  /* Terminator */
 };
 
-static int sp_openserport(char *dev, unsigned int baud)
+int sp_openserport(char *dev, unsigned int baud)
 {
        struct termios options;
        int fd, i;
@@ -208,20 +208,16 @@
                        break;
                }
        }
-       options.c_cflag &= ~PARENB;
-       options.c_cflag &= ~CSTOPB;
-       options.c_cflag &= ~CSIZE;
-       options.c_cflag |= CS8;
-       options.c_cflag &= ~CRTSCTS;
+       options.c_cflag &= ~(PARENB | CSTOPB | CSIZE | CRTSCTS);
+       options.c_cflag |= (CS8 | CLOCAL | CREAD);
        options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
        options.c_iflag &= ~(IXON | IXOFF | IXANY | ICRNL | IGNCR | INLCR);
        options.c_oflag &= ~OPOST;
-       options.c_cflag |= (CLOCAL | CREAD);
        tcsetattr(fd, TCSANOW, &options);
        return fd;
 }
 
-static void sp_flush_incoming(void)
+void sp_flush_incoming(void)
 {
        int i;
        for (i=0;i<100;i++) { /* In case the device doesnt do EAGAIN, just read 
0 */


-- 
Developer quote of the month: 
"We are juggling too many chainsaws and flaming arrows and tigers."


_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to