Subversion Repositories HelenOS-historic

Rev

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

Rev 1610 Rev 1646
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
static int animation = -1;
73
 
74
 
74
static int active_console = 0;
75
static int active_console = 0;
75
 
76
 
76
static void vp_switch(int vp)
77
static void vp_switch(int vp)
77
{
78
{
78
    async_msg(fbphone,FB_VIEWPORT_SWITCH, vp);
79
    async_msg(fbphone,FB_VIEWPORT_SWITCH, vp);
79
}
80
}
80
 
81
 
81
/** Create view port */
82
/** Create view port */
82
static int vp_create(unsigned int x, unsigned int y,
83
static int vp_create(unsigned int x, unsigned int y,
83
             unsigned int width, unsigned int height)
84
             unsigned int width, unsigned int height)
84
{
85
{
85
    /* Init function, use ipc_call_sync */
86
    /* Init function, use ipc_call_sync */
86
    return ipc_call_sync_2(fbphone, FB_VIEWPORT_CREATE,
87
    return ipc_call_sync_2(fbphone, FB_VIEWPORT_CREATE,
87
                   (x << 16) | y, (width << 16) | height,
88
                   (x << 16) | y, (width << 16) | height,
88
                   NULL, NULL);
89
                   NULL, NULL);
89
}
90
}
90
 
91
 
91
static void clear(void)
92
static void clear(void)
92
{
93
{
93
    async_msg(fbphone, FB_CLEAR, 0);
94
    async_msg(fbphone, FB_CLEAR, 0);
94
   
95
   
95
}
96
}
96
 
97
 
97
static void set_style(int fgcolor, int bgcolor)
98
static void set_style(int fgcolor, int bgcolor)
98
{
99
{
99
    async_msg_2(fbphone, FB_SET_STYLE, fgcolor, bgcolor);
100
    async_msg_2(fbphone, FB_SET_STYLE, fgcolor, bgcolor);
100
}
101
}
101
 
102
 
102
/** Transparent putchar */
103
/** Transparent putchar */
103
static void tran_putch(char c, int row, int col)
104
static void tran_putch(char c, int row, int col)
104
{
105
{
105
    async_msg_3(fbphone, FB_TRANS_PUTCHAR, c, row, col);
106
    async_msg_3(fbphone, FB_TRANS_PUTCHAR, c, row, col);
106
}
107
}
107
 
108
 
108
/** Redraw the button showing state of a given console */
109
/** Redraw the button showing state of a given console */
109
static void redraw_state(int consnum)
110
static void redraw_state(int consnum)
110
{
111
{
111
    char data[5];
112
    char data[5];
112
    int i;
113
    int i;
113
    enum butstate state = console_state[consnum];
114
    enum butstate state = console_state[consnum];
114
 
115
 
115
    vp_switch(cstatus_vp[consnum]);
116
    vp_switch(cstatus_vp[consnum]);
116
    if (ic_pixmaps[state] != -1)
117
    if (ic_pixmaps[state] != -1)
117
        async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], ic_pixmaps[state]);
118
        async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], ic_pixmaps[state]);
118
 
119
 
119
    if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state != CONS_DISCONNECTED_SEL) {
120
    if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state != CONS_DISCONNECTED_SEL) {
120
        snprintf(data, 5, "%d", consnum+1);
121
        snprintf(data, 5, "%d", consnum+1);
121
        for (i=0;data[i];i++)
122
        for (i=0;data[i];i++)
122
            tran_putch(data[i], 1, 2+i);
123
            tran_putch(data[i], 1, 2+i);
123
    }
124
    }
124
}
125
}
125
 
126
 
126
/** Notification run on changing console (except kernel console) */
127
/** Notification run on changing console (except kernel console) */
127
void gcons_change_console(int consnum)
128
void gcons_change_console(int consnum)
128
{
129
{
129
    int i;
130
    int i;
130
 
131
 
131
    if (!use_gcons)
132
    if (!use_gcons)
132
        return;
133
        return;
133
 
134
 
134
    if (active_console == KERNEL_CONSOLE) {
135
    if (active_console == KERNEL_CONSOLE) {
135
        for (i=0; i < CONSOLE_COUNT; i++)
136
        for (i=0; i < CONSOLE_COUNT; i++)
136
            redraw_state(i);
137
            redraw_state(i);
137
    } else {
138
    } else {
138
        if (console_state[active_console] == CONS_DISCONNECTED_SEL)
139
        if (console_state[active_console] == CONS_DISCONNECTED_SEL)
139
            console_state[active_console] = CONS_DISCONNECTED;
140
            console_state[active_console] = CONS_DISCONNECTED;
140
        else
141
        else
141
            console_state[active_console] = CONS_IDLE;
142
            console_state[active_console] = CONS_IDLE;
142
        redraw_state(active_console);
143
        redraw_state(active_console);
143
    }
144
    }
144
    active_console = consnum;
145
    active_console = consnum;
145
 
146
 
146
    if (console_state[consnum] == CONS_DISCONNECTED) {
147
    if (console_state[consnum] == CONS_DISCONNECTED) {
147
        console_state[consnum] = CONS_DISCONNECTED_SEL;
148
        console_state[consnum] = CONS_DISCONNECTED_SEL;
148
        redraw_state(consnum);
149
        redraw_state(consnum);
149
    } else
150
    } else
150
        console_state[consnum] = CONS_SELECTED;
151
        console_state[consnum] = CONS_SELECTED;
151
    redraw_state(consnum);
152
    redraw_state(consnum);
152
 
153
 
153
    vp_switch(console_vp);
154
    vp_switch(console_vp);
154
}
155
}
155
 
156
 
156
/** Notification function that gets called on new output to virtual console */
157
/** Notification function that gets called on new output to virtual console */
157
void gcons_notify_char(int consnum)
158
void gcons_notify_char(int consnum)
158
{
159
{
159
    if (!use_gcons)
160
    if (!use_gcons)
160
        return;
161
        return;
161
 
162
 
162
    if (consnum == active_console || console_state[consnum] == CONS_HAS_DATA)
163
    if (consnum == active_console || console_state[consnum] == CONS_HAS_DATA)
163
        return;
164
        return;
164
 
165
 
165
    console_state[consnum] = CONS_HAS_DATA;
166
    console_state[consnum] = CONS_HAS_DATA;
166
 
167
 
167
    if (active_console == KERNEL_CONSOLE)
168
    if (active_console == KERNEL_CONSOLE)
168
        return;
169
        return;
169
 
170
 
170
    redraw_state(consnum);
171
    redraw_state(consnum);
171
   
172
   
172
    vp_switch(console_vp);
173
    vp_switch(console_vp);
173
}
174
}
174
 
175
 
175
/** Notification function called on service disconnect from console */
176
/** Notification function called on service disconnect from console */
176
void gcons_notify_disconnect(int consnum)
177
void gcons_notify_disconnect(int consnum)
177
{
178
{
178
    if (!use_gcons)
179
    if (!use_gcons)
179
        return;
180
        return;
180
    if (active_console == consnum)
181
    if (active_console == consnum)
181
        console_state[consnum] = CONS_DISCONNECTED_SEL;
182
        console_state[consnum] = CONS_DISCONNECTED_SEL;
182
    else
183
    else
183
        console_state[consnum] = CONS_DISCONNECTED;
184
        console_state[consnum] = CONS_DISCONNECTED;
184
 
185
 
185
    if (active_console == KERNEL_CONSOLE)
186
    if (active_console == KERNEL_CONSOLE)
186
        return;
187
        return;
187
 
188
 
188
    redraw_state(consnum);
189
    redraw_state(consnum);
189
    vp_switch(console_vp);
190
    vp_switch(console_vp);
190
}
191
}
191
 
192
 
192
/** Notification function called on console connect */
193
/** Notification function called on console connect */
193
void gcons_notify_connect(int consnum)
194
void gcons_notify_connect(int consnum)
194
{
195
{
195
    if (!use_gcons)
196
    if (!use_gcons)
196
        return;
197
        return;
197
    if (active_console == consnum)
198
    if (active_console == consnum)
198
        console_state[consnum] = CONS_SELECTED;
199
        console_state[consnum] = CONS_SELECTED;
199
    else
200
    else
200
        console_state[consnum] = CONS_IDLE;
201
        console_state[consnum] = CONS_IDLE;
201
 
202
 
202
    if (active_console == KERNEL_CONSOLE)
203
    if (active_console == KERNEL_CONSOLE)
203
        return;
204
        return;
204
 
205
 
205
    redraw_state(consnum);
206
    redraw_state(consnum);
206
    vp_switch(console_vp);
207
    vp_switch(console_vp);
207
}
208
}
208
 
209
 
209
/** Change to kernel console */
210
/** Change to kernel console */
210
void gcons_in_kernel(void)
211
void gcons_in_kernel(void)
211
{
212
{
212
    if (console_state[active_console] == CONS_DISCONNECTED_SEL)
213
    if (console_state[active_console] == CONS_DISCONNECTED_SEL)
213
        console_state[active_console] = CONS_DISCONNECTED;
214
        console_state[active_console] = CONS_DISCONNECTED;
214
    else
215
    else
215
        console_state[active_console] = CONS_IDLE;
216
        console_state[active_console] = CONS_IDLE;
216
    redraw_state(active_console);
217
    redraw_state(active_console);
217
 
218
 
218
    active_console = KERNEL_CONSOLE; /* Set to kernel console */
219
    active_console = KERNEL_CONSOLE; /* Set to kernel console */
219
    vp_switch(0);
220
    vp_switch(0);
220
}
221
}
221
 
222
 
222
/** Draw a PPM pixmap to framebuffer
223
/** Draw a PPM pixmap to framebuffer
223
 *
224
 *
224
 * @param logo Pointer to PPM data
225
 * @param logo Pointer to PPM data
225
 * @param size Size of PPM data
226
 * @param size Size of PPM data
226
 * @param x Coordinate of upper left corner
227
 * @param x Coordinate of upper left corner
227
 * @param y Coordinate of upper left corner
228
 * @param y Coordinate of upper left corner
228
 */
229
 */
229
static void draw_pixmap(char *logo, size_t size, int x, int y)
230
static void draw_pixmap(char *logo, size_t size, int x, int y)
230
{
231
{
231
    char *shm;
232
    char *shm;
232
    int rc;
233
    int rc;
233
 
234
 
234
    /* Create area */
235
    /* Create area */
235
    shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
236
    shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
236
    if (shm == MAP_FAILED)
237
    if (shm == MAP_FAILED)
237
        return;
238
        return;
238
 
239
 
239
    memcpy(shm, logo, size);
240
    memcpy(shm, logo, size);
240
    /* Send area */
241
    /* Send area */
241
    rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
242
    rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
242
    if (rc)
243
    if (rc)
243
        goto exit;
244
        goto exit;
244
    rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
245
    rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
245
    if (rc)
246
    if (rc)
246
        goto drop;
247
        goto drop;
247
    /* Draw logo */
248
    /* Draw logo */
248
    async_msg_2(fbphone, FB_DRAW_PPM, x, y);
249
    async_msg_2(fbphone, FB_DRAW_PPM, x, y);
249
drop:
250
drop:
250
    /* Drop area */
251
    /* Drop area */
251
    async_msg(fbphone, FB_DROP_SHM, 0);
252
    async_msg(fbphone, FB_DROP_SHM, 0);
252
exit:      
253
exit:      
253
    /* Remove area */
254
    /* Remove area */
254
    munmap(shm, size);
255
    munmap(shm, size);
255
}
256
}
256
 
257
 
257
extern char _binary_helenos_ppm_start[0];
258
extern char _binary_helenos_ppm_start[0];
258
extern int _binary_helenos_ppm_size;
259
extern int _binary_helenos_ppm_size;
259
extern char _binary_nameic_ppm_start[0];
260
extern char _binary_nameic_ppm_start[0];
260
extern int _binary_nameic_ppm_size;
261
extern int _binary_nameic_ppm_size;
261
/** Redraws console graphics  */
262
/** Redraws console graphics  */
262
static void gcons_redraw_console(void)
263
static void gcons_redraw_console(void)
263
{
264
{
264
    int i;
265
    int i;
265
    size_t hsize = (size_t)&_binary_helenos_ppm_size;
266
    size_t hsize = (size_t)&_binary_helenos_ppm_size;
266
 
267
 
267
    if (!use_gcons)
268
    if (!use_gcons)
268
        return;
269
        return;
269
   
270
   
270
    vp_switch(0);
271
    vp_switch(0);
271
    set_style(MAIN_COLOR, MAIN_COLOR);
272
    set_style(MAIN_COLOR, MAIN_COLOR);
272
    clear();
273
    clear();
273
    draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-66, 2);
274
    draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-66, 2);
274
    draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 17);
275
    draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 17);
275
 
276
 
276
    for (i=0;i < CONSOLE_COUNT; i++)
277
    for (i=0;i < CONSOLE_COUNT; i++)
277
        redraw_state(i);
278
        redraw_state(i);
278
    vp_switch(console_vp);
279
    vp_switch(console_vp);
279
}
280
}
280
 
281
 
281
/** Creates a pixmap on framebuffer
282
/** Creates a pixmap on framebuffer
282
 *
283
 *
283
 * @param data PPM data
284
 * @param data PPM data
284
 * @param size PPM data size
285
 * @param size PPM data size
285
 * @return Pixmap identification
286
 * @return Pixmap identification
286
 */
287
 */
287
static int make_pixmap(char *data, int size)
288
static int make_pixmap(char *data, int size)
288
{
289
{
289
    char *shm;
290
    char *shm;
290
    int rc;
291
    int rc;
291
    int pxid = -1;
292
    int pxid = -1;
292
 
293
 
293
    /* Create area */
294
    /* Create area */
294
    shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
295
    shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
295
    if (shm == MAP_FAILED)
296
    if (shm == MAP_FAILED)
296
        return -1;
297
        return -1;
297
 
298
 
298
    memcpy(shm, data, size);
299
    memcpy(shm, data, size);
299
    /* Send area */
300
    /* Send area */
300
    rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
301
    rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
301
    if (rc)
302
    if (rc)
302
        goto exit;
303
        goto exit;
303
    rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
304
    rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
304
    if (rc)
305
    if (rc)
305
        goto drop;
306
        goto drop;
306
 
307
 
307
    /* Obtain pixmap */
308
    /* Obtain pixmap */
308
    rc = async_req(fbphone, FB_SHM2PIXMAP, 0, NULL);
309
    rc = async_req(fbphone, FB_SHM2PIXMAP, 0, NULL);
309
    if (rc < 0)
310
    if (rc < 0)
310
        goto drop;
311
        goto drop;
311
    pxid = rc;
312
    pxid = rc;
312
drop:
313
drop:
313
    /* Drop area */
314
    /* Drop area */
314
    async_msg(fbphone, FB_DROP_SHM, 0);
315
    async_msg(fbphone, FB_DROP_SHM, 0);
315
exit:      
316
exit:      
316
    /* Remove area */
317
    /* Remove area */
317
    munmap(shm, size);
318
    munmap(shm, size);
318
 
319
 
319
    return pxid;
320
    return pxid;
320
}
321
}
321
 
322
 
-
 
323
extern char _binary_anim_1_ppm_start[0];
-
 
324
extern int _binary_anim_1_ppm_size;
-
 
325
extern char _binary_anim_2_ppm_start[0];
-
 
326
extern int _binary_anim_2_ppm_size;
-
 
327
extern char _binary_anim_3_ppm_start[0];
-
 
328
extern int _binary_anim_3_ppm_size;
-
 
329
extern char _binary_anim_4_ppm_start[0];
-
 
330
extern int _binary_anim_4_ppm_size;
-
 
331
static void make_anim(void)
-
 
332
{
-
 
333
    int an;
-
 
334
    int pm;
-
 
335
 
-
 
336
    an = async_req(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE], NULL);
-
 
337
    if (an < 0)
-
 
338
        return;
-
 
339
 
-
 
340
    pm = make_pixmap(_binary_anim_1_ppm_start, (int)&_binary_anim_1_ppm_size);
-
 
341
    async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
-
 
342
 
-
 
343
    pm = make_pixmap(_binary_anim_2_ppm_start, (int)&_binary_anim_2_ppm_size);
-
 
344
    async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
-
 
345
 
-
 
346
    pm = make_pixmap(_binary_anim_3_ppm_start, (int)&_binary_anim_3_ppm_size);
-
 
347
    async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
-
 
348
 
-
 
349
    pm = make_pixmap(_binary_anim_4_ppm_start, (int)&_binary_anim_4_ppm_size);
-
 
350
    async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
-
 
351
 
-
 
352
    async_msg(fbphone, FB_ANIM_START, an);
-
 
353
 
-
 
354
    animation = an;
-
 
355
}
-
 
356
 
322
extern char _binary_cons_selected_ppm_start[0];
357
extern char _binary_cons_selected_ppm_start[0];
323
extern int _binary_cons_selected_ppm_size;
358
extern int _binary_cons_selected_ppm_size;
324
extern char _binary_cons_idle_ppm_start[0];
359
extern char _binary_cons_idle_ppm_start[0];
325
extern int _binary_cons_idle_ppm_size;
360
extern int _binary_cons_idle_ppm_size;
326
extern char _binary_cons_has_data_ppm_start[0];
361
extern char _binary_cons_has_data_ppm_start[0];
327
extern int _binary_cons_has_data_ppm_size;
362
extern int _binary_cons_has_data_ppm_size;
328
extern char _binary_cons_kernel_ppm_start[0];
363
extern char _binary_cons_kernel_ppm_start[0];
329
extern int _binary_cons_kernel_ppm_size;
364
extern int _binary_cons_kernel_ppm_size;
330
/** Initialize nice graphical console environment */
365
/** Initialize nice graphical console environment */
331
void gcons_init(int phone)
366
void gcons_init(int phone)
332
{
367
{
333
    int rc;
368
    int rc;
334
    int i;
369
    int i;
-
 
370
    int status_start = STATUS_START;
335
 
371
 
336
    fbphone = phone;
372
    fbphone = phone;
337
 
373
 
338
    rc = ipc_call_sync_2(phone, FB_GET_RESOLUTION, 0, 0, &xres, &yres);
374
    rc = ipc_call_sync_2(phone, FB_GET_RESOLUTION, 0, 0, &xres, &yres);
339
    if (rc)
375
    if (rc)
340
        return;
376
        return;
341
   
377
   
342
    if (xres < 800 || yres < 600)
378
    if (xres < 800 || yres < 600)
343
        return;
379
        return;
344
 
380
 
345
    /* create console viewport */
381
    /* create console viewport */
346
    /* Align width & height to character size */
382
    /* Align width & height to character size */
347
    console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP,
383
    console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP,
348
                   ALIGN_DOWN(xres-2*CONSOLE_MARGIN, 8),
384
                   ALIGN_DOWN(xres-2*CONSOLE_MARGIN, 8),
349
                   ALIGN_DOWN(yres-(CONSOLE_TOP+CONSOLE_MARGIN),16));
385
                   ALIGN_DOWN(yres-(CONSOLE_TOP+CONSOLE_MARGIN),16));
350
    if (console_vp < 0)
386
    if (console_vp < 0)
351
        return;
387
        return;
352
   
388
   
353
    /* Create status buttons */
389
    /* Create status buttons */
-
 
390
    status_start += (xres-800) / 2;
354
    for (i=0; i < CONSOLE_COUNT; i++) {
391
    for (i=0; i < CONSOLE_COUNT; i++) {
355
        cstatus_vp[i] = vp_create(STATUS_START+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
392
        cstatus_vp[i] = vp_create(status_start+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
356
                      STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT);
393
                      STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT);
357
        if (cstatus_vp[i] < 0)
394
        if (cstatus_vp[i] < 0)
358
            return;
395
            return;
359
        vp_switch(cstatus_vp[i]);
396
        vp_switch(cstatus_vp[i]);
360
        set_style(0x202020, 0xffffff);
397
        set_style(0x202020, 0xffffff);
361
    }
398
    }
362
   
399
   
363
    /* Initialize icons */
400
    /* Initialize icons */
364
    ic_pixmaps[CONS_SELECTED] = make_pixmap(_binary_cons_selected_ppm_start,
401
    ic_pixmaps[CONS_SELECTED] = make_pixmap(_binary_cons_selected_ppm_start,
365
                          (int)&_binary_cons_selected_ppm_size);
402
                          (int)&_binary_cons_selected_ppm_size);
366
    ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start,
403
    ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start,
367
                          (int)&_binary_cons_idle_ppm_size);
404
                          (int)&_binary_cons_idle_ppm_size);
368
    ic_pixmaps[CONS_HAS_DATA] = make_pixmap(_binary_cons_has_data_ppm_start,
405
    ic_pixmaps[CONS_HAS_DATA] = make_pixmap(_binary_cons_has_data_ppm_start,
369
                        (int)&_binary_cons_has_data_ppm_size);
406
                        (int)&_binary_cons_has_data_ppm_size);
370
    ic_pixmaps[CONS_DISCONNECTED] = make_pixmap(_binary_cons_idle_ppm_start,
407
    ic_pixmaps[CONS_DISCONNECTED] = make_pixmap(_binary_cons_idle_ppm_start,
371
                          (int)&_binary_cons_idle_ppm_size);
408
                          (int)&_binary_cons_idle_ppm_size);
372
    ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start,
409
    ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start,
373
                          (int)&_binary_cons_kernel_ppm_size);
410
                          (int)&_binary_cons_kernel_ppm_size);
374
    ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED];
411
    ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED];
-
 
412
   
-
 
413
    make_anim();
375
 
414
 
376
    use_gcons = 1;
415
    use_gcons = 1;
377
    console_state[0] = CONS_DISCONNECTED_SEL;
416
    console_state[0] = CONS_DISCONNECTED_SEL;
378
    console_state[KERNEL_CONSOLE] = CONS_KERNEL;
417
    console_state[KERNEL_CONSOLE] = CONS_KERNEL;
379
    gcons_redraw_console();
418
    gcons_redraw_console();
380
}
419
}
381
 
420