Subversion Repositories HelenOS-historic

Rev

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

Rev 1366 Rev 1392
Line 42... Line 42...
42
#include <unistd.h>
42
#include <unistd.h>
43
#include <stdlib.h>
43
#include <stdlib.h>
44
#include <ipc/ns.h>
44
#include <ipc/ns.h>
45
 
45
 
46
#include <kernel/errno.h>
46
#include <kernel/errno.h>
47
 
-
 
-
 
47
#include <async.h>
48
 
48
 
49
#include "fb.h"
49
#include "fb.h"
50
 
50
 
51
 
-
 
52
 
-
 
53
#define pl /*printf("FB:L:%d\n",(int)__LINE__);*/
-
 
54
 
-
 
55
#define EFB (-1)
51
#define EFB (-1)
56
 
52
 
57
#define DEFAULT_BGCOLOR     0x000080
53
#define DEFAULT_BGCOLOR     0x000080
58
#define DEFAULT_FGCOLOR     0xffff00
54
#define DEFAULT_FGCOLOR     0xffff00
59
#define DEFAULT_LOGOCOLOR   0x0000ff
55
#define DEFAULT_LOGOCOLOR   0x0000ff
Line 77... Line 73...
77
 
73
 
78
unsigned int mod_col(unsigned int col,int mod);
74
unsigned int mod_col(unsigned int col,int mod);
79
 
75
 
80
 
76
 
81
 
77
 
82
 
-
 
83
 
-
 
84
int main(int argc, char *argv[])
78
static int init_fb(void)
85
{
79
{
86
   
-
 
87
    __address fb_ph_addr;
80
    __address fb_ph_addr;
88
    unsigned int fb_width;
81
    unsigned int fb_width;
89
    unsigned int fb_height;
82
    unsigned int fb_height;
90
    unsigned int fb_bpp;
83
    unsigned int fb_bpp;
91
    unsigned int fb_scanline;
84
    unsigned int fb_scanline;
92
    __address fb_addr;
85
    __address fb_addr;
93
    int a=0;
86
    int a=0;
-
 
87
    int i,j,k;
-
 
88
    int w;
-
 
89
    char text[]="HelenOS Framebuffer driver\non Virtual Framebuffer\nVFB ";
94
 
90
 
95
 
-
 
96
    if(!sysinfo_value("fb")) return -1;
-
 
97
   
-
 
98
    fb_ph_addr=sysinfo_value("fb.address.physical");
91
    fb_ph_addr=sysinfo_value("fb.address.physical");
99
    fb_width=sysinfo_value("fb.width");
92
    fb_width=sysinfo_value("fb.width");
100
    fb_height=sysinfo_value("fb.height");
93
    fb_height=sysinfo_value("fb.height");
101
    fb_bpp=sysinfo_value("fb.bpp");
94
    fb_bpp=sysinfo_value("fb.bpp");
102
    fb_scanline=sysinfo_value("fb.scanline");
95
    fb_scanline=sysinfo_value("fb.scanline");
103
 
96
 
104
    fb_addr=ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE);
97
    fb_addr=ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE);
105
 
98
 
106
 
99
 
107
 
100
   
108
    map_physmem(task_get_id(),(void *)((__address)fb_ph_addr),(void *)fb_addr,
101
    map_physmem(task_get_id(),(void *)((__address)fb_ph_addr),(void *)fb_addr,
109
        (fb_scanline*fb_height+PAGE_SIZE-1)>>PAGE_WIDTH,1);
102
            (fb_scanline*fb_height+PAGE_SIZE-1)>>PAGE_WIDTH,1);
110
   
103
   
111
    fb_init(0,fb_addr, fb_width, fb_height, fb_bpp, fb_scanline,
104
    fb_init(0,fb_addr, fb_width, fb_height, fb_bpp, fb_scanline,
112
        MAIN_BGCOLOR,MAIN_FGCOLOR,MAIN_LOGOCOLOR);
105
        MAIN_BGCOLOR,MAIN_FGCOLOR,MAIN_LOGOCOLOR);
113
 
106
 
114
    fb_putchar(0,'\n');
107
    fb_putchar(0,'\n');
115
    fb_putchar(0,' ');
108
    fb_putchar(0,' ');
116
 
109
 
-
 
110
    for(i=0;i<H_NO_VFBS;i++)
-
 
111
        for(j=0;j<V_NO_VFBS;j++) {
-
 
112
            w = create_window(0,(fb_width/H_NO_VFBS)*i+SPACING,
-
 
113
                      (fb_height/V_NO_VFBS)*j+SPACING,(fb_width/H_NO_VFBS)-2*SPACING ,
-
 
114
                      (fb_height/V_NO_VFBS)-2*SPACING,mod_col(DEFAULT_BGCOLOR,/*i+j*H_NO_VFBS*/0),
-
 
115
                      mod_col(DEFAULT_FGCOLOR,/*i+j*H_NO_VFBS*/0),
-
 
116
                      mod_col(DEFAULT_LOGOCOLOR,/*i+j*H_NO_VFBS)*/0));
-
 
117
           
-
 
118
            if( w== EFB)
-
 
119
                return -1;
-
 
120
           
-
 
121
            for(k=0;text[k];k++)
-
 
122
                fb_putchar(w,text[k]);
-
 
123
            fb_putchar(w,w+'0');
-
 
124
            fb_putchar(w,'\n');
-
 
125
        }
-
 
126
    return 0;
-
 
127
}
117
 
128
 
-
 
129
int vfb_no = 1;
-
 
130
void client_connection(ipc_callid_t iid, ipc_call_t *icall)
118
    {
131
{
-
 
132
    ipc_callid_t callid;
119
        int i,j;
133
    ipc_call_t call;
-
 
134
    int vfb = vfb_no++;
120
 
135
 
121
        for(i=0;i<H_NO_VFBS;i++)
-
 
122
            for(j=0;j<V_NO_VFBS;j++)
-
 
123
            {
-
 
124
   
-
 
125
                int w=create_window(0,(fb_width/H_NO_VFBS)*i+SPACING,
-
 
126
                    (fb_height/V_NO_VFBS)*j+SPACING,(fb_width/H_NO_VFBS)-2*SPACING ,
-
 
127
                        (fb_height/V_NO_VFBS)-2*SPACING,mod_col(DEFAULT_BGCOLOR,/*i+j*H_NO_VFBS*/0),
-
 
128
                            mod_col(DEFAULT_FGCOLOR,/*i+j*H_NO_VFBS*/0),
-
 
129
                                mod_col(DEFAULT_LOGOCOLOR,/*i+j*H_NO_VFBS)*/0));
-
 
130
 
-
 
131
                if(w==EFB) return -1;
-
 
132
 
-
 
133
                {
-
 
134
                    char text[]="Hello, World from\nHelenOS Framebuffer driver\non Virtual Framebuffer\nVFB ";
-
 
135
                    int i;
136
    if (vfb > 9) {
136
                    for(i=0;text[i];i++) fb_putchar(w,text[i]);
-
 
137
                    fb_putchar(w,w+'0');
137
        ipc_answer_fast(iid, ELIMIT, 0,0);
138
                    fb_putchar(w,'\n');
-
 
139
                }
138
        return;
140
            }
-
 
141
    }
139
    }
-
 
140
    ipc_answer_fast(iid, 0, 0, 0);
142
 
141
 
-
 
142
    while (1) {
-
 
143
        callid = async_get_call(&call);
-
 
144
        switch (IPC_GET_METHOD(call)) {
-
 
145
        case IPC_M_PHONE_HUNGUP:
-
 
146
            ipc_answer_fast(callid,0,0,0);
-
 
147
            return; /* Exit thread */
-
 
148
 
-
 
149
        case FB_PUTCHAR:
-
 
150
            ipc_answer_fast(callid,0,0,0);
-
 
151
            fb_putchar(vfb,IPC_GET_ARG2(call));
-
 
152
            break;
-
 
153
        default:
-
 
154
            ipc_answer_fast(callid,ENOENT,0,0);
-
 
155
        }
-
 
156
    }
-
 
157
}
143
 
158
 
-
 
159
int main(int argc, char *argv[])
-
 
160
{
144
    ipc_call_t call;
161
    ipc_call_t call;
145
    ipc_callid_t callid;
162
    ipc_callid_t callid;
146
    char connected = 0;
163
    char connected = 0;
147
    int res;
164
    int res;
148
    int c;
165
    int c;
149
    ipcarg_t phonead;
166
    ipcarg_t phonead;
150
   
167
   
151
    ipcarg_t retval, arg1, arg2;
168
    ipcarg_t retval, arg1, arg2;
152
 
169
 
-
 
170
    if(!sysinfo_value("fb")) return -1;
153
 
171
 
154
 
172
 
155
    if ((res = ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, &phonead)) != 0)
173
    if ((res = ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, &phonead)) != 0)
156
    {
-
 
157
        return -1;
174
        return -1;
158
    };
-
 
159
 
-
 
160
       
175
   
161
    while (1) {
176
    init_fb();
162
        static int vfb_no=1;
-
 
163
 
-
 
164
        callid = ipc_wait_for_call(&call);
-
 
165
    //  printf("%s:Call phone=%lX..", NAME, call.in_phone_hash);
-
 
166
        switch (IPC_GET_METHOD(call)&((1<<METHOD_WIDTH)-1)) {
-
 
167
            case IPC_M_PHONE_HUNGUP:
-
 
168
//              fb_putchar(4,((a++)&15)+'A');
-
 
169
               
-
 
170
                retval = 0;
-
 
171
                break;
-
 
172
            case IPC_M_CONNECT_ME_TO:
-
 
173
                    retval = 0;
-
 
174
//              fb_putchar(1,((a++)&15)+'A');
-
 
175
                break;
-
 
176
            case FB_GET_VFB:
-
 
177
                retval = 0;
-
 
178
                arg1 = vfb_no++;   
-
 
179
//              fb_putchar(2,((a++)&15)+'A');
-
 
180
               
-
 
181
                break;
-
 
182
 
-
 
183
            case FB_PUTCHAR:
-
 
184
                retval = 0;
-
 
185
                fb_putchar(IPC_GET_ARG1(call),IPC_GET_ARG2(call));
-
 
186
//              fb_putchar(2,((a++)&15)+'A');
-
 
187
                break;
-
 
188
 
-
 
189
            default:
-
 
190
                retval = ENOENT;
-
 
191
//              fb_putchar(3,((a++)&15)+'A');
-
 
192
                break;
-
 
193
        }
-
 
194
 
-
 
195
        if (! (callid & IPC_CALLID_NOTIFICATION)) {
-
 
196
            ipc_answer_fast(callid, retval, arg1, arg2);
-
 
197
        }
-
 
198
    }
-
 
199
 
177
 
-
 
178
    async_manager();
-
 
179
    /* Never reached */
200
    return 0;
180
    return 0;
201
}
181
}
202
/*
182
/*
203
 * Copyright (C) 2006 Ondrej Palkovsky
183
 * Copyright (C) 2006 Ondrej Palkovsky
204
 * All rights reserved.
184
 * All rights reserved.
Line 307... Line 287...
307
#else
287
#else
308
    FB(item,fbaddress)[startbyte + 2] = RED(color, 8);
288
    FB(item,fbaddress)[startbyte + 2] = RED(color, 8);
309
    FB(item,fbaddress)[startbyte + 1] = GREEN(color, 8);
289
    FB(item,fbaddress)[startbyte + 1] = GREEN(color, 8);
310
    FB(item,fbaddress)[startbyte + 0] = BLUE(color, 8);
290
    FB(item,fbaddress)[startbyte + 0] = BLUE(color, 8);
311
#endif
291
#endif
312
                                                                                               
-
 
313
 
292
 
314
}
293
}
315
 
294
 
316
/** Return pixel color - 24-bit depth */
295
/** Return pixel color - 24-bit depth */
317
static int getpixel_3byte(int item,unsigned int x, unsigned int y)
296
static int getpixel_3byte(int item,unsigned int x, unsigned int y)
Line 369... Line 348...
369
static void clear_screen(int item)
348
static void clear_screen(int item)
370
{
349
{
371
    unsigned int y;
350
    unsigned int y;
372
    for (y = 0; y < FB(item,yres); y++)
351
    for (y = 0; y < FB(item,yres); y++)
373
    {
352
    {
374
        clear_line(item,y); pl
353
        clear_line(item,y);
375
    }  
354
    }  
376
}
355
}
377
 
356
 
378
 
357
 
379
/** Scroll screen one row up */
358
/** Scroll screen one row up */
Line 551... Line 530...
551
            FB(item,pixelbytes) = 4;
530
            FB(item,pixelbytes) = 4;
552
            break;
531
            break;
553
    }
532
    }
554
 
533
 
555
       
534
       
556
    FB(item,fbaddress) = (unsigned char *) addr; pl
535
    FB(item,fbaddress) = (unsigned char *) addr;
557
    FB(item,xres) = x; pl
536
    FB(item,xres) = x;
558
    FB(item,yres) = y; pl
537
    FB(item,yres) = y;
559
    FB(item,scanline) = scan; pl
538
    FB(item,scanline) = scan;
560
   
539
   
561
   
540
   
562
    FB(item,rows) = y / FONT_SCANLINES; pl
541
    FB(item,rows) = y / FONT_SCANLINES;
563
    FB(item,columns) = x / COL_WIDTH; pl
542
    FB(item,columns) = x / COL_WIDTH;
564
 
543
 
565
    FB(item,BGCOLOR)=BGCOLOR;
544
    FB(item,BGCOLOR)=BGCOLOR;
566
    FB(item,FGCOLOR)=FGCOLOR;
545
    FB(item,FGCOLOR)=FGCOLOR;
567
    FB(item,LOGOCOLOR)=LOGOCOLOR;
546
    FB(item,LOGOCOLOR)=LOGOCOLOR;
568
 
547
 
569
 
548
 
570
    clear_screen(item); pl
549
    clear_screen(item);
571
    draw_logo(item,FB(item,xres) - helenos_width, 0); pl
550
    draw_logo(item,FB(item,xres) - helenos_width, 0);
572
    invert_cursor(item); pl
551
    invert_cursor(item);
573
 
552
 
574
}
553
}
575
 
554
 
576
 
555
 
577
static int get_free_item()
556
static int get_free_item()