Ignore:
Timestamp:
2017-11-26T02:41:55Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f4cfd271
Parents:
9940ce0
Message:

Move sending side of Sun4v console out of output server.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/char/sun4v-con/sun4v-con.c

    r9940ce0 r5f4c41b2  
    3838#include <io/chardev_srv.h>
    3939#include <stdbool.h>
    40 #include <thread.h>
     40#include <sysinfo.h>
    4141
    4242#include "sun4v-con.h"
     
    5959} __attribute__((packed)) __attribute__((aligned(PAGE_SIZE))) *input_buffer_t;
    6060
     61#define OUTPUT_FIFO_SIZE  ((PAGE_SIZE) - 2 * sizeof(uint64_t))
     62
     63typedef volatile struct {
     64        uint64_t read_ptr;
     65        uint64_t write_ptr;
     66        char data[OUTPUT_FIFO_SIZE];
     67} __attribute__((packed)) output_fifo_t;
     68
    6169/* virtual address of the shared buffer */
    6270static input_buffer_t input_buffer;
     71static output_fifo_t *output_fifo;
    6372
    6473static int sun4v_con_read(chardev_srv_t *, void *, size_t, size_t *);
     
    7281static void sun4v_con_putchar(sun4v_con_t *con, uint8_t data)
    7382{
    74         (void) con;
    75         (void) data;
     83        if (data == '\n')
     84                sun4v_con_putchar(con, '\r');
     85
     86        while (output_fifo->write_ptr ==
     87            (output_fifo->read_ptr + OUTPUT_FIFO_SIZE - 1)
     88            % OUTPUT_FIFO_SIZE);
     89
     90        output_fifo->data[output_fifo->write_ptr] = data;
     91        output_fifo->write_ptr =
     92            ((output_fifo->write_ptr) + 1) % OUTPUT_FIFO_SIZE;
    7693}
    7794
     
    105122        }
    106123
     124        sysarg_t paddr;
     125        rc = sysinfo_get_value("niagara.outbuf.address", &paddr);
     126        if (rc != EOK) {
     127                ddf_msg(LVL_ERROR, "Outbuf address information not found");
     128                return rc;
     129        }
     130
     131        output_fifo = (output_fifo_t *) AS_AREA_ANY;
     132
     133        rc = physmem_map(paddr, 1, AS_AREA_READ | AS_AREA_WRITE,
     134            (void *) &output_fifo);
     135        if (rc != EOK) {
     136                ddf_msg(LVL_ERROR, "Error mapping memory: %d", rc);
     137                return rc;
     138        }
     139
    107140        rc = ddf_fun_bind(fun);
    108141        if (rc != EOK) {
     
    111144        }
    112145
     146        ddf_fun_add_to_category(fun, "console");
     147
    113148        return EOK;
    114149error:
    115         /* XXX Clean up thread */
    116 
    117150        if (input_buffer != (input_buffer_t) AS_AREA_ANY)
    118151                physmem_unmap((void *) input_buffer);
Note: See TracChangeset for help on using the changeset viewer.