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

Ignore:
Timestamp:
2017-11-27T08:25:37Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
59953b57
Parents:
7b8f933
git-author:
Jiri Svoboda <jiri@…> (2017-11-26 21:24:27)
git-committer:
Jiri Svoboda <jiri@…> (2017-11-27 08:25:37)
Message:

Niagara console driver buddies should share buffer definition.

File:
1 edited

Legend:

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

    r7b8f933 rd9ec808b  
    3939#include <stdbool.h>
    4040
     41#include "niagara_buf.h"
    4142#include "sun4v-con.h"
    4243
     
    4546#define POLL_INTERVAL  10000
    4647
    47 /*
    48  * Kernel counterpart of the driver pushes characters (it has read) here.
    49  * Keep in sync with the definition from
    50  * kernel/arch/sparc64/src/drivers/niagara.c.
    51  */
    52 #define INPUT_BUFFER_SIZE  ((PAGE_SIZE) - 2 * 8)
    53 
    54 typedef volatile struct {
    55         uint64_t write_ptr;
    56         uint64_t read_ptr;
    57         char data[INPUT_BUFFER_SIZE];
    58 } __attribute__((packed)) __attribute__((aligned(PAGE_SIZE))) *input_buffer_t;
    59 
    60 #define OUTPUT_FIFO_SIZE  ((PAGE_SIZE) - 2 * sizeof(uint64_t))
    61 
    62 typedef volatile struct {
    63         uint64_t read_ptr;
    64         uint64_t write_ptr;
    65         char data[OUTPUT_FIFO_SIZE];
    66 } __attribute__((packed)) output_fifo_t;
    67 
    6848/* virtual address of the shared buffer */
    69 static input_buffer_t input_buffer;
    70 static output_fifo_t *output_fifo;
     49static niagara_input_buffer_t *input_buffer;
     50static niagara_output_buffer_t *output_fifo;
    7151
    7252static int sun4v_con_read(chardev_srv_t *, void *, size_t, size_t *);
     
    8464
    8565        while (output_fifo->write_ptr ==
    86             (output_fifo->read_ptr + OUTPUT_FIFO_SIZE - 1)
    87             % OUTPUT_FIFO_SIZE);
     66            (output_fifo->read_ptr + OUTPUT_BUFFER_SIZE - 1)
     67            % OUTPUT_BUFFER_SIZE);
    8868
    8969        output_fifo->data[output_fifo->write_ptr] = data;
    9070        output_fifo->write_ptr =
    91             ((output_fifo->write_ptr) + 1) % OUTPUT_FIFO_SIZE;
     71            ((output_fifo->write_ptr) + 1) % OUTPUT_BUFFER_SIZE;
    9272}
    9373
     
    9979
    10080        con->res = *res;
    101         input_buffer = (input_buffer_t) AS_AREA_ANY;
     81        input_buffer = (niagara_input_buffer_t *) AS_AREA_ANY;
    10282
    10383        fun = ddf_fun_create(con->dev, fun_exposed, "a");
     
    121101        }
    122102
    123         output_fifo = (output_fifo_t *) AS_AREA_ANY;
     103        output_fifo = (niagara_output_buffer_t *) AS_AREA_ANY;
    124104
    125105        rc = physmem_map(res->out_base, 1, AS_AREA_READ | AS_AREA_WRITE,
     
    140120        return EOK;
    141121error:
    142         if (input_buffer != (input_buffer_t) AS_AREA_ANY)
     122        if (input_buffer != (niagara_input_buffer_t *) AS_AREA_ANY)
    143123                physmem_unmap((void *) input_buffer);
    144124
    145         if (output_fifo != (output_fifo_t *) AS_AREA_ANY)
     125        if (output_fifo != (niagara_output_buffer_t *) AS_AREA_ANY)
    146126                physmem_unmap((void *) output_fifo);
    147127
Note: See TracChangeset for help on using the changeset viewer.