From cc04d754913a7275ada255e1142c5a394b17e824 Mon Sep 17 00:00:00 2001
From: Rudolf Cornelissen
Date: Mon, 28 Jun 2004 19:48:57 +0000
Subject: [PATCH] fixed BIOS ROM readout
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8224 a95241bf-73f2-0310-859d-f6bbb57e9c96
---
.../accelerants/nvidia/engine/nv_general.c | 4 +-
.../accelerants/nvidia/engine/nv_info.c | 6 ++-
.../drivers/graphics/nvidia/UPDATE.html | 5 +-
.../kernel/drivers/graphics/nvidia/driver.c | 47 ++++++++++++-------
.../drivers/graphics/nvidia/nv.settings | 2 +-
5 files changed, 42 insertions(+), 22 deletions(-)
diff --git a/src/add-ons/accelerants/nvidia/engine/nv_general.c b/src/add-ons/accelerants/nvidia/engine/nv_general.c
index 310718b898..6441eca790 100644
--- a/src/add-ons/accelerants/nvidia/engine/nv_general.c
+++ b/src/add-ons/accelerants/nvidia/engine/nv_general.c
@@ -808,7 +808,9 @@ static status_t nvxx_general_powerup()
/* initialize the shared_info PINS struct */
result = parse_pins();
- if (result != B_OK) fake_pins();
+// if (result != B_OK) fake_pins();
+//temporary:
+ fake_pins();
/* log the PINS struct settings */
dump_pins();
diff --git a/src/add-ons/accelerants/nvidia/engine/nv_info.c b/src/add-ons/accelerants/nvidia/engine/nv_info.c
index 36dd00690f..40c8a5cd1a 100644
--- a/src/add-ons/accelerants/nvidia/engine/nv_info.c
+++ b/src/add-ons/accelerants/nvidia/engine/nv_info.c
@@ -33,10 +33,12 @@ status_t parse_pins ()
/* preset PINS read status to failed */
si->ps.pins_status = B_ERROR;
+ LOG(2,("INFO: cardROM size: %dKb\n", (si->rom.size / 1024)));
+
/* check the validity of PINS */
LOG(2,("INFO: Reading PINS info\n"));
- rom = (uint8 *) si->rom_mirror;
- /* check BIOS signature */
+ rom = (uint8 *) si->rom.mirror;
+ /* check BIOS signature - this is defined in the PCI standard */
if (rom[0]!=0x55 || rom[1]!=0xaa)
{
LOG(8,("INFO: BIOS signiture not found\n"));
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/UPDATE.html b/src/add-ons/kernel/drivers/graphics/nvidia/UPDATE.html
index 937243a0fc..c1c928fb93 100644
--- a/src/add-ons/kernel/drivers/graphics/nvidia/UPDATE.html
+++ b/src/add-ons/kernel/drivers/graphics/nvidia/UPDATE.html
@@ -4,12 +4,13 @@
Changes done for each driverversion:
-head (0.15), (Rudolf)
+head (0.16), (Rudolf)
- Added AGP mode capability on AGP cards along with the option to block it in nv.settings. No GART and AGP aperture support; but if your card and system AGP host bridge support the 'fastwrite' (FW) feature, you'll notice a nice speedup of mostly unaccelerated graphics. Tested Quake 2 in software rendering mode over here using timedemo1 with demo1.dm2: framerates jumped up to 140% of the 'original' in 'just' AGP2.0 4X mode!
Note please : You need the new AGP kernel driver I setup for this feature, without it you will remain using PCI mode as usual. This AGP driver will be released seperately asap: it's almost ready.
- Updated CRTC memory granularity settings on TNT2 and later cards to reduce use of card internal bandwidth: this should minimize or prevent distortions on cards that have limited bandwidth available (especially on older cards). Note: doesn't actually fix the problem! (to be continued...)
-
- Updated CRTC modeline tuning for panels: this should fix the 'right-shifted' picture on some panels in their native modes.
+
- Updated CRTC modeline tuning for panels: this should fix the 'right-shifted' picture on some panels in their native modes;
+
- Fixed BIOS ROM dump (to file) option.
nv_driver 0.10, (Rudolf)
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/driver.c b/src/add-ons/kernel/drivers/graphics/nvidia/driver.c
index cccefe53c0..5c9edfae66 100644
--- a/src/add-ons/kernel/drivers/graphics/nvidia/driver.c
+++ b/src/add-ons/kernel/drivers/graphics/nvidia/driver.c
@@ -267,11 +267,18 @@ static settings current_settings = { // see comments in nv.settings
false, // force_pci
};
-static void dumprom (void *rom, size_t size)
+static void dumprom (void *rom, uint32 size)
{
- int fd = open ("/boot/home/" DRIVER_PREFIX ".rom", O_WRONLY | O_CREAT, 0666);
+ int fd;
+ uint32 cnt;
+
+ fd = open ("/boot/home/" DRIVER_PREFIX ".rom", O_WRONLY | O_CREAT, 0666);
if (fd < 0) return;
- write (fd, rom, size);
+
+ /* apparantly max. 32kb may be written at once;
+ * the ROM size is a multiple of that anyway. */
+ for (cnt = 0; (cnt < size); cnt += 32768)
+ write (fd, ((void *)(((uint8 *)rom) + cnt)), 32768);
close (fd);
}
@@ -446,24 +453,25 @@ static status_t map_device(device_info *di)
// physical_entry physical_memory[2];
// #define G400_DMA_BUFFER_SIZE 1024*1024
- /*variables for making copy of ROM*/
+ /* variables for making copy of ROM */
char * rom_temp;
area_id rom_area;
+ uint32 rom_size;
/* Nvidia cards have registers in [0] and framebuffer in [1] */
int registers = 0;
int frame_buffer = 1;
// int pseudo_dma = 2;
- /* enable memory mapped IO, disable VGA I/O - this is standard*/
- tmpUlong = get_pci(PCI_command, 4);
+ /* enable memory mapped IO, disable VGA I/O - this is defined in the PCI standard */
+ tmpUlong = get_pci(PCI_command, 2);
/* enable PCI access */
tmpUlong |= PCI_command_memory;
/* enable busmastering */
tmpUlong |= PCI_command_master;
/* disable ISA I/O access */
tmpUlong &= ~PCI_command_io;
- set_pci(PCI_command, 4, tmpUlong);
+ set_pci(PCI_command, 2, tmpUlong);
/*work out which version of BeOS is running*/
get_system_info(&sysinfo);
@@ -500,15 +508,15 @@ static status_t map_device(device_info *di)
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];
+ /* enable ROM decoding - this is defined in the PCI standard */
+ tmpUlong = get_pci(PCI_rom_base, 4);
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,
+ (void *)di->pcii.u.h0.rom_base_pci,
+ di->pcii.u.h0.rom_size,
B_ANY_KERNEL_ADDRESS,
B_READ_AREA,
(void **)&(rom_temp)
@@ -521,12 +529,19 @@ static status_t map_device(device_info *di)
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);
+ /* dump ROM to file if selected in nv.settings */
+ if (current_settings.dumprom) dumprom (rom_temp, di->pcii.u.h0.rom_size);
+ /* we reserved 128Kb for the ROM mirror, but note actual size for reference */
+ si->rom.size = di->pcii.u.h0.rom_size;
+ /* make a copy of ROM for future reference, but truncate our mirror if needed */
+ rom_size = si->rom.size;
+ if (rom_size > (128 * 1024)) rom_size = (128 * 1024);
+ memcpy (si->rom.mirror, rom_temp, rom_size);
- /*disable ROM and delete the area*/
- set_pci(PCI_rom_base,4,0);
+ /* disable ROM decoding - this is defined in the PCI standard, and delete the area */
+ tmpUlong = get_pci(PCI_rom_base, 4);
+ tmpUlong &= 0xfffffffe;
+ set_pci(PCI_rom_base, 4, tmpUlong);
delete_area(rom_area);
/* work out a name for the framebuffer mapping*/
diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/nv.settings b/src/add-ons/kernel/drivers/graphics/nvidia/nv.settings
index a59caadfc6..14dbae91e5 100644
--- a/src/add-ons/kernel/drivers/graphics/nvidia/nv.settings
+++ b/src/add-ons/kernel/drivers/graphics/nvidia/nv.settings
@@ -14,7 +14,7 @@ hardcursor true # if true use on-chip cursor capabilities
#logmask 0x00000000 # nothing logged, is default
#logmask 0x08000604 # log overlay use in full
#logmask 0xffffffff # log everything
-dumprom false # dump bios rom in ~/nv.rom: probably not functional yet
+dumprom false # dump bios rom in ~/nv.rom
switchhead false # switch head assignment (dualhead cards only)
force_pci false # block AGP mode use if true (AGP cards only)
#--------- that's all.