@@ -187,35 +187,35 @@ bool flush_console(void)
return ret;
}
-static void inmem_write(char c)
+static void inmem_write(struct memcons *mcon, char c)
{
uint32_t opos;
if (!c)
return;
- memcons.obuf[memcons.out_pos++] = c;
- if (memcons.out_pos >= INMEM_CON_OUT_LEN) {
- memcons.out_pos = 0;
- memcons.has_wrapped = true;
+ mcon->obuf[mcon->out_pos++] = c;
+ if (mcon->out_pos >= INMEM_CON_OUT_LEN) {
+ mcon->out_pos = 0;
+ mcon->has_wrapped = true;
}
/*
- * We must always re-generate memcons.desc->out_pos because
+ * We must always re-generate mcon->desc->out_pos because
* under some circumstances, the console script will
* use a broken putmemproc that does RMW on the full
* 8 bytes containing out_pos and in_prod, thus corrupting
* out_pos
*/
- opos = memcons.out_pos;
- if (memcons.has_wrapped)
+ opos = mcon->out_pos;
+ if (mcon->has_wrapped)
opos |= MEMCONS_OUT_POS_WRAP;
lwsync();
- memcons.desc->out_pos = cpu_to_be32(opos);
+ mcon->desc->out_pos = cpu_to_be32(opos);
}
static void write_char(char c)
{
- inmem_write(c);
+ inmem_write(&memcons, c);
/* If head reaches tail, push tail around & drop chars */
if (flush_head == memcons.desc->out_pos)
@@ -250,15 +250,15 @@ ssize_t write(int fd __unused, const void *buf, size_t count)
return console_write(true, buf, count);
}
-static size_t inmem_read(char *buf, size_t req)
+static size_t inmem_read(struct memcons *mcon, char *buf, size_t req)
{
size_t read = 0;
- char *ibuf = (char *)be64_to_cpu(memcons.desc->ibuf_phys);
+ char *ibuf = (char *)be64_to_cpu(mcon->desc->ibuf_phys);
- while (req && be32_to_cpu(memcons.desc->in_prod) != be32_to_cpu(memcons.desc->in_cons)) {
- *(buf++) = ibuf[be32_to_cpu(memcons.desc->in_cons)];
+ while (req && be32_to_cpu(mcon->desc->in_prod) != be32_to_cpu(mcon->desc->in_cons)) {
+ *(buf++) = ibuf[be32_to_cpu(mcon->desc->in_cons)];
lwsync();
- memcons.desc->in_cons = cpu_to_be32((be32_to_cpu(memcons.desc->in_cons) + 1) % INMEM_CON_IN_LEN);
+ mcon->desc->in_cons = cpu_to_be32((be32_to_cpu(mcon->desc->in_cons) + 1) % INMEM_CON_IN_LEN);
req--;
read++;
}
@@ -271,7 +271,7 @@ ssize_t read(int fd __unused, void *buf, size_t req_count)
size_t count = 0;
if (!count)
- count = inmem_read(buf, req_count);
+ count = inmem_read(&memcons, buf, req_count);
if (need_unlock)
unlock(&con_lock);
return count;
Allow the console ring-buffer read/write functions to be used for any memcons structure. This way we can use them for both the msglog and the cronus in-memory console once they're split apart. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> --- core/console.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)