Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 59953b57 in mainline


Ignore:
Timestamp:
2017-11-27T08:33:46Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
c309b18
Parents:
d9ec808b
git-author:
Jiri Svoboda <jiri@…> (2017-11-26 21:33:12)
git-committer:
Jiri Svoboda <jiri@…> (2017-11-27 08:33:46)
Message:

Sun4v-con should not store per-instance buffer addresses in a global variable.

Location:
uspace/drv/char/sun4v-con
Files:
2 edited

Legend:

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

    rd9ec808b r59953b57  
    3939#include <stdbool.h>
    4040
    41 #include "niagara_buf.h"
    4241#include "sun4v-con.h"
    4342
     
    4544
    4645#define POLL_INTERVAL  10000
    47 
    48 /* virtual address of the shared buffer */
    49 static niagara_input_buffer_t *input_buffer;
    50 static niagara_output_buffer_t *output_fifo;
    5146
    5247static int sun4v_con_read(chardev_srv_t *, void *, size_t, size_t *);
     
    6358                sun4v_con_putchar(con, '\r');
    6459
    65         while (output_fifo->write_ptr ==
    66             (output_fifo->read_ptr + OUTPUT_BUFFER_SIZE - 1)
     60        while (con->output_buffer->write_ptr ==
     61            (con->output_buffer->read_ptr + OUTPUT_BUFFER_SIZE - 1)
    6762            % OUTPUT_BUFFER_SIZE);
    6863
    69         output_fifo->data[output_fifo->write_ptr] = data;
    70         output_fifo->write_ptr =
    71             ((output_fifo->write_ptr) + 1) % OUTPUT_BUFFER_SIZE;
     64        con->output_buffer->data[con->output_buffer->write_ptr] = data;
     65        con->output_buffer->write_ptr =
     66            ((con->output_buffer->write_ptr) + 1) % OUTPUT_BUFFER_SIZE;
    7267}
    7368
     
    7974
    8075        con->res = *res;
    81         input_buffer = (niagara_input_buffer_t *) AS_AREA_ANY;
     76        con->input_buffer = (niagara_input_buffer_t *) AS_AREA_ANY;
    8277
    8378        fun = ddf_fun_create(con->dev, fun_exposed, "a");
     
    9590
    9691        rc = physmem_map(res->in_base, 1, AS_AREA_READ | AS_AREA_WRITE,
    97             (void *) &input_buffer);
     92            (void *) &con->input_buffer);
    9893        if (rc != EOK) {
    9994                ddf_msg(LVL_ERROR, "Error mapping memory: %d", rc);
     
    10196        }
    10297
    103         output_fifo = (niagara_output_buffer_t *) AS_AREA_ANY;
     98        con->output_buffer = (niagara_output_buffer_t *) AS_AREA_ANY;
    10499
    105100        rc = physmem_map(res->out_base, 1, AS_AREA_READ | AS_AREA_WRITE,
    106             (void *) &output_fifo);
     101            (void *) &con->output_buffer);
    107102        if (rc != EOK) {
    108103                ddf_msg(LVL_ERROR, "Error mapping memory: %d", rc);
     
    120115        return EOK;
    121116error:
    122         if (input_buffer != (niagara_input_buffer_t *) AS_AREA_ANY)
    123                 physmem_unmap((void *) input_buffer);
     117        if (con->input_buffer != (niagara_input_buffer_t *) AS_AREA_ANY)
     118                physmem_unmap((void *) con->input_buffer);
    124119
    125         if (output_fifo != (niagara_output_buffer_t *) AS_AREA_ANY)
    126                 physmem_unmap((void *) output_fifo);
     120        if (con->output_buffer != (niagara_output_buffer_t *) AS_AREA_ANY)
     121                physmem_unmap((void *) con->output_buffer);
    127122
    128123        if (fun != NULL)
     
    148143    size_t *nread)
    149144{
     145        sun4v_con_t *con = (sun4v_con_t *) srv->srvs->sarg;
    150146        size_t p;
    151147        uint8_t *bp = (uint8_t *) buf;
    152148        char c;
    153149
    154         while (input_buffer->read_ptr == input_buffer->write_ptr)
     150        while (con->input_buffer->read_ptr == con->input_buffer->write_ptr)
    155151                fibril_usleep(POLL_INTERVAL);
    156152
    157153        p = 0;
    158         while (p < size && input_buffer->read_ptr != input_buffer->write_ptr) {
    159                 c = input_buffer->data[input_buffer->read_ptr];
    160                 input_buffer->read_ptr =
    161                     ((input_buffer->read_ptr) + 1) % INPUT_BUFFER_SIZE;
     154        while (p < size && con->input_buffer->read_ptr != con->input_buffer->write_ptr) {
     155                c = con->input_buffer->data[con->input_buffer->read_ptr];
     156                con->input_buffer->read_ptr =
     157                    ((con->input_buffer->read_ptr) + 1) % INPUT_BUFFER_SIZE;
    162158                bp[p++] = c;
    163159        }
  • uspace/drv/char/sun4v-con/sun4v-con.h

    rd9ec808b r59953b57  
    4242#include <stdint.h>
    4343
     44#include "niagara_buf.h"
     45
    4446/** Sun4v console resources */
    4547typedef struct {
     
    5456        chardev_srvs_t cds;
    5557        sun4v_con_res_t res;
     58        /** Virtual address of the shared input buffer */
     59        niagara_input_buffer_t *input_buffer;
     60        /** Virtual address of the shared input buffer */
     61        niagara_output_buffer_t *output_buffer;
    5662} sun4v_con_t;
    5763
Note: See TracChangeset for help on using the changeset viewer.