Exemplo n.º 1
0
int i825xx_load_device_pci(struct pci_device *device)
{
	int addr;
	char ret=0;
	if(!(addr = pci_get_base_address(device)))
	{
		device->flags |= PCI_ERROR;
		return 1;
	}
	i825xxdev_t *dev = create_new_device(addr, device);
	printk(1, "[i825xx]: Initiating i825xx controller (%x.%x.%x)...\n", 
		device->bus, device->dev, device->func);
	if(i825xx_init(dev))
		ret++;
	
	if(ret){
		printk(1, "[i825xx]: Device error when trying to initialize\n");
		device->flags |= PCI_ERROR;
		return -1;
	}
	struct inode *i = dfs_cn("i825xx", S_IFCHR, i8_maj, i8_min++);
	dev->node = i;
	printk(1, "[i825xx]: Success!\n");
	device->flags |= PCI_ENGAGED;
	device->flags |= PCI_DRIVEN;
	dev->inter = device->pcs->interrupt_line;
	/* TODO setup interrupt handler */
	//interrupt_register_handler(dev->inter, (isr_t)&i825xx_int);
	return 0;
}
Exemplo n.º 2
0
/*
 * Build the list of available crash devices.
 */
int
build_devices(void)
{
        char            *devname[NUM_DUMPDEVS];
        char            linebuf[LINEBUF_SIZE];
	int		i = 0, error = 0;

        for (i=0; i<MAX_DUMPUNITS; i++) {
        	dump_primary[i] = NULL;
        	dump_mirror[i] = NULL;
		device_list[i] = NULL;
        }

        if (get_disklist(linebuf, LINEBUF_SIZE, devname)) {
                Err("Can not get savecore disks, using defaults \n");
                set_default_disklist(linebuf, LINEBUF_SIZE, devname);
        }

        for (i=0; i<NUM_DUMPDEVS; i++) {
	        if (devname[i] == NULL) {
                    continue;
                }

                /*
                 * The stack variable devbuf is strdup'ed in create_new_device
		 * so that it isn't reused.
                 */
                device_list[i] = create_new_device(devname[i]);
                if (device_list[i] == NULL) {
                    Err("unable to create a device.\n");
	            error = DUMP_SETUP_ERROR;
	            break;
	        }
		if (open_device_file(device_list[i], O_RDWR) < 0) {
                        free(device_list[i]);
			device_list[i] = NULL;
			continue;
		}
	}
	return error;
}