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

📄 vbe.c

📁 xen虚拟机源代码安装包
💻 C
📖 第 1 页 / 共 3 页
字号:
// ============================================================================================//  //  Copyright (C) 2002 Jeroen Janssen////  This library is free software; you can redistribute it and/or//  modify it under the terms of the GNU Lesser General Public//  License as published by the Free Software Foundation; either//  version 2 of the License, or (at your option) any later version.////  This library is distributed in the hope that it will be useful,//  but WITHOUT ANY WARRANTY; without even the implied warranty of//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU//  Lesser General Public License for more details.////  You should have received a copy of the GNU Lesser General Public//  License along with this library; if not, write to the Free Software//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA// // ============================================================================================//  //  This VBE is part of the VGA Bios specific to the plex86/bochs Emulated VGA card. //  You can NOT drive any physical vga card with it. //// ============================================================================================//  //  This VBE Bios is based on information taken from ://   - VESA BIOS EXTENSION (VBE) Core Functions Standard Version 3.0 located at www.vesa.org//// ============================================================================================// defines available// disable VESA/VBE2 check in vbe info//#define VBE2_NO_VESA_CHECK#include "vbe.h"#include "vbetables.h"#define VBE_TOTAL_VIDEO_MEMORY_DIV_64K (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB*1024/64)// The current OEM Software Revision of this VBE Bios#define VBE_OEM_SOFTWARE_REV 0x0002;extern char vbebios_copyright;extern char vbebios_vendor_name;extern char vbebios_product_name;extern char vbebios_product_revision;ASM_START// FIXME: 'merge' these (c) etc strings with the vgabios.c strings?_vbebios_copyright:.ascii       "Bochs/Plex86 VBE(C) 2003 http://savannah.nongnu.org/projects/vgabios/".byte        0x00_vbebios_vendor_name:.ascii       "Bochs/Plex86 Developers".byte        0x00_vbebios_product_name:.ascii       "Bochs/Plex86 VBE Adapter".byte        0x00_vbebios_product_revision:.ascii       "$Id: vbe.c,v 1.60 2008/03/02 07:47:21 vruppert Exp $".byte        0x00_vbebios_info_string:.ascii      "Bochs VBE Display Adapter enabled".byte	0x0a,0x0d.byte	0x0a,0x0d.byte	0x00_no_vbebios_info_string:.ascii      "NO Bochs VBE Support available!".byte	0x0a,0x0d.byte	0x0a,0x0d.byte 0x00#if defined(USE_BX_INFO) || defined(DEBUG)msg_vbe_init:.ascii      "VBE Bios $Id: vbe.c,v 1.60 2008/03/02 07:47:21 vruppert Exp $".byte	0x0a,0x0d, 0x00#endif  .align 2vesa_pm_start:  dw vesa_pm_set_window - vesa_pm_start  dw vesa_pm_set_display_start - vesa_pm_start  dw vesa_pm_unimplemented - vesa_pm_start  dw vesa_pm_io_ports_table - vesa_pm_startvesa_pm_io_ports_table:  dw VBE_DISPI_IOPORT_INDEX  dw VBE_DISPI_IOPORT_INDEX + 1  dw VBE_DISPI_IOPORT_DATA  dw VBE_DISPI_IOPORT_DATA + 1  dw 0xffff  dw 0xffff  USE32vesa_pm_set_window:  cmp  bx, #0x00  je  vesa_pm_set_display_window1  mov  ax, #0x0100  retvesa_pm_set_display_window1:  mov  ax, dx  push dx  push ax  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_BANK  out  dx, ax  pop  ax  mov  dx, # VBE_DISPI_IOPORT_DATA  out  dx, ax  in   ax, dx  pop  dx  cmp  dx, ax  jne  illegal_window  mov  ax, #0x004f  retillegal_window:  mov  ax, #0x014f  retvesa_pm_set_display_start:  cmp  bl, #0x80  je   vesa_pm_set_display_start1  cmp  bl, #0x00  je   vesa_pm_set_display_start1  mov  ax, #0x0100  retvesa_pm_set_display_start1:; convert offset to (X, Y) coordinate ; (would be simpler to change Bochs VBE API...)  push eax  push ecx  push edx  push esi  push edi  shl edx, #16  and ecx, #0xffff  or ecx, edx  shl ecx, #2  mov eax, ecx  push eax  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_VIRT_WIDTH  out  dx, ax  mov  dx, # VBE_DISPI_IOPORT_DATA  in   ax, dx  movzx ecx, ax  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_BPP  out  dx, ax  mov  dx, # VBE_DISPI_IOPORT_DATA  in   ax, dx  movzx esi, ax  pop  eax  cmp esi, #4  jz bpp4_mode  add esi, #7  shr esi, #3  imul ecx, esi  xor edx, edx  div ecx  mov edi, eax  mov eax, edx  xor edx, edx  div esi  jmp set_xy_regsbpp4_mode:  shr ecx, #1  xor edx, edx  div ecx  mov edi, eax  mov eax, edx  shl eax, #1set_xy_regs:  push dx  push ax  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_X_OFFSET  out  dx, ax  pop  ax  mov  dx, # VBE_DISPI_IOPORT_DATA  out  dx, ax  pop  dx  mov  ax, di  push dx  push ax  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_Y_OFFSET  out  dx, ax  pop  ax  mov  dx, # VBE_DISPI_IOPORT_DATA  out  dx, ax  pop  dx  pop edi  pop esi  pop edx  pop ecx  pop eax  mov  ax, #0x004f  retvesa_pm_unimplemented:  mov ax, #0x014f  ret  USE16vesa_pm_end:; DISPI ioport functionsdispi_get_id:  push dx  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_ID  out  dx, ax  mov  dx, # VBE_DISPI_IOPORT_DATA  in   ax, dx  pop  dx  retdispi_set_id:  push dx  push ax  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_ID  out  dx, ax  pop  ax  mov  dx, # VBE_DISPI_IOPORT_DATA  out  dx, ax  pop  dx  retASM_ENDstatic void dispi_set_xres(xres)  Bit16u xres;{ASM_START  push bp  mov  bp, sp  push ax  push dx  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_XRES  out  dx, ax  mov  dx, # VBE_DISPI_IOPORT_DATA  mov  ax, 4[bp] ; xres  out  dx, ax  pop  dx  pop  ax  pop  bpASM_END}static void dispi_set_yres(yres)  Bit16u yres;{  outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_YRES);  outw(VBE_DISPI_IOPORT_DATA,yres);}static void dispi_set_bpp(bpp)  Bit16u bpp;{  outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BPP);  outw(VBE_DISPI_IOPORT_DATA,bpp);}ASM_START; AL = bits per pixel / AH = bytes per pixeldispi_get_bpp:  push dx  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_BPP  out  dx, ax  mov  dx, # VBE_DISPI_IOPORT_DATA  in   ax, dx  mov  ah, al  shr  ah, 3  test al, #0x07  jz   get_bpp_noinc  inc  ahget_bpp_noinc:  pop  dx  ret; get display capabilities_dispi_get_max_xres:  push dx  push bx  call dispi_get_enable  mov  bx, ax  or   ax, # VBE_DISPI_GETCAPS  call _dispi_set_enable  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_XRES  out  dx, ax  mov  dx, # VBE_DISPI_IOPORT_DATA  in   ax, dx  push ax  mov  ax, bx  call _dispi_set_enable  pop  ax  pop  bx  pop  dx  ret_dispi_get_max_bpp:  push dx  push bx  call dispi_get_enable  mov  bx, ax  or   ax, # VBE_DISPI_GETCAPS  call _dispi_set_enable  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_BPP  out  dx, ax  mov  dx, # VBE_DISPI_IOPORT_DATA  in   ax, dx  push ax  mov  ax, bx  call _dispi_set_enable  pop  ax  pop  bx  pop  dx  ret_dispi_set_enable:  push dx  push ax  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_ENABLE  out  dx, ax  pop  ax  mov  dx, # VBE_DISPI_IOPORT_DATA  out  dx, ax  pop  dx  retdispi_get_enable:  push dx  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_ENABLE  out  dx, ax  mov  dx, # VBE_DISPI_IOPORT_DATA  in   ax, dx  pop  dx  ret_dispi_set_bank:  push dx  push ax  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_BANK  out  dx, ax  pop  ax  mov  dx, # VBE_DISPI_IOPORT_DATA  out  dx, ax  pop  dx  retdispi_get_bank:  push dx  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_BANK  out  dx, ax  mov  dx, # VBE_DISPI_IOPORT_DATA  in   ax, dx  pop  dx  retASM_ENDstatic void dispi_set_bank_farcall(){ASM_START  cmp bx,#0x0100  je dispi_set_bank_farcall_get  or bx,bx  jnz dispi_set_bank_farcall_error  mov ax,dx  push dx  push ax  mov ax,# VBE_DISPI_INDEX_BANK  mov dx,# VBE_DISPI_IOPORT_INDEX  out dx,ax  pop ax  mov dx,# VBE_DISPI_IOPORT_DATA  out dx,ax  in  ax,dx  pop dx  cmp dx,ax  jne dispi_set_bank_farcall_error  mov ax, #0x004f  retfdispi_set_bank_farcall_get:  mov ax,# VBE_DISPI_INDEX_BANK  mov dx,# VBE_DISPI_IOPORT_INDEX  out dx,ax  mov dx,# VBE_DISPI_IOPORT_DATA  in ax,dx  mov dx,ax  retfdispi_set_bank_farcall_error:  mov ax,#0x014F  retfASM_END}ASM_STARTdispi_set_x_offset:  push dx  push ax  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_X_OFFSET  out  dx, ax  pop  ax  mov  dx, # VBE_DISPI_IOPORT_DATA  out  dx, ax  pop  dx  retdispi_get_x_offset:  push dx  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_X_OFFSET  out  dx, ax  mov  dx, # VBE_DISPI_IOPORT_DATA  in   ax, dx  pop  dx  retdispi_set_y_offset:  push dx  push ax  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_Y_OFFSET  out  dx, ax  pop  ax  mov  dx, # VBE_DISPI_IOPORT_DATA  out  dx, ax  pop  dx  retdispi_get_y_offset:  push dx  mov  dx, # VBE_DISPI_IOPORT_INDEX  mov  ax, # VBE_DISPI_INDEX_Y_OFFSET  out  dx, ax  mov  dx, # VBE_DISPI_IOPORT_DATA  in   ax, dx  pop  dx  retvga_set_virt_width:  push ax  push bx  push dx  mov  bx, ax  call dispi_get_bpp  cmp  al, #0x04  ja   set_width_svga  shr  bx, #1set_width_svga:  shr  bx, #3

⌨️ 快捷键说明

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