Print this page
NEX-18320 gfxp_vgatext: use dynamic vga state
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
NEX-18253 gfx_private: use unique, module based names
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
    loader: pxe receive cleanup
    9475 libefi: Do not return only if ReceiveFilter
    installboot: should support efi system partition
    8931 boot1.efi: scan all display modes rather than
    loader: spinconsole updates
    loader: gfx experiment to try GOP Blt() function.
    sha1 build test
    loader: add sha1 hash calculation
    common/sha1: update for loader build
    loader: biosdisk rework
    uts: 32-bit kernel FB needs mapping in low memory
    uts: add diag-device
    uts: boot console mirror with diag-device
    uts: enable very early console on ttya
    kmdb: add diag-device as input/output device
    uts: test VGA memory exclusion from mapping
    uts: clear boot mapping and protect boot pages test
    uts: add dboot map debug printf
    uts: need to release FB pages in release_bootstrap()
    uts: add screenmap ioctl
    uts: update sys/queue.h
    loader: add illumos uts/common to include path
    loader: tem/gfx font cleanup
    loader: vbe checks
    uts: gfx_private set KD_TEXT when KD_RESETTEXT is
    uts: gfx 8-bit update
    loader: gfx 8-bit fix
    loader: always set media size from partition.
    uts: MB2 support for 32-bit kernel
    loader: x86 should have tem 80x25
    uts: x86 should have tem 80x25
    uts: font update
    loader: font update
    uts: tem attributes
    loader: tem.c comment added
    uts: use font module
    loader: add font module
    loader: build rules for new font setup
    uts: gfx_private update for new font structure
    uts: early boot update for new font structure
    uts: font update
    uts: font build rules update for new fonts
    uts: tem update to new font structure
    loader: module.c needs to include tem_impl.h
    uts: gfx_private 8x16 font rework
    uts: make font_lookup public
    loader: font rework
    uts: font rework
    9259 libefi: efi_alloc_and_read should check for PMBR
    uts: tem utf-8 support
    loader: implement tem utf-8 support
    loader: tem should be able to display UTF-8
    7784 uts: console input should support utf-8
    7796 uts: ldterm default to utf-8
    uts: do not reset serial console
    uts: set up colors even if tem is not console
    uts: add type for early boot properties
    uts: gfx_private experiment with drm and vga
    uts: gfx_private should use setmode drm callback.
    uts: identify FB types and set up gfx_private based
    loader: replace gop and vesa with framebuffer
    uts: boot needs simple tem to support mdb
    uts: boot_keyboard should emit esc sequences for
    uts: gfx_private FB showuld be written by line
    kmdb: set terminal window size
    uts: gfx_private needs to keep track of early boot FB
    pnglite: move pnglite to usr/src/common
    loader: gfx_fb
    ficl-sys: add gfx primitives
    loader: add illumos.png logo
    ficl: add fb-putimage
    loader: add png support
    loader: add alpha blending for gfx_fb
    loader: use term-drawrect for menu frame
    ficl: add simple gfx words
    uts: provide fb_info via fbgattr dev_specific array.
    uts: gfx_private add alpha blending
    uts: update sys/ascii.h
    uts: tem OSC support (incomplete)
    uts: implement env module support and use data from
    uts: tem get colors from early boot data
    loader: use crc32 from libstand (libz)
    loader: optimize for size
    loader: pass tem info to the environment
    loader: import tem for loader console
    loader: UEFI loader needs to set ISADIR based on
    loader: need UEFI32 support
    8918 loader.efi: add vesa edid support
    uts: tem_safe_pix_clear_prom_output() should only
    uts: tem_safe_pix_clear_entire_screen() should use
    uts: tem_safe_check_first_time() should query cursor
    uts: tem implement cls callback & visual_io v4
    uts: gfx_vgatext use block cursor for vgatext
    uts: gfx_private implement cls callback & visual_io
    uts: gfx_private bitmap framebuffer implementation
    uts: early start frame buffer console support
    uts: font functions should check the input char
    uts: font rendering should support 16/24/32bit depths
    uts: use smallest font as fallback default.
    uts: update terminal dimensions based on selected
    7834 uts: vgatext should use gfx_private
    uts: add spacing property to 8859-1.bdf
    terminfo: add underline for sun-color
    terminfo: sun-color has 16 colors
    uts: add font load callback type
    loader: do not repeat int13 calls with error 0x20 and
    8905 loader: add skein/edonr support
    8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Revert "NEX-16819 loader UEFI support"
This reverts commit ec06b9fc617b99234e538bf2e7e4d02a24993e0c.
Reverting due to failures in the zfs-tests and the sharefs-tests
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
    loader: pxe receive cleanup
    9475 libefi: Do not return only if ReceiveFilter
    installboot: should support efi system partition
    8931 boot1.efi: scan all display modes rather than
    loader: spinconsole updates
    loader: gfx experiment to try GOP Blt() function.
    sha1 build test
    loader: add sha1 hash calculation
    common/sha1: update for loader build
    loader: biosdisk rework
    uts: 32-bit kernel FB needs mapping in low memory
    uts: add diag-device
    uts: boot console mirror with diag-device
    uts: enable very early console on ttya
    kmdb: add diag-device as input/output device
    uts: test VGA memory exclusion from mapping
    uts: clear boot mapping and protect boot pages test
    uts: add dboot map debug printf
    uts: need to release FB pages in release_bootstrap()
    uts: add screenmap ioctl
    uts: update sys/queue.h
    loader: add illumos uts/common to include path
    loader: tem/gfx font cleanup
    loader: vbe checks
    uts: gfx_private set KD_TEXT when KD_RESETTEXT is
    uts: gfx 8-bit update
    loader: gfx 8-bit fix
    loader: always set media size from partition.
    uts: MB2 support for 32-bit kernel
    loader: x86 should have tem 80x25
    uts: x86 should have tem 80x25
    uts: font update
    loader: font update
    uts: tem attributes
    loader: tem.c comment added
    uts: use font module
    loader: add font module
    loader: build rules for new font setup
    uts: gfx_private update for new font structure
    uts: early boot update for new font structure
    uts: font update
    uts: font build rules update for new fonts
    uts: tem update to new font structure
    loader: module.c needs to include tem_impl.h
    uts: gfx_private 8x16 font rework
    uts: make font_lookup public
    loader: font rework
    uts: font rework
    libefi: efi_alloc_and_read should check for PMBR
    uts: tem utf-8 support
    loader: implement tem utf-8 support
    loader: tem should be able to display UTF-8
    7784 uts: console input should support utf-8
    7796 uts: ldterm default to utf-8
    uts: do not reset serial console
    uts: set up colors even if tem is not console
    uts: add type for early boot properties
    uts: gfx_private experiment with drm and vga
    uts: gfx_private should use setmode drm callback.
    uts: identify FB types and set up gfx_private based
    loader: replace gop and vesa with framebuffer
    uts: boot needs simple tem to support mdb
    uts: boot_keyboard should emit esc sequences for
    uts: gfx_private FB showuld be written by line
    kmdb: set terminal window size
    uts: gfx_private needs to keep track of early boot FB
    pnglite: move pnglite to usr/src/common
    loader: gfx_fb
    ficl-sys: add gfx primitives
    loader: add illumos.png logo
    ficl: add fb-putimage
    loader: add png support
    loader: add alpha blending for gfx_fb
    loader: use term-drawrect for menu frame
    ficl: add simple gfx words
    uts: provide fb_info via fbgattr dev_specific array.
    uts: gfx_private add alpha blending
    uts: update sys/ascii.h
    uts: tem OSC support (incomplete)
    uts: implement env module support and use data from
    uts: tem get colors from early boot data
    loader: use crc32 from libstand (libz)
    loader: optimize for size
    loader: pass tem info to the environment
    loader: import tem for loader console
    loader: UEFI loader needs to set ISADIR based on
    loader: need UEFI32 support
    8918 loader.efi: add vesa edid support
    uts: tem_safe_pix_clear_prom_output() should only
    uts: tem_safe_pix_clear_entire_screen() should use
    uts: tem_safe_check_first_time() should query cursor
    uts: tem implement cls callback & visual_io v4
    uts: gfx_vgatext use block cursor for vgatext
    uts: gfx_private implement cls callback & visual_io
    uts: gfx_private bitmap framebuffer implementation
    uts: early start frame buffer console support
    uts: font functions should check the input char
    uts: font rendering should support 16/24/32bit depths
    uts: use smallest font as fallback default.
    uts: update terminal dimensions based on selected
    7834 uts: vgatext should use gfx_private
    uts: add spacing property to 8859-1.bdf
    terminfo: add underline for sun-color
    terminfo: sun-color has 16 colors
    uts: add font load callback type
    loader: do not repeat int13 calls with error 0x20 and
    8905 loader: add skein/edonr support
    8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/io/gfx_private/gfxp_vgatext.c
          +++ new/usr/src/uts/i86pc/io/gfx_private/gfxp_vgatext.c
↓ open down ↓ 30 lines elided ↑ open up ↑
  31   31  #include <sys/errno.h>
  32   32  #include <sys/types.h>
  33   33  #include <sys/conf.h>
  34   34  #include <sys/kmem.h>
  35   35  #include <sys/visual_io.h>
  36   36  #include <sys/font.h>
  37   37  #include <sys/fbio.h>
  38   38  #include <sys/ddi.h>
  39   39  #include <sys/stat.h>
  40   40  #include <sys/sunddi.h>
  41      -#include <sys/file.h>
  42   41  #include <sys/open.h>
  43   42  #include <sys/modctl.h>
  44      -#include <sys/vgareg.h>
  45      -#include <sys/vgasubr.h>
  46   43  #include <sys/pci.h>
  47   44  #include <sys/kd.h>
  48   45  #include <sys/ddi_impldefs.h>
  49   46  #include <sys/gfx_private.h>
       47 +#include "gfxp_fb.h"
  50   48  
  51   49  #define MYNAME  "gfxp_vgatext"
  52   50  
  53      -#define TEXT_ROWS               25
  54      -#define TEXT_COLS               80
  55      -
  56   51  #define VGA_BRIGHT_WHITE        0x0f
  57   52  #define VGA_BLACK               0x00
  58   53  
  59   54  #define VGA_REG_ADDR            0x3c0
  60   55  #define VGA_REG_SIZE            0x20
  61   56  
  62   57  #define VGA_MEM_ADDR            0xa0000
  63   58  #define VGA_MEM_SIZE            0x20000
  64   59  
  65   60  #define VGA_MMAP_FB_BASE        VGA_MEM_ADDR
  66   61  
  67      -struct vgatext_softc {
  68      -        struct vgaregmap        regs;
  69      -        struct vgaregmap        fb;
  70      -        off_t                   fb_size;
  71      -        int                     fb_regno;
  72      -        dev_info_t              *devi;
  73      -        int                     mode;   /* KD_TEXT or KD_GRAPHICS */
  74      -        caddr_t                 text_base;      /* hardware text base */
  75      -        char                    shadow[TEXT_ROWS*TEXT_COLS*2];
  76      -        caddr_t                 current_base;   /* hardware or shadow */
  77      -        struct {
  78      -                boolean_t visible;
  79      -                int row;
  80      -                int col;
  81      -        }                       cursor;
  82      -        struct vis_polledio     polledio;
  83      -        struct {
  84      -                unsigned char red;
  85      -                unsigned char green;
  86      -                unsigned char blue;
  87      -        }                       colormap[VGA8_CMAP_ENTRIES];
  88      -        unsigned char attrib_palette[VGA_ATR_NUM_PLT];
  89      -        unsigned int flags;
  90      -        kmutex_t lock;
  91      -};
  92      -
  93   62  typedef enum pc_colors {
  94   63          pc_black        = 0,
  95   64          pc_blue         = 1,
  96   65          pc_green        = 2,
  97   66          pc_cyan         = 3,
  98   67          pc_red          = 4,
  99   68          pc_magenta      = 5,
 100   69          pc_brown        = 6,
 101   70          pc_white        = 7,
 102   71          pc_grey         = 8,
↓ open down ↓ 36 lines elided ↑ open up ↑
 139  108  /*      real_type       owner */
 140  109          FBTYPE_SUNFAST_COLOR, 0,
 141  110  /* fbtype: type         h  w  depth cms  size */
 142  111          { FBTYPE_SUNFAST_COLOR, TEXT_ROWS, TEXT_COLS, 1,    256,  0 },
 143  112  /* fbsattr: flags emu_type      dev_specific */
 144  113          { 0, FBTYPE_SUN4COLOR, { 0 } },
 145  114  /*      emu_types */
 146  115          { -1 }
 147  116  };
 148  117  
 149      -#define GFXP_FLAG_CONSOLE 0x00000001
 150      -#define GFXP_IS_CONSOLE(softc) ((softc)->flags & GFXP_FLAG_CONSOLE)
      118 +static struct vis_identifier gfxp_vgatext_ident = { "illumos_text" };
 151  119  
 152      -/*
 153      - * Global name used to write the softc pointer in, for the
 154      - * data wrapper vgatext_return_pointers()
 155      - */
 156      -
 157      -
 158      -int gfxp_vgatext_detach(dev_info_t *devi, ddi_detach_cmd_t cmd,
 159      -        gfxp_vgatext_softc_ptr_t ptr);
 160      -static int vgatext_devinit(struct vgatext_softc *, struct vis_devinit *data);
 161      -static void     vgatext_cons_copy(struct vgatext_softc *,
      120 +int gfxp_vga_detach(dev_info_t *, ddi_detach_cmd_t, struct gfxp_fb_softc *);
      121 +static int vgatext_devinit(struct gfxp_fb_softc *, struct vis_devinit *data);
      122 +static void     vgatext_cons_copy(struct gfxp_fb_softc *,
 162  123                          struct vis_conscopy *);
 163      -static void     vgatext_cons_display(struct vgatext_softc *,
      124 +static void     vgatext_cons_display(struct gfxp_fb_softc *,
 164  125                          struct vis_consdisplay *);
 165      -static void     vgatext_cons_cursor(struct vgatext_softc *,
      126 +static int      vgatext_cons_clear(struct gfxp_fb_softc *,
      127 +                        struct vis_consclear *);
      128 +static void     vgatext_cons_cursor(struct gfxp_fb_softc *,
 166  129                          struct vis_conscursor *);
 167  130  static void     vgatext_polled_copy(struct vis_polledio_arg *,
 168  131                          struct vis_conscopy *);
 169  132  static void     vgatext_polled_display(struct vis_polledio_arg *,
 170  133                          struct vis_consdisplay *);
 171  134  static void     vgatext_polled_cursor(struct vis_polledio_arg *,
 172  135                          struct vis_conscursor *);
 173      -static void     vgatext_init(struct vgatext_softc *);
 174      -static void     vgatext_set_text(struct vgatext_softc *);
      136 +static void     vgatext_init(struct gfxp_fb_softc *);
      137 +static void     vgatext_set_text(struct gfxp_fb_softc *);
 175  138  
 176      -static void     vgatext_save_text(struct vgatext_softc *softc);
 177      -static void     vgatext_restore_textmode(struct vgatext_softc *softc);
 178      -static int      vgatext_suspend(struct vgatext_softc *softc);
 179      -static void     vgatext_resume(struct vgatext_softc *softc);
      139 +static void     vgatext_get_text(struct gfxp_fb_softc *softc);
      140 +static void     vgatext_save_text(struct gfxp_fb_softc *softc);
      141 +static void     vgatext_kdsettext(struct gfxp_fb_softc *softc);
      142 +static int      vgatext_suspend(struct gfxp_fb_softc *softc);
      143 +static void     vgatext_resume(struct gfxp_fb_softc *softc);
      144 +static int      vgatext_devmap(dev_t, devmap_cookie_t, offset_t, size_t,
      145 +    size_t *, uint_t, void *);
 180  146  
 181  147  #if     defined(USE_BORDERS)
 182      -static void     vgatext_init_graphics(struct vgatext_softc *);
      148 +static void     vgatext_init_graphics(struct gfxp_fb_softc *);
 183  149  #endif
 184  150  
 185      -static int vgatext_kdsetmode(struct vgatext_softc *softc, int mode);
 186      -static void vgatext_setfont(struct vgatext_softc *softc);
 187      -static void vgatext_get_cursor(struct vgatext_softc *softc,
 188      -                screen_pos_t *row, screen_pos_t *col);
 189      -static void vgatext_set_cursor(struct vgatext_softc *softc, int row, int col);
 190      -static void vgatext_hide_cursor(struct vgatext_softc *softc);
 191      -static void vgatext_save_colormap(struct vgatext_softc *softc);
 192      -static void vgatext_restore_colormap(struct vgatext_softc *softc);
      151 +static int vgatext_kdsetmode(struct gfxp_fb_softc *softc, int mode);
      152 +static void vgatext_setfont(struct gfxp_fb_softc *softc);
      153 +static void vgatext_get_cursor(struct gfxp_fb_softc *softc,
      154 +    screen_pos_t *row, screen_pos_t *col);
      155 +static void vgatext_set_cursor(struct gfxp_fb_softc *softc, int row, int col);
      156 +static void vgatext_hide_cursor(struct gfxp_fb_softc *softc);
      157 +static void vgatext_save_colormap(struct gfxp_fb_softc *softc);
      158 +static void vgatext_restore_colormap(struct gfxp_fb_softc *softc);
 193  159  static int vgatext_get_pci_reg_index(dev_info_t *const devi,
 194      -                unsigned long himask, unsigned long hival, unsigned long addr,
      160 +    unsigned long himask, unsigned long hival, unsigned long addr,
 195  161                  off_t *offset);
 196  162  static int vgatext_get_isa_reg_index(dev_info_t *const devi,
 197  163                  unsigned long hival, unsigned long addr, off_t *offset);
 198  164  
 199      -static char     vgatext_silent;
 200      -static char     happyface_boot;
      165 +static struct gfxp_ops gfxp_vgatext_ops = {
      166 +        .ident = &gfxp_vgatext_ident,
      167 +        .kdsetmode = vgatext_kdsetmode,
      168 +        .devinit = vgatext_devinit,
      169 +        .cons_copy = vgatext_cons_copy,
      170 +        .cons_display = vgatext_cons_display,
      171 +        .cons_cursor = vgatext_cons_cursor,
      172 +        .cons_clear = vgatext_cons_clear,
      173 +        .suspend = vgatext_suspend,
      174 +        .resume = vgatext_resume,
      175 +        .devmap = vgatext_devmap
      176 +};
 201  177  
 202      -gfxp_vgatext_softc_ptr_t
 203      -gfxp_vgatext_softc_alloc(void)
 204      -{
 205      -        return (kmem_zalloc(sizeof (struct vgatext_softc), KM_SLEEP));
 206      -}
 207      -
 208      -void
 209      -gfxp_vgatext_softc_free(gfxp_vgatext_softc_ptr_t ptr)
 210      -{
 211      -        kmem_free(ptr, sizeof (struct vgatext_softc));
 212      -}
 213      -
 214      -/*
 215      - * NOTE: this function is duplicated here and in consplat/vgatext while
 216      - *       we work on a set of commitable interfaces to sunpci.c.
 217      - *
 218      - * Use the class code to determine if the device is a PCI-to-PCI bridge.
 219      - * Returns:  B_TRUE  if the device is a bridge.
 220      - *           B_FALSE if the device is not a bridge or the property cannot be
 221      - *                   retrieved.
 222      - */
 223      -static boolean_t
 224      -is_pci_bridge(dev_info_t *dip)
 225      -{
 226      -        uint32_t class_code;
 227      -
 228      -        class_code = (uint32_t)ddi_prop_get_int(DDI_DEV_T_ANY, dip,
 229      -            DDI_PROP_DONTPASS, "class-code", 0xffffffff);
 230      -
 231      -        if (class_code == 0xffffffff || class_code == DDI_PROP_NOT_FOUND)
 232      -                return (B_FALSE);
 233      -
 234      -        class_code &= 0x00ffff00;
 235      -        if (class_code == ((PCI_CLASS_BRIDGE << 16) | (PCI_BRIDGE_PCI << 8)))
 236      -                return (B_TRUE);
 237      -
 238      -        return (B_FALSE);
 239      -}
 240      -
 241  178  #define STREQ(a, b)     (strcmp((a), (b)) == 0)
 242  179  
 243      -static void
 244      -gfxp_check_for_console(dev_info_t *devi, struct vgatext_softc *softc,
 245      -    int pci_pcie_bus)
 246      -{
 247      -        ddi_acc_handle_t pci_conf;
 248      -        dev_info_t *pdevi;
 249      -        uint16_t data16;
 250      -
 251      -        /*
 252      -         * Based on Section 11.3, "PCI Display Subsystem Initialization",
 253      -         * of the 1.1 PCI-to-PCI Bridge Architecture Specification
 254      -         * determine if this is the boot console device.  First, see
 255      -         * if the SBIOS has turned on PCI I/O for this device.  Then if
 256      -         * this is PCI/PCI-E, verify the parent bridge has VGAEnable set.
 257      -         */
 258      -
 259      -        if (pci_config_setup(devi, &pci_conf) != DDI_SUCCESS) {
 260      -                cmn_err(CE_WARN,
 261      -                    MYNAME
 262      -                    ": can't get PCI conf handle");
 263      -                return;
 264      -        }
 265      -
 266      -        data16 = pci_config_get16(pci_conf, PCI_CONF_COMM);
 267      -        if (data16 & PCI_COMM_IO)
 268      -                softc->flags |= GFXP_FLAG_CONSOLE;
 269      -
 270      -        pci_config_teardown(&pci_conf);
 271      -
 272      -        /* If IO not enabled or ISA/EISA, just return */
 273      -        if (!(softc->flags & GFXP_FLAG_CONSOLE) || !pci_pcie_bus)
 274      -                return;
 275      -
 276      -        /*
 277      -         * Check for VGA Enable in the Bridge Control register for all
 278      -         * PCI/PCIEX parents.  If not set all the way up the chain,
 279      -         * this cannot be the boot console.
 280      -         */
 281      -
 282      -        pdevi = devi;
 283      -        while (pdevi = ddi_get_parent(pdevi)) {
 284      -                int     error;
 285      -                ddi_acc_handle_t ppci_conf;
 286      -                char    *parent_type = NULL;
 287      -
 288      -                error = ddi_prop_lookup_string(DDI_DEV_T_ANY, pdevi,
 289      -                    DDI_PROP_DONTPASS, "device_type", &parent_type);
 290      -                if (error != DDI_SUCCESS) {
 291      -                        return;
 292      -                }
 293      -
 294      -                /* Verify still on the PCI/PCIEX parent tree */
 295      -                if (!STREQ(parent_type, "pci") &&
 296      -                    !STREQ(parent_type, "pciex")) {
 297      -                        ddi_prop_free(parent_type);
 298      -                        return;
 299      -                }
 300      -
 301      -                ddi_prop_free(parent_type);
 302      -                parent_type = NULL;
 303      -
 304      -                /* VGAEnable is set only for PCI-to-PCI bridges. */
 305      -                if (is_pci_bridge(pdevi) == B_FALSE)
 306      -                        continue;
 307      -
 308      -                if (pci_config_setup(pdevi, &ppci_conf) != DDI_SUCCESS)
 309      -                        continue;
 310      -
 311      -                data16 = pci_config_get16(ppci_conf, PCI_BCNF_BCNTRL);
 312      -                pci_config_teardown(&ppci_conf);
 313      -
 314      -                if (!(data16 & PCI_BCNF_BCNTRL_VGA_ENABLE)) {
 315      -                        softc->flags &= ~GFXP_FLAG_CONSOLE;
 316      -                        return;
 317      -                }
 318      -        }
 319      -}
 320      -
      180 +/*ARGSUSED*/
 321  181  int
 322      -gfxp_vgatext_attach(dev_info_t *devi, ddi_attach_cmd_t cmd,
 323      -    gfxp_vgatext_softc_ptr_t ptr)
      182 +gfxp_vga_attach(dev_info_t *devi, ddi_attach_cmd_t cmd,
      183 +    struct gfxp_fb_softc *softc)
 324  184  {
 325      -        struct vgatext_softc *softc = (struct vgatext_softc *)ptr;
 326  185          int     unit = ddi_get_instance(devi);
 327  186          int     error;
 328  187          char    *parent_type = NULL;
 329  188          int     reg_rnumber;
 330  189          off_t   reg_offset;
 331  190          off_t   mem_offset;
 332  191          char    *cons;
 333      -        int pci_pcie_bus = 0;
 334      -        int value;
      192 +        struct gfx_vga *vga;
 335  193  
 336      -        switch (cmd) {
 337      -        case DDI_ATTACH:
 338      -                break;
 339  194  
 340      -        case DDI_RESUME:
 341      -                vgatext_resume(softc);
 342      -                return (DDI_SUCCESS);
 343      -
 344      -        default:
 345      -                return (DDI_FAILURE);
 346      -        }
 347      -
 348      -        /* DDI_ATTACH */
 349      -
 350      -        softc->devi = devi; /* Copy and init DEVI */
 351      -
 352      -        softc->polledio.arg = (struct vis_polledio_arg *)softc;
 353  195          softc->polledio.display = vgatext_polled_display;
 354  196          softc->polledio.copy = vgatext_polled_copy;
 355  197          softc->polledio.cursor = vgatext_polled_cursor;
      198 +        softc->gfxp_ops = &gfxp_vgatext_ops;
      199 +        softc->fbgattr = &vgatext_attr;
      200 +        vga = kmem_zalloc(sizeof (*vga), KM_SLEEP);
      201 +        softc->console = (union gfx_console *)vga;
 356  202  
 357      -        mutex_init(&(softc->lock), NULL, MUTEX_DRIVER, NULL);
 358      -
 359  203          error = ddi_prop_lookup_string(DDI_DEV_T_ANY, ddi_get_parent(devi),
 360  204              DDI_PROP_DONTPASS, "device_type", &parent_type);
 361  205          if (error != DDI_SUCCESS) {
 362  206                  cmn_err(CE_WARN, MYNAME ": can't determine parent type.");
 363  207                  goto fail;
 364  208          }
 365  209  
 366  210          /* Not enable AGP and DRM by default */
 367  211          if (STREQ(parent_type, "isa") || STREQ(parent_type, "eisa")) {
 368  212                  reg_rnumber = vgatext_get_isa_reg_index(devi, 1, VGA_REG_ADDR,
 369  213                      &reg_offset);
 370  214                  if (reg_rnumber < 0) {
 371  215                          cmn_err(CE_WARN,
 372  216                              MYNAME
 373  217                              ": can't find reg entry for registers");
 374  218                          error = DDI_FAILURE;
 375  219                          goto fail;
 376  220                  }
 377      -                softc->fb_regno = vgatext_get_isa_reg_index(devi, 0,
      221 +                vga->fb_regno = vgatext_get_isa_reg_index(devi, 0,
 378  222                      VGA_MEM_ADDR, &mem_offset);
 379      -                if (softc->fb_regno < 0) {
      223 +                if (vga->fb_regno < 0) {
 380  224                          cmn_err(CE_WARN,
 381      -                            MYNAME
 382      -                            ": can't find reg entry for memory");
      225 +                            MYNAME ": can't find reg entry for memory");
 383  226                          error = DDI_FAILURE;
 384  227                          goto fail;
 385  228                  }
 386  229          } else if (STREQ(parent_type, "pci") || STREQ(parent_type, "pciex")) {
 387      -                pci_pcie_bus = 1;
 388  230                  reg_rnumber = vgatext_get_pci_reg_index(devi,
 389  231                      PCI_REG_ADDR_M|PCI_REG_REL_M,
 390  232                      PCI_ADDR_IO|PCI_RELOCAT_B, VGA_REG_ADDR,
 391  233                      &reg_offset);
 392  234                  if (reg_rnumber < 0) {
 393  235                          cmn_err(CE_WARN,
 394      -                            MYNAME
 395      -                            ": can't find reg entry for registers");
      236 +                            MYNAME ": can't find reg entry for registers");
 396  237                          error = DDI_FAILURE;
 397  238                          goto fail;
 398  239                  }
 399      -                softc->fb_regno = vgatext_get_pci_reg_index(devi,
      240 +                vga->fb_regno = vgatext_get_pci_reg_index(devi,
 400  241                      PCI_REG_ADDR_M|PCI_REG_REL_M,
 401  242                      PCI_ADDR_MEM32|PCI_RELOCAT_B, VGA_MEM_ADDR,
 402  243                      &mem_offset);
 403      -                if (softc->fb_regno < 0) {
      244 +                if (vga->fb_regno < 0) {
 404  245                          cmn_err(CE_WARN,
 405      -                            MYNAME
 406      -                            ": can't find reg entry for memory");
      246 +                            MYNAME ": can't find reg entry for memory");
 407  247                          error = DDI_FAILURE;
 408  248                          goto fail;
 409  249                  }
 410  250          } else {
 411  251                  cmn_err(CE_WARN, MYNAME ": unknown parent type \"%s\".",
 412  252                      parent_type);
 413  253                  error = DDI_FAILURE;
 414  254                  goto fail;
 415  255          }
 416  256          ddi_prop_free(parent_type);
 417  257          parent_type = NULL;
 418  258  
 419  259          error = ddi_regs_map_setup(devi, reg_rnumber,
 420      -            (caddr_t *)&softc->regs.addr, reg_offset, VGA_REG_SIZE,
 421      -            &dev_attr, &softc->regs.handle);
      260 +            (caddr_t *)&vga->regs.addr, reg_offset, VGA_REG_SIZE,
      261 +            &dev_attr, &vga->regs.handle);
 422  262          if (error != DDI_SUCCESS)
 423  263                  goto fail;
 424      -        softc->regs.mapped = B_TRUE;
      264 +        vga->regs.mapped = B_TRUE;
 425  265  
 426      -        softc->fb_size = VGA_MEM_SIZE;
      266 +        vga->fb_size = VGA_MEM_SIZE;
 427  267  
 428      -        error = ddi_regs_map_setup(devi, softc->fb_regno,
 429      -            (caddr_t *)&softc->fb.addr,
 430      -            mem_offset, softc->fb_size,
 431      -            &dev_attr, &softc->fb.handle);
      268 +        error = ddi_regs_map_setup(devi, vga->fb_regno,
      269 +            (caddr_t *)&vga->fb.addr, mem_offset, vga->fb_size, &dev_attr,
      270 +            &vga->fb.handle);
 432  271          if (error != DDI_SUCCESS)
 433  272                  goto fail;
 434      -        softc->fb.mapped = B_TRUE;
      273 +        vga->fb.mapped = B_TRUE;
 435  274  
 436      -        if (ddi_get8(softc->regs.handle,
 437      -            softc->regs.addr + VGA_MISC_R) & VGA_MISC_IOA_SEL)
 438      -                softc->text_base = (caddr_t)softc->fb.addr + VGA_COLOR_BASE;
      275 +        if (ddi_get8(vga->regs.handle,
      276 +            vga->regs.addr + VGA_MISC_R) & VGA_MISC_IOA_SEL)
      277 +                vga->text_base = (caddr_t)vga->fb.addr + VGA_COLOR_BASE;
 439  278          else
 440      -                softc->text_base = (caddr_t)softc->fb.addr + VGA_MONO_BASE;
      279 +                vga->text_base = (caddr_t)vga->fb.addr + VGA_MONO_BASE;
 441  280  
 442  281          if (ddi_prop_lookup_string(DDI_DEV_T_ANY, ddi_root_node(),
 443  282              DDI_PROP_DONTPASS, "console", &cons) == DDI_SUCCESS) {
 444  283                  if (strcmp(cons, "graphics") == 0) {
 445      -                        happyface_boot = 1;
 446      -                        vgatext_silent = 1;
 447      -                        softc->current_base = softc->shadow;
      284 +                        softc->happyface_boot = 1;
      285 +                        softc->silent = 1;
      286 +                        vga->current_base = vga->shadow;
 448  287                  } else {
 449      -                        softc->current_base = softc->text_base;
      288 +                        vga->current_base = vga->text_base;
 450  289                  }
 451  290                  ddi_prop_free(cons);
 452  291          } else {
 453      -                softc->current_base = softc->text_base;
      292 +                vga->current_base = vga->text_base;
 454  293          }
 455  294  
      295 +        /* Set cursor info. */
      296 +        vga->cursor.visible = fb_info.cursor.visible;
      297 +        vga->cursor.row = fb_info.cursor.pos.y;
      298 +        vga->cursor.col = fb_info.cursor.pos.x;
      299 +
 456  300          error = ddi_prop_create(makedevice(DDI_MAJOR_T_UNKNOWN, unit),
 457  301              devi, DDI_PROP_CANSLEEP, DDI_KERNEL_IOCTL, NULL, 0);
 458  302          if (error != DDI_SUCCESS)
 459  303                  goto fail;
 460  304  
 461      -        gfxp_check_for_console(devi, softc, pci_pcie_bus);
 462      -
 463      -        value = GFXP_IS_CONSOLE(softc) ? 1 : 0;
 464      -        if (ddi_prop_update_int(DDI_DEV_T_NONE, devi,
 465      -            "primary-controller", value) != DDI_SUCCESS) {
 466      -                cmn_err(CE_WARN,
 467      -                    "Can not %s primary-controller "
 468      -                    "property for driver", value ? "set" : "clear");
 469      -        }
 470      -
 471  305          /* only do this if not in graphics mode */
 472      -        if ((vgatext_silent == 0) && (GFXP_IS_CONSOLE(softc))) {
      306 +        if ((softc->silent == 0) && (GFXP_IS_CONSOLE(softc))) {
 473  307                  vgatext_init(softc);
 474  308                  vgatext_save_colormap(softc);
 475  309          }
 476  310  
 477  311          return (DDI_SUCCESS);
 478  312  
 479  313  fail:
      314 +        kmem_free(vga, sizeof (*vga));
 480  315          if (parent_type != NULL)
 481  316                  ddi_prop_free(parent_type);
 482      -        (void) gfxp_vgatext_detach(devi, DDI_DETACH, (void *)softc);
 483  317          return (error);
 484  318  }
 485  319  
 486  320  /*ARGSUSED*/
 487  321  int
 488      -gfxp_vgatext_detach(dev_info_t *devi, ddi_detach_cmd_t cmd,
 489      -    gfxp_vgatext_softc_ptr_t ptr)
      322 +gfxp_vga_detach(dev_info_t *devi, ddi_detach_cmd_t cmd,
      323 +    struct gfxp_fb_softc *softc)
 490  324  {
 491      -        struct vgatext_softc *softc = (struct vgatext_softc *)ptr;
 492      -
 493      -        (void) ddi_prop_remove(DDI_DEV_T_ANY, devi, "primary-controller");
 494      -
 495      -        switch (cmd) {
 496      -
 497      -        case DDI_SUSPEND:
 498      -                return (vgatext_suspend(softc));
 499      -                /* break; */
 500      -        case DDI_DETACH:
 501      -                if (softc->fb.mapped)
 502      -                        ddi_regs_map_free(&softc->fb.handle);
 503      -                if (softc->regs.mapped)
 504      -                        ddi_regs_map_free(&softc->regs.handle);
 505      -                mutex_destroy(&(softc->lock));
 506      -                return (DDI_SUCCESS);
 507      -
 508      -        default:
 509      -                cmn_err(CE_WARN, "gfxp_vgatext_detach: unknown cmd 0x%x\n",
 510      -                    cmd);
 511      -                return (DDI_FAILURE);
 512      -        }
      325 +        if (softc->console->vga.fb.mapped)
      326 +                ddi_regs_map_free(&softc->console->vga.fb.handle);
      327 +        if (softc->console->vga.regs.mapped)
      328 +                ddi_regs_map_free(&softc->console->vga.regs.handle);
      329 +        kmem_free(softc->console, sizeof (struct gfx_vga));
      330 +        return (DDI_SUCCESS);
 513  331  }
 514  332  
 515      -/*ARGSUSED*/
 516      -int
 517      -gfxp_vgatext_open(dev_t *devp, int flag, int otyp, cred_t *cred,
 518      -    gfxp_vgatext_softc_ptr_t ptr)
 519      -{
 520      -        struct vgatext_softc *softc = (struct vgatext_softc *)ptr;
 521      -
 522      -        if (softc == NULL || otyp == OTYP_BLK)
 523      -                return (ENXIO);
 524      -
 525      -        return (0);
 526      -}
 527      -
 528      -/*ARGSUSED*/
 529      -int
 530      -gfxp_vgatext_close(dev_t devp, int flag, int otyp, cred_t *cred,
 531      -    gfxp_vgatext_softc_ptr_t ptr)
 532      -{
 533      -        return (0);
 534      -}
 535      -
 536      -static int
 537      -do_gfx_ioctl(int cmd, intptr_t data, int mode, struct vgatext_softc *softc)
 538      -{
 539      -        static char kernel_only[] =
 540      -            "gfxp_vgatext_ioctl: %s is a kernel only ioctl";
 541      -        int err;
 542      -        int kd_mode;
 543      -
 544      -        switch (cmd) {
 545      -        case KDSETMODE:
 546      -                return (vgatext_kdsetmode(softc, (int)data));
 547      -
 548      -        case KDGETMODE:
 549      -                kd_mode = softc->mode;
 550      -                if (ddi_copyout(&kd_mode, (void *)data, sizeof (int), mode))
 551      -                        return (EFAULT);
 552      -                break;
 553      -
 554      -        case VIS_DEVINIT:
 555      -
 556      -                if (!(mode & FKIOCTL)) {
 557      -                        cmn_err(CE_CONT, kernel_only, "VIS_DEVINIT");
 558      -                        return (ENXIO);
 559      -                }
 560      -
 561      -                err = vgatext_devinit(softc, (struct vis_devinit *)data);
 562      -                if (err != 0) {
 563      -                        cmn_err(CE_WARN,
 564      -                            "gfxp_vgatext_ioctl:  could not"
 565      -                            " initialize console");
 566      -                        return (err);
 567      -                }
 568      -                break;
 569      -
 570      -        case VIS_CONSCOPY:      /* move */
 571      -        {
 572      -                struct vis_conscopy pma;
 573      -
 574      -                if (ddi_copyin((void *)data, &pma,
 575      -                    sizeof (struct vis_conscopy), mode))
 576      -                        return (EFAULT);
 577      -
 578      -                vgatext_cons_copy(softc, &pma);
 579      -                break;
 580      -        }
 581      -
 582      -        case VIS_CONSDISPLAY:   /* display */
 583      -        {
 584      -                struct vis_consdisplay display_request;
 585      -
 586      -                if (ddi_copyin((void *)data, &display_request,
 587      -                    sizeof (display_request), mode))
 588      -                        return (EFAULT);
 589      -
 590      -                vgatext_cons_display(softc, &display_request);
 591      -                break;
 592      -        }
 593      -
 594      -        case VIS_CONSCURSOR:
 595      -        {
 596      -                struct vis_conscursor cursor_request;
 597      -
 598      -                if (ddi_copyin((void *)data, &cursor_request,
 599      -                    sizeof (cursor_request), mode))
 600      -                        return (EFAULT);
 601      -
 602      -                vgatext_cons_cursor(softc, &cursor_request);
 603      -
 604      -                if (cursor_request.action == VIS_GET_CURSOR &&
 605      -                    ddi_copyout(&cursor_request, (void *)data,
 606      -                    sizeof (cursor_request), mode))
 607      -                        return (EFAULT);
 608      -                break;
 609      -        }
 610      -
 611      -        case VIS_GETCMAP:
 612      -        case VIS_PUTCMAP:
 613      -        case FBIOPUTCMAP:
 614      -        case FBIOGETCMAP:
 615      -                /*
 616      -                 * At the moment, text mode is not considered to have
 617      -                 * a color map.
 618      -                 */
 619      -                return (EINVAL);
 620      -
 621      -        case FBIOGATTR:
 622      -                if (copyout(&vgatext_attr, (void *)data,
 623      -                    sizeof (struct fbgattr)))
 624      -                        return (EFAULT);
 625      -                break;
 626      -
 627      -        case FBIOGTYPE:
 628      -                if (copyout(&vgatext_attr.fbtype, (void *)data,
 629      -                    sizeof (struct fbtype)))
 630      -                        return (EFAULT);
 631      -                break;
 632      -
 633      -        default:
 634      -                return (ENXIO);
 635      -        }
 636      -        return (0);
 637      -}
 638      -
 639      -/*ARGSUSED*/
 640      -int
 641      -gfxp_vgatext_ioctl(
 642      -    dev_t dev,
 643      -    int cmd,
 644      -    intptr_t data,
 645      -    int mode,
 646      -    cred_t *cred,
 647      -    int *rval,
 648      -    gfxp_vgatext_softc_ptr_t ptr)
 649      -{
 650      -        int err;
 651      -
 652      -        struct vgatext_softc *softc = (struct vgatext_softc *)ptr;
 653      -
 654      -        mutex_enter(&(softc->lock));
 655      -        err = do_gfx_ioctl(cmd, data, mode, softc);
 656      -        mutex_exit(&(softc->lock));
 657      -
 658      -        return (err);
 659      -}
 660      -
 661  333  /*
 662  334   * vgatext_save_text
 663      - * vgatext_restore_textmode
 664  335   * vgatext_suspend
 665  336   * vgatext_resume
 666  337   *
 667  338   *      Routines to save and restore contents of the VGA text area
 668  339   * Mostly, this is to support Suspend/Resume operation for graphics
 669  340   * device drivers.  Here in the VGAtext common code, we simply squirrel
 670  341   * away the contents of the hardware's text area during Suspend and then
 671  342   * put it back during Resume
 672  343   */
 673  344  static void
 674      -vgatext_save_text(struct vgatext_softc *softc)
      345 +vgatext_save_text(struct gfxp_fb_softc *softc)
 675  346  {
 676      -        unsigned        i;
      347 +        union gfx_console *console = softc->console;
      348 +        unsigned i;
 677  349  
 678      -        for (i = 0; i < sizeof (softc->shadow); i++)
 679      -                softc->shadow[i] = softc->current_base[i];
      350 +        for (i = 0; i < sizeof (console->vga.shadow); i++)
      351 +                console->vga.shadow[i] = console->vga.current_base[i];
 680  352  }
 681  353  
 682      -static void
 683      -vgatext_restore_textmode(struct vgatext_softc *softc)
 684      -{
 685      -        unsigned        i;
 686      -
 687      -        vgatext_init(softc);
 688      -        for (i = 0; i < sizeof (softc->shadow); i++) {
 689      -                softc->text_base[i] = softc->shadow[i];
 690      -        }
 691      -        if (softc->cursor.visible) {
 692      -                vgatext_set_cursor(softc,
 693      -                    softc->cursor.row, softc->cursor.col);
 694      -        }
 695      -        vgatext_restore_colormap(softc);
 696      -}
 697      -
 698  354  static int
 699      -vgatext_suspend(struct vgatext_softc *softc)
      355 +vgatext_suspend(struct gfxp_fb_softc *softc)
 700  356  {
 701  357          switch (softc->mode) {
 702  358          case KD_TEXT:
 703  359                  vgatext_save_text(softc);
 704  360                  break;
 705  361  
 706  362          case KD_GRAPHICS:
 707  363                  break;
 708  364  
 709  365          default:
 710  366                  cmn_err(CE_WARN, MYNAME ": unknown mode in vgatext_suspend.");
 711  367                  return (DDI_FAILURE);
 712  368          }
 713  369          return (DDI_SUCCESS);
 714  370  }
 715  371  
 716  372  static void
 717      -vgatext_resume(struct vgatext_softc *softc)
      373 +vgatext_resume(struct gfxp_fb_softc *softc)
 718  374  {
 719  375  
 720  376          switch (softc->mode) {
 721  377          case KD_TEXT:
 722      -                vgatext_restore_textmode(softc);
      378 +                vgatext_kdsettext(softc);
 723  379                  break;
 724  380  
 725  381          case KD_GRAPHICS:
 726  382  
 727  383                  /*
 728  384                   * Upon RESUME, the graphics device will always actually
 729  385                   * be in TEXT mode even though the Xorg server did not
 730  386                   * make that mode change itself (the suspend code did).
 731  387                   * We want first, therefore, to restore textmode
 732  388                   * operation fully, and then the Xorg server will
 733  389                   * do the rest to restore the device to its
 734  390                   * (hi resolution) graphics mode
 735  391                   */
 736      -                vgatext_restore_textmode(softc);
      392 +                vgatext_kdsettext(softc);
 737  393  #if     defined(USE_BORDERS)
 738  394                  vgatext_init_graphics(softc);
 739  395  #endif
 740  396                  break;
 741  397          default:
 742  398                  cmn_err(CE_WARN, MYNAME ": unknown mode in vgatext_resume.");
 743  399                  break;
 744  400          }
 745  401  }
 746  402  
 747  403  static void
 748      -vgatext_progressbar_stop()
      404 +vgatext_progressbar_stop(struct gfxp_fb_softc *softc)
 749  405  {
 750  406          extern void progressbar_stop(void);
 751  407  
 752      -        if (vgatext_silent == 1) {
 753      -                vgatext_silent = 0;
      408 +        if (softc->silent == 1) {
      409 +                softc->silent = 0;
 754  410                  progressbar_stop();
 755  411          }
 756  412  }
 757  413  
 758  414  static void
 759      -vgatext_kdsettext(struct vgatext_softc *softc)
      415 +vgatext_kdsettext(struct gfxp_fb_softc *softc)
 760  416  {
      417 +        union gfx_console *console = softc->console;
 761  418          int i;
 762  419  
 763  420          vgatext_init(softc);
 764      -        for (i = 0; i < sizeof (softc->shadow); i++) {
 765      -                softc->text_base[i] = softc->shadow[i];
      421 +        for (i = 0; i < sizeof (console->vga.shadow); i++) {
      422 +                console->vga.text_base[i] = console->vga.shadow[i];
 766  423          }
 767      -        softc->current_base = softc->text_base;
 768      -        if (softc->cursor.visible) {
      424 +        console->vga.current_base = console->vga.text_base;
      425 +        if (console->vga.cursor.visible) {
 769  426                  vgatext_set_cursor(softc,
 770      -                    softc->cursor.row, softc->cursor.col);
      427 +                    console->vga.cursor.row,
      428 +                    console->vga.cursor.col);
 771  429          }
 772  430          vgatext_restore_colormap(softc);
 773  431  }
 774  432  
 775  433  static void
 776      -vgatext_kdsetgraphics(struct vgatext_softc *softc)
      434 +vgatext_kdsetgraphics(struct gfxp_fb_softc *softc)
 777  435  {
 778      -        vgatext_progressbar_stop();
      436 +        vgatext_progressbar_stop(softc);
 779  437          vgatext_save_text(softc);
 780      -        softc->current_base = softc->shadow;
      438 +        softc->console->vga.current_base = softc->console->vga.shadow;
      439 +        vgatext_get_text(softc);
 781  440  #if     defined(USE_BORDERS)
 782  441          vgatext_init_graphics(softc);
 783  442  #endif
 784  443  }
 785  444  
 786  445  static int
 787      -vgatext_kdsetmode(struct vgatext_softc *softc, int mode)
      446 +vgatext_kdsetmode(struct gfxp_fb_softc *softc, int mode)
 788  447  {
 789      -        if ((mode == softc->mode) || (!GFXP_IS_CONSOLE(softc)))
 790      -                return (0);
 791      -
 792  448          switch (mode) {
 793  449          case KD_TEXT:
      450 +                if (softc->blt_ops.setmode != NULL)
      451 +                        softc->blt_ops.setmode(KD_TEXT);
 794  452                  vgatext_kdsettext(softc);
 795  453                  break;
 796  454  
 797  455          case KD_GRAPHICS:
 798  456                  vgatext_kdsetgraphics(softc);
      457 +                if (softc->blt_ops.setmode != NULL)
      458 +                        softc->blt_ops.setmode(KD_GRAPHICS);
 799  459                  break;
 800  460  
 801  461          case KD_RESETTEXT:
 802  462                  /*
 803  463                   * In order to avoid racing with a starting X server,
 804  464                   * this needs to be a test and set that is performed in
 805  465                   * a single (softc->lock protected) ioctl into this driver.
 806  466                   */
 807      -                if (softc->mode == KD_TEXT && vgatext_silent == 1) {
 808      -                        vgatext_progressbar_stop();
      467 +                if (softc->mode == KD_TEXT && softc->silent == 1) {
      468 +                        vgatext_progressbar_stop(softc);
 809  469                          vgatext_kdsettext(softc);
 810  470                  }
      471 +                mode = KD_TEXT;
 811  472                  break;
 812  473  
 813  474          default:
 814  475                  return (EINVAL);
 815  476          }
 816  477  
 817  478          softc->mode = mode;
 818  479          return (0);
 819  480  }
 820  481  
 821  482  /*ARGSUSED*/
 822      -int
 823      -gfxp_vgatext_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, size_t len,
      483 +static int
      484 +vgatext_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, size_t len,
 824  485      size_t *maplen, uint_t model, void *ptr)
 825  486  {
 826      -        struct vgatext_softc *softc = (struct vgatext_softc *)ptr;
      487 +        struct gfxp_fb_softc *softc = (struct gfxp_fb_softc *)ptr;
      488 +        union gfx_console *console;
 827  489          int err;
 828  490          size_t length;
 829  491  
 830  492  
 831  493          if (softc == NULL) {
 832  494                  cmn_err(CE_WARN, "vgatext: Can't find softstate");
 833  495                  return (-1);
 834  496          }
      497 +        console = softc->console;
 835  498  
 836  499          if (!(off >= VGA_MMAP_FB_BASE &&
 837      -            off < VGA_MMAP_FB_BASE + softc->fb_size)) {
      500 +            off < VGA_MMAP_FB_BASE + console->vga.fb_size)) {
 838  501                  cmn_err(CE_WARN, "vgatext: Can't map offset 0x%llx", off);
 839  502                  return (-1);
 840  503          }
 841  504  
 842      -        if (off + len > VGA_MMAP_FB_BASE + softc->fb_size)
 843      -                length = VGA_MMAP_FB_BASE + softc->fb_size - off;
      505 +        if (off + len > VGA_MMAP_FB_BASE + console->vga.fb_size)
      506 +                length = VGA_MMAP_FB_BASE + console->vga.fb_size - off;
 844  507          else
 845  508                  length = len;
 846  509  
 847  510          if ((err = devmap_devmem_setup(dhp, softc->devi,
 848      -            NULL, softc->fb_regno, off - VGA_MMAP_FB_BASE,
      511 +            NULL, console->vga.fb_regno, off - VGA_MMAP_FB_BASE,
 849  512              length, PROT_ALL, 0, &dev_attr)) < 0) {
 850  513                  return (err);
 851  514          }
 852  515  
 853  516  
 854  517          *maplen = length;
 855  518          return (0);
 856  519  }
 857  520  
 858  521  
 859  522  static int
 860      -vgatext_devinit(struct vgatext_softc *softc, struct vis_devinit *data)
      523 +vgatext_devinit(struct gfxp_fb_softc *softc, struct vis_devinit *data)
 861  524  {
 862  525          /* initialize console instance */
 863  526          data->version = VIS_CONS_REV;
 864  527          data->width = TEXT_COLS;
 865  528          data->height = TEXT_ROWS;
 866  529          data->linebytes = TEXT_COLS;
      530 +        data->color_map = NULL;
 867  531          data->depth = 4;
 868  532          data->mode = VIS_TEXT;
 869  533          data->polledio = &softc->polledio;
 870  534  
      535 +        vgatext_save_text(softc);       /* save current console */
      536 +        vgatext_hide_cursor(softc);
 871  537          return (0);
 872  538  }
 873  539  
 874  540  /*
      541 + * Binary searchable table for Unicode to CP437 conversion.
      542 + */
      543 +struct unicp437 {
      544 +        uint16_t        unicode_base;
      545 +        uint8_t         cp437_base;
      546 +        uint8_t         length;
      547 +};
      548 +
      549 +static const struct unicp437 cp437table[] = {
      550 +        { 0x0020, 0x20, 0x5e }, { 0x00a0, 0x20, 0x00 }, { 0x00a1, 0xad, 0x00 },
      551 +        { 0x00a2, 0x9b, 0x00 }, { 0x00a3, 0x9c, 0x00 }, { 0x00a5, 0x9d, 0x00 },
      552 +        { 0x00a7, 0x15, 0x00 }, { 0x00aa, 0xa6, 0x00 }, { 0x00ab, 0xae, 0x00 },
      553 +        { 0x00ac, 0xaa, 0x00 }, { 0x00b0, 0xf8, 0x00 }, { 0x00b1, 0xf1, 0x00 },
      554 +        { 0x00b2, 0xfd, 0x00 }, { 0x00b5, 0xe6, 0x00 }, { 0x00b6, 0x14, 0x00 },
      555 +        { 0x00b7, 0xfa, 0x00 }, { 0x00ba, 0xa7, 0x00 }, { 0x00bb, 0xaf, 0x00 },
      556 +        { 0x00bc, 0xac, 0x00 }, { 0x00bd, 0xab, 0x00 }, { 0x00bf, 0xa8, 0x00 },
      557 +        { 0x00c4, 0x8e, 0x01 }, { 0x00c6, 0x92, 0x00 }, { 0x00c7, 0x80, 0x00 },
      558 +        { 0x00c9, 0x90, 0x00 }, { 0x00d1, 0xa5, 0x00 }, { 0x00d6, 0x99, 0x00 },
      559 +        { 0x00dc, 0x9a, 0x00 }, { 0x00df, 0xe1, 0x00 }, { 0x00e0, 0x85, 0x00 },
      560 +        { 0x00e1, 0xa0, 0x00 }, { 0x00e2, 0x83, 0x00 }, { 0x00e4, 0x84, 0x00 },
      561 +        { 0x00e5, 0x86, 0x00 }, { 0x00e6, 0x91, 0x00 }, { 0x00e7, 0x87, 0x00 },
      562 +        { 0x00e8, 0x8a, 0x00 }, { 0x00e9, 0x82, 0x00 }, { 0x00ea, 0x88, 0x01 },
      563 +        { 0x00ec, 0x8d, 0x00 }, { 0x00ed, 0xa1, 0x00 }, { 0x00ee, 0x8c, 0x00 },
      564 +        { 0x00ef, 0x8b, 0x00 }, { 0x00f0, 0xeb, 0x00 }, { 0x00f1, 0xa4, 0x00 },
      565 +        { 0x00f2, 0x95, 0x00 }, { 0x00f3, 0xa2, 0x00 }, { 0x00f4, 0x93, 0x00 },
      566 +        { 0x00f6, 0x94, 0x00 }, { 0x00f7, 0xf6, 0x00 }, { 0x00f8, 0xed, 0x00 },
      567 +        { 0x00f9, 0x97, 0x00 }, { 0x00fa, 0xa3, 0x00 }, { 0x00fb, 0x96, 0x00 },
      568 +        { 0x00fc, 0x81, 0x00 }, { 0x00ff, 0x98, 0x00 }, { 0x0192, 0x9f, 0x00 },
      569 +        { 0x0393, 0xe2, 0x00 }, { 0x0398, 0xe9, 0x00 }, { 0x03a3, 0xe4, 0x00 },
      570 +        { 0x03a6, 0xe8, 0x00 }, { 0x03a9, 0xea, 0x00 }, { 0x03b1, 0xe0, 0x01 },
      571 +        { 0x03b4, 0xeb, 0x00 }, { 0x03b5, 0xee, 0x00 }, { 0x03bc, 0xe6, 0x00 },
      572 +        { 0x03c0, 0xe3, 0x00 }, { 0x03c3, 0xe5, 0x00 }, { 0x03c4, 0xe7, 0x00 },
      573 +        { 0x03c6, 0xed, 0x00 }, { 0x03d5, 0xed, 0x00 }, { 0x2010, 0x2d, 0x00 },
      574 +        { 0x2014, 0x2d, 0x00 }, { 0x2018, 0x60, 0x00 }, { 0x2019, 0x27, 0x00 },
      575 +        { 0x201c, 0x22, 0x00 }, { 0x201d, 0x22, 0x00 }, { 0x2022, 0x07, 0x00 },
      576 +        { 0x203c, 0x13, 0x00 }, { 0x207f, 0xfc, 0x00 }, { 0x20a7, 0x9e, 0x00 },
      577 +        { 0x20ac, 0xee, 0x00 }, { 0x2126, 0xea, 0x00 }, { 0x2190, 0x1b, 0x00 },
      578 +        { 0x2191, 0x18, 0x00 }, { 0x2192, 0x1a, 0x00 }, { 0x2193, 0x19, 0x00 },
      579 +        { 0x2194, 0x1d, 0x00 }, { 0x2195, 0x12, 0x00 }, { 0x21a8, 0x17, 0x00 },
      580 +        { 0x2202, 0xeb, 0x00 }, { 0x2208, 0xee, 0x00 }, { 0x2211, 0xe4, 0x00 },
      581 +        { 0x2212, 0x2d, 0x00 }, { 0x2219, 0xf9, 0x00 }, { 0x221a, 0xfb, 0x00 },
      582 +        { 0x221e, 0xec, 0x00 }, { 0x221f, 0x1c, 0x00 }, { 0x2229, 0xef, 0x00 },
      583 +        { 0x2248, 0xf7, 0x00 }, { 0x2261, 0xf0, 0x00 }, { 0x2264, 0xf3, 0x00 },
      584 +        { 0x2265, 0xf2, 0x00 }, { 0x2302, 0x7f, 0x00 }, { 0x2310, 0xa9, 0x00 },
      585 +        { 0x2320, 0xf4, 0x00 }, { 0x2321, 0xf5, 0x00 }, { 0x2500, 0xc4, 0x00 },
      586 +        { 0x2502, 0xb3, 0x00 }, { 0x250c, 0xda, 0x00 }, { 0x2510, 0xbf, 0x00 },
      587 +        { 0x2514, 0xc0, 0x00 }, { 0x2518, 0xd9, 0x00 }, { 0x251c, 0xc3, 0x00 },
      588 +        { 0x2524, 0xb4, 0x00 }, { 0x252c, 0xc2, 0x00 }, { 0x2534, 0xc1, 0x00 },
      589 +        { 0x253c, 0xc5, 0x00 }, { 0x2550, 0xcd, 0x00 }, { 0x2551, 0xba, 0x00 },
      590 +        { 0x2552, 0xd5, 0x00 }, { 0x2553, 0xd6, 0x00 }, { 0x2554, 0xc9, 0x00 },
      591 +        { 0x2555, 0xb8, 0x00 }, { 0x2556, 0xb7, 0x00 }, { 0x2557, 0xbb, 0x00 },
      592 +        { 0x2558, 0xd4, 0x00 }, { 0x2559, 0xd3, 0x00 }, { 0x255a, 0xc8, 0x00 },
      593 +        { 0x255b, 0xbe, 0x00 }, { 0x255c, 0xbd, 0x00 }, { 0x255d, 0xbc, 0x00 },
      594 +        { 0x255e, 0xc6, 0x01 }, { 0x2560, 0xcc, 0x00 }, { 0x2561, 0xb5, 0x00 },
      595 +        { 0x2562, 0xb6, 0x00 }, { 0x2563, 0xb9, 0x00 }, { 0x2564, 0xd1, 0x01 },
      596 +        { 0x2566, 0xcb, 0x00 }, { 0x2567, 0xcf, 0x00 }, { 0x2568, 0xd0, 0x00 },
      597 +        { 0x2569, 0xca, 0x00 }, { 0x256a, 0xd8, 0x00 }, { 0x256b, 0xd7, 0x00 },
      598 +        { 0x256c, 0xce, 0x00 }, { 0x2580, 0xdf, 0x00 }, { 0x2584, 0xdc, 0x00 },
      599 +        { 0x2588, 0xdb, 0x00 }, { 0x258c, 0xdd, 0x00 }, { 0x2590, 0xde, 0x00 },
      600 +        { 0x2591, 0xb0, 0x02 }, { 0x25a0, 0xfe, 0x00 }, { 0x25ac, 0x16, 0x00 },
      601 +        { 0x25b2, 0x1e, 0x00 }, { 0x25ba, 0x10, 0x00 }, { 0x25bc, 0x1f, 0x00 },
      602 +        { 0x25c4, 0x11, 0x00 }, { 0x25cb, 0x09, 0x00 }, { 0x25d8, 0x08, 0x00 },
      603 +        { 0x25d9, 0x0a, 0x00 }, { 0x263a, 0x01, 0x01 }, { 0x263c, 0x0f, 0x00 },
      604 +        { 0x2640, 0x0c, 0x00 }, { 0x2642, 0x0b, 0x00 }, { 0x2660, 0x06, 0x00 },
      605 +        { 0x2663, 0x05, 0x00 }, { 0x2665, 0x03, 0x01 }, { 0x266a, 0x0d, 0x00 },
      606 +        { 0x266c, 0x0e, 0x00 }
      607 +};
      608 +
      609 +static uint8_t
      610 +vga_get_cp437(uint32_t c)
      611 +{
      612 +        int min, mid, max;
      613 +
      614 +        min = 0;
      615 +        max = (sizeof(cp437table) / sizeof(struct unicp437)) - 1;
      616 +
      617 +        if (c < cp437table[0].unicode_base ||
      618 +            c > cp437table[max].unicode_base + cp437table[max].length)
      619 +                return ('?');
      620 +
      621 +        while (max >= min) {
      622 +                mid = (min + max) / 2;
      623 +                if (c < cp437table[mid].unicode_base)
      624 +                        max = mid - 1;
      625 +                else if (c > cp437table[mid].unicode_base +
      626 +                    cp437table[mid].length)
      627 +                        min = mid + 1;
      628 +                else
      629 +                        return (c - cp437table[mid].unicode_base +
      630 +                            cp437table[mid].cp437_base);
      631 +        }
      632 +
      633 +        return ('?');
      634 +}
      635 +
      636 +/*
 875  637   * display a string on the screen at (row, col)
 876  638   *       assume it has been cropped to fit.
 877  639   */
 878      -
 879  640  static void
 880      -vgatext_cons_display(struct vgatext_softc *softc, struct vis_consdisplay *da)
      641 +vgatext_cons_display(struct gfxp_fb_softc *softc, struct vis_consdisplay *da)
 881  642  {
 882      -        unsigned char   *string;
      643 +        uint32_t *string;
 883  644          int     i;
 884  645          unsigned char   attr;
 885  646          struct cgatext {
 886  647                  unsigned char ch;
 887  648                  unsigned char attr;
 888  649          };
 889  650          struct cgatext *addr;
 890  651  
 891  652          /*
 892  653           * Sanity checks.  This is a last-ditch effort to avoid damage
↓ open down ↓ 5 lines elided ↑ open up ↑
 898  659                  return;
 899  660  
 900  661          /*
 901  662           * To be fully general, we should copyin the data.  This is not
 902  663           * really relevant for this text-only driver, but a graphical driver
 903  664           * should support these ioctls from userland to enable simple
 904  665           * system startup graphics.
 905  666           */
 906  667          attr = (solaris_color_to_pc_color[da->bg_color & 0xf] << 4)
 907  668              | solaris_color_to_pc_color[da->fg_color & 0xf];
 908      -        string = da->data;
 909      -        addr = (struct cgatext *)softc->current_base
      669 +        string = (uint32_t *)da->data;
      670 +        addr = (struct cgatext *)softc->console->vga.current_base
 910  671              +  (da->row * TEXT_COLS + da->col);
 911  672          for (i = 0; i < da->width; i++) {
 912      -                addr->ch = string[i];
 913      -                addr->attr = attr;
 914      -                addr++;
      673 +                addr[i].ch = vga_get_cp437(string[i]);
      674 +                addr[i].attr = attr;
 915  675          }
 916  676  }
 917  677  
 918  678  static void
 919  679  vgatext_polled_display(
 920  680          struct vis_polledio_arg *arg,
 921  681          struct vis_consdisplay *da)
 922  682  {
 923      -        vgatext_cons_display((struct vgatext_softc *)arg, da);
      683 +        vgatext_cons_display((struct gfxp_fb_softc *)arg, da);
 924  684  }
 925  685  
 926  686  /*
 927  687   * screen-to-screen copy
 928  688   */
 929  689  
 930  690  static void
 931      -vgatext_cons_copy(struct vgatext_softc *softc, struct vis_conscopy *ma)
      691 +vgatext_cons_copy(struct gfxp_fb_softc *softc, struct vis_conscopy *ma)
 932  692  {
 933  693          unsigned short  *from;
 934  694          unsigned short  *to;
 935  695          int             cnt;
 936  696          screen_size_t chars_per_row;
 937  697          unsigned short  *to_row_start;
 938  698          unsigned short  *from_row_start;
 939  699          screen_size_t   rows_to_move;
 940  700          unsigned short  *base;
 941  701  
↓ open down ↓ 16 lines elided ↑ open up ↑
 958  718           * character/attribute pair is 16 bits.
 959  719           */
 960  720          chars_per_row = ma->e_col - ma->s_col + 1;
 961  721          rows_to_move = ma->e_row - ma->s_row + 1;
 962  722  
 963  723          /* More sanity checks. */
 964  724          if (ma->t_row + rows_to_move > TEXT_ROWS ||
 965  725              ma->t_col + chars_per_row > TEXT_COLS)
 966  726                  return;
 967  727  
 968      -        base = (unsigned short *)softc->current_base;
      728 +        base = (unsigned short *)softc->console->vga.current_base;
 969  729  
 970  730          to_row_start = base + ((ma->t_row * TEXT_COLS) + ma->t_col);
 971  731          from_row_start = base + ((ma->s_row * TEXT_COLS) + ma->s_col);
 972  732  
 973  733          if (to_row_start < from_row_start) {
 974  734                  while (rows_to_move-- > 0) {
 975  735                          to = to_row_start;
 976  736                          from = from_row_start;
 977  737                          to_row_start += TEXT_COLS;
 978  738                          from_row_start += TEXT_COLS;
↓ open down ↓ 17 lines elided ↑ open up ↑
 996  756                                  *--to = *--from;
 997  757                  }
 998  758          }
 999  759  }
1000  760  
1001  761  static void
1002  762  vgatext_polled_copy(
1003  763          struct vis_polledio_arg *arg,
1004  764          struct vis_conscopy *ca)
1005  765  {
1006      -        vgatext_cons_copy((struct vgatext_softc *)arg, ca);
      766 +        vgatext_cons_copy((struct gfxp_fb_softc *)arg, ca);
1007  767  }
1008  768  
      769 +/*ARGSUSED*/
      770 +static int
      771 +vgatext_cons_clear(struct gfxp_fb_softc *softc, struct vis_consclear *ca)
      772 +{
      773 +        uint16_t val, fg, *base;
      774 +        int i;
1009  775  
      776 +        if (ca->bg_color == 0)          /* bright white */
      777 +                fg = 1;                 /* black */
      778 +        else
      779 +                fg = 8;
      780 +
      781 +        val = (solaris_color_to_pc_color[ca->bg_color & 0xf] << 4) |
      782 +            solaris_color_to_pc_color[fg];
      783 +        val = (val << 8) | ' ';
      784 +
      785 +        base = (uint16_t *)softc->console->vga.current_base;
      786 +        for (i = 0; i < TEXT_ROWS * TEXT_COLS; i++)
      787 +                base[i] = val;
      788 +
      789 +        return (0);
      790 +}
      791 +
1010  792  static void
1011      -vgatext_cons_cursor(struct vgatext_softc *softc, struct vis_conscursor *ca)
      793 +vgatext_cons_cursor(struct gfxp_fb_softc *softc, struct vis_conscursor *ca)
1012  794  {
1013      -        if (vgatext_silent)
      795 +        if (softc->silent)
1014  796                  return;
1015  797  
1016  798          switch (ca->action) {
1017  799          case VIS_HIDE_CURSOR:
1018      -                softc->cursor.visible = B_FALSE;
1019      -                if (softc->current_base == softc->text_base)
      800 +                softc->console->vga.cursor.visible = B_FALSE;
      801 +                if (softc->console->vga.current_base ==
      802 +                    softc->console->vga.text_base)
1020  803                          vgatext_hide_cursor(softc);
1021  804                  break;
1022  805          case VIS_DISPLAY_CURSOR:
1023  806                  /*
1024  807                   * Sanity check.  This is a last-ditch effort to avoid
1025  808                   * damage from brokenness or maliciousness above.
1026  809                   */
1027  810                  if (ca->col < 0 || ca->col >= TEXT_COLS ||
1028  811                      ca->row < 0 || ca->row >= TEXT_ROWS)
1029  812                          return;
1030  813  
1031      -                softc->cursor.visible = B_TRUE;
1032      -                softc->cursor.col = ca->col;
1033      -                softc->cursor.row = ca->row;
1034      -                if (softc->current_base == softc->text_base)
      814 +                softc->console->vga.cursor.visible = B_TRUE;
      815 +                softc->console->vga.cursor.col = ca->col;
      816 +                softc->console->vga.cursor.row = ca->row;
      817 +                if (softc->console->vga.current_base ==
      818 +                    softc->console->vga.text_base)
1035  819                          vgatext_set_cursor(softc, ca->row, ca->col);
1036  820                  break;
1037  821          case VIS_GET_CURSOR:
1038      -                if (softc->current_base == softc->text_base) {
      822 +                if (softc->console->vga.current_base ==
      823 +                    softc->console->vga.text_base) {
1039  824                          vgatext_get_cursor(softc, &ca->row, &ca->col);
1040  825                  }
1041  826                  break;
1042  827          }
1043  828  }
1044  829  
1045  830  static void
1046  831  vgatext_polled_cursor(
1047  832          struct vis_polledio_arg *arg,
1048  833          struct vis_conscursor *ca)
1049  834  {
1050      -        vgatext_cons_cursor((struct vgatext_softc *)arg, ca);
      835 +        vgatext_cons_cursor((struct gfxp_fb_softc *)arg, ca);
1051  836  }
1052  837  
1053      -
1054      -
1055      -/*ARGSUSED*/
1056  838  static void
1057      -vgatext_hide_cursor(struct vgatext_softc *softc)
      839 +vgatext_hide_cursor(struct gfxp_fb_softc *softc)
1058  840  {
1059      -        /* Nothing at present */
      841 +        union gfx_console *console = softc->console;
      842 +        uint8_t msl, s;
      843 +
      844 +        if (softc->silent)
      845 +                return;
      846 +
      847 +        msl = vga_get_crtc(&console->vga.regs, VGA_CRTC_MAX_S_LN) & 0x1f;
      848 +        s = vga_get_crtc(&console->vga.regs, VGA_CRTC_CSSL) & 0xc0;
      849 +        s |= (1<<5);
      850 +
      851 +        /* disable cursor */
      852 +        vga_set_crtc(&console->vga.regs, VGA_CRTC_CSSL, s);
      853 +        vga_set_crtc(&console->vga.regs, VGA_CRTC_CESL, msl);
1060  854  }
1061  855  
1062  856  static void
1063      -vgatext_set_cursor(struct vgatext_softc *softc, int row, int col)
      857 +vgatext_set_cursor(struct gfxp_fb_softc *softc, int row, int col)
1064  858  {
      859 +        union gfx_console *console = softc->console;
1065  860          short   addr;
      861 +        uint8_t msl, s;
1066  862  
1067      -        if (vgatext_silent)
      863 +        if (softc->silent)
1068  864                  return;
1069  865  
      866 +        msl = vga_get_crtc(&console->vga.regs, VGA_CRTC_MAX_S_LN) & 0x1f;
      867 +        s = vga_get_crtc(&console->vga.regs, VGA_CRTC_CSSL) & 0xc0;
      868 +
1070  869          addr = row * TEXT_COLS + col;
1071  870  
1072      -        vga_set_crtc(&softc->regs, VGA_CRTC_CLAH, addr >> 8);
1073      -        vga_set_crtc(&softc->regs, VGA_CRTC_CLAL, addr & 0xff);
      871 +        vga_set_crtc(&console->vga.regs, VGA_CRTC_CLAH, addr >> 8);
      872 +        vga_set_crtc(&console->vga.regs, VGA_CRTC_CLAL, addr & 0xff);
      873 +
      874 +        /* enable cursor */
      875 +        vga_set_crtc(&console->vga.regs, VGA_CRTC_CSSL, s);
      876 +        vga_set_crtc(&console->vga.regs, VGA_CRTC_CESL, msl);
1074  877  }
1075  878  
1076      -static int vga_row, vga_col;
1077      -
1078  879  static void
1079      -vgatext_get_cursor(struct vgatext_softc *softc,
      880 +vgatext_get_cursor(struct gfxp_fb_softc *softc,
1080  881      screen_pos_t *row, screen_pos_t *col)
1081  882  {
      883 +        union gfx_console *console = softc->console;
1082  884          short   addr;
1083  885  
1084      -        addr = (vga_get_crtc(&softc->regs, VGA_CRTC_CLAH) << 8) +
1085      -            vga_get_crtc(&softc->regs, VGA_CRTC_CLAL);
      886 +        addr = (vga_get_crtc(&console->vga.regs, VGA_CRTC_CLAH) << 8) +
      887 +            vga_get_crtc(&console->vga.regs, VGA_CRTC_CLAL);
1086  888  
1087      -        vga_row = *row = addr / TEXT_COLS;
1088      -        vga_col = *col = addr % TEXT_COLS;
      889 +        *row = addr / TEXT_COLS;
      890 +        *col = addr % TEXT_COLS;
1089  891  }
1090  892  
      893 +static void
      894 +vgatext_get_text(struct gfxp_fb_softc *softc)
      895 +{
      896 +        union gfx_console *console = softc->console;
      897 +        struct vgareg *vga_reg;
      898 +        struct vgaregmap *regs;
      899 +        int i;
      900 +
      901 +        regs = &console->vga.regs;
      902 +        vga_reg = &console->vga.vga_reg;
      903 +
      904 +        vga_reg->vga_misc = vga_get_reg(regs, VGA_MISC_R);
      905 +
      906 +        /* get crt controller registers */
      907 +        for (i = 0; i < NUM_CRTC_REG; i++) {
      908 +                vga_reg->vga_crtc[i] = vga_get_crtc(regs, i);
      909 +        }
      910 +
      911 +        /* get attribute registers */
      912 +        for (i = 0; i < NUM_ATR_REG; i++) {
      913 +                vga_reg->vga_atr[i] = vga_get_atr(regs, i);
      914 +        }
      915 +
      916 +        /* get graphics controller registers */
      917 +        for (i = 0; i < NUM_GRC_REG; i++) {
      918 +                vga_reg->vga_grc[i] = vga_get_grc(regs, i);
      919 +        }
      920 +
      921 +        /* get sequencer registers */
      922 +        for (i = 1; i < NUM_SEQ_REG; i++) {
      923 +                vga_reg->vga_seq[i] = vga_get_seq(regs, i);
      924 +        }
      925 +}
      926 +
1091  927  /*
1092  928   * This code is experimental. It's only enabled if console is
1093  929   * set to graphics, a preliminary implementation of happyface boot.
1094  930   */
1095  931  static void
1096      -vgatext_set_text(struct vgatext_softc *softc)
      932 +vgatext_set_text(struct gfxp_fb_softc *softc)
1097  933  {
      934 +        union gfx_console *console = softc->console;
      935 +        struct vgareg *vga_reg;
      936 +        struct vgaregmap *regs;
1098  937          int i;
1099  938  
1100      -        if (happyface_boot == 0)
      939 +        regs = &console->vga.regs;
      940 +        vga_reg = &console->vga.vga_reg;
      941 +
      942 +        vgatext_get_text(softc);
      943 +/*
      944 +        if (softc->happyface_boot == 0)
1101  945                  return;
      946 +*/
1102  947  
1103      -        /* we are in graphics mode, set to text 80X25 mode */
      948 +        /*
      949 +         * Set output register bits for text mode.
      950 +         * Make sure the VGA adapter is not in monochrome emulation mode.
      951 +         */
      952 +        vga_set_reg(regs, VGA_MISC_W, VGA_MISC_HSP | VGA_MISC_PGSL |
      953 +            VGA_MISC_VCLK1 | VGA_MISC_ENB_RAM | VGA_MISC_IOA_SEL);
1104  954  
      955 +#if 0
1105  956          /* set misc registers */
1106      -        vga_set_reg(&softc->regs, VGA_MISC_W, VGA_MISC_TEXT);
      957 +        vga_set_reg(regs, VGA_MISC_W, vga_reg->vga_misc);
      958 +#endif
1107  959  
1108  960          /* set sequencer registers */
1109      -        vga_set_seq(&softc->regs, VGA_SEQ_RST_SYN,
1110      -            (vga_get_seq(&softc->regs, VGA_SEQ_RST_SYN) &
      961 +        vga_set_seq(&console->vga.regs, VGA_SEQ_RST_SYN,
      962 +            (vga_get_seq(&console->vga.regs, VGA_SEQ_RST_SYN) &
1111  963              ~VGA_SEQ_RST_SYN_NO_SYNC_RESET));
1112  964          for (i = 1; i < NUM_SEQ_REG; i++) {
1113      -                vga_set_seq(&softc->regs, i, VGA_SEQ_TEXT[i]);
      965 +                /* vga_set_seq(regs, i, vga_reg->vga_seq[i]); */
      966 +                vga_set_seq(regs, i, VGA_SEQ_TEXT[i]);
1114  967          }
1115      -        vga_set_seq(&softc->regs, VGA_SEQ_RST_SYN,
1116      -            (vga_get_seq(&softc->regs, VGA_SEQ_RST_SYN) |
      968 +        vga_set_seq(&console->vga.regs, VGA_SEQ_RST_SYN,
      969 +            (vga_get_seq(&console->vga.regs, VGA_SEQ_RST_SYN) |
1117  970              VGA_SEQ_RST_SYN_NO_ASYNC_RESET |
1118  971              VGA_SEQ_RST_SYN_NO_SYNC_RESET));
1119  972  
1120  973          /* set crt controller registers */
1121      -        vga_set_crtc(&softc->regs, VGA_CRTC_VRE,
1122      -            (vga_get_crtc(&softc->regs, VGA_CRTC_VRE) &
1123      -            ~VGA_CRTC_VRE_LOCK));
      974 +        vga_set_crtc(&console->vga.regs, VGA_CRTC_VRE,
      975 +            (vga_reg->vga_crtc[VGA_CRTC_VRE] & ~VGA_CRTC_VRE_LOCK));
1124  976          for (i = 0; i < NUM_CRTC_REG; i++) {
1125      -                vga_set_crtc(&softc->regs, i, VGA_CRTC_TEXT[i]);
      977 +                /* vga_set_crtc(regs, i, vga_reg->vga_crtc[i]); */
      978 +                vga_set_crtc(regs, i, VGA_CRTC_TEXT[i]);
1126  979          }
1127  980  
1128  981          /* set graphics controller registers */
1129  982          for (i = 0; i < NUM_GRC_REG; i++) {
1130      -                vga_set_grc(&softc->regs, i, VGA_GRC_TEXT[i]);
      983 +                /* vga_set_grc(regs, i, vga_reg->vga_grc[i]); */
      984 +                vga_set_grc(regs, i, VGA_GRC_TEXT[i]);
1131  985          }
1132  986  
1133  987          /* set attribute registers */
1134  988          for (i = 0; i < NUM_ATR_REG; i++) {
1135      -                vga_set_atr(&softc->regs, i, VGA_ATR_TEXT[i]);
      989 +                /* vga_set_atr(regs, i, vga_reg->vga_seq[i]); */
      990 +                vga_set_atr(regs, i, VGA_ATR_TEXT[i]);
1136  991          }
1137  992  
1138  993          /* set palette */
1139  994          for (i = 0; i < VGA_TEXT_CMAP_ENTRIES; i++) {
1140      -                vga_put_cmap(&softc->regs, i, VGA_TEXT_PALETTES[i][0] << 2,
      995 +                vga_put_cmap(&console->vga.regs, i,
      996 +                    VGA_TEXT_PALETTES[i][0] << 2,
1141  997                      VGA_TEXT_PALETTES[i][1] << 2,
1142  998                      VGA_TEXT_PALETTES[i][2] << 2);
1143  999          }
1144 1000          for (i = VGA_TEXT_CMAP_ENTRIES; i < VGA8_CMAP_ENTRIES; i++) {
1145      -                vga_put_cmap(&softc->regs, i, 0, 0, 0);
     1001 +                vga_put_cmap(&console->vga.regs, i, 0, 0, 0);
1146 1002          }
1147      -
1148      -        vgatext_save_colormap(softc);
1149 1003  }
1150 1004  
1151 1005  static void
1152      -vgatext_init(struct vgatext_softc *softc)
     1006 +vgatext_init(struct gfxp_fb_softc *softc)
1153 1007  {
     1008 +        union gfx_console *console = softc->console;
1154 1009          unsigned char atr_mode;
1155 1010  
1156      -        atr_mode = vga_get_atr(&softc->regs, VGA_ATR_MODE);
     1011 +        atr_mode = vga_get_atr(&console->vga.regs, VGA_ATR_MODE);
1157 1012          if (atr_mode & VGA_ATR_MODE_GRAPH)
1158 1013                  vgatext_set_text(softc);
1159      -        atr_mode = vga_get_atr(&softc->regs, VGA_ATR_MODE);
     1014 +        atr_mode = vga_get_atr(&console->vga.regs, VGA_ATR_MODE);
1160 1015          atr_mode &= ~VGA_ATR_MODE_BLINK;
1161 1016          atr_mode &= ~VGA_ATR_MODE_9WIDE;
1162      -        vga_set_atr(&softc->regs, VGA_ATR_MODE, atr_mode);
     1017 +        vga_set_atr(&console->vga.regs, VGA_ATR_MODE, atr_mode);
1163 1018  #if     defined(USE_BORDERS)
1164      -        vga_set_atr(&softc->regs, VGA_ATR_BDR_CLR,
1165      -            vga_get_atr(&softc->regs, VGA_BRIGHT_WHITE));
     1019 +        vga_set_atr(&console->vga.regs, VGA_ATR_BDR_CLR,
     1020 +            vga_get_atr(&console->vga.regs, VGA_BRIGHT_WHITE));
1166 1021  #else
1167      -        vga_set_atr(&softc->regs, VGA_ATR_BDR_CLR,
1168      -            vga_get_atr(&softc->regs, VGA_BLACK));
     1022 +        vga_set_atr(&console->vga.regs, VGA_ATR_BDR_CLR,
     1023 +            vga_get_atr(&console->vga.regs, VGA_BLACK));
1169 1024  #endif
1170 1025          vgatext_setfont(softc); /* need selectable font? */
1171 1026  }
1172 1027  
1173 1028  #if     defined(USE_BORDERS)
1174 1029  static void
1175      -vgatext_init_graphics(struct vgatext_softc *softc)
     1030 +vgatext_init_graphics(struct gfxp_fb_softc *softc)
1176 1031  {
1177      -        vga_set_atr(&softc->regs, VGA_ATR_BDR_CLR,
1178      -            vga_get_atr(&softc->regs, VGA_BLACK));
     1032 +        vga_set_atr(&softc->console->vga.regs, VGA_ATR_BDR_CLR,
     1033 +            vga_get_atr(&softc->console->vga.regs, VGA_BLACK));
1179 1034  }
1180 1035  #endif
1181 1036  
     1037 +/*
     1038 + * Binary searchable table for CP437 to Unicode conversion.
     1039 + */
     1040 +struct cp437uni {
     1041 +        uint8_t         cp437_base;
     1042 +        uint16_t        unicode_base;
     1043 +        uint8_t         length;
     1044 +};
     1045 +
     1046 +static const struct cp437uni cp437unitable[] = {
     1047 +        {   0, 0x0000, 0 }, {   1, 0x263A, 1 }, {   3, 0x2665, 1 },
     1048 +        {   5, 0x2663, 0 }, {   6, 0x2660, 0 }, {   7, 0x2022, 0 },
     1049 +        {   8, 0x25D8, 0 }, {   9, 0x25CB, 0 }, {  10, 0x25D9, 0 },
     1050 +        {  11, 0x2642, 0 }, {  12, 0x2640, 0 }, {  13, 0x266A, 1 },
     1051 +        {  15, 0x263C, 0 }, {  16, 0x25BA, 0 }, {  17, 0x25C4, 0 },
     1052 +        {  18, 0x2195, 0 }, {  19, 0x203C, 0 }, {  20, 0x00B6, 0 },
     1053 +        {  21, 0x00A7, 0 }, {  22, 0x25AC, 0 }, {  23, 0x21A8, 0 },
     1054 +        {  24, 0x2191, 0 }, {  25, 0x2193, 0 }, {  26, 0x2192, 0 },
     1055 +        {  27, 0x2190, 0 }, {  28, 0x221F, 0 }, {  29, 0x2194, 0 },
     1056 +        {  30, 0x25B2, 0 }, {  31, 0x25BC, 0 }, {  32, 0x0020, 0x5e },
     1057 +        { 127, 0x2302, 0 }, { 128, 0x00C7, 0 }, { 129, 0x00FC, 0 },
     1058 +        { 130, 0x00E9, 0 }, { 131, 0x00E2, 0 }, { 132, 0x00E4, 0 },
     1059 +        { 133, 0x00E0, 0 }, { 134, 0x00E5, 0 }, { 135, 0x00E7, 0 },
     1060 +        { 136, 0x00EA, 1 }, { 138, 0x00E8, 0 }, { 139, 0x00EF, 0 },
     1061 +        { 140, 0x00EE, 0 }, { 141, 0x00EC, 0 }, { 142, 0x00C4, 1 },
     1062 +        { 144, 0x00C9, 0 }, { 145, 0x00E6, 0 }, { 146, 0x00C6, 0 },
     1063 +        { 147, 0x00F4, 0 }, { 148, 0x00F6, 0 }, { 149, 0x00F2, 0 },
     1064 +        { 150, 0x00FB, 0 }, { 151, 0x00F9, 0 }, { 152, 0x00FF, 0 },
     1065 +        { 153, 0x00D6, 0 }, { 154, 0x00DC, 0 }, { 155, 0x00A2, 1 },
     1066 +        { 157, 0x00A5, 0 }, { 158, 0x20A7, 0 }, { 159, 0x0192, 0 },
     1067 +        { 160, 0x00E1, 0 }, { 161, 0x00ED, 0 }, { 162, 0x00F3, 0 },
     1068 +        { 163, 0x00FA, 0 }, { 164, 0x00F1, 0 }, { 165, 0x00D1, 0 },
     1069 +        { 166, 0x00AA, 0 }, { 167, 0x00BA, 0 }, { 168, 0x00BF, 0 },
     1070 +        { 169, 0x2310, 0 }, { 170, 0x00AC, 0 }, { 171, 0x00BD, 0 },
     1071 +        { 172, 0x00BC, 0 }, { 173, 0x00A1, 0 }, { 174, 0x00AB, 0 },
     1072 +        { 175, 0x00BB, 0 }, { 176, 0x2591, 2 }, { 179, 0x2502, 0 },
     1073 +        { 180, 0x2524, 0 }, { 181, 0x2561, 1 }, { 183, 0x2556, 0 },
     1074 +        { 184, 0x2555, 0 }, { 185, 0x2563, 0 }, { 186, 0x2551, 0 },
     1075 +        { 187, 0x2557, 0 }, { 188, 0x255D, 0 }, { 189, 0x255C, 0 },
     1076 +        { 190, 0x255B, 0 }, { 191, 0x2510, 0 }, { 192, 0x2514, 0 },
     1077 +        { 193, 0x2534, 0 }, { 194, 0x252C, 0 }, { 195, 0x251C, 0 },
     1078 +        { 196, 0x2500, 0 }, { 197, 0x253C, 0 }, { 198, 0x255E, 1 },
     1079 +        { 200, 0x255A, 0 }, { 201, 0x2554, 0 }, { 202, 0x2569, 0 },
     1080 +        { 203, 0x2566, 0 }, { 204, 0x2560, 0 }, { 205, 0x2550, 0 },
     1081 +        { 206, 0x256C, 0 }, { 207, 0x2567, 1 }, { 209, 0x2564, 1 },
     1082 +        { 211, 0x2559, 0 }, { 212, 0x2558, 0 }, { 213, 0x2552, 1 },
     1083 +        { 215, 0x256B, 0 }, { 216, 0x256A, 0 }, { 217, 0x2518, 0 },
     1084 +        { 218, 0x250C, 0 }, { 219, 0x2588, 0 }, { 220, 0x2584, 0 },
     1085 +        { 221, 0x258C, 0 }, { 222, 0x2590, 0 }, { 223, 0x2580, 0 },
     1086 +        { 224, 0x03B1, 0 }, { 225, 0x00DF, 0 }, { 226, 0x0393, 0 },
     1087 +        { 227, 0x03C0, 0 }, { 228, 0x03A3, 0 }, { 229, 0x03C3, 0 },
     1088 +        { 230, 0x00B5, 0 }, { 231, 0x03C4, 0 }, { 232, 0x03A6, 0 },
     1089 +        { 233, 0x0398, 0 }, { 234, 0x03A9, 0 }, { 235, 0x03B4, 0 },
     1090 +        { 236, 0x221E, 0 }, { 237, 0x03C6, 0 }, { 238, 0x03B5, 0 },
     1091 +        { 239, 0x2229, 0 }, { 240, 0x2261, 0 }, { 241, 0x00B1, 0 },
     1092 +        { 242, 0x2265, 0 }, { 243, 0x2264, 0 }, { 244, 0x2320, 1 },
     1093 +        { 246, 0x00F7, 0 }, { 247, 0x2248, 0 }, { 248, 0x00B0, 0 },
     1094 +        { 249, 0x2219, 0 }, { 250, 0x00B7, 0 }, { 251, 0x221A, 0 },
     1095 +        { 252, 0x207F, 0 }, { 253, 0x00B2, 0 }, { 254, 0x25A0, 0 },
     1096 +        { 255, 0x00A0, 0 }
     1097 +};
     1098 +
     1099 +static uint16_t
     1100 +vga_cp437_to_uni(uint8_t c)
     1101 +{
     1102 +        int min, mid, max;
     1103 +
     1104 +        min = 0;
     1105 +        max = (sizeof(cp437unitable) / sizeof(struct cp437uni)) - 1;
     1106 +
     1107 +        if (c < cp437unitable[0].cp437_base ||
     1108 +            c > cp437unitable[max].cp437_base + cp437unitable[max].length)
     1109 +                return ('?');
     1110 +
     1111 +        while (max >= min) {
     1112 +                mid = (min + max) / 2;
     1113 +                if (c < cp437unitable[mid].cp437_base)
     1114 +                        max = mid - 1;
     1115 +                else if (c > cp437unitable[mid].cp437_base +
     1116 +                    cp437unitable[mid].length)
     1117 +                        min = mid + 1;
     1118 +                else
     1119 +                        return (c - cp437unitable[mid].cp437_base +
     1120 +                            cp437unitable[mid].unicode_base);
     1121 +        }
     1122 +
     1123 +        return ('?');
     1124 +}
     1125 +
1182 1126  static void
1183      -vgatext_setfont(struct vgatext_softc *softc)
     1127 +vgatext_setfont(struct gfxp_fb_softc *softc)
1184 1128  {
1185      -        unsigned char *from;
1186      -        unsigned char *to;
1187      -        int     i;
1188      -        int     j;
1189      -        int     bpc;
     1129 +        union gfx_console *console = softc->console;
     1130 +        static uchar_t fsreg[8] = {0x0, 0x30, 0x5, 0x35, 0xa, 0x3a, 0xf, 0x3f};
1190 1131  
1191      -/*
1192      - * The newboot code to use font plane 2 breaks NVIDIA
1193      - * (and some ATI) behavior.  Revert back to the S10
1194      - * code.
1195      - */
     1132 +        const uchar_t *from;
     1133 +        uchar_t volatile *to;
     1134 +        uint16_t c;
     1135 +        int     i, j, s;
     1136 +        int     bpc, f_offset;
1196 1137  
     1138 +        /* Sync-reset the sequencer registers */
     1139 +        vga_set_seq(&console->vga.regs, 0x00, 0x01);
1197 1140          /*
1198      -         * I'm embarassed to say that I don't know what these magic
1199      -         * sequences do, other than at the high level of "set the
1200      -         * memory window to allow font setup".  I stole them straight
1201      -         * from "kd"...
     1141 +         *  enable write to plane2, since fonts
     1142 +         * could only be loaded into plane2
1202 1143           */
1203      -        vga_set_seq(&softc->regs, 0x02, 0x04);
1204      -        vga_set_seq(&softc->regs, 0x04, 0x06);
1205      -        vga_set_grc(&softc->regs, 0x05, 0x00);
1206      -        vga_set_grc(&softc->regs, 0x06, 0x04);
     1144 +        vga_set_seq(&console->vga.regs, 0x02, 0x04);
     1145 +        /*
     1146 +         *  sequentially access data in the bit map being
     1147 +         * selected by MapMask register (index 0x02)
     1148 +         */
     1149 +        vga_set_seq(&console->vga.regs, 0x04, 0x07);
     1150 +        /* Sync-reset ended, and allow the sequencer to operate */
     1151 +        vga_set_seq(&console->vga.regs, 0x00, 0x03);
1207 1152  
1208 1153          /*
     1154 +         *  select plane 2 on Read Mode 0
     1155 +         */
     1156 +        vga_set_grc(&console->vga.regs, 0x04, 0x02);
     1157 +        /*
     1158 +         *  system addresses sequentially access data, follow
     1159 +         * Memory Mode register bit 2 in the sequencer
     1160 +         */
     1161 +        vga_set_grc(&console->vga.regs, 0x05, 0x00);
     1162 +        /*
     1163 +         * set range of host memory addresses decoded by VGA
     1164 +         * hardware -- A0000h-BFFFFh (128K region)
     1165 +         */
     1166 +        vga_set_grc(&console->vga.regs, 0x06, 0x00);
     1167 +
     1168 +        /*
1209 1169           * This assumes 8x16 characters, which yield the traditional 80x25
1210 1170           * screen.  It really should support other character heights.
1211 1171           */
1212 1172          bpc = 16;
     1173 +        s = console->vga.vga_fontslot;
     1174 +        f_offset = s * 8 * 1024;
1213 1175          for (i = 0; i < 256; i++) {
1214      -                from = font_data_8x16.encoding[i];
1215      -                to = (unsigned char *)softc->fb.addr + i * 0x20;
     1176 +                c = vga_cp437_to_uni(i);
     1177 +                from = font_lookup(font_data_8x16.font, c);
     1178 +                to = (unsigned char *)console->vga.fb.addr + f_offset +
     1179 +                    i * 0x20;
1216 1180                  for (j = 0; j < bpc; j++)
1217 1181                          *to++ = *from++;
1218 1182          }
1219 1183  
1220      -        vga_set_seq(&softc->regs, 0x02, 0x03);
1221      -        vga_set_seq(&softc->regs, 0x04, 0x02);
1222      -        vga_set_grc(&softc->regs, 0x04, 0x00);
1223      -        vga_set_grc(&softc->regs, 0x05, 0x10);
1224      -        vga_set_grc(&softc->regs, 0x06, 0x0e);
     1184 +        /* Sync-reset the sequencer registers */
     1185 +        vga_set_seq(&console->vga.regs, 0x00, 0x01);
     1186 +        /* enable write to plane 0 and 1 */
     1187 +        vga_set_seq(&console->vga.regs, 0x02, 0x03);
     1188 +        /*
     1189 +         * enable character map selection
     1190 +         * and odd/even addressing
     1191 +         */
     1192 +        vga_set_seq(&console->vga.regs, 0x04, 0x03);
     1193 +        /*
     1194 +         * select font map
     1195 +         */
     1196 +        vga_set_seq(&console->vga.regs, 0x03, fsreg[s]);
     1197 +        /* Sync-reset ended, and allow the sequencer to operate */
     1198 +        vga_set_seq(&console->vga.regs, 0x00, 0x03);
1225 1199  
     1200 +        /* restore graphic registers */
     1201 +
     1202 +        /* select plane 0 */
     1203 +        vga_set_grc(&console->vga.regs, 0x04, 0x00);
     1204 +        /* enable odd/even addressing mode */
     1205 +        vga_set_grc(&console->vga.regs, 0x05, 0x10);
     1206 +        /*
     1207 +         * range of host memory addresses decoded by VGA
     1208 +         * hardware -- B8000h-BFFFFh (32K region)
     1209 +         */
     1210 +        vga_set_grc(&console->vga.regs, 0x06, 0x0e);
     1211 +        /* enable all color plane */
     1212 +        vga_set_atr(&console->vga.regs, 0x12, 0x0f);
     1213 +
1226 1214  }
1227 1215  
     1216 +int
     1217 +/*ARGSUSED*/
     1218 +gfxp_vga_scrnmap(int cmd, intptr_t data, int mode, struct gfxp_fb_softc *softc)
     1219 +{
     1220 +        return (ENXIO);
     1221 +}
     1222 +
1228 1223  static void
1229      -vgatext_save_colormap(struct vgatext_softc *softc)
     1224 +vgatext_save_colormap(struct gfxp_fb_softc *softc)
1230 1225  {
     1226 +        union gfx_console *console = softc->console;
1231 1227          int i;
1232 1228  
1233 1229          for (i = 0; i < VGA_ATR_NUM_PLT; i++) {
1234      -                softc->attrib_palette[i] = vga_get_atr(&softc->regs, i);
     1230 +                console->vga.attrib_palette[i] =
     1231 +                    vga_get_atr(&console->vga.regs, i);
1235 1232          }
1236 1233          for (i = 0; i < VGA8_CMAP_ENTRIES; i++) {
1237      -                vga_get_cmap(&softc->regs, i,
1238      -                    &softc->colormap[i].red,
1239      -                    &softc->colormap[i].green,
1240      -                    &softc->colormap[i].blue);
     1234 +                vga_get_cmap(&console->vga.regs, i,
     1235 +                    &console->vga.colormap[i].red,
     1236 +                    &console->vga.colormap[i].green,
     1237 +                    &console->vga.colormap[i].blue);
1241 1238          }
1242 1239  }
1243 1240  
1244 1241  static void
1245      -vgatext_restore_colormap(struct vgatext_softc *softc)
     1242 +vgatext_restore_colormap(struct gfxp_fb_softc *softc)
1246 1243  {
     1244 +        union gfx_console *console = softc->console;
1247 1245          int i;
1248 1246  
1249 1247          for (i = 0; i < VGA_ATR_NUM_PLT; i++) {
1250      -                vga_set_atr(&softc->regs, i, softc->attrib_palette[i]);
     1248 +                vga_set_atr(&console->vga.regs, i,
     1249 +                    console->vga.attrib_palette[i]);
1251 1250          }
1252 1251          for (i = 0; i < VGA8_CMAP_ENTRIES; i++) {
1253      -                vga_put_cmap(&softc->regs, i,
1254      -                    softc->colormap[i].red,
1255      -                    softc->colormap[i].green,
1256      -                    softc->colormap[i].blue);
     1252 +                vga_put_cmap(&console->vga.regs, i,
     1253 +                    console->vga.colormap[i].red,
     1254 +                    console->vga.colormap[i].green,
     1255 +                    console->vga.colormap[i].blue);
1257 1256          }
1258 1257  }
1259 1258  
1260 1259  /*
1261 1260   * search the entries of the "reg" property for one which has the desired
1262 1261   * combination of phys_hi bits and contains the desired address.
1263 1262   *
1264 1263   * This version searches a PCI-style "reg" property.  It was prompted by
1265 1264   * issues surrounding the presence or absence of an entry for the ROM:
1266 1265   * (a) a transition problem with PowerPC Virtual Open Firmware
↓ open down ↓ 100 lines elided ↑ open up ↑
1367 1366  
1368 1367          return (-1);
1369 1368  }
1370 1369  
1371 1370  /*
1372 1371   * This vgatext function is used to return the fb, and reg pointers
1373 1372   * and handles for peer graphics drivers.
1374 1373   */
1375 1374  
1376 1375  void
1377      -vgatext_return_pointers(struct vgatext_softc *softc, struct vgaregmap *fbs,
     1376 +vgatext_return_pointers(struct gfxp_fb_softc *softc, struct vgaregmap *fbs,
1378 1377      struct vgaregmap *regss)
1379 1378  {
1380 1379  
1381      -        fbs->addr       = softc->fb.addr;
1382      -        fbs->handle     = softc->fb.handle;
1383      -        fbs->mapped     = softc->fb.mapped;
1384      -        regss->addr     = softc->regs.addr;
1385      -        regss->handle   = softc->regs.handle;
1386      -        regss->mapped   = softc->regs.mapped;
1387      -}
1388      -
1389      -
1390      -/*
1391      - * ****************************************************************
1392      - * If we had a "bitmap" console implementation, it could
1393      - * use the functions below to cooperate with DRM.
1394      - */
1395      -
1396      -
1397      -/*
1398      - * If we had "bitmap" console support, this would
1399      - * register call-back functions: drm_gfxp_setmode,
1400      - * (and maybe others for blt, copy, clear) for the
1401      - * "bitmap" console to use.
1402      - *
1403      - * The current (text) console doesn't need it.
1404      - */
1405      -/* ARGSUSED */
1406      -void
1407      -gfxp_bm_register_fbops(gfxp_fb_softc_ptr_t softc,
1408      -    struct gfxp_blt_ops *ops)
1409      -{
1410      -}
1411      -
1412      -/*
1413      - * This is patchable with mdb, i.e.:
1414      - *      $ mdb -w /platform/i86pc/kernel/misc/amd64/gfx_private
1415      - *      > gfxp_fb_info?ddVV
1416      - *      1024    768     32      24
1417      - */
1418      -struct gfxp_bm_fb_info gfxp_fb_info = {
1419      -        .xres = 1024,
1420      -        .yres = 768,
1421      -        .bpp = 32,
1422      -        .depth = 24,
1423      -};
1424      -
1425      -/*
1426      - * If we had "bitmap" console support, this would
1427      - * ask the size of it. (how is TBD)
1428      - *
1429      - * Just guess (for now)
1430      - */
1431      -void
1432      -gfxp_bm_getfb_info(gfxp_fb_softc_ptr_t softc,
1433      -    struct gfxp_bm_fb_info *fbip)
1434      -{
1435      -        _NOTE(ARGUNUSED(softc))
1436      -
1437      -        *fbip = gfxp_fb_info;
     1380 +        fbs->addr       = softc->console->vga.fb.addr;
     1381 +        fbs->handle     = softc->console->vga.fb.handle;
     1382 +        fbs->mapped     = softc->console->vga.fb.mapped;
     1383 +        regss->addr     = softc->console->vga.regs.addr;
     1384 +        regss->handle   = softc->console->vga.regs.handle;
     1385 +        regss->mapped   = softc->console->vga.regs.mapped;
1438 1386  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX