[coreboot-gerrit] Change in coreboot[master]: console/flashconsole: Add support for tx_flush
Youness Alaoui (Code Review)
gerrit at coreboot.org
Wed May 24 18:57:31 CEST 2017
Youness Alaoui has uploaded a new change for review. ( https://review.coreboot.org/19865 )
Change subject: console/flashconsole: Add support for tx_flush
......................................................................
console/flashconsole: Add support for tx_flush
Support flushing the flash console so non \n terminated lines can
be printed to flash. Also use it internally when the line buffering
is done.
Change-Id: I6516ecefddf676bdac6fb97536a08a5c5ecc0d4d
Signed-off-by: Youness Alaoui <youness.alaoui at puri.sm>
---
M src/console/console.c
M src/drivers/spi/flashconsole.c
M src/include/console/flash.h
3 files changed, 46 insertions(+), 15 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/65/19865/1
diff --git a/src/console/console.c b/src/console/console.c
index 2b7f99d..877c8dc 100644
--- a/src/console/console.c
+++ b/src/console/console.c
@@ -63,6 +63,7 @@
__uart_tx_flush();
__ne2k_tx_flush();
__usb_tx_flush();
+ __flashconsole_tx_flush();
}
void console_write_line(uint8_t *buffer, size_t number_of_bytes)
diff --git a/src/drivers/spi/flashconsole.c b/src/drivers/spi/flashconsole.c
index 29680a2..b9b8877 100644
--- a/src/drivers/spi/flashconsole.c
+++ b/src/drivers/spi/flashconsole.c
@@ -98,7 +98,30 @@
memset(line_buffer, 0, LINE_BUFFER_SIZE);
// Set g_rdev last so tx_byte doesn't get executed early
car_set_var(g_rdev, rdev);
+}
+static const struct region_device *_tx_flush(const struct region_device *rdev)
+{
+ uint8_t *line_buffer = car_get_var_ptr(g_line_buffer);
+ uint32_t offset = car_get_var(g_offset);
+ uint32_t region_offset = car_get_var(g_region_offset);
+ uint32_t region_size = car_get_var(g_region_size);
+ uint32_t len = car_get_var(g_line_offset);
+
+ // We crop the rest of the line if the region is full
+ if (offset + len >= region_size)
+ len = region_size - offset;
+
+ rdev_writeat(rdev, line_buffer, region_offset + offset, len);
+
+ // If the region is full, stop future write attempts
+ if (offset + len >= region_size)
+ rdev = NULL;
+
+ car_set_var(g_offset, offset + len);
+ car_set_var(g_line_offset, 0);
+
+ return rdev;
}
void flashconsole_tx_byte(unsigned char c)
@@ -123,22 +146,23 @@
if (len >= LINE_BUFFER_SIZE - 1 ||
offset + len >= region_size || c == '\n') {
- uint32_t region_offset = car_get_var(g_region_offset);
-
- // We crop the rest of the line if the region is full
- if (offset + len >= region_size)
- len = region_size - offset;
-
- rdev_writeat(rdev, line_buffer, region_offset + offset,
- len);
-
- // If the region is full, stop future write attempts
- if (offset + len >= region_size)
- rdev = NULL;
-
- car_set_var(g_offset, offset + len);
- car_set_var(g_line_offset, 0);
+ rdev = _tx_flush(rdev);
}
car_set_var(g_rdev, rdev);
}
+
+}
+
+void flashconsole_tx_flush(void)
+{
+ const struct region_device *rdev = car_get_var(g_rdev);
+
+ if (rdev) {
+ /* Prevent any recursive loops in case the spi flash driver
+ * calls printk (in case of transaction timeout or
+ * any other error while writing) */
+ car_set_var(g_rdev, NULL);
+ rdev = _tx_flush(rdev);
+ car_set_var(g_rdev, rdev);
+ }
}
diff --git a/src/include/console/flash.h b/src/include/console/flash.h
index fa4de00..7bf0c93 100644
--- a/src/include/console/flash.h
+++ b/src/include/console/flash.h
@@ -21,6 +21,7 @@
void flashconsole_init(void);
void flashconsole_tx_byte(unsigned char c);
+void flashconsole_tx_flush(void);
#define __CONSOLE_FLASH_ENABLE__ IS_ENABLED(CONFIG_CONSOLE_SPI_FLASH)
@@ -30,9 +31,14 @@
{
flashconsole_tx_byte(data);
}
+static inline void __flashconsole_tx_flush(void)
+{
+ flashconsole_tx_flush();
+}
#else
static inline void __flashconsole_init(void) {}
static inline void __flashconsole_tx_byte(u8 data) {}
+static inline void __flashconsole_tx_flush(void) {}
#endif /* __CONSOLE_FLASH_ENABLE__ */
--
To view, visit https://review.coreboot.org/19865
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6516ecefddf676bdac6fb97536a08a5c5ecc0d4d
Gerrit-PatchSet: 1
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Youness Alaoui <snifikino at gmail.com>
More information about the coreboot-gerrit
mailing list