Subversion Repositories HelenOS-historic

Rev

Rev 1518 | Rev 1528 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1518 Rev 1522
Line 26... Line 26...
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>
-
 
32
#include <stdio.h>
31
 
33
 
32
#include "console.h"
34
#include "console.h"
-
 
35
#include "gcons.h"
33
 
36
 
34
#define CONSOLE_TOP      50
37
#define CONSOLE_TOP      50
35
#define CONSOLE_MARGIN   10
38
#define CONSOLE_MARGIN   10
36
 
39
 
37
#define STATUS_SPACE    20
40
#define STATUS_SPACE    20
38
#define STATUS_WIDTH    40
41
#define STATUS_WIDTH    40
39
#define STATUS_HEIGHT   30
42
#define STATUS_HEIGHT   30
40
 
43
 
-
 
44
#define MAIN_COLOR      0x118811
-
 
45
 
41
static int use_gcons = 0;
46
static int use_gcons = 0;
42
static ipcarg_t xres,yres;
47
static ipcarg_t xres,yres;
43
 
48
 
44
static int console_vp;
49
static int console_vp;
45
static int cstatus_vp[CONSOLE_COUNT];
50
static int cstatus_vp[CONSOLE_COUNT];
-
 
51
static int cstat_row, cstat_col; /* Size of cstatus buttons */
46
 
52
 
47
static int fbphone;
53
static int fbphone;
48
 
54
 
-
 
55
enum butstate {
-
 
56
    CONS_ACTIVE = 0,
-
 
57
    CONS_IDLE,
-
 
58
    CONS_HAS_INPUT
-
 
59
};
-
 
60
 
-
 
61
static struct {
-
 
62
    int fgcolor;
-
 
63
    int bgcolor;
-
 
64
} stat_colors[] = {
-
 
65
    {0xd0d0d0, 0x808080},
-
 
66
    {0xd0d0d0, 0x0},
-
 
67
    {0xd0d0d0, 0xa04040}
-
 
68
};
-
 
69
 
-
 
70
static int active_console = 0;
-
 
71
 
49
static void vp_switch(int vp)
72
static void vp_switch(int vp)
50
{
73
{
51
    ipc_call_sync_2(fbphone,FB_VIEWPORT_SWITCH, vp, 0, NULL, NULL);
74
    nsend_call(fbphone,FB_VIEWPORT_SWITCH, vp);
52
}
75
}
53
 
76
 
-
 
77
/** Create view port */
54
static int vp_create(unsigned int x, unsigned int y,
78
static int vp_create(unsigned int x, unsigned int y,
55
             unsigned int width, unsgined int height)
79
             unsigned int width, unsigned int height)
56
{
80
{
-
 
81
    /* Init function, use ipc_call_sync */
-
 
82
    return ipc_call_sync_2(fbphone, FB_VIEWPORT_CREATE,
57
    return  ipc_call_sync_2(fbphone, (x << 16) | y, (width << 16) | height,
83
                   (x << 16) | y, (width << 16) | height,
58
                NULL, NULL);
84
                   NULL, NULL);
59
}
85
}
60
 
86
 
61
static void fb_clear(void)
87
static void clear(void)
62
{
88
{
63
    ipc_call_sync_2(fbphone, FB_CLEAR, 0, 0, NULL, NULL);
89
    nsend_call(fbphone, FB_CLEAR, 0);
64
   
90
   
65
}
91
}
66
 
92
 
67
static void fb_set_style(int fgcolor, int bgcolor)
93
static void set_style(int fgcolor, int bgcolor)
68
{
94
{
-
 
95
    nsend_call_2(fbphone, FB_SET_STYLE, fgcolor, bgcolor);
-
 
96
}
-
 
97
 
-
 
98
static void putch(char c, int row, int col)
-
 
99
{
-
 
100
    nsend_call_3(fbphone, FB_PUTCHAR, c, row, col);
-
 
101
}
-
 
102
 
-
 
103
static void draw_stat(int consnum, enum butstate state)
-
 
104
{
-
 
105
    char data[5];
-
 
106
    int i;
-
 
107
   
69
    ipc_call_sync_2(fbphone, );
108
    vp_switch(cstatus_vp[consnum]);
-
 
109
    set_style(stat_colors[state].fgcolor, stat_colors[state].bgcolor);
-
 
110
    clear();
-
 
111
    snprintf(data, 5, "%d", consnum+1);
-
 
112
    for (i=0;data[i];i++)
-
 
113
        putch(data[i], 0, i);
70
}
114
}
71
 
115
 
72
void gcons_change_console(int consnum)
116
void gcons_change_console(int consnum)
73
{
117
{
74
    if (!use_gcons)
118
    if (!use_gcons)
75
        return;
119
        return;
76
 
120
   
-
 
121
    draw_stat(active_console, CONS_IDLE);
-
 
122
    active_console = consnum;
-
 
123
    draw_stat(consnum, CONS_ACTIVE);
77
    vp_switch(console_vp);
124
    vp_switch(console_vp);
78
}
125
}
79
 
126
 
80
void gcons_notify_char(int consnum)
127
void gcons_notify_char(int consnum)
81
{
128
{
Line 83... Line 130...
83
        return;
130
        return;
84
 
131
 
85
    vp_switch(console_vp);
132
    vp_switch(console_vp);
86
}
133
}
87
 
134
 
88
void gcons_redraw_console(int phone)
135
void gcons_redraw_console(void)
89
{
136
{
-
 
137
    int i;
-
 
138
 
90
    if (!use_gcons)
139
    if (!use_gcons)
91
        return;
140
        return;
92
   
141
   
93
    vp_switch(0);
142
    vp_switch(0);
94
    /* Set style...*/
143
    set_style(MAIN_COLOR, MAIN_COLOR);
95
    fb_clear();
144
    clear();
96
   
145
 
-
 
146
    for (i=0;i < CONSOLE_COUNT; i++)
-
 
147
        draw_stat(i, i == active_console ? CONS_ACTIVE : CONS_IDLE);
97
    vp_switch(console_vp);
148
    vp_switch(console_vp);
98
}
149
}
99
 
150
 
100
/** Initialize nice graphical console environment */
151
/** Initialize nice graphical console environment */
101
void gcons_init(int phone)
152
void gcons_init(int phone)
Line 118... Line 169...
118
    if (console_vp < 0)
169
    if (console_vp < 0)
119
        return;
170
        return;
120
   
171
   
121
    /* Create status buttons */
172
    /* Create status buttons */
122
    for (i=0; i < CONSOLE_COUNT; i++) {
173
    for (i=0; i < CONSOLE_COUNT; i++) {
123
        cstatus_vp[i] = vp_create(phone, CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
174
        cstatus_vp[i] = vp_create(CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
124
                      CONSOLE_MARGIN, STATUS_WIDTH, STATUS_HEIGHT);
175
                      CONSOLE_MARGIN, STATUS_WIDTH, STATUS_HEIGHT);
125
        if (cstatus_vp[i] < 0)
176
        if (cstatus_vp[i] < 0)
126
            return;
177
            return;
127
    }
178
    }
128
   
179
   
129
    use_gcons = 1;
180
    use_gcons = 1;
130
    gcons_draw_console();
181
    gcons_redraw_console();
131
}
182
}