Author: kallisti5 Date: 2011-08-03 01:11:15 +0200 (Wed, 03 Aug 2011) New Revision: 42550 Changeset: https://dev.haiku-os.org/changeset/42550 Modified: haiku/trunk/src/add-ons/accelerants/radeon_hd/accelerant.cpp haiku/trunk/src/add-ons/accelerants/radeon_hd/accelerant.h haiku/trunk/src/add-ons/accelerants/radeon_hd/bios.cpp haiku/trunk/src/add-ons/accelerants/radeon_hd/bios.h Log: * refactor accelerant debugging * clone VGA rom shared area in accelerant * enable access, and make a copy of the VGA bios * give malloc'ed VGA bios pointer to AtomBIOS parser * Still invalid BIOS magic * TODO : Move atomBIOS pointer and reorganize some stuff Modified: haiku/trunk/src/add-ons/accelerants/radeon_hd/accelerant.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/radeon_hd/accelerant.cpp 2011-08-02 22:42:57 UTC (rev 42549) +++ haiku/trunk/src/add-ons/accelerants/radeon_hd/accelerant.cpp 2011-08-02 23:11:15 UTC (rev 42550) @@ -17,6 +17,8 @@ #include "pll.h" #include "utility.h" +#include <Debug.h> + #include <errno.h> #include <stdlib.h> #include <stdio.h> @@ -27,9 +29,10 @@ #include <AGP.h> +#undef TRACE + #define TRACE_ACCELERANT #ifdef TRACE_ACCELERANT -extern "C" void _sPrintf(const char *format, ...); # define TRACE(x...) _sPrintf("radeon_hd: " x) #else # define TRACE(x...) ; @@ -138,8 +141,7 @@ status_t status = sharedCloner.InitCheck(); if (status < B_OK) { free(gInfo); - TRACE("%s, failed shared area%i, %i\n", - __func__, data.shared_info_area, gInfo->shared_info_area); + TRACE("%s, failed to create shared area\n", __func__); return status; } @@ -150,11 +152,24 @@ status = regsCloner.InitCheck(); if (status < B_OK) { free(gInfo); + TRACE("%s, failed to create mmio area\n", __func__); return status; } + AreaCloner romCloner; + gInfo->rom_area = romCloner.Clone("radeon hd rom", + (void **)&gInfo->rom, B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, + gInfo->shared_info->rom_area); + status = romCloner.InitCheck(); + if (status < B_OK) { + //free(gInfo); + TRACE("%s, failed to create rom area\n", __func__); + //return status; + } + sharedCloner.Keep(); regsCloner.Keep(); + romCloner.Keep(); // Define Radeon PLL default ranges gInfo->shared_info->pll_info.reference_frequency @@ -173,6 +188,7 @@ if (gInfo != NULL) { delete_area(gInfo->regs_area); delete_area(gInfo->shared_info_area); + delete_area(gInfo->rom_area); gInfo->regs_area = gInfo->shared_info_area = -1; @@ -192,6 +208,52 @@ } +status_t +radeon_init_bios() +{ + radeon_shared_info &info = *gInfo->shared_info; + + uint32 bus_cntl = Read32(OUT, R600_BUS_CNTL); + uint32 d1vga_control = Read32(OUT, D1VGA_CONTROL); + uint32 d2vga_control = Read32(OUT, D2VGA_CONTROL); + uint32 vga_render_control = Read32(OUT, VGA_RENDER_CONTROL); + uint32 rom_cntl = Read32(OUT, R600_ROM_CNTL); + + // Enable rom access + Write32(OUT, R600_BUS_CNTL, (bus_cntl & ~R600_BIOS_ROM_DIS)); + /* Disable VGA mode */ + Write32(OUT, D1VGA_CONTROL, (d1vga_control + & ~(DVGA_CONTROL_MODE_ENABLE + | DVGA_CONTROL_TIMING_SELECT))); + Write32(OUT, D2VGA_CONTROL, (d2vga_control + & ~(DVGA_CONTROL_MODE_ENABLE + | DVGA_CONTROL_TIMING_SELECT))); + Write32(OUT, VGA_RENDER_CONTROL, (vga_render_control + & ~VGA_VSTATUS_CNTL_MASK)); + Write32(OUT, R600_ROM_CNTL, rom_cntl | R600_SCK_OVERWRITE); + + void* atomBIOS = (void*)malloc(info.rom_size); + if (atomBIOS == NULL) + return B_NO_MEMORY; + + snooze(2); + + memcpy(atomBIOS, gInfo->rom, info.rom_size); + + /* restore regs */ + Write32(OUT, R600_BUS_CNTL, bus_cntl); + Write32(OUT, D1VGA_CONTROL, d1vga_control); + Write32(OUT, D2VGA_CONTROL, d2vga_control); + Write32(OUT, VGA_RENDER_CONTROL, vga_render_control); + Write32(OUT, R600_ROM_CNTL, rom_cntl); + + // Init AtomBIOS + bios_init(atomBIOS); + + return B_OK; +} + + // #pragma mark - public accelerant functions @@ -210,8 +272,7 @@ init_lock(&info.accelerant_lock, "radeon hd accelerant"); init_lock(&info.engine_lock, "radeon hd engine"); - // Init AtomBIOS - bios_init(); + radeon_init_bios(); status = detect_displays(); //if (status != B_OK) Modified: haiku/trunk/src/add-ons/accelerants/radeon_hd/accelerant.h =================================================================== --- haiku/trunk/src/add-ons/accelerants/radeon_hd/accelerant.h 2011-08-02 22:42:57 UTC (rev 42549) +++ haiku/trunk/src/add-ons/accelerants/radeon_hd/accelerant.h 2011-08-02 23:11:15 UTC (rev 42550) @@ -36,6 +36,9 @@ display_mode *mode_list; // cloned list of standard display modes area_id mode_list_area; + uint8 *rom; + area_id rom_area; + edid1_info edid_info; bool has_edid; Modified: haiku/trunk/src/add-ons/accelerants/radeon_hd/bios.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/radeon_hd/bios.cpp 2011-08-02 22:42:57 UTC (rev 42549) +++ haiku/trunk/src/add-ons/accelerants/radeon_hd/bios.cpp 2011-08-02 23:11:15 UTC (rev 42550) @@ -29,8 +29,15 @@ status_t -bios_init() +bios_init(void* bios) { + if (gInfo->rom == NULL) { + // just incase, this prevents a crash + TRACE("%s: called even though VGA rom hasn't been mapped!\n", + __func__); + return B_ERROR; + } + struct card_info *atom_card_info = (card_info*)malloc(sizeof(card_info)); @@ -55,7 +62,7 @@ atom_card_info->pll_write = _write32; // Point AtomBIOS parser to card bios and malloc gAtomBIOS - gAtomBIOS = atom_parse(atom_card_info, gInfo->shared_info->rom); + gAtomBIOS = atom_parse(atom_card_info, bios); if (gAtomBIOS == NULL) { TRACE("%s: couldn't parse system AtomBIOS\n", __func__); Modified: haiku/trunk/src/add-ons/accelerants/radeon_hd/bios.h =================================================================== --- haiku/trunk/src/add-ons/accelerants/radeon_hd/bios.h 2011-08-02 22:42:57 UTC (rev 42549) +++ haiku/trunk/src/add-ons/accelerants/radeon_hd/bios.h 2011-08-02 23:11:15 UTC (rev 42550) @@ -14,7 +14,7 @@ #include "atom.h" -status_t bios_init(); +status_t bios_init(void* bios); #endif /* RADEON_HD_BIOS_H */