source: mainline/uspace/srv/hid/fb/port/ski.c@ c7f9037

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since c7f9037 was 7c014d1, checked in by Martin Decky <martin@…>, 14 years ago

console and framebuffer server rewrite

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 * Copyright (c) 2006 Ondrej Palkovsky
3 * Copyright (c) 2008 Martin Decky
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @file
31 */
32
33#include <sys/types.h>
34#include <errno.h>
35#include <sysinfo.h>
36#include "../ctl/serial.h"
37#include "ski.h"
38
39#ifdef UARCH_ia64
40
41#define SKI_PUTCHAR 31
42
43/** Display character on ski debug console
44 *
45 * Use SSC (Simulator System Call) to
46 * display character on debug console.
47 *
48 * @param c Character to be printed.
49 *
50 */
51static void ski_putc(const char c)
52{
53 asm volatile (
54 "mov r15 = %0\n"
55 "mov r32 = %1\n" /* r32 is in0 */
56 "break 0x80000\n" /* modifies r8 */
57 :
58 : "i" (SKI_PUTCHAR), "r" (c)
59 : "r15", "in0", "r8"
60 );
61
62 if (c == '\n')
63 ski_putc('\r');
64}
65
66static void ski_putchar(wchar_t ch)
67{
68 if ((ch >= 0) && (ch < 128))
69 ski_putc(ch);
70 else
71 ski_putc('?');
72}
73
74static void ski_control_puts(const char *str)
75{
76 while (*str)
77 ski_putc(*(str++));
78}
79
80int ski_init(void)
81{
82 sysarg_t present;
83 int rc = sysinfo_get_value("fb", &present);
84 if (rc != EOK)
85 present = false;
86
87 if (!present)
88 return ENOENT;
89
90 sysarg_t kind;
91 rc = sysinfo_get_value("fb.kind", &kind);
92 if (rc != EOK)
93 kind = (sysarg_t) -1;
94
95 if (kind != 6)
96 return EINVAL;
97
98 return serial_init(ski_putchar, ski_control_puts);
99}
100
101#else /* UARCH_ia64 */
102
103int ski_init(void)
104{
105 return ENOENT;
106}
107
108#endif
109
110/** @}
111 */
Note: See TracBrowser for help on using the repository browser.