/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
#include <sys/visual_io.h>
#include <sys/ddi_impldefs.h>
#include "gfx_private.h"
struct vgatext_softc {
int fb_regno;
struct {
int row;
int col;
} cursor;
struct {
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned int flags;
};
typedef enum pc_colors {
pc_black = 0,
} pc_colors_t;
pc_brt_white, /* 0 - brt_white */
pc_black, /* 1 - black */
pc_blue, /* 2 - blue */
pc_green, /* 3 - green */
pc_cyan, /* 4 - cyan */
pc_red, /* 5 - red */
pc_magenta, /* 6 - magenta */
pc_brown, /* 7 - brown */
pc_white, /* 8 - white */
pc_grey, /* 9 - gery */
pc_brt_blue, /* 10 - brt_blue */
pc_brt_green, /* 11 - brt_green */
pc_brt_cyan, /* 12 - brt_cyan */
pc_brt_red, /* 13 - brt_red */
pc_brt_magenta, /* 14 - brt_magenta */
pc_yellow /* 15 - yellow */
};
};
/* default structure for FBIOGATTR ioctl */
/* real_type owner */
/* fbtype: type h w depth cms size */
/* fbsattr: flags emu_type dev_specific */
{ 0, FBTYPE_SUN4COLOR, { 0 } },
/* emu_types */
{ -1 }
};
/*
* Global name used to write the softc pointer in, for the
* data wrapper vgatext_return_pointers()
*/
static void vgatext_cons_copy(struct vgatext_softc *,
struct vis_conscopy *);
static void vgatext_cons_display(struct vgatext_softc *,
struct vis_consdisplay *);
static void vgatext_cons_cursor(struct vgatext_softc *,
struct vis_conscursor *);
static void vgatext_polled_copy(struct vis_polledio_arg *,
struct vis_conscopy *);
static void vgatext_polled_display(struct vis_polledio_arg *,
struct vis_consdisplay *);
static void vgatext_polled_cursor(struct vis_polledio_arg *,
struct vis_conscursor *);
static void vgatext_init(struct vgatext_softc *);
static void vgatext_set_text(struct vgatext_softc *);
#if defined(USE_BORDERS)
static void vgatext_init_graphics(struct vgatext_softc *);
#endif
static char vgatext_silent;
static char happyface_boot;
gfxp_vgatext_softc_alloc(void)
{
}
void
{
}
/*
* we work on a set of commitable interfaces to sunpci.c.
*
* Use the class code to determine if the device is a PCI-to-PCI bridge.
* Returns: B_TRUE if the device is a bridge.
* B_FALSE if the device is not a bridge or the property cannot be
* retrieved.
*/
static boolean_t
{
return (B_FALSE);
class_code &= 0x00ffff00;
return (B_TRUE);
return (B_FALSE);
}
static void
int pci_pcie_bus)
{
/*
* Based on Section 11.3, "PCI Display Subsystem Initialization",
* of the 1.1 PCI-to-PCI Bridge Architecture Specification
* determine if this is the boot console device. First, see
* if the SBIOS has turned on PCI I/O for this device. Then if
*/
": can't get PCI conf handle");
return;
}
if (data16 & PCI_COMM_IO)
return;
/*
* Check for VGA Enable in the Bridge Control register for all
* this cannot be the boot console.
*/
int error;
if (error != DDI_SUCCESS) {
return;
}
return;
}
parent_type = NULL;
/* VGAEnable is set only for PCI-to-PCI bridges. */
continue;
continue;
if (!(data16 & PCI_BCNF_BCNTRL_VGA_ENABLE)) {
return;
}
}
}
int
{
int error;
int reg_rnumber;
char *cons;
int pci_pcie_bus = 0;
int value;
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
/* DDI_ATTACH */
if (error != DDI_SUCCESS) {
goto fail;
}
/* Not enable AGP and DRM by default */
®_offset);
if (reg_rnumber < 0) {
": can't find reg entry for registers");
error = DDI_FAILURE;
goto fail;
}
": can't find reg entry for memory");
error = DDI_FAILURE;
goto fail;
}
pci_pcie_bus = 1;
®_offset);
if (reg_rnumber < 0) {
": can't find reg entry for registers");
error = DDI_FAILURE;
goto fail;
}
&mem_offset);
": can't find reg entry for memory");
error = DDI_FAILURE;
goto fail;
}
} else {
error = DDI_FAILURE;
goto fail;
}
parent_type = NULL;
if (error != DDI_SUCCESS)
goto fail;
if (error != DDI_SUCCESS)
goto fail;
else
happyface_boot = 1;
vgatext_silent = 1;
} else {
}
} else {
}
if (error != DDI_SUCCESS)
goto fail;
"Can not %s primary-controller "
}
/* only do this if not in graphics mode */
}
return (DDI_SUCCESS);
fail:
if (parent_type != NULL)
return (error);
}
/*ARGSUSED*/
int
{
switch (cmd) {
case DDI_SUSPEND:
return (vgatext_suspend(softc));
/* break; */
case DDI_DETACH:
return (DDI_SUCCESS);
default:
cmd);
return (DDI_FAILURE);
}
}
/*ARGSUSED*/
int
{
return (ENXIO);
return (0);
}
/*ARGSUSED*/
int
{
return (0);
}
static int
{
static char kernel_only[] =
"gfxp_vgatext_ioctl: %s is a kernel only ioctl";
int err;
int kd_mode;
switch (cmd) {
case KDSETMODE:
case KDGETMODE:
return (EFAULT);
break;
case VIS_DEVINIT:
return (ENXIO);
}
if (err != 0) {
"gfxp_vgatext_ioctl: could not"
" initialize console");
return (err);
}
break;
case VIS_CONSCOPY: /* move */
{
sizeof (struct vis_conscopy), mode))
return (EFAULT);
break;
}
case VIS_CONSDISPLAY: /* display */
{
sizeof (display_request), mode))
return (EFAULT);
break;
}
case VIS_CONSCURSOR:
{
sizeof (cursor_request), mode))
return (EFAULT);
sizeof (cursor_request), mode))
return (EFAULT);
break;
}
case VIS_GETCMAP:
case VIS_PUTCMAP:
case FBIOPUTCMAP:
case FBIOGETCMAP:
/*
* At the moment, text mode is not considered to have
* a color map.
*/
return (EINVAL);
case FBIOGATTR:
sizeof (struct fbgattr)))
return (EFAULT);
break;
case FBIOGTYPE:
sizeof (struct fbtype)))
return (EFAULT);
break;
default:
return (ENXIO);
}
return (0);
}
/*ARGSUSED*/
int
int cmd,
int mode,
int *rval,
{
int err;
return (err);
}
/*
* vgatext_save_text
* vgatext_restore_textmode
* vgatext_suspend
* vgatext_resume
*
* Routines to save and restore contents of the VGA text area
* device drivers. Here in the VGAtext common code, we simply squirrel
* away the contents of the hardware's text area during Suspend and then
* put it back during Resume
*/
static void
{
unsigned i;
}
static void
{
unsigned i;
}
}
}
static int
{
case KD_TEXT:
break;
case KD_GRAPHICS:
break;
default:
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static void
{
case KD_TEXT:
break;
case KD_GRAPHICS:
/*
* Upon RESUME, the graphics device will always actually
* be in TEXT mode even though the Xorg server did not
* make that mode change itself (the suspend code did).
* We want first, therefore, to restore textmode
* operation fully, and then the Xorg server will
* do the rest to restore the device to its
* (hi resolution) graphics mode
*/
#if defined(USE_BORDERS)
#endif
break;
default:
break;
}
}
static void
{
extern void progressbar_stop(void);
if (vgatext_silent == 1) {
vgatext_silent = 0;
}
}
static void
{
int i;
}
}
}
static void
{
#if defined(USE_BORDERS)
#endif
}
static int
{
return (0);
switch (mode) {
case KD_TEXT:
break;
case KD_GRAPHICS:
break;
case KD_RESETTEXT:
/*
* In order to avoid racing with a starting X server,
* this needs to be a test and set that is performed in
* a single (softc->lock protected) ioctl into this driver.
*/
}
break;
default:
return (EINVAL);
}
return (0);
}
/*ARGSUSED*/
int
{
int err;
return (-1);
}
if (!(off >= VGA_MMAP_FB_BASE &&
return (-1);
}
else
return (err);
}
return (0);
}
static int
{
/* initialize console instance */
return (0);
}
/*
* display a string on the screen at (row, col)
* assume it has been cropped to fit.
*/
static void
{
unsigned char *string;
int i;
unsigned char attr;
struct cgatext {
unsigned char ch;
unsigned char attr;
};
/*
* Sanity checks. This is a last-ditch effort to avoid damage
* from brokenness or maliciousness above.
*/
return;
/*
* To be fully general, we should copyin the data. This is not
* really relevant for this text-only driver, but a graphical driver
* should support these ioctls from userland to enable simple
* system startup graphics.
*/
addr++;
}
}
static void
struct vis_polledio_arg *arg,
struct vis_consdisplay *da)
{
}
/*
* screen-to-screen copy
*/
static void
{
unsigned short *from;
unsigned short *to;
int cnt;
unsigned short *to_row_start;
unsigned short *from_row_start;
unsigned short *base;
/*
* Sanity checks. Note that this is a last-ditch effort to avoid
* damage caused by broken-ness or maliciousness above.
*/
return;
/*
* Remember we're going to copy shorts because each
*/
/* More sanity checks. */
return;
if (to_row_start < from_row_start) {
while (rows_to_move-- > 0) {
to = to_row_start;
}
} else {
/*
* Offset to the end of the region and copy backwards.
*/
to_row_start += cnt;
from_row_start += cnt;
while (rows_to_move-- > 0) {
to = to_row_start;
}
}
}
static void
struct vis_polledio_arg *arg,
struct vis_conscopy *ca)
{
}
static void
{
if (vgatext_silent)
return;
case VIS_HIDE_CURSOR:
break;
case VIS_DISPLAY_CURSOR:
/*
* Sanity check. This is a last-ditch effort to avoid
* damage from brokenness or maliciousness above.
*/
return;
break;
case VIS_GET_CURSOR:
}
break;
}
}
static void
struct vis_polledio_arg *arg,
struct vis_conscursor *ca)
{
}
/*ARGSUSED*/
static void
{
/* Nothing at present */
}
static void
{
short addr;
if (vgatext_silent)
return;
}
static void
{
short addr;
}
/*
* This code is experimental. It's only enabled if console is
* set to graphics, a preliminary implementation of happyface boot.
*/
static void
{
int i;
if (happyface_boot == 0)
return;
/* we are in graphics mode, set to text 80X25 mode */
/* set misc registers */
/* set sequencer registers */
for (i = 1; i < NUM_SEQ_REG; i++) {
}
/* set crt controller registers */
for (i = 0; i < NUM_CRTC_REG; i++) {
}
/* set graphics controller registers */
for (i = 0; i < NUM_GRC_REG; i++) {
}
/* set attribute registers */
for (i = 0; i < NUM_ATR_REG; i++) {
}
/* set palette */
for (i = 0; i < VGA_TEXT_CMAP_ENTRIES; i++) {
}
for (i = VGA_TEXT_CMAP_ENTRIES; i < VGA8_CMAP_ENTRIES; i++) {
}
}
static void
{
unsigned char atr_mode;
if (atr_mode & VGA_ATR_MODE_GRAPH)
#if defined(USE_BORDERS)
#else
#endif
}
#if defined(USE_BORDERS)
static void
{
}
#endif
static void
{
extern bitmap_data_t font_data_8x16;
unsigned char *from;
unsigned char *to;
int i;
int j;
int bpc;
/*
* The newboot code to use font plane 2 breaks NVIDIA
* (and some ATI) behavior. Revert back to the S10
* code.
*/
/*
* I'm embarassed to say that I don't know what these magic
* sequences do, other than at the high level of "set the
* memory window to allow font setup". I stole them straight
* from "kd"...
*/
/*
* This assumes 8x16 characters, which yield the traditional 80x25
* screen. It really should support other character heights.
*/
bpc = 16;
for (i = 0; i < 256; i++) {
for (j = 0; j < bpc; j++)
}
}
static void
{
int i;
for (i = 0; i < VGA_ATR_NUM_PLT; i++) {
}
for (i = 0; i < VGA8_CMAP_ENTRIES; i++) {
}
}
static void
{
int i;
for (i = 0; i < VGA_ATR_NUM_PLT; i++) {
}
for (i = 0; i < VGA8_CMAP_ENTRIES; i++) {
}
}
/*
* search the entries of the "reg" property for one which has the desired
* combination of phys_hi bits and contains the desired address.
*
* This version searches a PCI-style "reg" property. It was prompted by
* issues surrounding the presence or absence of an entry for the ROM:
* (a) a transition problem with PowerPC Virtual Open Firmware
* (b) uncertainty as to whether an entry will be included on a device
* with ROM support (and so an "active" ROM base address register),
* but no ROM actually installed.
*
* See the note below on vgatext_get_isa_reg_index for the reasons for
* returning the offset.
*
* Note that this routine may not be fully general; it is intended for the
* specific purpose of finding a couple of particular VGA reg entries and
* may not be suitable for all reg-searching purposes.
*/
static int
dev_info_t *const devi,
unsigned long himask,
unsigned long hival,
unsigned long addr,
{
return (-1);
}
continue;
continue;
continue;
continue;
continue;
return (index);
}
return (-1);
}
/*
* search the entries of the "reg" property for one which has the desired
* combination of phys_hi bits and contains the desired address.
*
* This version searches a ISA-style "reg" property. It was prompted by
* issues surrounding 8514/A support. By IEEE 1275 compatibility conventions,
* 8514/A registers should have been added after all standard VGA registers.
* (a) lists the 8514/A registers before the video memory, and then
* (b) also sorts the entries so that I/O entries come before memory
* entries.
*
* It returns the "reg" index and offset into that register set.
* The offset is needed because there exist (broken?) BIOSes that
* report larger ranges enclosing the standard ranges. One reports
* 0x3bf for 0x21 instead of 0x3c0 for 0x20, for instance. Using the
* offset adjusts for this difference in the base of the register set.
*
* Note that this routine may not be fully general; it is intended for the
* specific purpose of finding a couple of particular VGA reg entries and
* may not be suitable for all reg-searching purposes.
*/
static int
dev_info_t *const devi,
unsigned long hival,
unsigned long addr,
{
return (-1);
}
continue;
continue;
continue;
return (index);
}
return (-1);
}
/*
* This vgatext function is used to return the fb, and reg pointers
* and handles for peer graphics drivers.
*/
void
{
}