diff -rubB --new-file base-sys/conf/files.ia64 sys/conf/files.ia64 --- base-sys/conf/files.ia64 2010-02-06 15:16:40.000000000 +0000 +++ sys/conf/files.ia64 2010-02-06 15:20:46.000000000 +0000 @@ -59,6 +59,7 @@ dev/syscons/scterm-teken.c optional sc dev/syscons/scvgarndr.c optional sc vga dev/syscons/scvtb.c optional sc +dev/syscons/scnewvga.c optional scnewvga dev/uart/uart_cpu_ia64.c optional uart dev/acpica/acpi_if.m standard ia64/acpica/OsdEnvironment.c optional acpi diff -rubB --new-file base-sys/dev/syscons/scnewvga.c sys/dev/syscons/scnewvga.c --- base-sys/dev/syscons/scnewvga.c 1970-01-01 00:00:00.000000000 +0000 +++ sys/dev/syscons/scnewvga.c 2010-02-07 11:24:38.000000000 +0000 @@ -0,0 +1,615 @@ +/*- + * Copyright (c) 2009, 2010 Rink Springer + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer as + * the first lines of this file unmodified. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct newvga_softc { + video_adapter_t sc_va; + + bus_space_tag_t mem_bst; + bus_space_handle_t mem_bsh; + + bus_space_tag_t io_bst; + bus_space_handle_t io_bsh; +}; + +#define MEM_WRITE(sc, ofs, val) \ + bus_space_write_1(sc->mem_bst, sc->mem_bsh, ofs, val) +#define IO_WRITE(sc, ofs, val) \ + bus_space_write_1(sc->io_bst, sc->io_bsh, ofs, val) + +static struct newvga_softc newvga_sc; /* XXX */ + +static vi_probe_t newvga_probe; +static vi_init_t newvga_init; +static vi_get_info_t newvga_get_info; +static vi_query_mode_t newvga_query_mode; +static vi_set_mode_t newvga_set_mode; +static vi_save_font_t newvga_save_font; +static vi_load_font_t newvga_load_font; +static vi_show_font_t newvga_show_font; +static vi_save_palette_t newvga_save_palette; +static vi_load_palette_t newvga_load_palette; +static vi_set_border_t newvga_set_border; +static vi_save_state_t newvga_save_state; +static vi_load_state_t newvga_load_state; +static vi_set_win_org_t newvga_set_win_org; +static vi_read_hw_cursor_t newvga_read_hw_cursor; +static vi_set_hw_cursor_t newvga_set_hw_cursor; +static vi_set_hw_cursor_shape_t newvga_set_hw_cursor_shape; +static vi_blank_display_t newvga_blank_display; +static vi_mmap_t newvga_mmap; +static vi_ioctl_t newvga_ioctl; +static vi_clear_t newvga_clear; +static vi_fill_rect_t newvga_fill_rect; +static vi_bitblt_t newvga_bitblt; +static vi_diag_t newvga_diag; +static vi_save_cursor_palette_t newvga_save_cursor_palette; +static vi_load_cursor_palette_t newvga_load_cursor_palette; +static vi_copy_t newvga_copy; +static vi_putp_t newvga_putp; +static vi_putc_t newvga_putc; +static vi_puts_t newvga_puts; +static vi_putm_t newvga_putm; + +static video_switch_t newvgavidsw = { + .probe = newvga_probe, + .init = newvga_init, + .get_info = newvga_get_info, + .query_mode = newvga_query_mode, + .set_mode = newvga_set_mode, + .save_font = newvga_save_font, + .load_font = newvga_load_font, + .show_font = newvga_show_font, + .save_palette = newvga_save_palette, + .load_palette = newvga_load_palette, + .set_border = newvga_set_border, + .save_state = newvga_save_state, + .load_state = newvga_load_state, + .set_win_org = newvga_set_win_org, + .read_hw_cursor = newvga_read_hw_cursor, + .set_hw_cursor = newvga_set_hw_cursor, + .set_hw_cursor_shape = newvga_set_hw_cursor_shape, + .blank_display = newvga_blank_display, + .mmap = newvga_mmap, + .ioctl = newvga_ioctl, + .clear = newvga_clear, + .fill_rect = newvga_fill_rect, + .bitblt = newvga_bitblt, + NULL, + NULL, + .diag = newvga_diag, + .save_cursor_palette = newvga_save_cursor_palette, + .load_cursor_palette = newvga_load_cursor_palette, + .copy = newvga_copy, + .putp = newvga_putp, + .putc = newvga_putc, + .puts = newvga_puts, + .putm = newvga_putm +}; + +static int newvga_configure(int flags); +VIDEO_DRIVER(newvga, newvgavidsw, newvga_configure); + +static vr_init_t vgar_init; +static vr_clear_t vgar_clear; +static vr_draw_border_t vgar_draw_border; +static vr_draw_t vgar_draw; +static vr_set_cursor_t vgar_set_cursor; +static vr_draw_cursor_t vgar_draw_cursor; +static vr_blink_cursor_t vgar_blink_cursor; +static vr_set_mouse_t vgar_set_mouse; +static vr_draw_mouse_t vgar_draw_mouse; + +/* + * We use our own renderer; this is because we must emulate a hardware + * cursor. + */ +static sc_rndr_sw_t vgarend = { + vgar_init, + vgar_clear, + vgar_draw_border, + vgar_draw, + vgar_set_cursor, + vgar_draw_cursor, + vgar_blink_cursor, + vgar_set_mouse, + vgar_draw_mouse +}; +RENDERER(newvga, 0, vgarend, newvga_set); +RENDERER_MODULE(nvga, newvga_set); + +#define VGA_MEM_BASE 0xb8000 +#define VGA_REG_BASE 0x3c0 + +static int +newvga_get_resources(struct newvga_softc* sc) +{ +#if defined(__ia64__) + sc->mem_bst = IA64_BUS_SPACE_MEM; + sc->mem_bsh = IA64_PHYS_TO_RR6(VGA_MEM_BASE); + sc->io_bst = IA64_BUS_SPACE_IO; + sc->io_bsh = VGA_REG_BASE; +#elif defined(__amd64__) + sc->mem_bst = AMD64_BUS_SPACE_MEM; + sc->mem_bsh = KERNBASE + VGA_MEM_BASE; + sc->io_bst = AMD64_BUS_SPACE_IO; + sc->io_bsh = VGA_REG_BASE; +#elif defined(__i386__) + sc->mem_bst = I386_BUS_SPACE_MEM; + sc->mem_bsh = KERNBASE + VGA_MEM_BASE; + sc->io_bst = I386_BUS_SPACE_IO; + sc->io_bsh = VGA_REG_BASE; +#else + #error Implement this architecture! +#endif + return 1; +} + +static int +newvga_init(int unit, video_adapter_t* adp, int flags) +{ + struct newvga_softc* sc = &newvga_sc; + video_info_t* vi; + vi = &adp->va_info; + + vid_init_struct (adp, "newvga", KD_VGA, unit); + if (!(adp->va_flags & V_ADP_INITIALIZED)) { + /* + * Map the framebuffer and I/O ports; this is being done in + * quite a crude way, since the bus we are attaching to (nexus) + * may not have the resources we are looking for. Since the address + * we bind to is always fixed, just forcibly grabbing the resources + * shouldn't hurt (much) + */ + if (!newvga_get_resources(sc)) + return (ENXIO); + + /* + * This is needed because scinit() attempts to copy the + * current framebuffer and uses adp->va_window as base + * address. + */ + adp->va_window = sc->mem_bsh; + + /* Clear the screen while we are at it */ + bzero_io((void *)adp->va_window, 80 * 25 * 2); + + /* + * XXX hide the cursor; we assume the user wants our + * block-cursor. + */ + IO_WRITE(sc, 0x14, 14); IO_WRITE(sc, 0x15, 0xff); + IO_WRITE(sc, 0x14, 15); IO_WRITE(sc, 0x15, 0xff); + + /* don't ever do this again! */ + adp->va_flags |= V_ADP_INITIALIZED; + } + + vi->vi_mode = M_TEXT_80x25; + vi->vi_cwidth = 8; + vi->vi_cheight = 116; + vi->vi_height = 25; + vi->vi_width = 80; + vi->vi_depth = 4; + vi->vi_planes = 1; + vi->vi_flags = V_INFO_COLOR; + vi->vi_mem_model = V_INFO_MM_TEXT; + adp->va_flags |= V_ADP_COLOR; + + if (vid_register(adp) < 0) + return (ENXIO); + + adp->va_flags |= V_ADP_REGISTERED; + + return 0; +} + +static int +newvga_probe(int unit, video_adapter_t** adp, void* arg, int flags) +{ + return 0; +} + +static int +newvga_configure(int flags) +{ + struct newvga_softc* sc = &newvga_sc; + + if (!(flags & VIO_PROBE_ONLY)) + return 1; + + /* + * XXX we should probe for a vga device; on ia64, this can be done + * by checking whether the memory map has hardware mappings for + * memory 0xb8000 and i/o port 0x3c0. + * + * XXX on i386/amd64, we can just look at the BIOS data segment. + */ + newvga_init(0, &sc->sc_va, 0); + return 1; +} + +static void +newvga_sc_identify(driver_t* driver, device_t parent) +{ + BUS_ADD_CHILD(parent, INT_MAX, SC_DRIVER_NAME, 0); +} + +static int +newvga_sc_probe(device_t dev) +{ + device_set_desc(dev, "VGA system console"); + return (sc_probe_unit(device_get_unit(dev), device_get_flags(dev) | SC_AUTODETECT_KBD)); +} + +static int +newvga_sc_attach(device_t dev) +{ + return (sc_attach_unit(device_get_unit(dev), device_get_flags(dev) | SC_AUTODETECT_KBD)); +} + +static device_method_t newvga_sc_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, newvga_sc_identify), + DEVMETHOD(device_probe, newvga_sc_probe), + DEVMETHOD(device_attach, newvga_sc_attach), + { 0, 0 } +}; + +static driver_t newvga_sc_driver = { + SC_DRIVER_NAME, + newvga_sc_methods, + sizeof(sc_softc_t) +}; + +static devclass_t sc_devclass; + +/* + * We must attach to the nexus bus, since that's the only bus we know will be + * available. + */ +DRIVER_MODULE(sc, nexus, newvga_sc_driver, sc_devclass, 0, 0); + +static void +vgar_init(scr_stat* scp) +{ +} + +static void +vgar_clear(scr_stat* scp, int c, int attr) +{ + sc_vtb_clear(&scp->scr, c, attr); +} + +static void +vgar_draw_border(scr_stat* scp, int color) +{ + vidd_set_border(scp->sc->adp, color); +} + +static void +vgar_draw(scr_stat* scp, int from, int count, int flip) +{ + video_adapter_t* adp = scp->sc->adp; + int i, c, a; + + if (!flip) { + /* Normal printing */ + vidd_puts(adp, from, (uint16_t*)sc_vtb_pointer(&scp->vtb, from), count); + } else { + /* This is for selections and such: invert the color attribute */ + for (i = count; i-- > 0; ++from) { + c = sc_vtb_getc(&scp->vtb, from); + a = sc_vtb_geta(&scp->vtb, from) >> 8; + vidd_putc(adp, from, c, (a >> 4) | ((a & 0xf) << 4)); + } + } +} + +static void +vgar_set_cursor(scr_stat* scp, int base, int height, int blink) +{ + if (base <= 0 || base >= scp->font_size); + return; + vidd_set_hw_cursor_shape(scp->sc->adp, base, height, + scp->font_size, blink); +} + +static void +vgar_draw_cursor(scr_stat* scp, int at, int blink, int on, int flip) +{ + video_adapter_t *adp; + int a, c; + + if (scp->curs_attr.height <= 0) + return; + + adp = scp->sc->adp; + if(blink) { + /* XXX unsupported */ + } else { + if(on) { + scp->status |= VR_CURSOR_ON; + vidd_putc(scp->sc->adp, scp->cursor_oldpos, + sc_vtb_getc(&scp->vtb, scp->cursor_oldpos), + sc_vtb_geta(&scp->vtb, scp->cursor_oldpos) >> 8); + a = sc_vtb_geta(&scp->vtb, at) >> 8; + c = sc_vtb_getc(&scp->vtb, at); + vidd_putc(scp->sc->adp, at, c, + (a >> 4) | ((a & 0xf) << 4)); + scp->cursor_saveunder_attr = a; + scp->cursor_saveunder_char = c; + } else { + if (scp->status & VR_CURSOR_ON) + vidd_putc(scp->sc->adp, at, + scp->cursor_saveunder_char, + scp->cursor_saveunder_attr); + scp->status &= ~VR_CURSOR_ON; + } + } + +} + +static void +vgar_blink_cursor(scr_stat* scp, int at, int flip) +{ +} + +static void +vgar_set_mouse(scr_stat* scp) +{ +} + +static void +vgar_draw_mouse(scr_stat* scp, int x, int y, int on) +{ + /* TODO */ +} + +static int +newvga_get_info(video_adapter_t *adp, int mode, video_info_t *info) +{ + bcopy(&adp->va_info, info, sizeof(*info)); + return (0); +} + +static int +newvga_query_mode(video_adapter_t *adp, video_info_t *info) +{ + return (ENODEV); +} + +static int +newvga_set_mode(video_adapter_t *adp, int mode) +{ + return (0); +} + +static int +newvga_save_font(video_adapter_t *adp, int page, int size, int width, + u_char *data, int c, int count) +{ + return (ENODEV); +} + +static int +newvga_load_font(video_adapter_t *adp, int page, int size, int width, + u_char *data, int c, int count) +{ + return (ENODEV); +} + +static int +newvga_show_font(video_adapter_t *adp, int page) +{ + return (ENODEV); +} + +static int +newvga_save_palette(video_adapter_t *adp, u_char *palette) +{ + return (ENODEV); +} + +static int +newvga_load_palette(video_adapter_t *adp, u_char *palette) +{ + return (ENODEV); +} + +static int +newvga_set_border(video_adapter_t *adp, int border) +{ + return (0); +} + +static int +newvga_save_state(video_adapter_t *adp, void *p, size_t size) +{ + return (ENODEV); +} + +static int +newvga_load_state(video_adapter_t *adp, void *p) +{ + return (ENODEV); +} + +static int +newvga_set_win_org(video_adapter_t *adp, off_t offset) +{ + return (ENODEV); +} + +static int +newvga_read_hw_cursor(video_adapter_t *adp, int *col, int *row) +{ + *col = 0; + *row = 0; + return (0); +} + +static int +newvga_set_hw_cursor(video_adapter_t *adp, int col, int row) +{ + return (ENODEV); +} + +static int +newvga_set_hw_cursor_shape(video_adapter_t *adp, int base, int height, + int celsize, int blink) +{ + return (ENODEV); +} + +static int +newvga_blank_display(video_adapter_t *adp, int mode) +{ + return (0); +} + +static int +newvga_mmap(video_adapter_t *adp, vm_ooffset_t offset, vm_paddr_t *paddr, + int prot, vm_memattr_t* memattr) +{ + return (EINVAL); +} + +static int +newvga_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data) +{ + return (fb_commonioctl(adp, cmd, data)); +} + +static int +newvga_clear(video_adapter_t *adp) +{ + return (0); +} + +static int +newvga_fill_rect(video_adapter_t *adp, int val, int x, int y, int cx, int cy) +{ + return (0); +} + +static int +newvga_bitblt(video_adapter_t *adp, ...) +{ + return (ENODEV); +} + +static int +newvga_diag(video_adapter_t *adp, int level) +{ + video_info_t info; + + fb_dump_adp_info(adp->va_name, adp, level); + newvga_get_info(adp, 0, &info); + fb_dump_mode_info(adp->va_name, adp, &info, level); + return (0); +} + +static int +newvga_save_cursor_palette(video_adapter_t *adp, u_char *palette) +{ + return (ENODEV); +} + +static int +newvga_load_cursor_palette(video_adapter_t *adp, u_char *palette) +{ + return (ENODEV); +} + +static int +newvga_copy(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst, int n) +{ + return (ENODEV); +} + +static int +newvga_putp(video_adapter_t *adp, vm_offset_t off, u_int32_t p, u_int32_t a, + int size, int bpp, int bit_ltor, int byte_ltor) +{ + return (ENODEV); +} + +static int +newvga_putc(video_adapter_t *adp, vm_offset_t off, u_int8_t c, u_int8_t a) +{ + struct newvga_softc* sc = &newvga_sc; + uint32_t row, col; + + /* calculate the position in the frame buffer */ + row = (off / adp->va_info.vi_width); + col = (off % adp->va_info.vi_width); + + MEM_WRITE(sc, (row * 160) + (col * 2) + 0, c); + MEM_WRITE(sc, (row * 160) + (col * 2) + 1, a); + return (0); +} + +static int +newvga_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len) +{ + int i; + + for (i = 0; i < len; i++) { + vidd_putc(adp, off + i, s[i] & 0xff, (s[i] & 0xff00) >> 8); + } + return (0); +} + +static int +newvga_putm(video_adapter_t *adp, int x, int y, u_int8_t *pixel_image, + u_int32_t pixel_mask, int size, int width) +{ + return (ENODEV); +} void diff -rubB --new-file base-sys/ia64/conf/NOTES sys/ia64/conf/NOTES --- base-sys/ia64/conf/NOTES 2010-02-06 15:16:23.000000000 +0000 +++ sys/ia64/conf/NOTES 2010-02-07 11:21:02.000000000 +0000 @@ -107,3 +107,9 @@ # The following devices are not supported. nodevice fdc nooption FDC_DEBUG + +# Use syscons(4) as console driver. This only supports VGA cards, +# and currently always assumes they are there. +device sc +device fb +device scnewvga