source: mainline/kernel/arch/ia32/src/drivers/vesa.c@ f1a2c6e

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since f1a2c6e was a71c158, checked in by Martin Decky <martin@…>, 16 years ago

kernel output devices now suport multiple instances (except ski and sgcn, which respect the same interface, but behave as singletons)
if more than one output device gets initialized, the output is cloned to all of them
get rid of arch_grab_console() and arch_release_console() (output devices can implement a generic "redraw" method, input devices respect the "silent" global variable)
related cleanups and modifications

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 * Copyright (c) 2006 Jakub Vana
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
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
15 * derived from this software without specific prior written permission.
16 *
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
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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
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
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup ia32
30 * @{
31 */
32/**
33 * @file
34 * @brief VESA frame buffer driver.
35 */
36
37#ifdef CONFIG_FB
38
39#include <genarch/fb/fb.h>
40#include <genarch/fb/visuals.h>
41#include <arch/drivers/vesa.h>
42#include <console/chardev.h>
43#include <console/console.h>
44#include <putchar.h>
45#include <mm/page.h>
46#include <mm/frame.h>
47#include <mm/as.h>
48#include <arch/mm/page.h>
49#include <synch/spinlock.h>
50#include <arch/asm.h>
51#include <arch/types.h>
52#include <memstr.h>
53#include <bitops.h>
54
55uint32_t vesa_ph_addr;
56uint16_t vesa_width;
57uint16_t vesa_height;
58uint16_t vesa_bpp;
59uint16_t vesa_scanline;
60
61uint8_t vesa_red_mask;
62uint8_t vesa_red_pos;
63
64uint8_t vesa_green_mask;
65uint8_t vesa_green_pos;
66
67uint8_t vesa_blue_mask;
68uint8_t vesa_blue_pos;
69
70bool vesa_init(void)
71{
72 if ((vesa_width == 0xffff) || (vesa_height == 0xffff))
73 return false;
74
75 visual_t visual;
76
77 switch (vesa_bpp) {
78 case 8:
79 visual = VISUAL_INDIRECT_8;
80 break;
81 case 16:
82 if ((vesa_red_mask == 5) && (vesa_red_pos == 10)
83 && (vesa_green_mask == 5) && (vesa_green_pos == 5)
84 && (vesa_blue_mask == 5) && (vesa_blue_pos == 0))
85 visual = VISUAL_RGB_5_5_5_LE;
86 else
87 visual = VISUAL_RGB_5_6_5_LE;
88 break;
89 case 24:
90 visual = VISUAL_BGR_8_8_8;
91 break;
92 case 32:
93 visual = VISUAL_BGR_8_8_8_0;
94 break;
95 default:
96 LOG("Unsupported bits per pixel.");
97 return false;
98 }
99
100 fb_properties_t vesa_props = {
101 .addr = vesa_ph_addr,
102 .offset = 0,
103 .x = vesa_width,
104 .y = vesa_height,
105 .scan = vesa_scanline,
106 .visual = visual,
107 };
108
109 outdev_t *fbdev = fb_init(&vesa_props);
110 if (!fbdev)
111 return false;
112
113 stdout_wire(fbdev);
114 return true;
115}
116
117#endif
118
119/** @}
120 */
Note: See TracBrowser for help on using the repository browser.