status_t intel_extreme_init(intel_info &info) { CALLED(); info.aperture = gGART->map_aperture(info.pci->bus, info.pci->device, info.pci->function, 0, &info.aperture_base); if (info.aperture < B_OK) { ERROR("error: could not map GART aperture!\n"); return info.aperture; } AreaKeeper sharedCreator; info.shared_area = sharedCreator.Create("intel extreme shared info", (void**)&info.shared_info, B_ANY_KERNEL_ADDRESS, ROUND_TO_PAGE_SIZE(sizeof(intel_shared_info)) + 3 * B_PAGE_SIZE, B_FULL_LOCK, 0); if (info.shared_area < B_OK) { ERROR("error: could not create shared area!\n"); gGART->unmap_aperture(info.aperture); return info.shared_area; } memset((void*)info.shared_info, 0, sizeof(intel_shared_info)); int fbIndex = 0; int mmioIndex = 1; if (info.device_type.InFamily(INTEL_TYPE_9xx)) { // For some reason Intel saw the need to change the order of the // mappings with the introduction of the i9xx family mmioIndex = 0; fbIndex = 2; } // evaluate driver settings, if any bool hardwareCursor; read_settings(hardwareCursor); // memory mapped I/O // TODO: registers are mapped twice (by us and intel_gart), maybe we // can share it between the drivers AreaKeeper mmioMapper; info.registers_area = mmioMapper.Map("intel extreme mmio", info.pci->u.h0.base_registers[mmioIndex], info.pci->u.h0.base_register_sizes[mmioIndex], B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, (void**)&info.registers); if (mmioMapper.InitCheck() < B_OK) { ERROR("error: could not map memory I/O!\n"); gGART->unmap_aperture(info.aperture); return info.registers_area; } uint32* blocks = info.shared_info->register_blocks; blocks[REGISTER_BLOCK(REGS_FLAT)] = 0; // setup the register blocks for the different architectures if (info.device_type.HasPlatformControlHub()) { // PCH based platforms (IronLake and up) blocks[REGISTER_BLOCK(REGS_NORTH_SHARED)] = PCH_NORTH_SHARED_REGISTER_BASE; blocks[REGISTER_BLOCK(REGS_NORTH_PIPE_AND_PORT)] = PCH_NORTH_PIPE_AND_PORT_REGISTER_BASE; blocks[REGISTER_BLOCK(REGS_NORTH_PLANE_CONTROL)] = PCH_NORTH_PLANE_CONTROL_REGISTER_BASE; blocks[REGISTER_BLOCK(REGS_SOUTH_SHARED)] = PCH_SOUTH_SHARED_REGISTER_BASE; blocks[REGISTER_BLOCK(REGS_SOUTH_TRANSCODER_PORT)] = PCH_SOUTH_TRANSCODER_AND_PORT_REGISTER_BASE; } else { // (G)MCH/ICH based platforms blocks[REGISTER_BLOCK(REGS_NORTH_SHARED)] = MCH_SHARED_REGISTER_BASE; blocks[REGISTER_BLOCK(REGS_NORTH_PIPE_AND_PORT)] = MCH_PIPE_AND_PORT_REGISTER_BASE; blocks[REGISTER_BLOCK(REGS_NORTH_PLANE_CONTROL)] = MCH_PLANE_CONTROL_REGISTER_BASE; blocks[REGISTER_BLOCK(REGS_SOUTH_SHARED)] = ICH_SHARED_REGISTER_BASE; blocks[REGISTER_BLOCK(REGS_SOUTH_TRANSCODER_PORT)] = ICH_PORT_REGISTER_BASE; } // make sure bus master, memory-mapped I/O, and frame buffer is enabled set_pci_config(info.pci, PCI_command, 2, get_pci_config(info.pci, PCI_command, 2) | PCI_command_io | PCI_command_memory | PCI_command_master); // reserve ring buffer memory (currently, this memory is placed in // the graphics memory), but this could bring us problems with // write combining... ring_buffer &primary = info.shared_info->primary_ring_buffer; if (intel_allocate_memory(info, 16 * B_PAGE_SIZE, 0, 0, (addr_t*)&primary.base) == B_OK) { primary.register_base = INTEL_PRIMARY_RING_BUFFER; primary.size = 16 * B_PAGE_SIZE; primary.offset = (addr_t)primary.base - info.aperture_base; } // Enable clock gating intel_en_gating(info); // Enable automatic gpu downclocking if we can to save power intel_en_downclock(info); // no errors, so keep areas and mappings sharedCreator.Detach(); mmioMapper.Detach(); aperture_info apertureInfo; gGART->get_aperture_info(info.aperture, &apertureInfo); info.shared_info->registers_area = info.registers_area; info.shared_info->graphics_memory = (uint8*)info.aperture_base; info.shared_info->physical_graphics_memory = apertureInfo.physical_base; info.shared_info->graphics_memory_size = apertureInfo.size; info.shared_info->frame_buffer = 0; info.shared_info->dpms_mode = B_DPMS_ON; info.shared_info->got_vbt = get_lvds_mode_from_bios( &info.shared_info->current_mode); /* at least 855gm can't drive more than one head at time */ if (info.device_type.InFamily(INTEL_TYPE_8xx)) info.shared_info->single_head_locked = 1; if (info.device_type.InFamily(INTEL_TYPE_9xx)) { info.shared_info->pll_info.reference_frequency = 96000; // 96 kHz info.shared_info->pll_info.max_frequency = 400000; // 400 MHz RAM DAC speed info.shared_info->pll_info.min_frequency = 20000; // 20 MHz } else { info.shared_info->pll_info.reference_frequency = 48000; // 48 kHz info.shared_info->pll_info.max_frequency = 350000; // 350 MHz RAM DAC speed info.shared_info->pll_info.min_frequency = 25000; // 25 MHz } info.shared_info->pll_info.divisor_register = INTEL_DISPLAY_A_PLL_DIVISOR_0; info.shared_info->device_type = info.device_type; #ifdef __HAIKU__ strlcpy(info.shared_info->device_identifier, info.device_identifier, sizeof(info.shared_info->device_identifier)); #else strcpy(info.shared_info->device_identifier, info.device_identifier); #endif // setup overlay registers status_t status = intel_allocate_memory(info, B_PAGE_SIZE, 0, intel_uses_physical_overlay(*info.shared_info) ? B_APERTURE_NEED_PHYSICAL : 0, (addr_t*)&info.overlay_registers, &info.shared_info->physical_overlay_registers); if (status == B_OK) { info.shared_info->overlay_offset = (addr_t)info.overlay_registers - info.aperture_base; init_overlay_registers(info.overlay_registers); } else { ERROR("error: could not allocate overlay memory! %s\n", strerror(status)); } // Allocate hardware status page and the cursor memory if (intel_allocate_memory(info, B_PAGE_SIZE, 0, B_APERTURE_NEED_PHYSICAL, (addr_t*)info.shared_info->status_page, &info.shared_info->physical_status_page) == B_OK) { // TODO: set status page } if (hardwareCursor) { intel_allocate_memory(info, B_PAGE_SIZE, 0, B_APERTURE_NEED_PHYSICAL, (addr_t*)&info.shared_info->cursor_memory, &info.shared_info->physical_cursor_memory); } init_interrupt_handler(info); TRACE("%s: completed successfully!\n", __func__); return B_OK; }
static void determine_memory_sizes(intel_info &info, size_t >tSize, size_t &stolenSize) { // read stolen memory from the PCI configuration of the PCI bridge uint8 controlRegister = INTEL_GRAPHICS_MEMORY_CONTROL; if ((info.type & INTEL_TYPE_GROUP_MASK) == INTEL_TYPE_SNB) controlRegister = SNB_GRAPHICS_MEMORY_CONTROL; uint16 memoryConfig = get_pci_config(info.bridge, controlRegister, 2); size_t memorySize = 1 << 20; // 1 MB gttSize = 0; stolenSize = 0; if (info.type == INTEL_TYPE_965) { switch (memoryConfig & i965_GTT_MASK) { case i965_GTT_128K: gttSize = 128 << 10; break; case i965_GTT_256K: gttSize = 256 << 10; break; case i965_GTT_512K: gttSize = 512 << 10; break; } } else if (info.type == INTEL_TYPE_G33 || (info.type & INTEL_TYPE_GROUP_MASK) == INTEL_TYPE_IGD) { switch (memoryConfig & G33_GTT_MASK) { case G33_GTT_1M: gttSize = 1 << 20; break; case G33_GTT_2M: gttSize = 2 << 20; break; } } else if ((info.type & INTEL_TYPE_GROUP_MASK) == INTEL_TYPE_G4x || (info.type & INTEL_TYPE_GROUP_MASK) == INTEL_TYPE_ILK) { switch (memoryConfig & G4X_GTT_MASK) { case G4X_GTT_NONE: gttSize = 0; break; case G4X_GTT_1M_NO_IVT: gttSize = 1 << 20; break; case G4X_GTT_2M_NO_IVT: case G4X_GTT_2M_IVT: gttSize = 2 << 20; break; case G4X_GTT_3M_IVT: gttSize = 3 << 20; break; case G4X_GTT_4M_IVT: gttSize = 4 << 20; break; } } else if ((info.type & INTEL_TYPE_GROUP_MASK) == INTEL_TYPE_SNB) { switch (memoryConfig & SNB_GTT_SIZE_MASK) { case SNB_GTT_SIZE_NONE: gttSize = 0; break; case SNB_GTT_SIZE_1MB: gttSize = 1 << 20; break; case SNB_GTT_SIZE_2MB: gttSize = 2 << 20; break; } } else { // older models have the GTT as large as their frame buffer mapping // TODO: check if the i9xx version works with the i8xx chips as well size_t frameBufferSize = 0; if ((info.type & INTEL_TYPE_8xx) != 0) { if (info.type == INTEL_TYPE_83x && (memoryConfig & MEMORY_MASK) == i830_FRAME_BUFFER_64M) frameBufferSize = 64 << 20; else frameBufferSize = 128 << 20; } else if ((info.type & INTEL_TYPE_9xx) != 0) frameBufferSize = info.display.u.h0.base_register_sizes[2]; TRACE("frame buffer size %lu MB\n", frameBufferSize >> 20); gttSize = frameBufferSize / 1024; } // TODO: test with different models! if (info.type == INTEL_TYPE_83x) { // Older chips switch (memoryConfig & STOLEN_MEMORY_MASK) { case i830_LOCAL_MEMORY_ONLY: // TODO: determine its size! dprintf("intel_gart: getting local memory size not " "implemented.\n"); break; case i830_STOLEN_512K: memorySize >>= 1; break; case i830_STOLEN_1M: // default case break; case i830_STOLEN_8M: memorySize *= 8; break; } } else if ((info.type & INTEL_TYPE_GROUP_MASK) == INTEL_TYPE_SNB) {