Page 1 of 2

The happiest screenshot of my entire OS-dev life!

Posted: Tue Jan 27, 2009 1:29 pm
by JamesM
Hi,

Title is no joke - I finally got my nvidia 2D acceleration driver working! It took 3-4 days of solid work, but now I have hardware bitblitting and rectangle drawing. Hardware cursors soon to follow!

The screenshow below was generated by the following code (after switching modes with my VBE driver).

Code: Select all

  // Pink background to make sure we see any effects - engine may accidentally blit black pixels for example, and we won't pick that
  // up on a black background.
  for (int x = 0; x < 512; x++)
  {
    for (int y = 0; y < 512; y++)
    {
      pFb->write16(0xF00F, (y * 1024 + x) * 2);
    }
  }

  // Draw an image.
  for (int x = 0; x < 128; x++)
  {
    for (int y = 256; y < 128+256; y++)
    {
      pFb->write16(0xFFFF, (y * 1024 + x) * 2);
    }
  }

  // Card detection is done but not coded yet - hardcoded to the device class in my testbed.
  Dma *pDma = new Dma(pRegs, pFb, NV30A, NV34, 0x300000 /* Card RAM - hardcoded for now */);
  pDma->init();

  pDma->screenToScreenBlit(0, 256, 400, 100, 100, 100);

  pDma->fillRectangle(600, 600, 100, 100);

  for(;;);
}

EDIT - linked to it instead because it's HUUGEE!!!
http://www.jamesmolloy.co.uk/rubbish-bin/nvidia1.jpg

Re: The happiest screenshot of my entire OS-dev life!

Posted: Tue Jan 27, 2009 1:36 pm
by AJ
Congratulations! I'm already looking forward to the "3D modelling with bump mapping" screen shot =D> I'd top up that glass :)

Cheers,
Adam

Re: The happiest screenshot of my entire OS-dev life!

Posted: Tue Jan 27, 2009 1:51 pm
by DeletedAccount
Well done =D>

Regards
Shrek

Re: The happiest screenshot of my entire OS-dev life!

Posted: Tue Jan 27, 2009 2:27 pm
by stephenj
Nice!

GUI stuff is the best because you can show it to people who don't know how to code.

You should do a youtube demo to really show off :)

Re: The happiest screenshot of my entire OS-dev life!

Posted: Tue Jan 27, 2009 7:51 pm
by clange
Cool achievement - congratulation.

clange

Re: The happiest screenshot of my entire OS-dev life!

Posted: Wed Jan 28, 2009 2:43 am
by Combuster
I see you also succesfully tackled the challenge of implementing hardware acceleration =D> :D

You mind telling us where you got the necessary documentation from?

Re: The happiest screenshot of my entire OS-dev life!

Posted: Wed Jan 28, 2009 5:56 am
by Creature
Graphics-related programming has always been my favourite subject, so I have the same question as Combuster.

Congratulations!

Re: The happiest screenshot of my entire OS-dev life!

Posted: Wed Jan 28, 2009 6:23 am
by eddyb
Combuster wrote:You mind telling us where you got the necessary documentation from?
as he said in #osdev and #exclaim: reverse engineering and some open source drivers :P

Re: The happiest screenshot of my entire OS-dev life!

Posted: Wed Jan 28, 2009 6:39 am
by JamesM
Combuster wrote:I see you also succesfully tackled the challenge of implementing hardware acceleration =D> :D

You mind telling us where you got the necessary documentation from?
Hey Combuster,

Mainly the Haiku nvidia driver and the nouveau driver. The haiku one is based on the nouveau one but has more comments so reads better. I also found that a lot of the code there relates to coldstarting the card - copying VGA BIOSes and suchlike around, which you don't really need to do.

Cheers,

James

Re: The happiest screenshot of my entire OS-dev life!

Posted: Wed Jan 28, 2009 10:18 am
by JamesM
berkus wrote:
JamesM wrote:I also found that a lot of the code there relates to coldstarting the card - copying VGA BIOSes and suchlike around, which you don't really need to do.
Why are they doing it though?
A poignant question that I can't answer. I assume it must be needed for something. What is a different matter - remember that both these drivers are based on reverse engineered code.

All I know is that my code works without doing the coldstart/bios copy.

James

Re: The happiest screenshot of my entire OS-dev life!

Posted: Wed Jan 28, 2009 11:01 am
by AJ
Hi,

Just guesswork, but perhaps the Video BIOS copy is just a version of Video BIOS Shadowing - the author of the driver just wanted a speed increase so copied the BIOS from the video ROM in to main memory?

As for the cold start - is it possible that unflushed video RAM could cause wierdness if the PC was reset? If so, perhaps it's just to make ensure that the GPU/video RAM are in a known state. If so, it would be wise to include the coldstart code because you'll never know what set of circumstances could make it go for a burton in future.

Cheers,
Adam

Re: The happiest screenshot of my entire OS-dev life!

Posted: Fri Jan 30, 2009 9:58 am
by jal
berkus wrote:Why are they doing it though?
A while ago I read an article about some Linux guys using vm86 or an emulator of sorts to set video modes using the BIOS. For some reason, though I would assume it's the easiest thing to reverse engineer, setting modes is considered to be difficult to do without BIOS help. Or something.


JAL

Re: The happiest screenshot of my entire OS-dev life!

Posted: Fri Jan 30, 2009 10:36 am
by earlz
nice work.. not just getting an accelerated driver working, but a closed documentation one as well! if you happen to reverse engineer a driver that works better than those linux drivers you should share it! maybe people have been looking for good updated drivers for nvidia cards

Re: The happiest screenshot of my entire OS-dev life!

Posted: Fri Jan 30, 2009 11:52 am
by stephenj
Earlz, you might want to look at Nouveau

Re: The happiest screenshot of my entire OS-dev life!

Posted: Sun Feb 08, 2009 10:37 pm
by blackoil
well, I expect a ASM / C seperated version, that we can share to use in own OS.

from PCI32 tool, my gfx card info
Bus 1 (AGP), Device Number 0, Device Function 0
Vendor 10DEh Nvidia Corp
Device 0110h GeForce2 MX/MX 400 [NV11]
Command 0007h (I/O Access, Memory Access, BusMaster)
Status 02B0h (Has Capabilities List, Supports 66MHz, Supports Back-To-Back Tra
s., Medium Timing)
Revision B2h, Header Type 00h, Bus Latency Timer F8h
Minimum Bus Grant 05h, Maximum Bus Latency 01h
Self test 00h (Self test not supported)
PCI Class Display, type VGA
Subsystem ID 009110DEh Unknown
Subsystem Vendor 10DEh Nvidia Corp
Address 0 is a Memory Address (anywhere in 0-4Gb) : FD000000h
Address 1 is a Memory Address (anywhere in 0-4Gb, Prefetchable) : E8000000h
System IRQ 16, INT# A
Expansion ROM of 64Kb decoded by this card (Currently disabled)
New Capabilities List Present:
Power Management Capability, Version 1.1
Does not support low power State D1 or D2
Does not support PME# signalling
Current Power State : D0 (Device operational, no power saving)
AGP Capability, Version 2.0 (AGP 4x and below support)
AGP Speed(s) Supported : 1x 2x 4x
FW Transfers Supported : No
>4Gb Address Space Supported : No
Sideband Addressing Supported : No
Maximum Command Queue Length : 32 bytes
AGP Speed Selected : 4x
FW Transfers Enabled : No
>4Gb Address Space Enabled : No
AGP Enabled : Yes
Sideband Addressing Enabled : No
Current Command Queue Length : 32 bytes

address FD000000h is for framebuffer
address E8000000h is for mmio
and PCI32 knows something of FIFO cmd queue.

register map & cmd code are needed to
unlock the engine
put src dest width height colormix in respective registers
then queue cmd code