Subversion Repositories HelenOS

Rev

Rev 4055 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4055 Rev 4156
Line 1... Line 1...
1
/*
1
/*
-
 
2
 * Copyright (c) 2006 Josef Cejka
-
 
3
 * Copyright (c) 2006 Jakub Vana
2
 * Copyright (c) 2008 Jiri Svoboda
4
 * Copyright (c) 2008 Jiri Svoboda
3
 * All rights reserved.
5
 * All rights reserved.
4
 *
6
 *
5
 * Redistribution and use in source and binary forms, with or without
7
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
8
 * modification, are permitted provided that the following conditions
Line 33... Line 35...
33
 */
35
 */
34
 
36
 
35
#include <async.h>
37
#include <async.h>
36
#include <io/stream.h>
38
#include <io/stream.h>
37
#include <ipc/console.h>
39
#include <ipc/console.h>
-
 
40
#include <ipc/services.h>
38
#include <console.h>
41
#include <console.h>
39
 
42
 
-
 
43
static int console_phone = -1;
-
 
44
 
-
 
45
void console_open(void)
-
 
46
{
-
 
47
    if (console_phone < 0) {
-
 
48
        int phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0, 0);
-
 
49
        if (phone >= 0)
-
 
50
            console_phone = phone;
-
 
51
    }
-
 
52
}
-
 
53
 
-
 
54
void console_close(void)
-
 
55
{
-
 
56
    if (console_phone >= 0) {
-
 
57
        if (ipc_hangup(console_phone) == 0) {
-
 
58
            console_phone = -1;
-
 
59
        }
-
 
60
    }
-
 
61
}
-
 
62
 
-
 
63
int console_phone_get(void)
-
 
64
{
-
 
65
    if (console_phone < 0)
-
 
66
        console_open();
-
 
67
   
-
 
68
    return console_phone;
-
 
69
}
-
 
70
 
-
 
71
void console_wait(void)
-
 
72
{
-
 
73
    while (console_phone < 0)
-
 
74
        console_open();
-
 
75
}
-
 
76
 
40
void console_clear(void)
77
void console_clear(void)
41
{
78
{
42
    int cons_phone = get_console_phone();
79
    int cons_phone = console_phone_get();
43
    async_msg_0(cons_phone, CONSOLE_CLEAR);
80
    async_msg_0(cons_phone, CONSOLE_CLEAR);
44
}
81
}
45
 
82
 
46
void console_goto(int row, int col)
83
void console_goto(int row, int col)
47
{
84
{
48
    int cons_phone = get_console_phone();
85
    int cons_phone = console_phone_get();
49
    async_msg_2(cons_phone, CONSOLE_GOTO, row, col);
86
    async_msg_2(cons_phone, CONSOLE_GOTO, row, col);
50
}
87
}
51
 
88
 
-
 
89
void console_putchar(int c)
-
 
90
{
-
 
91
    int cons_phone = console_phone_get();
-
 
92
    async_msg_1(cons_phone, CONSOLE_PUTCHAR, c);
-
 
93
}
-
 
94
 
52
void console_flush(void)
95
void console_flush(void)
53
{
96
{
54
    int cons_phone = get_console_phone();
97
    int cons_phone = console_phone_get();
55
    async_msg_0(cons_phone, CONSOLE_FLUSH);
98
    async_msg_0(cons_phone, CONSOLE_FLUSH);
56
}
99
}
57
 
100
 
58
int console_get_size(int *rows, int *cols)
101
int console_get_size(int *rows, int *cols)
59
{
102
{
60
    int cons_phone = get_console_phone();
103
    int cons_phone = console_phone_get();
61
    ipcarg_t r, c;
104
    ipcarg_t r, c;
62
    int rc;
105
    int rc;
63
 
106
 
64
    rc = async_req_0_2(cons_phone, CONSOLE_GETSIZE, &r, &c);
107
    rc = async_req_0_2(cons_phone, CONSOLE_GETSIZE, &r, &c);
65
 
108
 
Line 69... Line 112...
69
    return rc;
112
    return rc;
70
}
113
}
71
 
114
 
72
void console_set_style(int style)
115
void console_set_style(int style)
73
{
116
{
74
    int cons_phone = get_console_phone();
117
    int cons_phone = console_phone_get();
75
    async_msg_1(cons_phone, CONSOLE_SET_STYLE, style);
118
    async_msg_1(cons_phone, CONSOLE_SET_STYLE, style);
76
}
119
}
77
 
120
 
78
void console_set_color(int fg_color, int bg_color, int flags)
121
void console_set_color(int fg_color, int bg_color, int flags)
79
{
122
{
80
    int cons_phone = get_console_phone();
123
    int cons_phone = console_phone_get();
81
    async_msg_3(cons_phone, CONSOLE_SET_COLOR, fg_color, bg_color, flags);
124
    async_msg_3(cons_phone, CONSOLE_SET_COLOR, fg_color, bg_color, flags);
82
}
125
}
83
 
126
 
84
void console_set_rgb_color(int fg_color, int bg_color)
127
void console_set_rgb_color(int fg_color, int bg_color)
85
{
128
{
86
    int cons_phone = get_console_phone();
129
    int cons_phone = console_phone_get();
87
    async_msg_2(cons_phone, CONSOLE_SET_RGB_COLOR, fg_color, bg_color);
130
    async_msg_2(cons_phone, CONSOLE_SET_RGB_COLOR, fg_color, bg_color);
88
}
131
}
89
 
132
 
90
void console_cursor_visibility(int show)
133
void console_cursor_visibility(int show)
91
{
134
{
92
    int cons_phone = get_console_phone();
135
    int cons_phone = console_phone_get();
93
    async_msg_1(cons_phone, CONSOLE_CURSOR_VISIBILITY, show != 0);
136
    async_msg_1(cons_phone, CONSOLE_CURSOR_VISIBILITY, show != 0);
94
}
137
}
95
 
138
 
96
/** @}
139
/** @}
97
 */
140
 */