rem: if (current_settings.dumprom) dumprom (rom_temp, 32768);   set_pci(PCI_rom_base,4,0);
add: tmpUlong = get_pci(PCI_rom_base, 4); tmpUlong &= 0xfffffffe; set_pci(PCI_rom_base, 4, tmpUlong);
context: static status_t map_device(device_info *di){	char buffer[B_OS_NAME_LENGTH]; /*memory for device name*/	shared_info *si = di->si;	uint32	tmpUlong;	pci_info *pcii = &(di->pcii);	system_info sysinfo;	/*variables for making copy of ROM*/	char * rom_temp;	area_id rom_area;	int frame_buffer = 0;	/* only NM2097 and later cards have two register area's:	 * older cards have their PCI registers in the frame_buffer space */	int registers = 1;	int registers2 = 2;	/* enable memory mapped IO, disable VGA I/O - this is standard*/	tmpUlong = get_pci(PCI_command, 4);	/* make sure ISA access is enabled: all Neomagic cards still partly rely on this */	tmpUlong |= PCI_command_io;	/* make sure PCI access is enabled */	tmpUlong |= PCI_command_memory;	tmpUlong |= PCI_command_master;	set_pci(PCI_command, 4, tmpUlong); 	/*work out which version of BeOS is running*/ 	get_system_info(&sysinfo); 	if (sysinfo.kernel_build_date[0]=='J')/*FIXME - better ID version*/ 	{ 		si->use_clone_bugfix = 1; 	} 	else 	{ 		si->use_clone_bugfix = 0; 	}	/* map card's register area's */	switch (di->pcii.device_id)	{	case 0x0001:	case 0x0002:	case 0x0003:		/* NM2070, NM2090 and NM2093 have no seperate register area's,		 * so do nothing here except notify accelerant. */		si->regs_in_fb = true;		break;	default:		/* we map the registers seperately from the framebuffer */		si->regs_in_fb = false;		/* work out a name for the register mapping */		sprintf(buffer, DEVICE_FORMAT " regs",			di->pcii.vendor_id, di->pcii.device_id,			di->pcii.bus, di->pcii.device, di->pcii.function);		/* get a virtual memory address for the registers*/		si->regs_area = map_physical_memory(			buffer,			(void *) di->pcii.u.h0.base_registers[registers],			di->pcii.u.h0.base_register_sizes[registers],			B_ANY_KERNEL_ADDRESS, 			(si->use_clone_bugfix ? B_READ_AREA|B_WRITE_AREA : 0),			(void **)&(di->regs)); 		si->clone_bugfix_regs = (uint32 *) di->regs;		/* if mapping registers to vmem failed then pass on error */		if (si->regs_area < 0) return si->regs_area;		/* work out a name for the register mapping */		sprintf(buffer, DEVICE_FORMAT " regs2",			di->pcii.vendor_id, di->pcii.device_id,			di->pcii.bus, di->pcii.device, di->pcii.function);		si->regs2_area = map_physical_memory(			buffer,			(void *) di->pcii.u.h0.base_registers[registers2],			di->pcii.u.h0.base_register_sizes[registers2],			B_ANY_KERNEL_ADDRESS,			(si->use_clone_bugfix ? B_READ_AREA|B_WRITE_AREA : 0),			(void **)&(di->regs2));	 	si->clone_bugfix_regs2 = (uint32 *) di->regs2;		/* if mapping registers to vmem failed then pass on error */		if (si->regs2_area < 0)		{			delete_area(si->regs_area);			si->regs_area = -1;			return si->regs2_area;		}		break;	}	/* work out a name for the ROM mapping*/	sprintf(buffer, DEVICE_FORMAT " rom",		di->pcii.vendor_id, di->pcii.device_id,		di->pcii.bus, di->pcii.device, di->pcii.function);	/*place ROM over the fbspace (this is definately safe)*/	tmpUlong = di->pcii.u.h0.base_registers[frame_buffer];	tmpUlong |= 0x00000001;	set_pci(PCI_rom_base, 4, tmpUlong);	rom_area = map_physical_memory(		buffer,		(void *)di->pcii.u.h0.base_registers[frame_buffer],		32768,		B_ANY_KERNEL_ADDRESS,		B_READ_AREA,		(void **)&(rom_temp)	);	/* if mapping ROM to vmem failed then clean up and pass on error */	if (rom_area < 0) {		if (si->regs_area >= 0)		{			delete_area(si->regs_area);			si->regs_area = -1;		}		if (si->regs2_area >= 0)		{			delete_area(si->regs2_area);			si->regs2_area = -1;		}		return rom_area;	}	/* make a copy of ROM for future reference*/	memcpy (si->rom_mirror, rom_temp, 32768);	if (current_settings.dumprom) dumprom (rom_temp, 32768);	/*disable ROM and delete the area*/	set_pci(PCI_rom_base,4,0);	delete_area(rom_area);	/* work out a name for the framebuffer mapping*/	sprintf(buffer, DEVICE_FORMAT " framebuffer",		di->pcii.vendor_id, di->pcii.device_id,		di->pcii.bus, di->pcii.device, di->pcii.function);	/* map the framebuffer into vmem, using Write Combining*/	si->fb_area = map_physical_memory(		buffer,		(void *) di->pcii.u.h0.base_registers[frame_buffer],		di->pcii.u.h0.base_register_sizes[frame_buffer],		B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,		B_READ_AREA + B_WRITE_AREA,		&(si->framebuffer));	/*if failed with write combining try again without*/	if (si->fb_area < 0) {		si->fb_area = map_physical_memory(			buffer,			(void *) di->pcii.u.h0.base_registers[frame_buffer],			di->pcii.u.h0.base_register_sizes[frame_buffer],			B_ANY_KERNEL_BLOCK_ADDRESS,			B_READ_AREA + B_WRITE_AREA,			&(si->framebuffer));	}			/* if there was an error, delete our other areas and pass on error*/	if (si->fb_area < 0)	{		if (si->regs_area >= 0)		{			delete_area(si->regs_area);			si->regs_area = -1;		}		if (si->regs2_area >= 0)		{			delete_area(si->regs2_area);			si->regs2_area = -1;		}		return si->fb_area;	}	/* older cards have their registers in the framebuffer area */	switch (di->pcii.device_id)	{	case 0x0001:		/* NM2070 cards */		di->regs = (uint32 *)((uint8 *)si->framebuffer + 0x100000); 		si->clone_bugfix_regs = (uint32 *) di->regs;		break;	case 0x0002:	case 0x0003:		/* NM2090 and NM2093 cards */		di->regs = (uint32 *)((uint8 *)si->framebuffer + 0x200000); 		si->clone_bugfix_regs = (uint32 *) di->regs;		break;	}	/* remember the DMA address of the frame buffer for BDirectWindow?? purposes */	si->framebuffer_pci = (void *) di->pcii.u.h0.base_registers_pci[frame_buffer];	// remember settings for use here and in accelerant	si->settings = current_settings; 	/* in any case, return the result */	return si->fb_area;}