Subversion Repositories HelenOS-historic

Rev

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

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