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

📄 vgapci.c

📁 基于组件方式开发操作系统的OSKIT源代码
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include "libvga.h"#define PCI_CONF_ADDR  0xcf8#define PCI_CONF_DATA  0xcfcstatic int pci_read_header (unsigned char bus, unsigned char device,        unsigned char fn, unsigned long *buf){  int i;  unsigned long bx = ((fn&7)<<8) | ((device&31)<<11) | (bus<<16) |                        0x80000000;  for (i=0; i<16; i++) {        outl (PCI_CONF_ADDR, bx|(i<<2));        buf[i] = inl (PCI_CONF_DATA);  }  return 0;}/* find a vga device of the specified vendor, and return   its configuration (16 dwords) in conf    return zero if device found.   */ int __svgalib_pci_find_vendor_vga(unsigned int vendor, unsigned long *conf){ unsigned long buf[16];  int bus,device,cont;    cont=1;#ifndef OSKIT  if (getenv("IOPERM") == NULL) {        if (iopl(3) < 0) {	    printf("svgalib: vgapci: cannot get I/O permissions\n");	    exit(1);	}  }#endif  for(bus=0;(bus<16)&&cont;bus++)                  for(device=0;(device<256)&&cont;device++){      pci_read_header(bus,device,0,buf);      if(((buf[0]&0xffff)==vendor)&&(((buf[2]>>16)&0xffff)==0x0300))cont=0;    };  if(!cont){memcpy(conf,buf,64); };/*  for(i=0;i<16;i++)printf("%u\n",buf[i]);*/#ifndef OSKIT  if (getenv("IOPERM") == NULL)  	iopl(0);#endif  return cont;}

⌨️ 快捷键说明

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