Subversion Repositories HelenOS-historic

Rev

Rev 1766 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1766 Rev 1780
Line 47... Line 47...
47
 
47
 
48
#include "helenos.xbm"
48
#include "helenos.xbm"
49
 
49
 
50
SPINLOCK_INITIALIZE(fb_lock);
50
SPINLOCK_INITIALIZE(fb_lock);
51
 
51
 
52
static __u8 *fbaddress = NULL;
52
static uint8_t *fbaddress = NULL;
53
 
53
 
54
static __u8 *blankline = NULL;
54
static uint8_t *blankline = NULL;
55
static __u8 *dbbuffer = NULL; /* Buffer for fast scrolling console */
55
static uint8_t *dbbuffer = NULL; /* Buffer for fast scrolling console */
56
static int dboffset;
56
static int dboffset;
57
 
57
 
58
static unsigned int xres = 0;
58
static unsigned int xres = 0;
59
static unsigned int yres = 0;
59
static unsigned int yres = 0;
60
static unsigned int scanline = 0;
60
static unsigned int scanline = 0;
Line 96... Line 96...
96
    return (*(int *)src) & 0xffffff;
96
    return (*(int *)src) & 0xffffff;
97
}
97
}
98
 
98
 
99
static void rgb_3byte(void *dst, int rgb)
99
static void rgb_3byte(void *dst, int rgb)
100
{
100
{
101
    __u8 *scr = dst;
101
    uint8_t *scr = dst;
102
#if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN))
102
#if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN))
103
    scr[0] = RED(rgb, 8);
103
    scr[0] = RED(rgb, 8);
104
    scr[1] = GREEN(rgb, 8);
104
    scr[1] = GREEN(rgb, 8);
105
    scr[2] = BLUE(rgb, 8);
105
    scr[2] = BLUE(rgb, 8);
106
#else
106
#else
Line 110... Line 110...
110
#endif
110
#endif
111
}
111
}
112
 
112
 
113
static int byte3_rgb(void *src)
113
static int byte3_rgb(void *src)
114
{
114
{
115
    __u8 *scr = src;
115
    uint8_t *scr = src;
116
#if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN))
116
#if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN))
117
    return scr[0] << 16 | scr[1] << 8 | scr[2];
117
    return scr[0] << 16 | scr[1] << 8 | scr[2];
118
#else
118
#else
119
    return scr[2] << 16 | scr[1] << 8 | scr[0];
119
    return scr[2] << 16 | scr[1] << 8 | scr[0];
120
#endif  
120
#endif  
Line 122... Line 122...
122
 
122
 
123
/**  16-bit depth (5:6:5) */
123
/**  16-bit depth (5:6:5) */
124
static void rgb_2byte(void *dst, int rgb)
124
static void rgb_2byte(void *dst, int rgb)
125
{
125
{
126
    /* 5-bit, 6-bits, 5-bits */
126
    /* 5-bit, 6-bits, 5-bits */
127
    *((__u16 *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5);
127
    *((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5);
128
}
128
}
129
 
129
 
130
/** 16-bit depth (5:6:5) */
130
/** 16-bit depth (5:6:5) */
131
static int byte2_rgb(void *src)
131
static int byte2_rgb(void *src)
132
{
132
{
133
    int color = *(__u16 *)(src);
133
    int color = *(uint16_t *)(src);
134
    return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
134
    return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
135
}
135
}
136
 
136
 
137
/** Put pixel - 8-bit depth (3:2:3) */
137
/** Put pixel - 8-bit depth (3:2:3) */
138
static void rgb_1byte(void *dst, int rgb)
138
static void rgb_1byte(void *dst, int rgb)
139
{
139
{
140
    *(__u8 *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3);
140
    *(uint8_t *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3);
141
}
141
}
142
 
142
 
143
/** Return pixel color - 8-bit depth (3:2:3) */
143
/** Return pixel color - 8-bit depth (3:2:3) */
144
static int byte1_rgb(void *src)
144
static int byte1_rgb(void *src)
145
{
145
{
146
    int color = *(__u8 *)src;
146
    int color = *(uint8_t *)src;
147
    return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
147
    return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
148
}
148
}
149
 
149
 
150
static void putpixel(unsigned int x, unsigned int y, int color)
150
static void putpixel(unsigned int x, unsigned int y, int color)
151
{
151
{
Line 182... Line 182...
182
 
182
 
183
 
183
 
184
/** Scroll screen one row up */
184
/** Scroll screen one row up */
185
static void scroll_screen(void)
185
static void scroll_screen(void)
186
{
186
{
187
    __u8 *lastline = &fbaddress[(rows - 1) * ROW_BYTES];
187
    uint8_t *lastline = &fbaddress[(rows - 1) * ROW_BYTES];
188
    int firstsz;
188
    int firstsz;
189
 
189
 
190
    if (dbbuffer) {
190
    if (dbbuffer) {
191
        memcpy(&dbbuffer[dboffset*scanline], blankline, FONT_SCANLINES*scanline);
191
        memcpy(&dbbuffer[dboffset*scanline], blankline, FONT_SCANLINES*scanline);
192
       
192
       
Line 223... Line 223...
223
 
223
 
224
/***************************************************************/
224
/***************************************************************/
225
/* Character-console functions */
225
/* Character-console functions */
226
 
226
 
227
/** Draw character at given position */
227
/** Draw character at given position */
228
static void draw_glyph(__u8 glyph, unsigned int col, unsigned int row)
228
static void draw_glyph(uint8_t glyph, unsigned int col, unsigned int row)
229
{
229
{
230
    unsigned int y;
230
    unsigned int y;
231
 
231
 
232
    for (y = 0; y < FONT_SCANLINES; y++)
232
    for (y = 0; y < FONT_SCANLINES; y++)
233
        draw_glyph_line(fb_font[glyph * FONT_SCANLINES + y], col * COL_WIDTH, row * FONT_SCANLINES + y);
233
        draw_glyph_line(fb_font[glyph * FONT_SCANLINES + y], col * COL_WIDTH, row * FONT_SCANLINES + y);
Line 334... Line 334...
334
 * @param y    Screen height in pixels
334
 * @param y    Screen height in pixels
335
 * @param bpp  Bits per pixel (8, 16, 24, 32)
335
 * @param bpp  Bits per pixel (8, 16, 24, 32)
336
 * @param scan Bytes per one scanline
336
 * @param scan Bytes per one scanline
337
 *
337
 *
338
 */
338
 */
339
void fb_init(__address addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan)
339
void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan)
340
{
340
{
341
    switch (bpp) {
341
    switch (bpp) {
342
        case 8:
342
        case 8:
343
            rgb2scr = rgb_1byte;
343
            rgb2scr = rgb_1byte;
344
            scr2rgb = byte1_rgb;
344
            scr2rgb = byte1_rgb;
Line 364... Line 364...
364
    }
364
    }
365
   
365
   
366
    unsigned int fbsize = scan * y;
366
    unsigned int fbsize = scan * y;
367
   
367
   
368
    /* Map the framebuffer */
368
    /* Map the framebuffer */
369
    fbaddress = (__u8 *) hw_map((__address) addr, fbsize);
369
    fbaddress = (uint8_t *) hw_map((uintptr_t) addr, fbsize);
370
   
370
   
371
    xres = x;
371
    xres = x;
372
    yres = y;
372
    yres = y;
373
    bitspp = bpp;
373
    bitspp = bpp;
374
    scanline = scan;
374
    scanline = scan;
Line 397... Line 397...
397
    if (!dbbuffer)
397
    if (!dbbuffer)
398
        printf("Failed to allocate scroll buffer.\n");
398
        printf("Failed to allocate scroll buffer.\n");
399
    dboffset = 0;
399
    dboffset = 0;
400
 
400
 
401
    /* Initialized blank line */
401
    /* Initialized blank line */
402
    blankline = (__u8 *) malloc(ROW_BYTES, FRAME_ATOMIC);
402
    blankline = (uint8_t *) malloc(ROW_BYTES, FRAME_ATOMIC);
403
    if (!blankline)
403
    if (!blankline)
404
        panic("Failed to allocate blank line for framebuffer.");
404
        panic("Failed to allocate blank line for framebuffer.");
405
    for (y=0; y < FONT_SCANLINES; y++)
405
    for (y=0; y < FONT_SCANLINES; y++)
406
        for (x=0; x < xres; x++)
406
        for (x=0; x < xres; x++)
407
            (*rgb2scr)(&blankline[POINTPOS(x,y)],BGCOLOR);
407
            (*rgb2scr)(&blankline[POINTPOS(x,y)],BGCOLOR);