⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vbe.c

📁 xen虚拟机源代码安装包
💻 C
📖 第 1 页 / 共 3 页
字号:
        lfb_flag=using_lfb?VBE_DISPI_LFB_ENABLED:0;        no_clear=((BX & VBE_MODE_PRESERVE_DISPLAY_MEMORY) == VBE_MODE_PRESERVE_DISPLAY_MEMORY)?VBE_DISPI_NOCLEARMEM:0;        BX = (BX & 0x1ff);        //result=read_word(ss,AX);                // check for non vesa mode        if (BX<VBE_MODE_VESA_DEFINED)        {                Bit8u   mode;                                dispi_set_enable(VBE_DISPI_DISABLED);                // call the vgabios in order to set the video mode                // this allows for going back to textmode with a VBE call (some applications expect that to work)                                mode=(BX & 0xff);                biosfn_set_video_mode(mode);                result = 0x4f;        }                cur_info = mode_info_find_mode(BX, using_lfb, &cur_info);        if (cur_info != 0)        {#ifdef DEBUG                printf("VBE found mode %x, setting:\n", BX);                printf("\txres%x yres%x bpp%x\n",                        cur_info->info.XResolution,                        cur_info->info.YResolution,                        cur_info->info.BitsPerPixel);#endif                                // first disable current mode (when switching between vesa modi)                dispi_set_enable(VBE_DISPI_DISABLED);                if (cur_info->info.BitsPerPixel == 4)                {                  biosfn_set_video_mode(0x6a);                }                dispi_set_bpp(cur_info->info.BitsPerPixel);                dispi_set_xres(cur_info->info.XResolution);                dispi_set_yres(cur_info->info.YResolution);                dispi_set_bank(0);                dispi_set_enable(VBE_DISPI_ENABLED | no_clear | lfb_flag);                vga_compat_setup();                write_word(BIOSMEM_SEG,BIOSMEM_VBE_MODE,BX);                write_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL,(0x60 | no_clear));                result = 0x4f;                          }        else        {#ifdef DEBUG                printf("VBE *NOT* found mode %x\n" , BX);#endif                        result = 0x100;                                // FIXME: redirect non VBE modi to normal VGA bios operation                //        (switch back to VGA mode                if (BX == 3)                        result = 0x4f;        }        write_word(ss, AX, result);}/** Function 03h - Return Current VBE Mode *  * Input: *              AX      = 4F03h * Output: *              AX      = VBE Return Status *              BX      = Current VBE Mode *  */ASM_STARTvbe_biosfn_return_current_mode:  push ds  mov  ax, # BIOSMEM_SEG  mov  ds, ax  call dispi_get_enable  and  ax, # VBE_DISPI_ENABLED  jz   no_vbe_mode  mov  bx, # BIOSMEM_VBE_MODE  mov  ax, [bx]  mov  bx, ax  jnz  vbe_03_okno_vbe_mode:  mov  bx, # BIOSMEM_CURRENT_MODE  mov  al, [bx]  mov  bl, al  xor  bh, bhvbe_03_ok:  mov  ax, #0x004f  pop  ds  retASM_ENDBit16u vbe_biosfn_read_video_state_size(){    return 9 * 2;}void vbe_biosfn_save_video_state(ES, BX)     Bit16u ES; Bit16u BX;{    Bit16u enable, i;    outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);    enable = inw(VBE_DISPI_IOPORT_DATA);    write_word(ES, BX, enable);    BX += 2;    if (!(enable & VBE_DISPI_ENABLED))         return;    for(i = VBE_DISPI_INDEX_XRES; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) {        if (i != VBE_DISPI_INDEX_ENABLE) {            outw(VBE_DISPI_IOPORT_INDEX, i);            write_word(ES, BX, inw(VBE_DISPI_IOPORT_DATA));            BX += 2;        }    }}void vbe_biosfn_restore_video_state(ES, BX)     Bit16u ES; Bit16u BX;{    Bit16u enable, i;    enable = read_word(ES, BX);    BX += 2;        if (!(enable & VBE_DISPI_ENABLED)) {        outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);        outw(VBE_DISPI_IOPORT_DATA, enable);    } else {        outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES);        outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));        BX += 2;        outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES);        outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));        BX += 2;        outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);        outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));        BX += 2;        outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);        outw(VBE_DISPI_IOPORT_DATA, enable);        for(i = VBE_DISPI_INDEX_BANK; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) {            outw(VBE_DISPI_IOPORT_INDEX, i);            outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));            BX += 2;        }    }}/** Function 04h - Save/Restore State *  * Input: *              AX      = 4F04h *              DL      = 00h Return Save/Restore State buffer size *                        01h Save State *                        02h Restore State *              CX      = Requested states *              ES:BX   = Pointer to buffer (if DL <> 00h) * Output: *              AX      = VBE Return Status *              BX      = Number of 64-byte blocks to hold the state buffer (if DL=00h) *  */void vbe_biosfn_save_restore_state(AX, CX, DX, ES, BX)Bit16u *AX; Bit16u CX; Bit16u DX; Bit16u ES; Bit16u *BX;{    Bit16u ss=get_SS();    Bit16u result, val;    result = 0x4f;    switch(GET_DL()) {    case 0x00:        val = biosfn_read_video_state_size2(CX);#ifdef DEBUG        printf("VGA state size=%x\n", val);#endif        if (CX & 8)            val += vbe_biosfn_read_video_state_size();        write_word(ss, BX, val);        break;    case 0x01:        val = read_word(ss, BX);        val = biosfn_save_video_state(CX, ES, val);#ifdef DEBUG        printf("VGA save_state offset=%x\n", val);#endif        if (CX & 8)            vbe_biosfn_save_video_state(ES, val);        break;    case 0x02:        val = read_word(ss, BX);        val = biosfn_restore_video_state(CX, ES, val);#ifdef DEBUG        printf("VGA restore_state offset=%x\n", val);#endif        if (CX & 8)            vbe_biosfn_restore_video_state(ES, val);        break;    default:        // function failed        result = 0x100;        break;    }    write_word(ss, AX, result);}/** Function 05h - Display Window Control *  * Input: *              AX      = 4F05h *     (16-bit) BH      = 00h Set memory window *                      = 01h Get memory window *              BL      = Window number *                      = 00h Window A *                      = 01h Window B *              DX      = Window number in video memory in window *                        granularity units (Set Memory Window only) * Note: *              If this function is called while in a linear frame buffer mode, *              this function must fail with completion code AH=03h *  * Output: *              AX      = VBE Return Status *              DX      = Window number in window granularity units *                        (Get Memory Window only) */ASM_STARTvbe_biosfn_display_window_control:  cmp  bl, #0x00  jne  vbe_05_failed  cmp  bh, #0x01  je   get_display_window  jb   set_display_window  mov  ax, #0x0100  retset_display_window:  mov  ax, dx  call _dispi_set_bank  call dispi_get_bank  cmp  ax, dx  jne  vbe_05_failed  mov  ax, #0x004f  retget_display_window:  call dispi_get_bank  mov  dx, ax  mov  ax, #0x004f  retvbe_05_failed:  mov  ax, #0x014f  retASM_END/** Function 06h - Set/Get Logical Scan Line Length * * Input: *              AX      = 4F06h *              BL      = 00h Set Scan Line Length in Pixels *                      = 01h Get Scan Line Length *                      = 02h Set Scan Line Length in Bytes *                      = 03h Get Maximum Scan Line Length *              CX      = If BL=00h Desired Width in Pixels *                        If BL=02h Desired Width in Bytes *                        (Ignored for Get Functions) *  * Output:  *              AX      = VBE Return Status *              BX      = Bytes Per Scan Line *              CX      = Actual Pixels Per Scan Line *                        (truncated to nearest complete pixel) *              DX      = Maximum Number of Scan Lines  */ASM_STARTvbe_biosfn_set_get_logical_scan_line_length:  mov  ax, cx  cmp  bl, #0x01  je   get_logical_scan_line_length  cmp  bl, #0x02  je   set_logical_scan_line_bytes  jb   set_logical_scan_line_pixels  mov  ax, #0x0100  retset_logical_scan_line_bytes:  push ax  call dispi_get_bpp  xor  bh, bh  mov  bl, ah  or   bl, bl  jnz  no_4bpp_1  shl  ax, #3  mov  bl, #1no_4bpp_1:  xor  dx, dx  pop  ax  div  bxset_logical_scan_line_pixels:  call dispi_set_virt_widthget_logical_scan_line_length:  call dispi_get_bpp  xor  bh, bh  mov  bl, ah  call dispi_get_virt_width  mov  cx, ax  or   bl, bl  jnz  no_4bpp_2  shr  ax, #3  mov  bl, #1no_4bpp_2:  mul  bx  mov  bx, ax  call dispi_get_virt_height  mov  dx, ax  mov  ax, #0x004f  retASM_END/** Function 07h - Set/Get Display Start *  * Input(16-bit): *              AX      = 4F07h *              BH      = 00h Reserved and must be 00h *              BL      = 00h Set Display Start *                      = 01h Get Display Start *                      = 02h Schedule Display Start (Alternate) *                      = 03h Schedule Stereoscopic Display Start *                      = 04h Get Scheduled Display Start Status *                      = 05h Enable Stereoscopic Mode *                      = 06h Disable Stereoscopic Mode *                      = 80h Set Display Start during Vertical Retrace *                      = 82h Set Display Start during Vertical Retrace (Alternate) *                      = 83h Set Stereoscopic Display Start during Vertical Retrace *              ECX     = If BL=02h/82h Display Start Address in bytes *                        If BL=03h/83h Left Image Start Address in bytes *              EDX     = If BL=03h/83h Right Image Start Address in bytes *              CX      = If BL=00h/80h First Displayed Pixel In Scan Line *              DX      = If BL=00h/80h First Displayed Scan Line * * Output: *              AX      = VBE Return Status *              BH      = If BL=01h Reserved and will be 0 *              CX      = If BL=01h First Displayed Pixel In Scan Line *                        If BL=04h 0 if flip has not occurred, not 0 if it has *              DX      = If BL=01h First Displayed Scan Line * * Input(32-bit):  *              BH      = 00h Reserved and must be 00h *              BL      = 00h Set Display Start *                      = 80h Set Display Start during Vertical Retrace *              CX      = Bits 0-15 of display start address *              DX      = Bits 16-31 of display start address *              ES      = Selector for memory mapped registers  */ASM_STARTvbe_biosfn_set_get_display_start:  cmp  bl, #0x80  je   set_display_start  cmp  bl, #0x01  je   get_display_start  jb   set_display_start  mov  ax, #0x0100  retset_display_start:  mov  ax, cx  call dispi_set_x_offset  mov  ax, dx  call dispi_set_y_offset  mov  ax, #0x004f  retget_display_start:  call dispi_get_x_offset  mov  cx, ax  call dispi_get_y_offset  mov  dx, ax  xor  bh, bh  mov  ax, #0x004f  retASM_END  /** Function 08h - Set/Get Dac Palette Format *  * Input: *              AX      = 4F08h *              BL      = 00h set DAC palette width *                      = 01h get DAC palette width *              BH      = If BL=00h: desired number of bits per primary color * Output: *              AX      = VBE Return Status *              BH      = current number of bits per primary color (06h = standard VGA) */ASM_STARTvbe_biosfn_set_get_dac_palette_format:  cmp  bl, #0x01  je   get_dac_palette_format  jb   set_dac_palette_format  mov  ax, #0x0100  retset_dac_palette_format:  call dispi_get_enable  cmp  bh, #0x06  je   set_normal_dac  cmp  bh, #0x08  jne  vbe_08_unsupported  or   ax, # VBE_DISPI_8BIT_DAC  jnz  set_dac_modeset_normal_dac:  and  ax, #~ VBE_DISPI_8BIT_DACset_dac_mode:  call _dispi_set_enableget_dac_palette_format:  mov  bh, #0x06  call dispi_get_enable  and  ax, # VBE_DISPI_8BIT_DAC  jz   vbe_08_ok  mov  bh, #0x08vbe_08_ok:  mov  ax, #0x004f  retvbe_08_unsupported:  mov  ax, #0x014f  retASM_END/** Function 09h - Set/Get Palette Data *  * Input: *              AX      = 4F09h * Output: *              AX      = VBE Return Status * * FIXME: incomplete API description, Input & Output */void vbe_biosfn_set_get_palette_data(AX){}/** Function 0Ah - Return VBE Protected Mode Interface * Input:    AX   = 4F0Ah   VBE 2.0 Protected Mode Interface *           BL   = 00h          Return protected mode table * * * Output:   AX   =         Status *           ES   =         Real Mode Segment of Table *           DI   =         Offset of Table *           CX   =         Length of Table including protected mode code *                          (for copying purposes) */ASM_STARTvbe_biosfn_return_protected_mode_interface:  test bl, bl  jnz _fail  mov di, #0xc000  mov es, di  mov di, # vesa_pm_start  mov cx, # vesa_pm_end  sub cx, di  mov ax, #0x004f  ret_fail:  mov ax, #0x014f  retASM_END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -