Subversion Repositories HelenOS-historic

Rev

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

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