initial SIS315PRO support
This commit is contained in:
parent
646ada34d1
commit
01b08a0f15
4 changed files with 251 additions and 1 deletions
|
@ -147,6 +147,7 @@ kernel = {
|
||||||
mips_yeeloong = term/at_keyboard.c;
|
mips_yeeloong = term/at_keyboard.c;
|
||||||
mips_yeeloong = term/serial.c;
|
mips_yeeloong = term/serial.c;
|
||||||
mips_yeeloong = video/sm712.c;
|
mips_yeeloong = video/sm712.c;
|
||||||
|
mips_yeeloong = video/sis315pro.c;
|
||||||
extra_dist = video/sm712_init.c;
|
extra_dist = video/sm712_init.c;
|
||||||
mips_yeeloong = commands/keylayouts.c;
|
mips_yeeloong = commands/keylayouts.c;
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <grub/machine/ec.h>
|
#include <grub/machine/ec.h>
|
||||||
|
|
||||||
extern void grub_video_sm712_init (void);
|
extern void grub_video_sm712_init (void);
|
||||||
|
extern void grub_video_sis315pro_init (void);
|
||||||
extern void grub_video_init (void);
|
extern void grub_video_init (void);
|
||||||
extern void grub_bitmap_init (void);
|
extern void grub_bitmap_init (void);
|
||||||
extern void grub_font_init (void);
|
extern void grub_font_init (void);
|
||||||
|
@ -202,6 +203,7 @@ grub_machine_init (void)
|
||||||
relies on a working heap. */
|
relies on a working heap. */
|
||||||
grub_video_init ();
|
grub_video_init ();
|
||||||
grub_video_sm712_init ();
|
grub_video_sm712_init ();
|
||||||
|
grub_video_sis315pro_init ();
|
||||||
grub_bitmap_init ();
|
grub_bitmap_init ();
|
||||||
grub_font_init ();
|
grub_font_init ();
|
||||||
grub_gfxterm_init ();
|
grub_gfxterm_init ();
|
||||||
|
|
246
grub-core/video/sis315pro.c
Normal file
246
grub-core/video/sis315pro.c
Normal file
|
@ -0,0 +1,246 @@
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* GRUB is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define grub_video_render_target grub_video_fbrender_target
|
||||||
|
|
||||||
|
#include <grub/err.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/dl.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/video.h>
|
||||||
|
#include <grub/video_fb.h>
|
||||||
|
#include <grub/pci.h>
|
||||||
|
#include <grub/vga.h>
|
||||||
|
|
||||||
|
#define GRUB_SIS315PRO_PCIID 0x03251039
|
||||||
|
#define GRUB_SIS315PRO_TOTAL_MEMORY_SPACE 0x800000
|
||||||
|
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
struct grub_video_mode_info mode_info;
|
||||||
|
struct grub_video_render_target *render_target;
|
||||||
|
|
||||||
|
grub_uint8_t *ptr;
|
||||||
|
int mapped;
|
||||||
|
grub_uint32_t base;
|
||||||
|
grub_pci_device_t dev;
|
||||||
|
} framebuffer;
|
||||||
|
|
||||||
|
#ifndef TEST
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_sis315pro_video_init (void)
|
||||||
|
{
|
||||||
|
/* Reset frame buffer. */
|
||||||
|
grub_memset (&framebuffer, 0, sizeof(framebuffer));
|
||||||
|
|
||||||
|
return grub_video_fb_init ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_sis315pro_video_fini (void)
|
||||||
|
{
|
||||||
|
if (framebuffer.mapped)
|
||||||
|
grub_pci_device_unmap_range (framebuffer.dev, framebuffer.ptr,
|
||||||
|
GRUB_SIS315PRO_TOTAL_MEMORY_SPACE);
|
||||||
|
|
||||||
|
return grub_video_fb_fini ();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_sis315pro_setup (unsigned int width, unsigned int height,
|
||||||
|
unsigned int mode_type,
|
||||||
|
unsigned int mode_mask __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
int depth;
|
||||||
|
grub_err_t err;
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
|
#ifndef TEST
|
||||||
|
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid __attribute__ ((unused)));
|
||||||
|
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
grub_pci_address_t addr;
|
||||||
|
grub_uint32_t class;
|
||||||
|
|
||||||
|
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
|
||||||
|
class = grub_pci_read (addr);
|
||||||
|
|
||||||
|
if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA
|
||||||
|
|| pciid != GRUB_SIS315PRO_PCIID)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
found = 1;
|
||||||
|
|
||||||
|
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
||||||
|
framebuffer.base = grub_pci_read (addr);
|
||||||
|
framebuffer.dev = dev;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Decode depth from mode_type. If it is zero, then autodetect. */
|
||||||
|
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
||||||
|
>> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
|
||||||
|
|
||||||
|
if ((width != 640 && width != 0) || (height != 400 && height != 0)
|
||||||
|
|| (depth != 8 && depth != 0))
|
||||||
|
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||||
|
"Only 640x400x8 is supported");
|
||||||
|
|
||||||
|
grub_pci_iterate (find_card);
|
||||||
|
if (!found)
|
||||||
|
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
|
||||||
|
#endif
|
||||||
|
/* Fill mode info details. */
|
||||||
|
framebuffer.mode_info.width = 640;
|
||||||
|
framebuffer.mode_info.height = 400;
|
||||||
|
framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
|
||||||
|
framebuffer.mode_info.bpp = 8;
|
||||||
|
framebuffer.mode_info.bytes_per_pixel = 1;
|
||||||
|
framebuffer.mode_info.pitch = 640 * 1;
|
||||||
|
framebuffer.mode_info.number_of_colors = 256;
|
||||||
|
framebuffer.mode_info.red_mask_size = 0;
|
||||||
|
framebuffer.mode_info.red_field_pos = 0;
|
||||||
|
framebuffer.mode_info.green_mask_size = 0;
|
||||||
|
framebuffer.mode_info.green_field_pos = 0;
|
||||||
|
framebuffer.mode_info.blue_mask_size = 0;
|
||||||
|
framebuffer.mode_info.blue_field_pos = 0;
|
||||||
|
framebuffer.mode_info.reserved_mask_size = 0;
|
||||||
|
framebuffer.mode_info.reserved_field_pos = 0;
|
||||||
|
#ifndef TEST
|
||||||
|
framebuffer.mode_info.blit_format
|
||||||
|
= grub_video_get_blit_format (&framebuffer.mode_info);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* We can safely discard volatile attribute. */
|
||||||
|
#ifndef TEST
|
||||||
|
framebuffer.ptr
|
||||||
|
= (void *) grub_pci_device_map_range (framebuffer.dev,
|
||||||
|
framebuffer.base,
|
||||||
|
GRUB_SIS315PRO_TOTAL_MEMORY_SPACE);
|
||||||
|
#endif
|
||||||
|
framebuffer.mapped = 1;
|
||||||
|
|
||||||
|
#ifndef TEST
|
||||||
|
/* Prevent garbage from appearing on the screen. */
|
||||||
|
grub_memset (framebuffer.ptr, 0,
|
||||||
|
framebuffer.mode_info.height * framebuffer.mode_info.pitch);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TEST
|
||||||
|
err = grub_video_fb_create_render_target_from_pointer (&framebuffer
|
||||||
|
.render_target,
|
||||||
|
&framebuffer.mode_info,
|
||||||
|
framebuffer.ptr);
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = grub_video_fb_set_active_render_target (framebuffer.render_target);
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
/* Copy default palette to initialize emulated palette. */
|
||||||
|
err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
|
||||||
|
grub_video_fbstd_colors);
|
||||||
|
#endif
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef TEST
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_sis315pro_swap_buffers (void)
|
||||||
|
{
|
||||||
|
/* TODO: Implement buffer swapping. */
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_sis315pro_set_active_render_target (struct grub_video_render_target *target)
|
||||||
|
{
|
||||||
|
if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
|
||||||
|
target = framebuffer.render_target;
|
||||||
|
|
||||||
|
return grub_video_fb_set_active_render_target (target);
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_sis315pro_get_info_and_fini (struct grub_video_mode_info *mode_info,
|
||||||
|
void **framebuf)
|
||||||
|
{
|
||||||
|
grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info));
|
||||||
|
*framebuf = (char *) framebuffer.ptr;
|
||||||
|
|
||||||
|
grub_video_fb_fini ();
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct grub_video_adapter grub_video_sis315pro_adapter =
|
||||||
|
{
|
||||||
|
.name = "SIS315PRO Video Driver",
|
||||||
|
.id = GRUB_VIDEO_DRIVER_SIS315PRO,
|
||||||
|
|
||||||
|
.prio = GRUB_VIDEO_ADAPTER_PRIO_NATIVE,
|
||||||
|
|
||||||
|
.init = grub_video_sis315pro_video_init,
|
||||||
|
.fini = grub_video_sis315pro_video_fini,
|
||||||
|
.setup = grub_video_sis315pro_setup,
|
||||||
|
.get_info = grub_video_fb_get_info,
|
||||||
|
.get_info_and_fini = grub_video_sis315pro_get_info_and_fini,
|
||||||
|
.set_palette = grub_video_fb_set_palette,
|
||||||
|
.get_palette = grub_video_fb_get_palette,
|
||||||
|
.set_viewport = grub_video_fb_set_viewport,
|
||||||
|
.get_viewport = grub_video_fb_get_viewport,
|
||||||
|
.map_color = grub_video_fb_map_color,
|
||||||
|
.map_rgb = grub_video_fb_map_rgb,
|
||||||
|
.map_rgba = grub_video_fb_map_rgba,
|
||||||
|
.unmap_color = grub_video_fb_unmap_color,
|
||||||
|
.fill_rect = grub_video_fb_fill_rect,
|
||||||
|
.blit_bitmap = grub_video_fb_blit_bitmap,
|
||||||
|
.blit_render_target = grub_video_fb_blit_render_target,
|
||||||
|
.scroll = grub_video_fb_scroll,
|
||||||
|
.swap_buffers = grub_video_sis315pro_swap_buffers,
|
||||||
|
.create_render_target = grub_video_fb_create_render_target,
|
||||||
|
.delete_render_target = grub_video_fb_delete_render_target,
|
||||||
|
.set_active_render_target = grub_video_sis315pro_set_active_render_target,
|
||||||
|
.get_active_render_target = grub_video_fb_get_active_render_target,
|
||||||
|
|
||||||
|
.next = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(video_sis315pro)
|
||||||
|
{
|
||||||
|
grub_video_register (&grub_video_sis315pro_adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(video_sis315pro)
|
||||||
|
{
|
||||||
|
grub_video_unregister (&grub_video_sis315pro_adapter);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
grub_video_sis315pro_setup (640, 400, 0, 0);
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -211,7 +211,8 @@ typedef enum grub_video_driver_id
|
||||||
GRUB_VIDEO_DRIVER_VGA,
|
GRUB_VIDEO_DRIVER_VGA,
|
||||||
GRUB_VIDEO_DRIVER_CIRRUS,
|
GRUB_VIDEO_DRIVER_CIRRUS,
|
||||||
GRUB_VIDEO_DRIVER_BOCHS,
|
GRUB_VIDEO_DRIVER_BOCHS,
|
||||||
GRUB_VIDEO_DRIVER_SDL
|
GRUB_VIDEO_DRIVER_SDL,
|
||||||
|
GRUB_VIDEO_DRIVER_SIS315PRO,
|
||||||
} grub_video_driver_id_t;
|
} grub_video_driver_id_t;
|
||||||
|
|
||||||
typedef enum grub_video_adapter_prio
|
typedef enum grub_video_adapter_prio
|
||||||
|
|
Loading…
Reference in a new issue