source: mainline/uspace/srv/hid/fb/niagara.c@ c0e53ff

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since c0e53ff was 336d2f52, checked in by Jakub Jermar <jakub@…>, 14 years ago

Remove support for Sun hardware for which we have no test plan.

This includes the removal of the following functionality only available
via the Simics simulator, for which we have been unable to secure a
license:

  • FHC bus and interrupt controller
  • Zilog 8530 serial controller attached to Sun keyboard
  • Serengeti and SGCN support
  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2006 Ondrej Palkovsky
3 * Copyright (c) 2008 Martin Decky
4 * Copyright (c) 2008 Pavel Rimsky
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * - The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/** @defgroup niagarafb
32 * @brief userland driver of the Niagara console output
33 * @{
34 */
35/** @file
36 */
37
38#include <async.h>
39#include <sysinfo.h>
40#include <as.h>
41#include <errno.h>
42#include <stdio.h>
43#include <ddi.h>
44
45#include "serial_console.h"
46#include "niagara.h"
47
48#define WIDTH 80
49#define HEIGHT 24
50
51/**
52 * Virtual address mapped to the buffer shared with the kernel counterpart.
53 */
54static uintptr_t output_buffer_addr;
55
56/*
57 * Kernel counterpart of the driver reads characters to be printed from here.
58 * Keep in sync with the definition from
59 * kernel/arch/sparc64/src/drivers/niagara.c.
60 */
61#define OUTPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8)
62typedef volatile struct {
63 uint64_t read_ptr;
64 uint64_t write_ptr;
65 char data[OUTPUT_BUFFER_SIZE];
66}
67 __attribute__ ((packed))
68 __attribute__ ((aligned(PAGE_SIZE)))
69 *output_buffer_t;
70
71output_buffer_t output_buffer;
72
73/**
74 * Pushes the character to the Niagara serial.
75 * @param c character to be pushed
76 */
77static void niagara_putc(char c)
78{
79 while (output_buffer->write_ptr ==
80 (output_buffer->read_ptr + OUTPUT_BUFFER_SIZE - 1)
81 % OUTPUT_BUFFER_SIZE)
82 ;
83 output_buffer->data[output_buffer->write_ptr] = (uint64_t) c;
84 output_buffer->write_ptr =
85 ((output_buffer->write_ptr) + 1) % OUTPUT_BUFFER_SIZE;
86}
87
88/**
89 * Initializes the Niagara serial driver.
90 */
91int niagara_init(void)
92{
93 sysarg_t paddr;
94 if (sysinfo_get_value("niagara.outbuf.address", &paddr) != EOK)
95 return -1;
96
97 output_buffer_addr = (uintptr_t) as_get_mappable_page(PAGE_SIZE);
98 int result = physmem_map((void *) paddr,
99 (void *) output_buffer_addr, 1,
100 AS_AREA_READ | AS_AREA_WRITE);
101
102 if (result != 0) {
103 printf("Niagara: uspace driver couldn't map physical memory: %d\n",
104 result);
105 }
106
107 output_buffer = (output_buffer_t) output_buffer_addr;
108
109 serial_console_init(niagara_putc, WIDTH, HEIGHT);
110 async_set_client_connection(serial_client_connection);
111 return 0;
112}
113
114/**
115 * @}
116 */
117
Note: See TracBrowser for help on using the repository browser.