Esempio n. 1
0
void amdrv100init(uint8_t bus, uint8_t slot)
{
  printf("amd_rv100: init on bus:slot %x:%x\n", bus, slot);
  uint16_t vendor = pci_config_read_word(bus, slot, 0, 0);
  if(vendor == 0xFFFF)
  {
    puts("amd_rv100: init failed: device not found on specified bus:slot\n");
    return;
  }
  uint16_t device = pci_config_read_word(bus, slot, 0, 2);
  if(device != 0x4c59)
  {
    puts("amd_rv100: init failed: device is not compatible\n");
    return;
  }
  uint32_t fbaddr = pci_config_read_dword(bus, slot, 0, 0x10) & ~0xF;
  uint32_t port = pci_config_read_dword(bus, slot, 0, 0x14) & ~0x3;
  printf("amd_rv100: framebuffer addr: 0x%x port: 0x%x\n", fbaddr, port);
  vga_card* v = graphics_add_card();
  if(!v) return;
  v->bus = bus;
  v->slot = slot;
  v->data[0] = fbaddr;
  v->data[1] = port;
  pci_config_write_byte(bus, slot, 0, 0x3d, 1);
  pci_config_write_byte(bus, slot, 0, 0x3c, 11);
  vdestroy();
  vinit(1024, 768, 32, 1024 * 4, fbaddr);
  printf("amd_rv100: finished.\n");
}
Esempio n. 2
0
int pci_config_write(unsigned char bus, unsigned char dev, unsigned char func,
		    unsigned char cmd, int len, unsigned long val)
{
    int ret;
    
    ret = enable_app_io();
    if (ret != 0)
	return ret;
    switch(len)
    {
	case 4:
	    pci_config_write_long(bus, dev, func, cmd, val);
	    break;
	case 2:
	    pci_config_write_word(bus, dev, func, cmd, val);
	    break;
	case 1:
	    pci_config_write_byte(bus, dev, func, cmd, val);
	    break;
	default:
	    printf("libdha_pci: wrong length to read: %u\n",len);
    }
    disable_app_io();

    return 0;
}
Esempio n. 3
0
int pci_config_write(unsigned char bus, unsigned char dev, unsigned char func,
		    unsigned char cmd, int len, unsigned long val)
{
    int ret;
    
    int dhahelper_fd;
    if ( (dhahelper_fd = open("/dev/dhahelper",O_RDWR)) > 0)
    {
	int retval;
	dhahelper_pci_config_t pcic;
	pcic.operation = PCI_OP_WRITE;
	pcic.bus = bus;
	pcic.dev = dev;
	pcic.func = func;
	pcic.cmd = cmd;
	pcic.size = len;
	pcic.ret = val;
	retval = ioctl(dhahelper_fd, DHAHELPER_PCI_CONFIG, &pcic);
	close(dhahelper_fd);
	return retval;
    }
    ret = enable_app_io();
    if (ret != 0)
	return ret;
    switch(len)
    {
	case 4:
	    pci_config_write_long(bus, dev, func, cmd, val);
	    break;
	case 2:
	    pci_config_write_word(bus, dev, func, cmd, val);
	    break;
	case 1:
	    pci_config_write_byte(bus, dev, func, cmd, val);
	    break;
	default:
	    printf("libdha_pci: wrong length to read: %u\n",len);
    }
    disable_app_io();

    return 0;
}