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

Changeset d9ec808b in mainline


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.

Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/src/drivers/niagara.c

    r7b8f933 rd9ec808b  
    4242#include <arch.h>
    4343#include <mm/slab.h>
     44#include <arch/drivers/niagara_buf.h>
    4445#include <arch/drivers/kbd.h>
    4546#include <arch/sun4v/hypercall.h>
     
    8182 * buffer definition follows.
    8283 */
    83 #define OUTPUT_BUFFER_SIZE  ((PAGE_SIZE) - 2 * 8)
    84 
    85 static volatile struct {
    86         uint64_t read_ptr;
    87         uint64_t write_ptr;
    88         char data[OUTPUT_BUFFER_SIZE];
    89 } __attribute__ ((packed)) __attribute__ ((aligned(PAGE_SIZE))) output_buffer;
     84static volatile niagara_output_buffer_t __attribute__ ((aligned(PAGE_SIZE)))
     85    output_buffer;
    9086
    9187static parea_t outbuf_parea;
     
    9490 * Analogous to the output_buffer, see the previous definition.
    9591 */
    96 #define INPUT_BUFFER_SIZE  ((PAGE_SIZE) - 2 * 8)
    97 
    98 static volatile struct {
    99         uint64_t write_ptr;
    100         uint64_t read_ptr;
    101         char data[INPUT_BUFFER_SIZE];
    102 } __attribute__ ((packed)) __attribute__ ((aligned(PAGE_SIZE))) input_buffer;
     92static volatile niagara_input_buffer_t __attribute__ ((aligned(PAGE_SIZE)))
     93    input_buffer;
    10394
    10495static parea_t inbuf_parea;
  • 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.