change log for rtems (2010-06-22)

rtems-vc at rtems.org rtems-vc at rtems.org
Tue Jun 22 12:12:06 UTC 2010


 *ccj* (on branch rtems-4-10-branch):
2010-06-22      Chris Johns <chrisj at rtems.org>

        * startup/m68k-stub.c: PR 1539. Fix buffer overrun.

M 1.126.2.1  c/src/lib/libbsp/m68k/ods68302/ChangeLog
M 1.11.2.1  c/src/lib/libbsp/m68k/ods68302/startup/m68k-stub.c

diff -u rtems/c/src/lib/libbsp/m68k/ods68302/ChangeLog:1.126 rtems/c/src/lib/libbsp/m68k/ods68302/ChangeLog:1.126.2.1
--- rtems/c/src/lib/libbsp/m68k/ods68302/ChangeLog:1.126	Fri Apr 30 11:44:16 2010
+++ rtems/c/src/lib/libbsp/m68k/ods68302/ChangeLog	Tue Jun 22 06:23:22 2010
@@ -1,3 +1,7 @@
+2010-06-22     Chris Johns <chrisj at rtems.org>
+
+	* startup/m68k-stub.c: PR 1539. Fix buffer overrun.
+
 2010-04-30	Joel Sherrill <joel.sherrilL at OARcorp.com>
 
 	* include/bsp.h: Add BSP_SMALL_MEMORY.

diff -u rtems/c/src/lib/libbsp/m68k/ods68302/startup/m68k-stub.c:1.11 rtems/c/src/lib/libbsp/m68k/ods68302/startup/m68k-stub.c:1.11.2.1
--- rtems/c/src/lib/libbsp/m68k/ods68302/startup/m68k-stub.c:1.11	Wed Apr 28 14:43:37 2010
+++ rtems/c/src/lib/libbsp/m68k/ods68302/startup/m68k-stub.c	Tue Jun 22 06:23:22 2010
@@ -601,7 +601,7 @@
     count = 0;
 
     /* now, read until a # or end of buffer is found */
-    while (count < BUFMAX) {
+    while (count < (BUFMAX - 1)) {
       ch = getDebugChar() & 0x7f;
       if (ch == '#') break;
       checksum = checksum + ch;


 *sh*:
2010-06-22	Arnout Vandecappelle <arnout at mind.be>

	PR 1580/misc
	* libchip/i2c/spi-sd-card.c: Use bigger chunks and yield processor
	while waiting for read data.

M  1.527  c/src/ChangeLog
M   1.22  c/src/libchip/i2c/spi-sd-card.c

diff -u rtems/c/src/ChangeLog:1.526 rtems/c/src/ChangeLog:1.527
--- rtems/c/src/ChangeLog:1.526	Tue Jun 22 03:41:08 2010
+++ rtems/c/src/ChangeLog	Tue Jun 22 06:36:13 2010
@@ -1,5 +1,11 @@
 2010-06-22	Arnout Vandecappelle <arnout at mind.be>
 
+	PR 1580/misc
+	* libchip/i2c/spi-sd-card.c: Use bigger chunks and yield processor
+	while waiting for read data.
+
+2010-06-22	Arnout Vandecappelle <arnout at mind.be>
+
 	PR 1579/misc
 	* libchip/i2c/spi-sd-card.c: Gradually increasing sleep times when
 	waiting for write to finish.

diff -u rtems/c/src/libchip/i2c/spi-sd-card.c:1.21 rtems/c/src/libchip/i2c/spi-sd-card.c:1.22
--- rtems/c/src/libchip/i2c/spi-sd-card.c:1.21	Tue Jun 22 03:41:08 2010
+++ rtems/c/src/libchip/i2c/spi-sd-card.c	Tue Jun 22 06:36:14 2010
@@ -374,7 +374,7 @@
 	   FIXME should actually look at R2W_FACTOR for non-HC cards. */
 	int retries = e->n_ac_max * 25 / 10;
 	/* n_ac_max/100 is supposed to be the average waiting time. To
-	   approximate this, we start with waiting n_ac_max/250 and
+	   approximate this, we start with waiting n_ac_max/150 and
 	   gradually increase the waiting time. */
 	int wait_time_bytes = (retries + 149) / 150;
 	while (e->busy) {
@@ -530,57 +530,65 @@
 {
 	int rv = 0;
 
-	/* Access time idle tokens */
-	uint32_t n_ac = 1;
-
 	/* Discard command response */
 	int r = e->response_index + 1;
 
-	/* Minimum token number before data start */
-	int next_response_size = 2;
-
 	/* Standard response size */
 	int response_size = SD_CARD_COMMAND_SIZE;
 
+	/* Where the response is stored */
+	uint8_t *response = e->response;
+
 	/* Data input index */
 	int i = 0;
 
 	/* CRC check of data */
 	uint16_t crc16;
 
+	/* Maximum number of tokens to read. */
+	int retries = e->n_ac_max;
+
 	SD_CARD_INVALIDATE_RESPONSE_INDEX( e);
 
 	while (true) {
 		RTEMS_DEBUG_PRINT( "Search from %u to %u\n", r, response_size - 1);
 
 		/* Search the data start token in in current response buffer */
+		retries -= (response_size - r);
 		while (r < response_size) {
-			RTEMS_DEBUG_PRINT( "Token [%02u]: 0x%02x\n", r, e->response [r]);
-			if (n_ac > e->n_ac_max) {
-				RTEMS_SYSLOG_ERROR( "Timeout\n");
-				return -RTEMS_IO_ERROR;
-			} else if (e->response [r] == start_token) {
+			RTEMS_DEBUG_PRINT( "Token [%02u]: 0x%02x\n", r, response [r]);
+			if (response [r] == start_token) {
 				/* Discard data start token */
 				++r;
 				goto sd_card_read_start;
-			} else if (SD_CARD_IS_DATA_ERROR( e->response [r])) {
-				RTEMS_SYSLOG_ERROR( "Data error token [%02i]: 0x%02" PRIx8 "\n", r, e->response [r]);
+			} else if (SD_CARD_IS_DATA_ERROR( response [r])) {
+				RTEMS_SYSLOG_ERROR( "Data error token [%02i]: 0x%02" PRIx8 "\n", r, response [r]);
 				return -RTEMS_IO_ERROR;
-			} else if (e->response [r] != SD_CARD_IDLE_TOKEN) {
-				RTEMS_SYSLOG_ERROR( "Unexpected token [%02i]: 0x%02" PRIx8 "\n", r, e->response [r]);
+			} else if (response [r] != SD_CARD_IDLE_TOKEN) {
+				RTEMS_SYSLOG_ERROR( "Unexpected token [%02i]: 0x%02" PRIx8 "\n", r, response [r]);
 				return -RTEMS_IO_ERROR;
 			}
-			++n_ac;
 			++r;
 		}
 
-		/* Query more */
-		rv = sd_card_query( e, e->response, next_response_size);
-		RTEMS_CHECK_RV( rv, "Query data start token");
+		if (retries <= 0) {
+			RTEMS_SYSLOG_ERROR( "Timeout\n");
+			return -RTEMS_IO_ERROR;
+		}
 
-		/* Set standard query size */
-		response_size = next_response_size;
-		next_response_size = SD_CARD_COMMAND_SIZE;
+		if (e->schedule_if_busy)
+			rtems_task_wake_after( RTEMS_YIELD_PROCESSOR);
+
+		/* Query more.  We typically have to wait between 10 and 100
+		   bytes.  To reduce overhead, read the response in chunks of
+		   50 bytes - this doesn't introduce too much copy overhead
+		   but does allow SPI DMA transfers to work efficiently. */
+		response = in;
+		response_size = 50;
+		if (response_size > n)
+			response_size = n;
+		rv = sd_card_query( e, response, response_size);
+		RTEMS_CHECK_RV( rv, "Query data start token");
 
 		/* Reset start position */
 		r = 0;
@@ -590,7 +598,7 @@
 
 	/* Read data */
 	while (r < response_size && i < n) {
-		in [i++] = e->response [r++];
+		in [i++] = response [r++];
 	}
 
 	/* Read more data? */



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20100622/24e63c02/attachment-0001.html>


More information about the vc mailing list