flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Accessing Video Card RAM?

Goto page 1, 2, 3  Next
Author
Thread Post new topic Reply to topic
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 27 Dec 2007, 21:08
Hey!

I was thinking about this a little while ago:

Suppose I wanted to access the RAM on my video card, would I do that directly like any other memory (e.g. move the memory address into ebx, and then store values using [ebx]) or do I have to access it somehow through my PCI/AGP/PCIe bus?

For the record I have an NVIDIA GeForce FX 5200 AGP Version with it's location being on PCI bus 1, device 0, function 0.

It's Resource Settings are the following (found under Device Manager Resources):

Memory Range FD000000 - FDFFFFFF
Memory Range E0000000 - E7FFFFFF
IRQ 16
I/O Range 03B0 - 03BB
I/O Range 03C0 - 03DF
Memory Range 000A0000 - 000BFFFF
Post 27 Dec 2007, 21:08
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20356
Location: In your JS exploiting you and your system
revolution 27 Dec 2007, 21:14
rhyno_dagreat wrote:
would I do that directly like any other memory (e.g. move the memory address into ebx, and then store values using [ebx]) or do I have to access it somehow through my PCI/AGP/PCIe bus?
Both of your proposed suggestions are the same thing. The bus is how you access the memory. Just read/write memory in the normal fashion. Of course, under a protected OS like Windows/Linux/Unix you will need to be in Ring0 to get access to those address ranges.
Post 27 Dec 2007, 21:14
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 27 Dec 2007, 21:25
Well, it would be for my own OS. Razz

But if that's the case, then what's up with having to read from/ write to ports for the PCI (e.g. Dex's Sound card program)? Or is that in the case of a processor on it?
Post 27 Dec 2007, 21:25
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20356
Location: In your JS exploiting you and your system
revolution 27 Dec 2007, 21:29
You gotta set resolutions/colours/mapping/etc. thats what ports are for.

Download the specs for your card. It will tell you how to set memory ranges and things.
Post 27 Dec 2007, 21:29
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 27 Dec 2007, 21:31
I wish I could, but nVidia wouldn't give out information if their lives depended upon it.
Post 27 Dec 2007, 21:31
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 27 Dec 2007, 21:36
What graphics mode are you using?


Last edited by dosin on 27 Dec 2007, 21:57; edited 2 times in total
Post 27 Dec 2007, 21:36
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 27 Dec 2007, 21:46
I would like to use hardware 800x600x32 (if possible).

I would also like to use hardware 2D drawing routines, maybe 3D in the future.
Post 27 Dec 2007, 21:46
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 27 Dec 2007, 21:50
Ya! Thats the mode I am working on..

all you need to do is set the mode you want:

0x4115 =800*600

Here is a link to a post for a VesaDemo.zip
that Dex4u made:
http://board.flatassembler.net/topic.php?t=7037

Dex4u has helped me a lot with this and if you look back in the forum there are different stuff like creating fonts in this mode..


Last edited by dosin on 27 Dec 2007, 22:24; edited 1 time in total
Post 27 Dec 2007, 21:50
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 27 Dec 2007, 22:06
rhyno: It is possible to locate address of video framebuffer by listing PCI devices. Feryno found this method recently.

But switching modes can hardly be done in some general way, you'd have to code card-specific driver, or call VESA, or something like that.
Post 27 Dec 2007, 22:06
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 27 Dec 2007, 22:25
Ah, I see. But as far as being able to tell what functions are which on the card, that's not standardized among all/most cards, is it?

Just an example, not to be taken literally:

Function1 - PutPixel(DWORD XCoord, DWORD YCoord)
Post 27 Dec 2007, 22:25
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 28 Dec 2007, 00:33
Quote:
I wanted to access the RAM on my video card, would I do that directly like any other memory (e.g. move the memory address into ebx, and then store values using [ebx])


YES.

Quote:
have to access it somehow through my PCI/AGP/PCIe bus


NOT "access", but maybe activate before ? Question

Quote:

Memory Range FD000000 - FDFFFFFF


Junk range ? 16 MiB anyway ...

Quote:

Memory Range E0000000 - E7FFFFFF


This seems to be the LFB Laughing

Quote:

IRQ 16
I/O Range 03B0 - 03BB
I/O Range 03C0 - 03DF


Silly IRQ + ports where you will have to deal with if ... you don't use VESA.

Quote:

Memory Range 000A0000 - 000BFFFF


Seems to be VGA Shocked

2 options:

- VESA (see other nice thread, avoids dealing with PCI/AGP/PCIe)
- "somehow through my PCI/AGP/PCIe bus" - YES, but don't ask me about how ! (and ask card inventors why they: 1. make simple things complicated 2. then don't even release the documentation Sad )

Quote:

Function1 - PutPixel(DWORD XCoord, DWORD YCoord)


Trivial as hell: LFBStart + XCoord * BytesPerPixel + YCoord * BytesPerScanline -> BOOM !!!

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug


Last edited by DOS386 on 28 Dec 2007, 06:08; edited 2 times in total
Post 28 Dec 2007, 00:33
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 28 Dec 2007, 03:54
Here the problem, you would be able to read/write to that LFB address, but first you would need to switch to the right mode, which is card specific.

Example if you code for the XBOX you would write to memory from 0xf0040000 to 0xf0086000 to write directly to screen, that as a nVidia GeForce 3MX, 64 MB of RAM graphic card. But on the Xbox the mode is set at bootup to 640x480 32bpp.

But i have found this link has some good info
http://coding.derkeiler.com/Archive/Assembler/alt.lang.asm/2003-11/0150.html

PS: I have always had a idea, of us OS dev's comeing up with a cheap and common hardware spec, that we all use or try to get.

eg: RTL8139 and a AC97 etc.
Post 28 Dec 2007, 03:54
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 790
Location: Adelaide
sinsi 28 Dec 2007, 06:00
rhyno_dagreat wrote:
Ah, I see. But as far as being able to tell what functions are which on the card, that's not standardized among all/most cards, is it?

Just an example, not to be taken literally:

Function1 - PutPixel(DWORD XCoord, DWORD YCoord)


Look at VESA 2 functions - with a little code, PutPixel is easy-peasy.
You get the LFB address, bytes per scan line, bits per pixel - simple arithmetic (for "linear" modes - forget about "banked" modes, not worth the headf*ck).

Some nvidia cards actually have VBE 3 and VBE acceleration functions, but VBE 2 has been the norm for a while.



edfed, go to sleep man.

Edit by Loco: The last line maybe refers to the split part that can be found here
Edit by sinsi: thanks man
Post 28 Dec 2007, 06:00
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 28 Dec 2007, 06:45
vid - Can you point Feryno to this thread with maybe an explaination of how he did it?

DOS386 - That's a lot of info. And the last bit... It acts like DOS video memory in that sense!? *smacks self in forehead*

Dex - Thanks for the link, it was interesting.

Sinsi - How can I get the LFB address from Vesa?

edfed - Lol.

I'm wondering, though. Will the LFB point at a random address as the beginning address for each mode when I start up that mode or will it be static like how memory is set in the sense of DOS video memory and such?
Post 28 Dec 2007, 06:45
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 28 Dec 2007, 07:00
> Sinsi - How can I get the LFB address from Vesa?

Download my LFB VESATEST (EXE is DOS only) : http://board.flatassembler.net/download.php?id=3472

> It acts like DOS video memory in that sense!?

You can access it via $A0000...$AFFFF - but then you will have to switch silly banks. And, this banking will not avoid the need to set a mode first.

> Will the LFB point at a random address as the beginning address

NO. It's usually > 2 GiB and theoretically can be different for every single mode, but in fact all modes use the same address (0 - no LFB ???). But it varies from card model to model. What a luck that I finalized (ignoring 1'000'000 compiler warnings Laughing ) my VESATEST 2 days ago Shocked


Last edited by DOS386 on 28 Dec 2007, 07:03; edited 1 time in total
Post 28 Dec 2007, 07:00
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4347
Location: Now
edfed 28 Dec 2007, 07:02
how t launch a XBOX game in a real xbox environment?

i think there is a int 13h like function to load the game, and a jmp game....

but it' only my imagination...
640*480 32bpp .... good, project gotham racing 2 nurburgring...

is there a FPU in the xbox?
how to control the graphix 3D card?
i want to use the pixel shader in asm, how to do?

undocumented?
Post 28 Dec 2007, 07:02
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 28 Dec 2007, 07:25
DOS386 - Finalize it how?

Note - how do I run this? Window's won't let it run.
Post 28 Dec 2007, 07:25
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 28 Dec 2007, 07:32
rhyno wrote:

> how do I run this? Window's won't let it run.

I had written:

> VESATEST (EXE is DOS only)

rhyno had written even before:

> Well, it would be for my own OS.

Then you will have to shut down "Windows" as well Idea

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 28 Dec 2007, 07:32
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 28 Dec 2007, 07:35
DOS386 - I failed to read it! I apologize. What can I run it with? MiniDOS?
It won't work in MiniDOS... Time to try FreeDOS... if it will work. =-/
Post 28 Dec 2007, 07:35
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 28 Dec 2007, 19:10
> What can I run it with? MiniDOS?

NO. DPMI32 app requiring file I/O.

> It won't work in MiniDOS...

Yeah ... MiniDOS isn't complete (see FAQ).

> Time to try FreeDOS... if it will work

YES. It's supposed to and works for me.

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 28 Dec 2007, 19:10
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.