source: mainline/uspace/srv/hid/output/port/ski.c@ 24abb85d

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

Reduce the number of files that include <sys/types.h>

  • Property mode set to 100644
File size: 2.6 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 <errno.h>
34#include <sysinfo.h>
35#include "../ctl/serial.h"
36#include "ski.h"
37
38#ifdef UARCH_ia64
39
40#define SKI_PUTCHAR 31
41
42/** Display character on ski debug console
43 *
44 * Use SSC (Simulator System Call) to
45 * display character on debug console.
46 *
47 * @param c Character to be printed.
48 *
49 */
50static void ski_putc(const char c)
51{
52 asm volatile (
53 "mov r15 = %0\n"
54 "mov r32 = %1\n" /* r32 is in0 */
55 "break 0x80000\n" /* modifies r8 */
56 :
57 : "i" (SKI_PUTCHAR), "r" (c)
58 : "r15", "in0", "r8"
59 );
60
61 if (c == '\n')
62 ski_putc('\r');
63}
64
65static void ski_putchar(wchar_t ch)
66{
67 if ((ch >= 0) && (ch < 128))
68 ski_putc(ch);
69 else
70 ski_putc('?');
71}
72
73static void ski_control_puts(const char *str)
74{
75 while (*str)
76 ski_putc(*(str++));
77}
78
79int ski_init(void)
80{
81 sysarg_t present;
82 int rc = sysinfo_get_value("fb", &present);
83 if (rc != EOK)
84 present = false;
85
86 if (!present)
87 return ENOENT;
88
89 sysarg_t kind;
90 rc = sysinfo_get_value("fb.kind", &kind);
91 if (rc != EOK)
92 kind = (sysarg_t) -1;
93
94 if (kind != 6)
95 return EINVAL;
96
97 return serial_init(ski_putchar, ski_control_puts);
98}
99
100#else /* UARCH_ia64 */
101
102int ski_init(void)
103{
104 return ENOENT;
105}
106
107#endif
108
109/** @}
110 */
Note: See TracBrowser for help on using the repository browser.