Index: kernel/arch/sparc64/include/arch/drivers/niagara_buf.h
===================================================================
--- kernel/arch/sparc64/include/arch/drivers/niagara_buf.h	(revision d9ec808b547e5990edc7280d9d8399acd2a5d86f)
+++ kernel/arch/sparc64/include/arch/drivers/niagara_buf.h	(revision d9ec808b547e5990edc7280d9d8399acd2a5d86f)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2008 Pavel Rimsky
+ * Copyright (c) 2017 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup sparc64
+ * @{
+ */
+/**
+ * @file
+ * @brief Niagara input/output buffer shared between kernel and user space
+ */
+
+#ifdef KERNEL
+#include <mm/as.h>
+#else
+#include <as.h>
+#endif
+
+#include <stdint.h>
+
+#define OUTPUT_BUFFER_SIZE  ((PAGE_SIZE) - 2 * 8)
+
+typedef struct {
+	uint64_t read_ptr;
+	uint64_t write_ptr;
+	char data[OUTPUT_BUFFER_SIZE];
+} __attribute__ ((packed)) niagara_output_buffer_t;
+
+#define INPUT_BUFFER_SIZE  ((PAGE_SIZE) - 2 * 8)
+
+typedef struct {
+	uint64_t write_ptr;
+	uint64_t read_ptr;
+	char data[INPUT_BUFFER_SIZE];
+} __attribute__ ((packed)) niagara_input_buffer_t;
+
+/** @}
+ */
Index: kernel/arch/sparc64/src/drivers/niagara.c
===================================================================
--- kernel/arch/sparc64/src/drivers/niagara.c	(revision 7b8f9334dad3203745fb5ee2bf4bedb758659ae3)
+++ kernel/arch/sparc64/src/drivers/niagara.c	(revision d9ec808b547e5990edc7280d9d8399acd2a5d86f)
@@ -42,4 +42,5 @@
 #include <arch.h>
 #include <mm/slab.h>
+#include <arch/drivers/niagara_buf.h>
 #include <arch/drivers/kbd.h>
 #include <arch/sun4v/hypercall.h>
@@ -81,11 +82,6 @@
  * buffer definition follows.
  */
-#define OUTPUT_BUFFER_SIZE  ((PAGE_SIZE) - 2 * 8)
-
-static volatile struct {
-	uint64_t read_ptr;
-	uint64_t write_ptr;
-	char data[OUTPUT_BUFFER_SIZE];
-} __attribute__ ((packed)) __attribute__ ((aligned(PAGE_SIZE))) output_buffer;
+static volatile niagara_output_buffer_t __attribute__ ((aligned(PAGE_SIZE)))
+    output_buffer;
 
 static parea_t outbuf_parea;
@@ -94,11 +90,6 @@
  * Analogous to the output_buffer, see the previous definition.
  */
-#define INPUT_BUFFER_SIZE  ((PAGE_SIZE) - 2 * 8)
-
-static volatile struct {
-	uint64_t write_ptr;
-	uint64_t read_ptr;
-	char data[INPUT_BUFFER_SIZE];
-} __attribute__ ((packed)) __attribute__ ((aligned(PAGE_SIZE))) input_buffer;
+static volatile niagara_input_buffer_t __attribute__ ((aligned(PAGE_SIZE)))
+    input_buffer;
 
 static parea_t inbuf_parea;
Index: uspace/drv/char/sun4v-con/niagara_buf.h
===================================================================
--- uspace/drv/char/sun4v-con/niagara_buf.h	(revision d9ec808b547e5990edc7280d9d8399acd2a5d86f)
+++ uspace/drv/char/sun4v-con/niagara_buf.h	(revision d9ec808b547e5990edc7280d9d8399acd2a5d86f)
@@ -0,0 +1,1 @@
+../../../../kernel/arch/sparc64/include/arch/drivers/niagara_buf.h
Index: uspace/drv/char/sun4v-con/sun4v-con.c
===================================================================
--- uspace/drv/char/sun4v-con/sun4v-con.c	(revision 7b8f9334dad3203745fb5ee2bf4bedb758659ae3)
+++ uspace/drv/char/sun4v-con/sun4v-con.c	(revision d9ec808b547e5990edc7280d9d8399acd2a5d86f)
@@ -39,4 +39,5 @@
 #include <stdbool.h>
 
+#include "niagara_buf.h"
 #include "sun4v-con.h"
 
@@ -45,28 +46,7 @@
 #define POLL_INTERVAL  10000
 
-/*
- * Kernel counterpart of the driver pushes characters (it has read) here.
- * Keep in sync with the definition from
- * kernel/arch/sparc64/src/drivers/niagara.c.
- */
-#define INPUT_BUFFER_SIZE  ((PAGE_SIZE) - 2 * 8)
-
-typedef volatile struct {
-	uint64_t write_ptr;
-	uint64_t read_ptr;
-	char data[INPUT_BUFFER_SIZE];
-} __attribute__((packed)) __attribute__((aligned(PAGE_SIZE))) *input_buffer_t;
-
-#define OUTPUT_FIFO_SIZE  ((PAGE_SIZE) - 2 * sizeof(uint64_t))
-
-typedef volatile struct {
-	uint64_t read_ptr;
-	uint64_t write_ptr;
-	char data[OUTPUT_FIFO_SIZE];
-} __attribute__((packed)) output_fifo_t;
-
 /* virtual address of the shared buffer */
-static input_buffer_t input_buffer;
-static output_fifo_t *output_fifo;
+static niagara_input_buffer_t *input_buffer;
+static niagara_output_buffer_t *output_fifo;
 
 static int sun4v_con_read(chardev_srv_t *, void *, size_t, size_t *);
@@ -84,10 +64,10 @@
 
 	while (output_fifo->write_ptr ==
-	    (output_fifo->read_ptr + OUTPUT_FIFO_SIZE - 1)
-	    % OUTPUT_FIFO_SIZE);
+	    (output_fifo->read_ptr + OUTPUT_BUFFER_SIZE - 1)
+	    % OUTPUT_BUFFER_SIZE);
 
 	output_fifo->data[output_fifo->write_ptr] = data;
 	output_fifo->write_ptr =
-	    ((output_fifo->write_ptr) + 1) % OUTPUT_FIFO_SIZE;
+	    ((output_fifo->write_ptr) + 1) % OUTPUT_BUFFER_SIZE;
 }
 
@@ -99,5 +79,5 @@
 
 	con->res = *res;
-	input_buffer = (input_buffer_t) AS_AREA_ANY;
+	input_buffer = (niagara_input_buffer_t *) AS_AREA_ANY;
 
 	fun = ddf_fun_create(con->dev, fun_exposed, "a");
@@ -121,5 +101,5 @@
 	}
 
-	output_fifo = (output_fifo_t *) AS_AREA_ANY;
+	output_fifo = (niagara_output_buffer_t *) AS_AREA_ANY;
 
 	rc = physmem_map(res->out_base, 1, AS_AREA_READ | AS_AREA_WRITE,
@@ -140,8 +120,8 @@
 	return EOK;
 error:
-	if (input_buffer != (input_buffer_t) AS_AREA_ANY)
+	if (input_buffer != (niagara_input_buffer_t *) AS_AREA_ANY)
 		physmem_unmap((void *) input_buffer);
 
-	if (output_fifo != (output_fifo_t *) AS_AREA_ANY)
+	if (output_fifo != (niagara_output_buffer_t *) AS_AREA_ANY)
 		physmem_unmap((void *) output_fifo);
 
