Subversion Repositories HelenOS-historic

Rev

Rev 1558 | Rev 1610 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1558 Rev 1592
1
/*
1
/*
2
 * Copyright (C) 2006 Ondrej Palkovsky
2
 * Copyright (C) 2006 Ondrej Palkovsky
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
#include <ipc/fb.h>
29
#include <ipc/fb.h>
30
#include <ipc/ipc.h>
30
#include <ipc/ipc.h>
31
#include <async.h>
31
#include <async.h>
32
#include <stdio.h>
32
#include <stdio.h>
33
#include <sys/mman.h>
33
#include <sys/mman.h>
34
#include <string.h>
34
#include <string.h>
35
#include <align.h>
35
#include <align.h>
36
 
36
 
37
#include "console.h"
37
#include "console.h"
38
#include "gcons.h"
38
#include "gcons.h"
39
 
39
 
40
#define CONSOLE_TOP      65
40
#define CONSOLE_TOP      65
41
#define CONSOLE_MARGIN   6
41
#define CONSOLE_MARGIN   6
42
 
42
 
43
#define STATUS_START    110
43
#define STATUS_START    110
44
#define STATUS_TOP      8
44
#define STATUS_TOP      8
45
#define STATUS_SPACE    3
45
#define STATUS_SPACE    3
46
#define STATUS_WIDTH    48
46
#define STATUS_WIDTH    48
47
#define STATUS_HEIGHT   48
47
#define STATUS_HEIGHT   48
48
 
48
 
49
#define MAIN_COLOR      0xffffff
49
#define MAIN_COLOR      0xffffff
50
 
50
 
51
static int use_gcons = 0;
51
static int use_gcons = 0;
52
static ipcarg_t xres,yres;
52
static ipcarg_t xres,yres;
53
 
53
 
54
enum butstate {
54
enum butstate {
55
    CONS_DISCONNECTED = 0,
55
    CONS_DISCONNECTED = 0,
56
    CONS_SELECTED,
56
    CONS_SELECTED,
57
    CONS_IDLE,
57
    CONS_IDLE,
58
    CONS_HAS_DATA,
58
    CONS_HAS_DATA,
59
    CONS_KERNEL,
59
    CONS_KERNEL,
60
    CONS_DISCONNECTED_SEL,
60
    CONS_DISCONNECTED_SEL,
61
    CONS_LAST
61
    CONS_LAST
62
};
62
};
63
 
63
 
64
static int console_vp;
64
static int console_vp;
65
static int cstatus_vp[CONSOLE_COUNT];
65
static int cstatus_vp[CONSOLE_COUNT];
66
static int cstat_row, cstat_col; /* Size of cstatus buttons */
66
static int cstat_row, cstat_col; /* Size of cstatus buttons */
67
static enum butstate console_state[CONSOLE_COUNT];
67
static enum butstate console_state[CONSOLE_COUNT];
68
 
68
 
69
static int fbphone;
69
static int fbphone;
70
 
70
 
71
/** List of pixmaps identifying these icons */
71
/** List of pixmaps identifying these icons */
72
static int ic_pixmaps[CONS_LAST] = {-1,-1,-1,-1,-1,-1};
72
static int ic_pixmaps[CONS_LAST] = {-1,-1,-1,-1,-1,-1};
73
 
73
 
74
static int active_console = 0;
74
static int active_console = 0;
75
 
75
 
76
static void vp_switch(int vp)
76
static void vp_switch(int vp)
77
{
77
{
78
    nsend_call(fbphone,FB_VIEWPORT_SWITCH, vp);
78
    nsend_call(fbphone,FB_VIEWPORT_SWITCH, vp);
79
}
79
}
80
 
80
 
81
/** Create view port */
81
/** Create view port */
82
static int vp_create(unsigned int x, unsigned int y,
82
static int vp_create(unsigned int x, unsigned int y,
83
             unsigned int width, unsigned int height)
83
             unsigned int width, unsigned int height)
84
{
84
{
85
    /* Init function, use ipc_call_sync */
85
    /* Init function, use ipc_call_sync */
86
    return ipc_call_sync_2(fbphone, FB_VIEWPORT_CREATE,
86
    return ipc_call_sync_2(fbphone, FB_VIEWPORT_CREATE,
87
                   (x << 16) | y, (width << 16) | height,
87
                   (x << 16) | y, (width << 16) | height,
88
                   NULL, NULL);
88
                   NULL, NULL);
89
}
89
}
90
 
90
 
91
static void clear(void)
91
static void clear(void)
92
{
92
{
93
    nsend_call(fbphone, FB_CLEAR, 0);
93
    nsend_call(fbphone, FB_CLEAR, 0);
94
   
94
   
95
}
95
}
96
 
96
 
97
static void set_style(int fgcolor, int bgcolor)
97
static void set_style(int fgcolor, int bgcolor)
98
{
98
{
99
    nsend_call_2(fbphone, FB_SET_STYLE, fgcolor, bgcolor);
99
    nsend_call_2(fbphone, FB_SET_STYLE, fgcolor, bgcolor);
100
}
100
}
101
 
101
 
102
/** Transparent putchar */
102
/** Transparent putchar */
103
static void tran_putch(char c, int row, int col)
103
static void tran_putch(char c, int row, int col)
104
{
104
{
105
    nsend_call_3(fbphone, FB_TRANS_PUTCHAR, c, row, col);
105
    nsend_call_3(fbphone, FB_TRANS_PUTCHAR, c, row, col);
106
}
106
}
107
 
107
 
108
/** Redraw the button showing state of a given console */
108
/** Redraw the button showing state of a given console */
109
static void redraw_state(int consnum)
109
static void redraw_state(int consnum)
110
{
110
{
111
    char data[5];
111
    char data[5];
112
    int i;
112
    int i;
113
    enum butstate state = console_state[consnum];
113
    enum butstate state = console_state[consnum];
114
 
114
 
115
    vp_switch(cstatus_vp[consnum]);
115
    vp_switch(cstatus_vp[consnum]);
116
    if (ic_pixmaps[state] != -1)
116
    if (ic_pixmaps[state] != -1)
117
        nsend_call_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], ic_pixmaps[state]);
117
        nsend_call_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], ic_pixmaps[state]);
118
 
118
 
119
    if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state != CONS_DISCONNECTED_SEL) {
119
    if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state != CONS_DISCONNECTED_SEL) {
120
        snprintf(data, 5, "%d", consnum+1);
120
        snprintf(data, 5, "%d", consnum+1);
121
        for (i=0;data[i];i++)
121
        for (i=0;data[i];i++)
122
            tran_putch(data[i], 1, 2+i);
122
            tran_putch(data[i], 1, 2+i);
123
    }
123
    }
124
}
124
}
125
 
125
 
126
/** Notification run on changing console (except kernel console) */
126
/** Notification run on changing console (except kernel console) */
127
void gcons_change_console(int consnum)
127
void gcons_change_console(int consnum)
128
{
128
{
129
    int i;
129
    int i;
130
 
130
 
131
    if (!use_gcons)
131
    if (!use_gcons)
132
        return;
132
        return;
133
 
133
 
134
    if (active_console == KERNEL_CONSOLE) {
134
    if (active_console == KERNEL_CONSOLE) {
135
        for (i=0; i < CONSOLE_COUNT; i++)
135
        for (i=0; i < CONSOLE_COUNT; i++)
136
            redraw_state(i);
136
            redraw_state(i);
137
    } else {
137
    } else {
138
        if (console_state[active_console] == CONS_DISCONNECTED_SEL)
138
        if (console_state[active_console] == CONS_DISCONNECTED_SEL)
139
            console_state[active_console] = CONS_DISCONNECTED;
139
            console_state[active_console] = CONS_DISCONNECTED;
140
        else
140
        else
141
            console_state[active_console] = CONS_IDLE;
141
            console_state[active_console] = CONS_IDLE;
142
        redraw_state(active_console);
142
        redraw_state(active_console);
143
    }
143
    }
144
    active_console = consnum;
144
    active_console = consnum;
145
 
145
 
146
    if (console_state[consnum] == CONS_DISCONNECTED) {
146
    if (console_state[consnum] == CONS_DISCONNECTED) {
147
        console_state[consnum] = CONS_DISCONNECTED_SEL;
147
        console_state[consnum] = CONS_DISCONNECTED_SEL;
148
        redraw_state(consnum);
148
        redraw_state(consnum);
149
    } else
149
    } else
150
        console_state[consnum] = CONS_SELECTED;
150
        console_state[consnum] = CONS_SELECTED;
151
    redraw_state(consnum);
151
    redraw_state(consnum);
152
 
152
 
153
    vp_switch(console_vp);
153
    vp_switch(console_vp);
154
}
154
}
155
 
155
 
156
/** Notification function that gets called on new output to virtual console */
156
/** Notification function that gets called on new output to virtual console */
157
void gcons_notify_char(int consnum)
157
void gcons_notify_char(int consnum)
158
{
158
{
159
    if (!use_gcons)
159
    if (!use_gcons)
160
        return;
160
        return;
161
 
161
 
162
    if (consnum == active_console || console_state[consnum] == CONS_HAS_DATA)
162
    if (consnum == active_console || console_state[consnum] == CONS_HAS_DATA)
163
        return;
163
        return;
164
 
164
 
165
    console_state[consnum] = CONS_HAS_DATA;
165
    console_state[consnum] = CONS_HAS_DATA;
166
 
166
 
167
    if (active_console == KERNEL_CONSOLE)
167
    if (active_console == KERNEL_CONSOLE)
168
        return;
168
        return;
169
 
169
 
170
    redraw_state(consnum);
170
    redraw_state(consnum);
171
   
171
   
172
    vp_switch(console_vp);
172
    vp_switch(console_vp);
173
}
173
}
174
 
174
 
-
 
175
/** Notification function called on service disconnect from console */
-
 
176
void gcons_notify_disconnect(int consnum)
-
 
177
{
-
 
178
    if (!use_gcons)
-
 
179
        return;
-
 
180
    if (active_console == consnum)
-
 
181
        console_state[consnum] = CONS_DISCONNECTED_SEL;
-
 
182
    else
-
 
183
        console_state[consnum] = CONS_DISCONNECTED;
-
 
184
 
-
 
185
    if (active_console == KERNEL_CONSOLE)
-
 
186
        return;
-
 
187
 
-
 
188
    redraw_state(consnum);
-
 
189
    vp_switch(console_vp);
-
 
190
}
-
 
191
 
175
/** Notification function called on console connect */
192
/** Notification function called on console connect */
176
void gcons_notify_connect(int consnum)
193
void gcons_notify_connect(int consnum)
177
{
194
{
178
    if (!use_gcons)
195
    if (!use_gcons)
179
        return;
196
        return;
180
    if (active_console == consnum)
197
    if (active_console == consnum)
181
        console_state[consnum] = CONS_SELECTED;
198
        console_state[consnum] = CONS_SELECTED;
182
    else
199
    else
183
        console_state[consnum] = CONS_IDLE;
200
        console_state[consnum] = CONS_IDLE;
184
 
201
 
185
    if (active_console == KERNEL_CONSOLE)
202
    if (active_console == KERNEL_CONSOLE)
186
        return;
203
        return;
187
 
204
 
188
    redraw_state(consnum);
205
    redraw_state(consnum);
189
    vp_switch(console_vp);
206
    vp_switch(console_vp);
190
}
207
}
191
 
208
 
192
/** Change to kernel console */
209
/** Change to kernel console */
193
void gcons_in_kernel(void)
210
void gcons_in_kernel(void)
194
{
211
{
195
    if (console_state[active_console] == CONS_DISCONNECTED_SEL)
212
    if (console_state[active_console] == CONS_DISCONNECTED_SEL)
196
        console_state[active_console] = CONS_DISCONNECTED;
213
        console_state[active_console] = CONS_DISCONNECTED;
197
    else
214
    else
198
        console_state[active_console] = CONS_IDLE;
215
        console_state[active_console] = CONS_IDLE;
199
    redraw_state(active_console);
216
    redraw_state(active_console);
200
 
217
 
201
    active_console = KERNEL_CONSOLE; /* Set to kernel console */
218
    active_console = KERNEL_CONSOLE; /* Set to kernel console */
202
    vp_switch(0);
219
    vp_switch(0);
203
}
220
}
204
 
221
 
205
/** Draw a PPM pixmap to framebuffer
222
/** Draw a PPM pixmap to framebuffer
206
 *
223
 *
207
 * @param logo Pointer to PPM data
224
 * @param logo Pointer to PPM data
208
 * @param size Size of PPM data
225
 * @param size Size of PPM data
209
 * @param x Coordinate of upper left corner
226
 * @param x Coordinate of upper left corner
210
 * @param y Coordinate of upper left corner
227
 * @param y Coordinate of upper left corner
211
 */
228
 */
212
static void draw_pixmap(char *logo, size_t size, int x, int y)
229
static void draw_pixmap(char *logo, size_t size, int x, int y)
213
{
230
{
214
    char *shm;
231
    char *shm;
215
    int rc;
232
    int rc;
216
 
233
 
217
    /* Create area */
234
    /* Create area */
218
    shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
235
    shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
219
    if (shm == MAP_FAILED)
236
    if (shm == MAP_FAILED)
220
        return;
237
        return;
221
 
238
 
222
    memcpy(shm, logo, size);
239
    memcpy(shm, logo, size);
223
    /* Send area */
240
    /* Send area */
224
    rc = sync_send_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
241
    rc = sync_send_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
225
    if (rc)
242
    if (rc)
226
        goto exit;
243
        goto exit;
227
    rc = sync_send_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
244
    rc = sync_send_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
228
    if (rc)
245
    if (rc)
229
        goto drop;
246
        goto drop;
230
    /* Draw logo */
247
    /* Draw logo */
231
    nsend_call_2(fbphone, FB_DRAW_PPM, x, y);
248
    nsend_call_2(fbphone, FB_DRAW_PPM, x, y);
232
drop:
249
drop:
233
    /* Drop area */
250
    /* Drop area */
234
    nsend_call(fbphone, FB_DROP_SHM, 0);
251
    nsend_call(fbphone, FB_DROP_SHM, 0);
235
exit:      
252
exit:      
236
    /* Remove area */
253
    /* Remove area */
237
    munmap(shm, size);
254
    munmap(shm, size);
238
}
255
}
239
 
256
 
240
extern char _binary_helenos_ppm_start[0];
257
extern char _binary_helenos_ppm_start[0];
241
extern int _binary_helenos_ppm_size;
258
extern int _binary_helenos_ppm_size;
242
extern char _binary_nameic_ppm_start[0];
259
extern char _binary_nameic_ppm_start[0];
243
extern int _binary_nameic_ppm_size;
260
extern int _binary_nameic_ppm_size;
244
/** Redraws console graphics  */
261
/** Redraws console graphics  */
245
static void gcons_redraw_console(void)
262
static void gcons_redraw_console(void)
246
{
263
{
247
    int i;
264
    int i;
248
    size_t hsize = (size_t)&_binary_helenos_ppm_size;
265
    size_t hsize = (size_t)&_binary_helenos_ppm_size;
249
 
266
 
250
    if (!use_gcons)
267
    if (!use_gcons)
251
        return;
268
        return;
252
   
269
   
253
    vp_switch(0);
270
    vp_switch(0);
254
    set_style(MAIN_COLOR, MAIN_COLOR);
271
    set_style(MAIN_COLOR, MAIN_COLOR);
255
    clear();
272
    clear();
256
    draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-66, 2);
273
    draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-66, 2);
257
    draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 17);
274
    draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 17);
258
 
275
 
259
    for (i=0;i < CONSOLE_COUNT; i++)
276
    for (i=0;i < CONSOLE_COUNT; i++)
260
        redraw_state(i);
277
        redraw_state(i);
261
    vp_switch(console_vp);
278
    vp_switch(console_vp);
262
}
279
}
263
 
280
 
264
/** Creates a pixmap on framebuffer
281
/** Creates a pixmap on framebuffer
265
 *
282
 *
266
 * @param data PPM data
283
 * @param data PPM data
267
 * @param size PPM data size
284
 * @param size PPM data size
268
 * @return Pixmap identification
285
 * @return Pixmap identification
269
 */
286
 */
270
static int make_pixmap(char *data, int size)
287
static int make_pixmap(char *data, int size)
271
{
288
{
272
    char *shm;
289
    char *shm;
273
    int rc;
290
    int rc;
274
    int pxid = -1;
291
    int pxid = -1;
275
 
292
 
276
    /* Create area */
293
    /* Create area */
277
    shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
294
    shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
278
    if (shm == MAP_FAILED)
295
    if (shm == MAP_FAILED)
279
        return -1;
296
        return -1;
280
 
297
 
281
    memcpy(shm, data, size);
298
    memcpy(shm, data, size);
282
    /* Send area */
299
    /* Send area */
283
    rc = sync_send_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
300
    rc = sync_send_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
284
    if (rc)
301
    if (rc)
285
        goto exit;
302
        goto exit;
286
    rc = sync_send_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
303
    rc = sync_send_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
287
    if (rc)
304
    if (rc)
288
        goto drop;
305
        goto drop;
289
 
306
 
290
    /* Obtain pixmap */
307
    /* Obtain pixmap */
291
    rc = sync_send(fbphone, FB_SHM2PIXMAP, 0, NULL);
308
    rc = sync_send(fbphone, FB_SHM2PIXMAP, 0, NULL);
292
    if (rc < 0)
309
    if (rc < 0)
293
        goto drop;
310
        goto drop;
294
    pxid = rc;
311
    pxid = rc;
295
drop:
312
drop:
296
    /* Drop area */
313
    /* Drop area */
297
    nsend_call(fbphone, FB_DROP_SHM, 0);
314
    nsend_call(fbphone, FB_DROP_SHM, 0);
298
exit:      
315
exit:      
299
    /* Remove area */
316
    /* Remove area */
300
    munmap(shm, size);
317
    munmap(shm, size);
301
 
318
 
302
    return pxid;
319
    return pxid;
303
}
320
}
304
 
321
 
305
extern char _binary_cons_selected_ppm_start[0];
322
extern char _binary_cons_selected_ppm_start[0];
306
extern int _binary_cons_selected_ppm_size;
323
extern int _binary_cons_selected_ppm_size;
307
extern char _binary_cons_idle_ppm_start[0];
324
extern char _binary_cons_idle_ppm_start[0];
308
extern int _binary_cons_idle_ppm_size;
325
extern int _binary_cons_idle_ppm_size;
309
extern char _binary_cons_has_data_ppm_start[0];
326
extern char _binary_cons_has_data_ppm_start[0];
310
extern int _binary_cons_has_data_ppm_size;
327
extern int _binary_cons_has_data_ppm_size;
311
extern char _binary_cons_kernel_ppm_start[0];
328
extern char _binary_cons_kernel_ppm_start[0];
312
extern int _binary_cons_kernel_ppm_size;
329
extern int _binary_cons_kernel_ppm_size;
313
/** Initialize nice graphical console environment */
330
/** Initialize nice graphical console environment */
314
void gcons_init(int phone)
331
void gcons_init(int phone)
315
{
332
{
316
    int rc;
333
    int rc;
317
    int i;
334
    int i;
318
 
335
 
319
    fbphone = phone;
336
    fbphone = phone;
320
 
337
 
321
    rc = ipc_call_sync_2(phone, FB_GET_RESOLUTION, 0, 0, &xres, &yres);
338
    rc = ipc_call_sync_2(phone, FB_GET_RESOLUTION, 0, 0, &xres, &yres);
322
    if (rc)
339
    if (rc)
323
        return;
340
        return;
324
   
341
   
325
    if (xres < 800 || yres < 600)
342
    if (xres < 800 || yres < 600)
326
        return;
343
        return;
327
 
344
 
328
    /* create console viewport */
345
    /* create console viewport */
329
    /* Align width & height to character size */
346
    /* Align width & height to character size */
330
    console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP,
347
    console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP,
331
                   ALIGN_DOWN(xres-2*CONSOLE_MARGIN, 8),
348
                   ALIGN_DOWN(xres-2*CONSOLE_MARGIN, 8),
332
                   ALIGN_DOWN(yres-(CONSOLE_TOP+CONSOLE_MARGIN),16));
349
                   ALIGN_DOWN(yres-(CONSOLE_TOP+CONSOLE_MARGIN),16));
333
    if (console_vp < 0)
350
    if (console_vp < 0)
334
        return;
351
        return;
335
   
352
   
336
    /* Create status buttons */
353
    /* Create status buttons */
337
    for (i=0; i < CONSOLE_COUNT; i++) {
354
    for (i=0; i < CONSOLE_COUNT; i++) {
338
        cstatus_vp[i] = vp_create(STATUS_START+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
355
        cstatus_vp[i] = vp_create(STATUS_START+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
339
                      STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT);
356
                      STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT);
340
        if (cstatus_vp[i] < 0)
357
        if (cstatus_vp[i] < 0)
341
            return;
358
            return;
342
        vp_switch(cstatus_vp[i]);
359
        vp_switch(cstatus_vp[i]);
343
        set_style(0x202020, 0xffffff);
360
        set_style(0x202020, 0xffffff);
344
    }
361
    }
345
   
362
   
346
    /* Initialize icons */
363
    /* Initialize icons */
347
    ic_pixmaps[CONS_SELECTED] = make_pixmap(_binary_cons_selected_ppm_start,
364
    ic_pixmaps[CONS_SELECTED] = make_pixmap(_binary_cons_selected_ppm_start,
348
                          (int)&_binary_cons_selected_ppm_size);
365
                          (int)&_binary_cons_selected_ppm_size);
349
    ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start,
366
    ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start,
350
                          (int)&_binary_cons_idle_ppm_size);
367
                          (int)&_binary_cons_idle_ppm_size);
351
    ic_pixmaps[CONS_HAS_DATA] = make_pixmap(_binary_cons_has_data_ppm_start,
368
    ic_pixmaps[CONS_HAS_DATA] = make_pixmap(_binary_cons_has_data_ppm_start,
352
                        (int)&_binary_cons_has_data_ppm_size);
369
                        (int)&_binary_cons_has_data_ppm_size);
353
    ic_pixmaps[CONS_DISCONNECTED] = make_pixmap(_binary_cons_idle_ppm_start,
370
    ic_pixmaps[CONS_DISCONNECTED] = make_pixmap(_binary_cons_idle_ppm_start,
354
                          (int)&_binary_cons_idle_ppm_size);
371
                          (int)&_binary_cons_idle_ppm_size);
355
    ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start,
372
    ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start,
356
                          (int)&_binary_cons_kernel_ppm_size);
373
                          (int)&_binary_cons_kernel_ppm_size);
357
    ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED];
374
    ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED];
358
 
375
 
359
    use_gcons = 1;
376
    use_gcons = 1;
360
    console_state[0] = CONS_DISCONNECTED_SEL;
377
    console_state[0] = CONS_DISCONNECTED_SEL;
361
    console_state[KERNEL_CONSOLE] = CONS_KERNEL;
378
    console_state[KERNEL_CONSOLE] = CONS_KERNEL;
362
    gcons_redraw_console();
379
    gcons_redraw_console();
363
}
380
}
364
 
381