MCPcopy Create free account
hub / github.com/coreboot/coreboot / flashconsole_tx_flush

Function flashconsole_tx_flush

src/drivers/spi/flashconsole.c:86–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86void flashconsole_tx_flush(void)
87{
88 size_t len = line_offset;
89 size_t region_size;
90
91 /* Prevent any recursive loops in case the spi flash driver
92 * calls printk (in case of transaction timeout or
93 * any other error while writing) */
94 static bool busy;
95
96 /* In addition to being an obvious runtime optimization, checking for
97 * len = 0 also prevents false disabling of the driver, as rdev_writeat
98 * seems to return -1 if len is zero even though this should be a
99 * recoverable condition. */
100 if (busy || !rdev_ptr || len == 0)
101 return;
102
103 busy = true;
104 region_size = region_device_sz(rdev_ptr);
105 if (offset + len >= region_size)
106 len = region_size - offset;
107
108 if (rdev_writeat(&rdev, line_buffer, offset, len) != len)
109 return;
110
111 // If the region is full, stop future write attempts
112 if (offset + len >= region_size)
113 return;
114
115 offset += len;
116 line_offset = 0;
117
118 busy = false;
119}

Callers 2

flashconsole_tx_byteFunction · 0.85
__flashconsole_tx_flushFunction · 0.85

Calls 2

region_device_szFunction · 0.85
rdev_writeatFunction · 0.85

Tested by

no test coverage detected