OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [i386/] [pcmb/] [v2_0/] [support/] [gfxmode.c] - Blame information for rev 454

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      gfxmode.c
4
//
5
//      Display information about the available graphics modes.
6
//
7
//==========================================================================
8
//####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//==========================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):    bartv
44
// Date:         2002-04-26
45
// Purpose:      Display information about the various graphics modes
46
// Description:
47
//
48
//    RedBoot on a PC has an option to switch to a suitable graphics mode
49
//    during bootstrap, by calling the video BIOS before switching from
50
//    real to protected mode. This is controlled by the option
51
//    CYGNUM_HAL_I386_PC_STARTUP_VIDEO_MODE in the RedBoot configuration.
52
//    It is then possible to download an eCos application which uses
53
//    the current graphics mode.
54
//
55
//    However different graphics cards will use different numbers for
56
//    the various resolutions, so the user must somehow find out which
57
//    graphics mode corresponds to which resolution and depth. That
58
//    can be achieved by creating another eCos configuration suitable
59
//    for applications, and then building this utility with that
60
//    configuration. RedBoot can then be reconfigured and rebuilt
61
//    to use the right video mode.
62
//
63
//####DESCRIPTIONEND####
64
//
65
//========================================================================*/
66
 
67
#include <stdio.h>
68
#include <stdlib.h>
69
 
70
struct VBESVGAInfoBlock {
71
    unsigned char   signature[4];      /* VESA */
72
    unsigned short  version;
73
    char*           oem_string_ptr;
74
    unsigned char   capabilities[4];
75
    unsigned short* video_mode_ptr;
76
    unsigned short  total_memory;
77
    unsigned short  oem_software_rev;
78
    char*           oem_vendor_name_ptr;
79
    char*           oem_product_name_ptr;
80
    char*           oem_product_rev_ptr;
81
    /* Reserved data here */
82
} __attribute__((packed));
83
 
84
struct VBEModeInfoBlock {
85
    unsigned short  mode_attributes;
86
    unsigned char   win_a_atributes;
87
    unsigned char   win_b_attributes;
88
    unsigned short  win_granularity;
89
    unsigned short  win_size;
90
    unsigned short  win_a_segment;
91
    unsigned short  win_b_segment;
92
    unsigned int    win_func_ptr;
93
    unsigned short  bytes_per_scanline;
94
    unsigned short  x_resolution;
95
    unsigned short  y_resolution;
96
    unsigned char   x_char_size;
97
    unsigned char   y_char_size;
98
    unsigned char   number_of_planes;
99
    unsigned char   bits_per_pixel;
100
    unsigned char   number_of_banks;
101
    unsigned char   memory_model;
102
    unsigned char   bank_size;
103
    unsigned char   number_of_image_pages;
104
    unsigned char   reserved;
105
    unsigned char   red_mask_size;
106
    unsigned char   red_field_position;
107
    unsigned char   green_mask_size;
108
    unsigned char   green_field_position;
109
    unsigned char   blue_mask_size;
110
    unsigned char   blue_field_position;
111
    unsigned char   reserved_mask_size;
112
    unsigned char   reserved_field_position;
113
    unsigned char   direct_color_mode_info;
114
    unsigned int    physical_base_ptr;
115
    unsigned int    offscreen_memory_offset;
116
    unsigned short  offscreen_memory_size;
117
} __attribute__((packed));
118
 
119
static char*
120
segoff_to_phys(char* addr)
121
{
122
    int x       = (int) addr;
123
    int segment = (x >> 12) & 0x0FFFF0;
124
    int offset  = x & 0x0FFFF;
125
    return (char*) (segment | offset);
126
}
127
 
128
int
129
main(int argc, char** argv)
130
{
131
    struct VBESVGAInfoBlock*    info_block = (struct VBESVGAInfoBlock*) 0x000A0000;
132
    struct VBEModeInfoBlock*    current_mode = (struct VBEModeInfoBlock*) 0x000A0200;
133
    int i;
134
 
135
    printf("VESA info: %c%c%c%c\n", info_block->signature[0], info_block->signature[1],
136
           info_block->signature[2], info_block->signature[3]);
137
    printf("version %04x\n", info_block->version);
138
    if (NULL != info_block->oem_string_ptr) {
139
        info_block->oem_string_ptr = segoff_to_phys(info_block->oem_string_ptr);
140
        printf("OEM %s\n", info_block->oem_string_ptr);
141
    }
142
    printf("total memory %dK\n", 64 * info_block->total_memory);
143
    printf("oem software rev %04x\n", info_block->oem_software_rev);
144
    if (NULL != info_block->oem_vendor_name_ptr) {
145
        info_block->oem_vendor_name_ptr = segoff_to_phys(info_block->oem_vendor_name_ptr);
146
        printf("OEM vendor %s\n", info_block->oem_vendor_name_ptr);
147
    }
148
    if (NULL != info_block->oem_product_name_ptr) {
149
        info_block->oem_product_name_ptr = segoff_to_phys(info_block->oem_product_name_ptr);
150
        printf("OEM product name %s\n", info_block->oem_product_name_ptr);
151
    }
152
    if (NULL != info_block->oem_product_rev_ptr) {
153
        info_block->oem_product_rev_ptr = segoff_to_phys(info_block->oem_product_rev_ptr);
154
        printf("OEM product revision %s\n", info_block->oem_product_rev_ptr);
155
    }
156
    printf("Capabilities: %02x, %02x, %02x, %02x\n",
157
           info_block->capabilities[0], info_block->capabilities[1],
158
           info_block->capabilities[2], info_block->capabilities[3]);
159
    info_block->video_mode_ptr = (unsigned short*) segoff_to_phys((char*) info_block->video_mode_ptr);
160
    for (i = 0; 0x0FFFF != info_block->video_mode_ptr[i]; i++) {
161
        int mode = info_block->video_mode_ptr[i];
162
        struct VBEModeInfoBlock*   mode_data   = (struct VBEModeInfoBlock*) (0x0A0400 + (0x100 * i));
163
        printf("Mode %04x: %4d*%4d @ %2dbpp, %4d bytes/line, fb %s 0x%08x\n", mode,
164
               mode_data->x_resolution, mode_data->y_resolution, mode_data->bits_per_pixel,
165
               mode_data->bytes_per_scanline,
166
               (0 == (mode_data->mode_attributes & 0x0080)) ? "no " : "yes",
167
               mode_data->physical_base_ptr);
168
        if (8 < mode_data->bits_per_pixel) {
169
            printf("    red %d bits << %d, green %d bits << %d, blue %d bits << %d, reserved %d bits << %d\n",
170
                   mode_data->red_mask_size, mode_data->red_field_position,
171
                   mode_data->green_mask_size, mode_data->green_field_position,
172
                   mode_data->blue_mask_size, mode_data->blue_field_position,
173
                   mode_data->reserved_mask_size, mode_data->reserved_field_position);
174
        }
175
    }
176
 
177
    printf("Current mode: %4d*%4d @ %2dbpp, %4d bytes/line, fb %s 0x%08x\n",
178
           current_mode->x_resolution, current_mode->y_resolution, current_mode->bits_per_pixel,
179
           current_mode->bytes_per_scanline,
180
           (0 == (current_mode->mode_attributes & 0x0080)) ? "no" : "yes",
181
           current_mode->physical_base_ptr);
182
    if (8 < current_mode->bits_per_pixel) {
183
        printf("    red %d bits << %d, green %d bits << %d, blue %d bits << %d, reserved %d bits << %d\n",
184
               current_mode->red_mask_size, current_mode->red_field_position,
185
               current_mode->green_mask_size, current_mode->green_field_position,
186
               current_mode->blue_mask_size, current_mode->blue_field_position,
187
               current_mode->reserved_mask_size, current_mode->reserved_field_position);
188
    }
189
 
190
    exit(0);
191
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.