From 81cd6636667750c27d5bad289fa2625926d7c953 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Tue, 2 Aug 2011 23:11:15 +0000 Subject: [PATCH] * 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 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42550 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../accelerants/radeon_hd/accelerant.cpp | 71 +++++++++++++++++-- .../accelerants/radeon_hd/accelerant.h | 3 + src/add-ons/accelerants/radeon_hd/bios.cpp | 11 ++- src/add-ons/accelerants/radeon_hd/bios.h | 2 +- 4 files changed, 79 insertions(+), 8 deletions(-) diff --git a/src/add-ons/accelerants/radeon_hd/accelerant.cpp b/src/add-ons/accelerants/radeon_hd/accelerant.cpp index 75b342d575..93e5cf1241 100644 --- a/src/add-ons/accelerants/radeon_hd/accelerant.cpp +++ b/src/add-ons/accelerants/radeon_hd/accelerant.cpp @@ -17,6 +17,8 @@ #include "pll.h" #include "utility.h" +#include + #include #include #include @@ -27,9 +29,10 @@ #include +#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 @@ init_common(int device, bool isClone) 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 @@ init_common(int device, bool isClone) 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 @@ uninit_common(void) 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 @@ uninit_common(void) } +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 @@ radeon_init_accelerant(int device) 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) diff --git a/src/add-ons/accelerants/radeon_hd/accelerant.h b/src/add-ons/accelerants/radeon_hd/accelerant.h index 8c2502c4de..282868b668 100644 --- a/src/add-ons/accelerants/radeon_hd/accelerant.h +++ b/src/add-ons/accelerants/radeon_hd/accelerant.h @@ -36,6 +36,9 @@ struct accelerant_info { 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; diff --git a/src/add-ons/accelerants/radeon_hd/bios.cpp b/src/add-ons/accelerants/radeon_hd/bios.cpp index ace7119982..6118792c5d 100644 --- a/src/add-ons/accelerants/radeon_hd/bios.cpp +++ b/src/add-ons/accelerants/radeon_hd/bios.cpp @@ -29,8 +29,15 @@ atom_context *gAtomBIOS; 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 @@ bios_init() 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__); diff --git a/src/add-ons/accelerants/radeon_hd/bios.h b/src/add-ons/accelerants/radeon_hd/bios.h index 6f731b5f86..97faed79cb 100644 --- a/src/add-ons/accelerants/radeon_hd/bios.h +++ b/src/add-ons/accelerants/radeon_hd/bios.h @@ -14,7 +14,7 @@ #include "atom.h" -status_t bios_init(); +status_t bios_init(void* bios); #endif /* RADEON_HD_BIOS_H */