Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Direct Access to video RAM

Hi, is there any way that I can access the video RAM directly under WindowsXP, and I don't mean like using an API such as DX/GL, or using DOS/BIOS services, i mean like writing directly into my [old Radeon 9000] grapphics card? Why can't I just access it like I would in DOS, by writing to a sertain mem? I mean if i know the address of any byte inside the vram , whats preventing me from writing on it? Thanks, Tim.

Comments

  • zibadianzibadian Member Posts: 6,349
    : Hi, is there any way that I can access the video RAM directly under
    : WindowsXP, and I don't mean like using an API such as DX/GL, or
    : using DOS/BIOS services, i mean like writing directly into my [old
    : Radeon 9000] grapphics card? Why can't I just access it like I would
    : in DOS, by writing to a sertain mem? I mean if i know the address of
    : any byte inside the vram , whats preventing me from writing on it?
    : Thanks, Tim.
    :
    In the old DOS days, the video RAM was part of the main RAM. Nowadays the video RAM resides on the video card and no longer in the main RAM. For low-level programming you need to create the screen image in the main RAM and then use the card's api to copy it into the card's video RAM.
  • vanillasnake21vanillasnake21 Member Posts: 21
    : In the old DOS days, the video RAM was part of the main RAM.
    : Nowadays the video RAM resides on the video card and no longer in
    : the main RAM. For low-level programming you need to create the
    : screen image in the main RAM and then use the card's api to copy it
    : into the card's video RAM.

    But for example, If I plan on developing my own os, how do I output quality images (i mean not like VGA 640x480x16) but like Windows or other OSs how do I do that? What does windows do to draw all the backgrounds and windows, I don't think it uses your graphics card, then how, thanks.
  • MT2002MT2002 Member Posts: 1,444
    : : In the old DOS days, the video RAM was part of the main RAM.
    : : Nowadays the video RAM resides on the video card and no longer in
    : : the main RAM. For low-level programming you need to create the
    : : screen image in the main RAM and then use the card's api to copy it
    : : into the card's video RAM.
    :
    : But for example, If I plan on developing my own os, how do I output
    : quality images (i mean not like VGA 640x480x16) but like Windows or
    : other OSs how do I do that? What does windows do to draw all the
    : backgrounds and windows, I don't think it uses your graphics card,
    : then how, thanks.
    :

    The video memory directly on video cards are not mapped to display memory.
    They are used by the GPU for faster hardware blitting and processing.

    Video memory is mapped in memory just like any other devices. In 16bit
    real mode, Video Memory is mapped from 0xB800:0 (Text mode), 0xA000:0
    (Graphics modes).

    For a 32 bit protected mode OS, you would need to write directly to
    the video ports and develope a driver to map video memory.

    Windows is a protected mode OS.

    For 16 bit modes, it is useually already mapped to 0xA000:0. So,
    to draw a pixel, just do this:
    [code]
    unsigned char* pmem = MK_FP (0xA000,0); // include dos.h -- get far ptr
    pMem[1] = 0xA; // draw a pixel
    [/code]
    This will *only* work in 16 bit compiliers. It wont work in 32bit
    compiliers for the reasons described above. Also, Windows doesnt allow
    direct access to hardware ports. Because of this, you either need a
    16 bit compilier, or a 32 bit compilier (without Win32 libraries)

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website[rightbr][/link][/size]
  • vanillasnake21vanillasnake21 Member Posts: 21
    : Video memory is mapped in memory just like any other devices. In
    : 16bit
    : real mode, Video Memory is mapped from 0xB800:0 (Text mode), 0xA000:0
    : (Graphics modes).
    :
    : For a 32 bit protected mode OS, you would need to write directly to
    : the video ports and develope a driver to map video memory.
    :
    : Windows is a protected mode OS.
    So what exactly is handling the video when I'm in proteced mode? Is it still the graphics memory? So technically if I write to graphics memory while im in protected mode (with a driver or wat not) I will be able to achive high resolutions and a 32 bit depth? Are there any books that describe video architectures that I need? Thanks for fast replies
  • MT2002MT2002 Member Posts: 1,444
    : : Video memory is mapped in memory just like any other devices. In
    : : 16bit
    : : real mode, Video Memory is mapped from 0xB800:0 (Text mode), 0xA000:0
    : : (Graphics modes).
    : :
    : : For a 32 bit protected mode OS, you would need to write directly to
    : : the video ports and develope a driver to map video memory.
    : :
    : : Windows is a protected mode OS.
    : So what exactly is handling the video when I'm in proteced mode? Is
    : it still the graphics memory? So technically if I write to graphics
    : memory while im in protected mode (with a driver or wat not) I will
    : be able to achive high resolutions and a 32 bit depth? Are there any
    : books that describe video architectures that I need? Thanks for fast
    : replies
    :

    For high resolution graphics in pmode, you will need to learn how
    to program an SVGA driver to support it.

    If you never had experienced programming the VGA, SVGA can be hard.

    After mapping video memory to 0xA000 through SVGA, then you can just
    access VRAM directly, just like real mode.

    [b]Note: This will only work if you have the envirement set up
    for low level C or C++. Windows will not allow *any* Win32 PE/MZ
    executable to directly access hardware.[/b]

    If this is what you are looking for, Ill post a link to a tutorial for you.
    I dont know what compilier you have, so I dont know if the above will
    work for you or not.

    Writing your own drivers (For SVGA, for example) require that your program
    run in Ring 0, while most programs are in Ring 3 (This is one reason why
    Windows does not allow direct hardware access)

    As you can see, its much easier to either go through a System API,
    or the video interrupts mapped by the BIOS. (You can always switch
    to v8086 mode, and execute the video interrupts, then switch back :-))

    If you still decide this is what you want, Ill post links:-)


    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website[rightbr][/link][/size]
  • vanillasnake21vanillasnake21 Member Posts: 21
    : For high resolution graphics in pmode, you will need to learn how
    : to program an SVGA driver to support it.
    :
    : If you never had experienced programming the VGA, SVGA can be hard.
    :
    : After mapping video memory to 0xA000 through SVGA, then you can just
    : access VRAM directly, just like real mode.
    :
    : [b]Note: This will only work if you have the envirement set up
    : for low level C or C++. Windows will not allow *any* Win32 PE/MZ
    : executable to directly access hardware.[/b]
    :
    : If this is what you are looking for, Ill post a link to a tutorial
    : for you.
    : I dont know what compilier you have, so I dont know if the above will
    : work for you or not.
    :
    : Writing your own drivers (For SVGA, for example) require that your
    : program
    : run in Ring 0, while most programs are in Ring 3 (This is one reason
    : why
    : Windows does not allow direct hardware access)
    :
    : As you can see, its much easier to either go through a System API,
    : or the video interrupts mapped by the BIOS. (You can always switch
    : to v8086 mode, and execute the video interrupts, then switch back
    : :-))
    :
    : If you still decide this is what you want, Ill post links:-)
    :

    thanks, first off a few questions...
    My intentions are actually a little different than simply writing my own app that will run under windows, I just want to know how windows does it, so I can use it as an example for moyabe doing something similar in a different OS or something. So for example, we have a comp with no OS (or a very simple kernel) and its running in protected mode, how can this OS display the high resolutions and bitdepths similar to those of Windows. As you can see there are no rings, and no restrictions so basically I can talk directly to hardware. Do I still have to address SVGA? Doesnt SVGA output 800x600 res? If so, then windows isn't using SVGA? Thnks a lot :]



  • MT2002MT2002 Member Posts: 1,444
    : thanks, first off a few questions...
    : My intentions are actually a little different than simply writing my
    : own app that will run under windows, I just want to know how windows
    : does it, so I can use it as an example for moyabe doing something
    : similar in a different OS or something. So for example, we have a
    : comp with no OS (or a very simple kernel) and its running in
    : protected mode, how can this OS display the high resolutions and
    : bitdepths similar to those of Windows. As you can see there are no
    : rings, and no restrictions so basically I can talk directly to
    : hardware. Do I still have to address SVGA? Doesnt SVGA output
    : 800x600 res? If so, then windows isn't using SVGA? Thnks a lot :]
    :

    If you want your program to run under Windows, you will either
    need to go through the system API, or build a 16 bit program.
    No exceptions. 16 bit programs are elmulated by Windows NTVDM
    to emulate real mode programs, so it will work

    OS Kernels execute at Ring 0. The processor uses the rings inheritely
    for protection. Ring 0 has no protection nor limtations, so if a tiny
    bug happens in the kernel, it can force the processor to reboot.

    All Ring 0 programs, such as Kernels and device drivers, communicate to
    the hardware through memory mapped software ports. Along with this,
    video memory is useually mapped to 0xA000:0.

    You should look at Vesa programming. Higher resolution video is
    useually handled by specific video drivers developed by a specific
    manufacturer. This is true, even for Windows. (ie, Uninstall all
    video drivers, and see what you are left with :-))

    There are *lots* of tutorials on the web. Just type "Vesa programming"
    in Google, and be amazed:-D

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website[rightbr][/link][/size]
  • vanillasnake21vanillasnake21 Member Posts: 21

    : There are *lots* of tutorials on the web. Just type "Vesa
    : programming"
    : in Google, and be amazed:-D

    Thanks, now I get it, thats the thing, I though that Windows itself is responsible for rendering all the hi-res graphics, if someone had just told me that thats the responsibility of the gfx card it would have been a different story, "sigh", anyways thanks a lot I will definitely look into VESA and from what I already found thats all I need, VBE supports 1024x768x32
    which is perfect, but one last question, since VBE 2.0 and VESA 1 are all standards, does that mean that only certain cards support them? So I would not be able to use VBE on an older card (say for example my current card - radeon 9000 :D)
  • MT2002MT2002 Member Posts: 1,444

    : which is perfect, but one last question, since VBE 2.0 and VESA 1
    : are all standards, does that mean that only certain cards support
    : them? So I would not be able to use VBE on an older card (say for
    : example my current card - radeon 9000 :D)

    I should note that, if you are building your own OS, you will
    need to write the drivers (or try to get the companies to do it)
    that are compatible with your OS.

    Vesa should be supported, Im not sure about VBE though.

    I would recommend first building a VGA driver, and handling
    other drivers ontop of that (Such as Vesa). This way, if its not
    supported, you can fall back to VGA graphics.

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website[rightbr][/link][/size]
  • counteropcounterop Member Posts: 3
    Old topic, but a little clarity as I was reinvesting into this. To start, VESA was an organization that set the standards of video resolutions. It worked mainly before the year 2000 when you could directly access the video memory at address 0xA000:offset. They also created the idea of "video banking" to utilize the video memory beyond the 64k limit being this was the most memory would hold.

    Now a number of factors limit, prevent and alter these methods as "Microsoft" does it from their low-level. To start, those video resolutions were "square" and not up-to-date with modern LCD monitors that are "rectangular". You will notice that most resolutions supported by the VESA standard are "square." So hence, this was one reason that it still exists in onboard chips but "not" in video cards. This was stated above, but not clarified.

    Drivers are also required to directly access video cards. This was the driver nightmare of the 80s and 90s that was solved for the better part by Windows. A number of "foreign" cards were being installed and used in desktops. The video was also partly the responsibility of the CRT monitors and not always the computer itself. As technology adapted, people wanted more to play their silly video games at higher qualities other than blocks. The force of new generations somehow requiring 3-D graphics made the introduction of "GPUs" that was essentially stupid to move a chip 3 inches away and through an adapater. However, in nanoseconds it was essential.

    The above was very correct in the differences of 16-bit and 32-bit, however CPUs also hinder this. If you were writing an ASM program you must access the CPU. However, with the knowledge of upcoming multi-processors to access them you need yet another add-on arhcheticture. It was not necessarily because of the Windows NT operating system preventing this from their drivers, but also the fact of accessing ASM commands (which is processor driven). The complexity of computers has hindered old ideas and in away was "thrown in the works."

    You can with DOS-Box and a free MASM compiler (must be installed in the C drive specifically) create ASM programs to some degree. However and indeed, Windows NT systems prevent calls to BIOS/Motherboard/CPU calls such as INT10h, INT21h (keyboards, mice and video). You will have to use the drivers used on your system, but to overwrite this you will have to rewrite the driver. "Without" the source code to these drivers it is virtually impossible to do so unless you work for IBM.

    My complaint suggestion as the others is to install a Linux system and do a write() command to the device file "/dev/vcs0" and have bash parsed the junk...

Sign In or Register to comment.