Example #1
0
static void
vbe_104f00(struct bregs *regs)
{
    u16 seg = regs->es;
    struct vbe_info *info = (void*)(regs->di+0);

    if (GET_FARVAR(seg, info->signature) == VBE2_SIGNATURE) {
        dprintf(4, "Get VBE Controller: VBE2 Signature found\n");
    } else if (GET_FARVAR(seg, info->signature) == VESA_SIGNATURE) {
        dprintf(4, "Get VBE Controller: VESA Signature found\n");
    } else {
        dprintf(4, "Get VBE Controller: Invalid Signature\n");
    }

    memset_far(seg, info, 0, sizeof(*info));

    SET_FARVAR(seg, info->signature, VESA_SIGNATURE);

    SET_FARVAR(seg, info->version, 0x0300);

    SET_FARVAR(seg, info->oem_string,
            SEGOFF(get_global_seg(), (u32)VBE_OEM_STRING));
    SET_FARVAR(seg, info->capabilities, GET_GLOBAL(VBE_capabilities));

    /* We generate our mode list in the reserved field of the info block */
    u16 *destmode = (void*)info->reserved;
    SET_FARVAR(seg, info->video_mode, SEGOFF(seg, (u32)destmode));

    /* Total memory (in 64k blocks) */
    SET_FARVAR(seg, info->total_memory
               , GET_GLOBAL(VBE_total_memory) / (64*1024));

    SET_FARVAR(seg, info->oem_vendor_string,
            SEGOFF(get_global_seg(), (u32)VBE_VENDOR_STRING));
    SET_FARVAR(seg, info->oem_product_string,
            SEGOFF(get_global_seg(), (u32)VBE_PRODUCT_STRING));
    SET_FARVAR(seg, info->oem_revision_string,
            SEGOFF(get_global_seg(), (u32)VBE_REVISION_STRING));

    /* Fill list of modes */
    u16 *last = (void*)&info->reserved[sizeof(info->reserved)];
    vgahw_list_modes(seg, destmode, last - 1);

    regs->ax = 0x004f;
}
Example #2
0
static void
vbe_104f01(struct bregs *regs)
{
    u16 seg = regs->es;
    struct vbe_mode_info *info = (void*)(regs->di+0);
    u16 mode = regs->cx;

    dprintf(1, "VBE mode info request: %x\n", mode);

    struct vgamode_s *vmode_g = vgahw_find_mode(mode & ~MF_VBEFLAGS);
    if (! vmode_g) {
        dprintf(1, "VBE mode %x not found\n", mode);
        regs->ax = 0x014f;
        return;
    }

    memset_far(seg, info, 0, sizeof(*info));

    // Basic information about video controller.
    u32 win_granularity = GET_GLOBAL(VBE_win_granularity);
    SET_FARVAR(seg, info->winA_attributes,
               (win_granularity ? VBE_WINDOW_ATTRIBUTE_RELOCATABLE : 0) |
               VBE_WINDOW_ATTRIBUTE_READABLE |
               VBE_WINDOW_ATTRIBUTE_WRITEABLE);
    SET_FARVAR(seg, info->winB_attributes, 0);
    SET_FARVAR(seg, info->win_granularity, win_granularity);
    SET_FARVAR(seg, info->win_size, 64); /* Bank size 64K */
    SET_FARVAR(seg, info->winA_seg, GET_GLOBAL(vmode_g->sstart));
    SET_FARVAR(seg, info->winB_seg, 0x0);
    extern void entry_104f05(void);
    SET_FARVAR(seg, info->win_func_ptr
               , SEGOFF(get_global_seg(), (u32)entry_104f05));
    // Basic information about mode.
    int width = GET_GLOBAL(vmode_g->width);
    int height = GET_GLOBAL(vmode_g->height);
    int linesize = DIV_ROUND_UP(width * vga_bpp(vmode_g), 8);
    SET_FARVAR(seg, info->bytes_per_scanline, linesize);
    SET_FARVAR(seg, info->xres, width);
    SET_FARVAR(seg, info->yres, height);
    SET_FARVAR(seg, info->xcharsize, GET_GLOBAL(vmode_g->cwidth));
    SET_FARVAR(seg, info->ycharsize, GET_GLOBAL(vmode_g->cheight));
    int depth = GET_GLOBAL(vmode_g->depth);
    SET_FARVAR(seg, info->bits_per_pixel, depth);
    u8 memmodel = GET_GLOBAL(vmode_g->memmodel);
    SET_FARVAR(seg, info->mem_model, memmodel);
    SET_FARVAR(seg, info->reserved0, 1);

    // Mode specific info.
    u16 mode_attr = VBE_MODE_ATTRIBUTE_SUPPORTED |
                    VBE_MODE_ATTRIBUTE_EXTENDED_INFORMATION_AVAILABLE |
                    VBE_MODE_ATTRIBUTE_COLOR_MODE |
                    VBE_MODE_ATTRIBUTE_GRAPHICS_MODE |
                    VBE_MODE_ATTRIBUTE_NOT_VGA_COMPATIBLE;
    u32 framebuffer = 0;
    int planes = 1, banks = 1;
    u32 pages = GET_GLOBAL(VBE_total_memory) / ALIGN(height * linesize, 64*1024);
    switch (memmodel) {
    case MM_TEXT:
        mode_attr &= ~VBE_MODE_ATTRIBUTE_GRAPHICS_MODE;
        mode_attr |= VBE_MODE_ATTRIBUTE_TTY_BIOS_SUPPORT;
        if (GET_GLOBAL(vmode_g->sstart) == SEG_MTEXT)
            mode_attr &= ~VBE_MODE_ATTRIBUTE_COLOR_MODE;
        pages = 1;
        break;
    case MM_CGA:
        pages = 1;
        banks = 2;
        SET_FARVAR(seg, info->bank_size, 8);
        break;
    case MM_PLANAR:
        planes = 4;
        pages /= 4;
        break;
    default:
        framebuffer = GET_GLOBAL(VBE_framebuffer);
        if (framebuffer)
            mode_attr |= VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE;
        break;
    }
    SET_FARVAR(seg, info->mode_attributes, mode_attr);
    SET_FARVAR(seg, info->planes, planes);
    SET_FARVAR(seg, info->pages, pages - 1);
    SET_FARVAR(seg, info->banks, banks);

    // Pixel color breakdown
    u8 r_size, r_pos, g_size, g_pos, b_size, b_pos, a_size, a_pos;
    switch (depth) {
    case 15: r_size = 5; r_pos = 10; g_size = 5; g_pos = 5;
             b_size = 5; b_pos = 0; a_size = 1; a_pos = 15; break;
    case 16: r_size = 5; r_pos = 11; g_size = 6; g_pos = 5;
             b_size = 5; b_pos = 0; a_size = 0; a_pos = 0; break;
    case 24: r_size = 8; r_pos = 16; g_size = 8; g_pos = 8;
             b_size = 8; b_pos = 0; a_size = 0; a_pos = 0; break;
    case 32: r_size = 8; r_pos = 16; g_size = 8; g_pos = 8;
             b_size = 8; b_pos = 0; a_size = 8; a_pos = 24;
             SET_FARVAR(seg, info->directcolor_info,
                        VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE);
             break;
    default: r_size = 0; r_pos = 0; g_size = 0; g_pos = 0;
             b_size = 0; b_pos = 0; a_size = 0; a_pos = 0; break;
    }
    SET_FARVAR(seg, info->red_size, r_size);
    SET_FARVAR(seg, info->red_pos, r_pos);
    SET_FARVAR(seg, info->green_size, g_size);
    SET_FARVAR(seg, info->green_pos, g_pos);
    SET_FARVAR(seg, info->blue_size, b_size);
    SET_FARVAR(seg, info->blue_pos, b_pos);
    SET_FARVAR(seg, info->alpha_size, a_size);
    SET_FARVAR(seg, info->alpha_pos, a_pos);

    // Linear framebuffer info.
    if (framebuffer) {
        SET_FARVAR(seg, info->phys_base, framebuffer);

        SET_FARVAR(seg, info->reserved1, 0);
        SET_FARVAR(seg, info->reserved2, 0);
        SET_FARVAR(seg, info->linear_bytes_per_scanline, linesize);
        SET_FARVAR(seg, info->linear_pages, 0);
        SET_FARVAR(seg, info->linear_red_size, r_size);
        SET_FARVAR(seg, info->linear_red_pos, r_pos);
        SET_FARVAR(seg, info->linear_green_size, g_size);
        SET_FARVAR(seg, info->linear_green_pos, g_pos);
        SET_FARVAR(seg, info->linear_blue_size, b_size);
        SET_FARVAR(seg, info->linear_blue_pos, b_pos);
        SET_FARVAR(seg, info->linear_alpha_size, a_size);
        SET_FARVAR(seg, info->linear_alpha_pos, a_pos);
    }

    regs->ax = 0x004f;
}
Example #3
0
static inline void
memset_stride(u16 seg, void *dst, u8 val, int setlen, int stride, int lines)
{
    for (; lines; lines--, dst+=stride)
        memset_far(seg, dst, val, setlen);
}