Subversion Repositories HelenOS-historic

Rev

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

Rev 1555 Rev 1557
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
static void putch(char c, int row, int col)
102
static void putch(char c, int row, int col)
103
{
103
{
104
    nsend_call_3(fbphone, FB_PUTCHAR, c, row, col);
104
    nsend_call_3(fbphone, FB_PUTCHAR, c, row, col);
105
}
105
}
106
 
106
 
107
static void redraw_state(int consnum)
107
static void redraw_state(int consnum)
108
{
108
{
109
    char data[5];
109
    char data[5];
110
    int i;
110
    int i;
111
    enum butstate state = console_state[consnum];
111
    enum butstate state = console_state[consnum];
112
 
112
 
113
    vp_switch(cstatus_vp[consnum]);
113
    vp_switch(cstatus_vp[consnum]);
114
    if (ic_pixmaps[state] != -1)
114
    if (ic_pixmaps[state] != -1)
115
        nsend_call_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], ic_pixmaps[state]);
115
        nsend_call_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], ic_pixmaps[state]);
116
 
116
 
117
    if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state != CONS_DISCONNECTED_SEL) {
117
    if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state != CONS_DISCONNECTED_SEL) {
118
        snprintf(data, 5, "%d", consnum+1);
118
        snprintf(data, 5, "%d", consnum+1);
119
        for (i=0;data[i];i++)
119
        for (i=0;data[i];i++)
120
            putch(data[i], 1, 2+i);
120
            putch(data[i], 1, 2+i);
121
    }
121
    }
122
}
122
}
123
 
123
 
124
/** Notification run on changing console (except kernel console) */
124
/** Notification run on changing console (except kernel console) */
125
void gcons_change_console(int consnum)
125
void gcons_change_console(int consnum)
126
{
126
{
127
    int i;
127
    int i;
128
 
128
 
129
    if (!use_gcons)
129
    if (!use_gcons)
130
        return;
130
        return;
131
 
131
 
132
    if (active_console == KERNEL_CONSOLE) {
132
    if (active_console == KERNEL_CONSOLE) {
133
        for (i=0; i < CONSOLE_COUNT; i++)
133
        for (i=0; i < CONSOLE_COUNT; i++)
134
            redraw_state(i);
134
            redraw_state(i);
135
    } else {
135
    } else {
136
        if (console_state[active_console] == CONS_DISCONNECTED_SEL)
136
        if (console_state[active_console] == CONS_DISCONNECTED_SEL)
137
            console_state[active_console] = CONS_DISCONNECTED;
137
            console_state[active_console] = CONS_DISCONNECTED;
138
        else
138
        else
139
            console_state[active_console] = CONS_IDLE;
139
            console_state[active_console] = CONS_IDLE;
140
        redraw_state(active_console);
140
        redraw_state(active_console);
141
    }
141
    }
142
    active_console = consnum;
142
    active_console = consnum;
143
 
143
 
144
    if (console_state[consnum] == CONS_DISCONNECTED) {
144
    if (console_state[consnum] == CONS_DISCONNECTED) {
145
        console_state[consnum] = CONS_DISCONNECTED_SEL;
145
        console_state[consnum] = CONS_DISCONNECTED_SEL;
146
        redraw_state(consnum);
146
        redraw_state(consnum);
147
    } else
147
    } else
148
        console_state[consnum] = CONS_SELECTED;
148
        console_state[consnum] = CONS_SELECTED;
149
    redraw_state(consnum);
149
    redraw_state(consnum);
150
 
150
 
151
    vp_switch(console_vp);
151
    vp_switch(console_vp);
152
}
152
}
153
 
153
 
154
/** Notification function that gets called on new output to virtual console */
154
/** Notification function that gets called on new output to virtual console */
155
void gcons_notify_char(int consnum)
155
void gcons_notify_char(int consnum)
156
{
156
{
157
    if (!use_gcons)
157
    if (!use_gcons)
158
        return;
158
        return;
159
 
159
 
160
    if (consnum == active_console || console_state[consnum] == CONS_HAS_DATA)
160
    if (consnum == active_console || console_state[consnum] == CONS_HAS_DATA)
161
        return;
161
        return;
162
 
162
 
163
    console_state[consnum] = CONS_HAS_DATA;
163
    console_state[consnum] = CONS_HAS_DATA;
164
 
164
 
165
    if (active_console == KERNEL_CONSOLE)
165
    if (active_console == KERNEL_CONSOLE)
166
        return;
166
        return;
167
 
167
 
168
    redraw_state(consnum);
168
    redraw_state(consnum);
169
   
169
   
170
    vp_switch(console_vp);
170
    vp_switch(console_vp);
171
}
171
}
172
 
172
 
173
void gcons_notify_connect(int consnum)
173
void gcons_notify_connect(int consnum)
174
{
174
{
175
    if (!use_gcons)
175
    if (!use_gcons)
176
        return;
176
        return;
177
    if (active_console == consnum)
177
    if (active_console == consnum)
178
        console_state[consnum] = CONS_SELECTED;
178
        console_state[consnum] = CONS_SELECTED;
179
    else
179
    else
180
        console_state[consnum] = CONS_IDLE;
180
        console_state[consnum] = CONS_IDLE;
181
 
181
 
182
    if (active_console == KERNEL_CONSOLE)
182
    if (active_console == KERNEL_CONSOLE)
183
        return;
183
        return;
184
 
184
 
185
    redraw_state(consnum);
185
    redraw_state(consnum);
186
    vp_switch(console_vp);
186
    vp_switch(console_vp);
187
}
187
}
188
 
188
 
189
/** Change to kernel console */
189
/** Change to kernel console */
190
void gcons_in_kernel(void)
190
void gcons_in_kernel(void)
191
{
191
{
192
    if (console_state[active_console] = CONS_DISCONNECTED_SEL)
192
    if (console_state[active_console] == CONS_DISCONNECTED_SEL)
193
        console_state[active_console] = CONS_DISCONNECTED;
193
        console_state[active_console] = CONS_DISCONNECTED;
194
    else
194
    else
195
        console_state[active_console] = CONS_IDLE;
195
        console_state[active_console] = CONS_IDLE;
196
    redraw_state(active_console);
196
    redraw_state(active_console);
197
 
197
 
198
    active_console = KERNEL_CONSOLE; /* Set to kernel console */
198
    active_console = KERNEL_CONSOLE; /* Set to kernel console */
199
    vp_switch(0);
199
    vp_switch(0);
200
}
200
}
201
 
201
 
202
/** Draw a PPM pixmap to framebuffer
202
/** Draw a PPM pixmap to framebuffer
203
 *
203
 *
204
 * @param logo Pointer to PPM data
204
 * @param logo Pointer to PPM data
205
 * @param size Size of PPM data
205
 * @param size Size of PPM data
206
 * @param x Coordinate of upper left corner
206
 * @param x Coordinate of upper left corner
207
 * @param y Coordinate of upper left corner
207
 * @param y Coordinate of upper left corner
208
 */
208
 */
209
static void draw_pixmap(char *logo, size_t size, int x, int y)
209
static void draw_pixmap(char *logo, size_t size, int x, int y)
210
{
210
{
211
    char *shm;
211
    char *shm;
212
    int rc;
212
    int rc;
213
 
213
 
214
    /* Create area */
214
    /* Create area */
215
    shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
215
    shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
216
    if (shm == MAP_FAILED)
216
    if (shm == MAP_FAILED)
217
        return;
217
        return;
218
 
218
 
219
    memcpy(shm, logo, size);
219
    memcpy(shm, logo, size);
220
    /* Send area */
220
    /* Send area */
221
    rc = sync_send_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
221
    rc = sync_send_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
222
    if (rc)
222
    if (rc)
223
        goto exit;
223
        goto exit;
224
    rc = sync_send_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
224
    rc = sync_send_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
225
    if (rc)
225
    if (rc)
226
        goto drop;
226
        goto drop;
227
    /* Draw logo */
227
    /* Draw logo */
228
    nsend_call_2(fbphone, FB_DRAW_PPM, x, y);
228
    nsend_call_2(fbphone, FB_DRAW_PPM, x, y);
229
drop:
229
drop:
230
    /* Drop area */
230
    /* Drop area */
231
    nsend_call(fbphone, FB_DROP_SHM, 0);
231
    nsend_call(fbphone, FB_DROP_SHM, 0);
232
exit:      
232
exit:      
233
    /* Remove area */
233
    /* Remove area */
234
    munmap(shm, size);
234
    munmap(shm, size);
235
}
235
}
236
 
236
 
237
extern char _binary_helenos_ppm_start[0];
237
extern char _binary_helenos_ppm_start[0];
238
extern int _binary_helenos_ppm_size;
238
extern int _binary_helenos_ppm_size;
239
extern char _binary_nameic_ppm_start[0];
239
extern char _binary_nameic_ppm_start[0];
240
extern int _binary_nameic_ppm_size;
240
extern int _binary_nameic_ppm_size;
241
static void gcons_redraw_console(void)
241
static void gcons_redraw_console(void)
242
{
242
{
243
    int i;
243
    int i;
244
    size_t hsize = (size_t)&_binary_helenos_ppm_size;
244
    size_t hsize = (size_t)&_binary_helenos_ppm_size;
245
 
245
 
246
    if (!use_gcons)
246
    if (!use_gcons)
247
        return;
247
        return;
248
   
248
   
249
    vp_switch(0);
249
    vp_switch(0);
250
    set_style(MAIN_COLOR, MAIN_COLOR);
250
    set_style(MAIN_COLOR, MAIN_COLOR);
251
    clear();
251
    clear();
252
    draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-66, 2);
252
    draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-66, 2);
253
    draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 17);
253
    draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 17);
254
 
254
 
255
 
255
 
256
    for (i=0;i < CONSOLE_COUNT; i++)
256
    for (i=0;i < CONSOLE_COUNT; i++)
257
        redraw_state(i);
257
        redraw_state(i);
258
    vp_switch(console_vp);
258
    vp_switch(console_vp);
259
}
259
}
260
 
260
 
261
static int make_pixmap(char *data, int size)
261
static int make_pixmap(char *data, int size)
262
{
262
{
263
    char *shm;
263
    char *shm;
264
    int rc;
264
    int rc;
265
    int pxid = -1;
265
    int pxid = -1;
266
 
266
 
267
    /* Create area */
267
    /* Create area */
268
    shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
268
    shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
269
    if (shm == MAP_FAILED)
269
    if (shm == MAP_FAILED)
270
        return -1;
270
        return -1;
271
 
271
 
272
    memcpy(shm, data, size);
272
    memcpy(shm, data, size);
273
    /* Send area */
273
    /* Send area */
274
    rc = sync_send_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
274
    rc = sync_send_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
275
    if (rc)
275
    if (rc)
276
        goto exit;
276
        goto exit;
277
    rc = sync_send_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
277
    rc = sync_send_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
278
    if (rc)
278
    if (rc)
279
        goto drop;
279
        goto drop;
280
 
280
 
281
    /* Obtain pixmap */
281
    /* Obtain pixmap */
282
    rc = sync_send(fbphone, FB_SHM2PIXMAP, 0, NULL);
282
    rc = sync_send(fbphone, FB_SHM2PIXMAP, 0, NULL);
283
    if (rc < 0)
283
    if (rc < 0)
284
        goto drop;
284
        goto drop;
285
    pxid = rc;
285
    pxid = rc;
286
drop:
286
drop:
287
    /* Drop area */
287
    /* Drop area */
288
    nsend_call(fbphone, FB_DROP_SHM, 0);
288
    nsend_call(fbphone, FB_DROP_SHM, 0);
289
exit:      
289
exit:      
290
    /* Remove area */
290
    /* Remove area */
291
    munmap(shm, size);
291
    munmap(shm, size);
292
 
292
 
293
    return pxid;
293
    return pxid;
294
}
294
}
295
 
295
 
296
extern char _binary_cons_selected_ppm_start[0];
296
extern char _binary_cons_selected_ppm_start[0];
297
extern int _binary_cons_selected_ppm_size;
297
extern int _binary_cons_selected_ppm_size;
298
extern char _binary_cons_idle_ppm_start[0];
298
extern char _binary_cons_idle_ppm_start[0];
299
extern int _binary_cons_idle_ppm_size;
299
extern int _binary_cons_idle_ppm_size;
300
extern char _binary_cons_has_data_ppm_start[0];
300
extern char _binary_cons_has_data_ppm_start[0];
301
extern int _binary_cons_has_data_ppm_size;
301
extern int _binary_cons_has_data_ppm_size;
302
extern char _binary_cons_kernel_ppm_start[0];
302
extern char _binary_cons_kernel_ppm_start[0];
303
extern int _binary_cons_kernel_ppm_size;
303
extern int _binary_cons_kernel_ppm_size;
304
/** Initialize nice graphical console environment */
304
/** Initialize nice graphical console environment */
305
void gcons_init(int phone)
305
void gcons_init(int phone)
306
{
306
{
307
    int rc;
307
    int rc;
308
    int i;
308
    int i;
309
 
309
 
310
    fbphone = phone;
310
    fbphone = phone;
311
 
311
 
312
    rc = ipc_call_sync_2(phone, FB_GET_RESOLUTION, 0, 0, &xres, &yres);
312
    rc = ipc_call_sync_2(phone, FB_GET_RESOLUTION, 0, 0, &xres, &yres);
313
    if (rc)
313
    if (rc)
314
        return;
314
        return;
315
   
315
   
316
    if (xres < 800 || yres < 600)
316
    if (xres < 800 || yres < 600)
317
        return;
317
        return;
318
 
318
 
319
    /* create console viewport */
319
    /* create console viewport */
320
    /* Align width & height to character size */
320
    /* Align width & height to character size */
321
    console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP,
321
    console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP,
322
                   ALIGN_DOWN(xres-2*CONSOLE_MARGIN, 8),
322
                   ALIGN_DOWN(xres-2*CONSOLE_MARGIN, 8),
323
                   ALIGN_DOWN(yres-(CONSOLE_TOP+CONSOLE_MARGIN),16));
323
                   ALIGN_DOWN(yres-(CONSOLE_TOP+CONSOLE_MARGIN),16));
324
    if (console_vp < 0)
324
    if (console_vp < 0)
325
        return;
325
        return;
326
   
326
   
327
    /* Create status buttons */
327
    /* Create status buttons */
328
    for (i=0; i < CONSOLE_COUNT; i++) {
328
    for (i=0; i < CONSOLE_COUNT; i++) {
329
        cstatus_vp[i] = vp_create(STATUS_START+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
329
        cstatus_vp[i] = vp_create(STATUS_START+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
330
                      STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT);
330
                      STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT);
331
        if (cstatus_vp[i] < 0)
331
        if (cstatus_vp[i] < 0)
332
            return;
332
            return;
333
        vp_switch(cstatus_vp[i]);
333
        vp_switch(cstatus_vp[i]);
334
        set_style(0x202020, 0xffffff);
334
        set_style(0x202020, 0xffffff);
335
    }
335
    }
336
   
336
   
337
    /* Initialize icons */
337
    /* Initialize icons */
338
    ic_pixmaps[CONS_SELECTED] = make_pixmap(_binary_cons_selected_ppm_start,
338
    ic_pixmaps[CONS_SELECTED] = make_pixmap(_binary_cons_selected_ppm_start,
339
                          (int)&_binary_cons_selected_ppm_size);
339
                          (int)&_binary_cons_selected_ppm_size);
340
    ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start,
340
    ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start,
341
                          (int)&_binary_cons_idle_ppm_size);
341
                          (int)&_binary_cons_idle_ppm_size);
342
    ic_pixmaps[CONS_HAS_DATA] = make_pixmap(_binary_cons_has_data_ppm_start,
342
    ic_pixmaps[CONS_HAS_DATA] = make_pixmap(_binary_cons_has_data_ppm_start,
343
                        (int)&_binary_cons_has_data_ppm_size);
343
                        (int)&_binary_cons_has_data_ppm_size);
344
    ic_pixmaps[CONS_DISCONNECTED] = make_pixmap(_binary_cons_idle_ppm_start,
344
    ic_pixmaps[CONS_DISCONNECTED] = make_pixmap(_binary_cons_idle_ppm_start,
345
                          (int)&_binary_cons_idle_ppm_size);
345
                          (int)&_binary_cons_idle_ppm_size);
346
    ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start,
346
    ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start,
347
                          (int)&_binary_cons_kernel_ppm_size);
347
                          (int)&_binary_cons_kernel_ppm_size);
348
    ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED];
348
    ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED];
349
 
349
 
350
    use_gcons = 1;
350
    use_gcons = 1;
351
    console_state[0] = CONS_DISCONNECTED_SEL;
351
    console_state[0] = CONS_DISCONNECTED_SEL;
352
    console_state[KERNEL_CONSOLE] = CONS_KERNEL;
352
    console_state[KERNEL_CONSOLE] = CONS_KERNEL;
353
    gcons_redraw_console();
353
    gcons_redraw_console();
354
}
354
}
355
 
355