source: rtems/c/src/lib/libbsp/i386/pc386/console/fb_vga.c @ 40d5b64b

4.104.114.84.9
Last change on this file since 40d5b64b was 40d5b64b, checked in by Ralf Corsepius <ralf.corsepius@…>, on Jan 29, 2007 at 4:32:10 AM

2007-01-29 Ralf Corsépius <ralf.corsepius@…>

  • console/fb_vga.c: Eliminate u16, u32.
  • Property mode set to 100644
File size: 5.7 KB
Line 
1/*
2 * Copyright (c) 2000 - Rosimildo da Silva ( rdasilva@connecttel.com )
3 *
4 * MODULE DESCRIPTION:
5 * This module implements the micro FB driver for "Bare VGA". It uses the
6 * routines for "bare hardware" that comes with MicroWindows.
7 *
8 *  $Id$
9 *
10 */
11
12#include <stdlib.h>
13#include <stdio.h>
14#include <errno.h>
15#include <sys/types.h>
16
17#include <bsp.h>
18#include <bsp/irq.h>
19#include <rtems/libio.h>
20
21#include <rtems/mw_fb.h>
22
23/* these routines are defined in the microwindows code. This
24   driver is here more as an example of how to implement and
25   use the micro FB interface
26*/
27extern void ega_hwinit( void );
28extern void ega_hwterm( void );
29
30/* screen information for the VGA driver */
31static struct fb_screeninfo fb_info =
32{
33   640, 480,                     /* screen size x, y  */
34   4,                            /* bits per pixel    */
35   80,                           /* chars per line    */
36   (volatile char *)0xA0000,     /* buffer pointer    */
37   0x10000,                      /* buffer size       */
38   FB_TYPE_VGA_PLANES,           /* type of dsplay    */
39        FB_VISUAL_PSEUDOCOLOR         /* color scheme used */
40};
41
42static uint16_t red16[] = {
43    0x0000, 0x0000, 0x0000, 0x0000, 0xaaaa, 0xaaaa, 0xaaaa, 0xaaaa,
44    0x5555, 0x5555, 0x5555, 0x5555, 0xffff, 0xffff, 0xffff, 0xffff
45};
46static uint16_t green16[] = {
47    0x0000, 0x0000, 0xaaaa, 0xaaaa, 0x0000, 0x0000, 0x5555, 0xaaaa,
48    0x5555, 0x5555, 0xffff, 0xffff, 0x5555, 0x5555, 0xffff, 0xffff
49};
50static uint16_t blue16[] = {
51    0x0000, 0xaaaa, 0x0000, 0xaaaa, 0x0000, 0xaaaa, 0x0000, 0xaaaa,
52    0x5555, 0xffff, 0x5555, 0xffff, 0x5555, 0xffff, 0x5555, 0xffff
53};
54
55/*
56 * fbvga device driver INITIALIZE entry point.
57 */
58rtems_device_driver
59fbvga_initialize(  rtems_device_major_number major,
60                   rtems_device_minor_number minor,
61                   void                      *arg)
62{
63   rtems_status_code status;
64
65  printk( "FBVGA -- driver initializing..\n" );
66  /*
67   * Register the device
68   */
69  status = rtems_io_register_name ("/dev/fb0", major, 0);
70  if (status != RTEMS_SUCCESSFUL)
71  {
72      printk("Error registering FBVGA device!\n");
73      rtems_fatal_error_occurred( status );
74  }
75  return RTEMS_SUCCESSFUL;
76}
77
78/*
79 * fbvga device driver OPEN entry point
80 */
81rtems_device_driver
82fbvga_open( rtems_device_major_number major,
83            rtems_device_minor_number minor,
84            void                      *arg)
85{
86/*  rtems_status_code status; */
87  printk( "FBVGA open called.\n" );
88  return RTEMS_SUCCESSFUL;
89}
90
91/*
92 * fbvga device driver CLOSE entry point
93 */
94rtems_device_driver
95fbvga_close(rtems_device_major_number major,
96            rtems_device_minor_number minor,
97            void                      *arg)
98{
99  printk( "FBVGA close called.\n" );
100  return RTEMS_SUCCESSFUL;
101}
102
103/*
104 * fbvga device driver READ entry point.
105 * Read characters from the PS/2 mouse.
106 */
107rtems_device_driver
108fbvga_read( rtems_device_major_number major,
109            rtems_device_minor_number minor,
110            void                      *arg)
111{
112  rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
113  printk( "FBVGA read called.\n" );
114  rw_args->bytes_moved = 0;
115  return RTEMS_SUCCESSFUL;
116}
117
118/*
119 * fbvga device driver WRITE entry point.
120 * Write characters to the PS/2 mouse.
121 */
122rtems_device_driver
123fbvga_write( rtems_device_major_number major,
124             rtems_device_minor_number minor,
125             void                    * arg)
126{
127  rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
128  printk( "FBVGA write called.\n" );
129  rw_args->bytes_moved = 0;
130  return RTEMS_SUCCESSFUL;
131}
132
133static int get_screen_info( struct fb_screeninfo *info )
134{
135  *info = fb_info;
136  return 0;
137}
138
139static int get_palette( struct fb_cmap *cmap )
140{
141  uint32_t i;
142
143  if( cmap->start + cmap->len >= 16 )
144      return 1;
145
146  for( i = 0; i < cmap->len; i++ )
147  {
148    cmap->red[ cmap->start + i ]   = red16[ cmap->start + i ];
149    cmap->green[ cmap->start + i ] = green16[ cmap->start + i ];
150    cmap->blue[ cmap->start + i ]  = blue16[ cmap->start + i ];
151  }
152  return 0;
153}
154
155static int set_palette( struct fb_cmap *cmap )
156{
157  uint32_t i;
158
159  if( cmap->start + cmap->len >= 16 )
160      return 1;
161
162  for( i = 0; i < cmap->len; i++ )
163  {
164    red16[ cmap->start + i ] = cmap->red[ cmap->start + i ];
165    green16[ cmap->start + i ] = cmap->green[ cmap->start + i ];
166    blue16[ cmap->start + i ] = cmap->blue[ cmap->start + i ];
167  }
168  return 0;
169}
170
171/*
172 * IOCTL entry point -- This method is called to carry
173 * all services of this interface.
174 */
175rtems_device_driver
176fbvga_control( rtems_device_major_number major,
177               rtems_device_minor_number minor,
178               void                      * arg
179)
180{
181        rtems_libio_ioctl_args_t *args = arg;
182   printk( "FBVGA ioctl called, cmd=%x\n", args->command  );
183   switch( args->command )
184   {
185      case FB_SCREENINFO:
186      args->ioctl_return =  get_screen_info( args->buffer );
187      break;
188      case FB_GETPALETTE:
189      args->ioctl_return =  get_palette( args->buffer );
190      break;
191      case FB_SETPALETTE:
192      args->ioctl_return =  set_palette( args->buffer );
193      break;
194
195      /* this function would execute one of the routines of the
196       * interface based on the operation requested
197       */
198      case FB_EXEC_FUNCTION:
199      {
200         struct fb_exec_function *env = args->buffer;
201         switch( env->func_no )
202         {
203           case FB_FUNC_ENTER_GRAPHICS:
204           /* enter graphics mode*/
205           ega_hwinit();
206           break;
207
208           case FB_FUNC_EXIT_GRAPHICS:
209           /* leave graphics mode*/
210           ega_hwterm();
211           break;
212
213           case FB_FUNC_IS_DIRTY:
214           break;
215
216           case FB_FUNC_GET_MODE:
217           break;
218
219           default:
220           break;
221         }
222      }
223      /* no break on purpose */
224           default:
225      args->ioctl_return = 0;
226                break;
227
228   }
229   return RTEMS_SUCCESSFUL;
230}
Note: See TracBrowser for help on using the repository browser.