[DOSEMU Logo]
DOSEMU.org

| Home | | Developer Releases | | Stable Releases | | Documentation |

Home
README
Technical README
HOWTO
DANG  - 0.99
EMUfailure
Misc
Next Previous Contents

5. The Video group of Modules

All of the Video handling code is in the "video" subdirectory.

There is one file for each video card or chipset and the master file. To Add a new card, it needs a set of save & restore routines putting in a file here.

5.1 env/video/vc.c Information

Here's all the calls to the code to try and properly save & restore the video state between VC's and the attempts to control updates to the VC whilst the user is using another. We map between the real screen address and that used by DOSEMU here too.

Attempts to use a cards own bios require the addition of the parameter "graphics" to the video statement in "/etc/dosemu.conf". This will make the emulator try to execute the card's initialization routine which is normally located at address c000:0003. This can now be changed as an option.

5.2 env/video/video.c Information

5.3 Functions in env/video/video.c

These are the functions defined in env/video/video.c.

video_init

Set pointer to correct structure of functions to initialize, close, etc... video routines.

5.4 Remarks in env/video/video.c

Here the sleeping lion will be awoken and eat much of CPU time !!!

The result of setting VM86_SCREEN_BITMAP (at state of Linux 1.1.56): Each vm86 call will set 32 pages of video mem RD-only (there may be 1000000 per second) Write access to RD-only page results in page-fault (mm/memory.c), which will set a bit in current->screen_bitmap and calls do_wp_page() which does __get_free_page(GFP_KERNEL) but frees it immediatly, because copy-on-write is not neccessary and sets RD/WR for the page. (this could happen 32000000 per second, if the CPU were fast enough) It would be better to get the DIRTY-bit directly from the page table, isn't it? A special syscall in emumodule could do this.

-----

reserve_video_memory()

This procedure is trying to eke out all the UMB blocks possible to maximize your memory under DOSEMU. If you know about dual monitor setups, you can contribute by putting in the correct graphics page address values.

5.5 env/video/X.c Information

This module contains the video interface for the X Window System. It has mouse and selection 'cut' support.

5.6 Functions in env/video/X.c

These are the functions defined in env/video/X.c.

vga256_cmap_init

Allocates a colormap for 256 color modes and initializes it.

X_close

Destroys the window, unloads font, pixmap and colormap.

X_setmode

Resizes the window, also the graphical sizes/video modes. remember the dos videomodi

X_change_mouse_cursor(void)

This function seems to be called each screen_update :( It is called in base/mouse/mouse.c:mouse_cursor(int) a lot for show and hide.

X_redraw_screen

Redraws the entire screen, also in graphics mode Used for expose events etc.

returns: nothing

Arguments are:

  • none

X_update_screen

Updates the X screen, in text mode and in graphics mode. Both text and graphics in X have to be smarter and improved.

X_update_screen returns 0 if nothing was updated, 1 if the whole screen was updated, and 2 for a partial update.

It is called in arch/linux/async/signal.c::SIGALRM_call() as part of a struct video_system (see end of X.c) every 50 ms or every 10 ms if 2 was returned, depending somewhat on various config options as e.g. config.X_updatefreq and VIDEO_CHECK_DIRTY. At least it is supposed to do that.

Arguments are:

  • none

set_mouse_position

places the mouse on the right position Not tested in X with graphics

returns: nothing

Arguments are:

  • x,y - coordinates

5.7 Remarks in env/video/X.c

DO NOT REMOVE THIS TEST!!! It is magic, without it EMS fails on my machine under X. Perhaps someday when we don't use a buggy /proc/self/mem.. -- EB 18 May 1998 A slightly further look says it's not the test so much as suppressing noop resize events... -- EB 1 June 1998

5.8 env/video/vgaemu.c Information

The VGA emulator for DOSEmu.

Emulated are the video memory and the VGA register set (CRTC, DAC, etc.). Parts of the hardware emulation is done in separate files (attremu.c, crtcemu.c, dacemu.c and seqemu.c).

VGAEmu uses the video BIOS code in base/bios/int10.c and env/video/vesa.c.

For an excellent reference to programming SVGA cards see Finn Thøgersen's VGADOC4, available at http://www.datashopper.dk/ finth

5.9 Functions in env/video/vgaemu.c

These are the functions defined in env/video/vgaemu.c.

VGA_emulate_outb

Emulates writes to VGA ports. This is a hardware emulation function.

Arguments are:

  • port - The port being written to.
  • value - The value written,

VGA_emulate_inb

Emulates reads from VGA ports. This is a hardware emulation function.

Arguments are:

  • port - The port being read from.

vga_emu_fault

vga_emu_fault() is used to catch video access, and handle it. This function is called from arch/linux/async/sigsegv.c::dosemu_fault1(). The sigcontext_struct is defined in include/cpu.h. Now it catches only changes in a 4K page, but maybe it is useful to catch each video access. The problem when you do that is, you have to simulate each instruction which could write to the video memory. It is easy to get the place where the exception happens (scp->cr2), but what are those changes? An other problem is, it could eat a lot of time, but it does now also.

Arguments are:

  • scp - A pointer to a struct sigcontext_struct holding some relevant data.

vga_emu_init

vga_emu_init() must be called before using the VGAEmu functions. It is only called from env/video/X.c::X_init() at the moment. This function basically initializes the global variable `vga' and allocates the VGA memory.

It does in particular *not* map any memory into the range 0xa0000 - 0xc0000, this is done as part of a VGA mode switch.

There should be an accompanying vga_emu_done().

Arguments are:

  • vedt - Pointer to struct describing the type of display we are actually
  • attached to.

vga_emu_update

vga_emu_update() scans the VGA memory for dirty (= written to since last update) pages and returns the changed area in *veut. See the definition of vga_emu_update_type in env/video/vgaemu_inside.h for details.

You will need to call this function repeatedly until it returns 0 to grab all changes. You can specify an upper limit for the size of the area that will be returned using `veut->max_max_len' and `veut->max_len'. See the example in env/video/X.c how this works.

If the return value of vga_emu_update() is >= 0, it is the number of changed pages, -1 means there are still changed pages but the maximum update chunk size (`veut->max_max_len') was exceeded.

This function does in its current form not work for Hercules modes; it does, however work for text modes, although this feature is currently not used.

Arguments are:

  • veut - A pointer to a vga_emu_update_type object holding all relevant info.

vga_emu_switch_bank

vga_emu_switch_bank() is used to emulate video-bankswitching.

This function returns True on success and False on error, usually indicating an invalid bank number.

Arguments are:

  • bank - The bank to switch to.

vga_emu_find_mode

Searches a video mode with the requested mode number.

The search starts with the mode *after* the mode `vmi' points to. If `vmi' == NULL, starts at the beginning of the internal mode table. `mode' may be a standard VGA mode number (0 ... 0x7f) or a VESA mode number (>= 0x100). The mode number may have its don't-clear-bit (bit 7 or bit 15) or its use-lfb-bit (bit 14) set. The special mode number -1 will match any mode and may be used to scan through the whole table.

Returns NULL if no mode was found and a pointer into the mode table otherwise. The returned pointer is a suitable argument for subsequent calls to this function.

You should (and can) access the mode table only through this function.

Arguments are:

  • mode - video mode.
  • vmi - pointer into internal mode list

vga_emu_setmode

Set a video mode.

Switches to `mode' with text sizes `width' and `height' or (if no such mode was found) at least `width' and `height'.

Arguments are:

  • mode - The new video mode.
  • width - Number of text columns.
  • height - Number of text rows.

dirty_all_video_pages

Marks the whole VGA memory as modified.

vga_emu_set_text_page

Set visible text page.

`vga.display_start' is set to `page' * `page_size'. This function works only in text modes.

Arguments are:

  • page - Number of the text page.
  • page_size - Size of one text page.

5.10 env/video/vesa.c Information

VESA BIOS Extensions for VGAEmu.

Supported are VBE version 2.0, including a linear frame buffer and display power management support.

5.11 Functions in env/video/vesa.c

These are the functions defined in env/video/vesa.c.

vbe_init

Initializes the VGA/VBE BIOS and the VBE support.

Arguments are:

  • vedt - Pointer to struct describing the type of display we are actually
  • attached to.

vesa_emu_fault

vesa_emu_fault() is used to handle video ROM accesses. This function is called from env/video/vgaemu.c:vga_emu_fault(). The sigcontext_struct is defined in include/cpu.h It just jumps over the instruction (LWORD (eip) += instr-len) which caused the write exception to the video ROM. It is needed for some dirty programs that try to write to a ROM (dos=high,umb seems to do this, but not on all PC's). We're sure now, nobody can write to the ROM and we don't crash on it, just ignore as it should be!

Arguments are:

  • scp - A pointer to a struct sigcontext_struct holding some relevant data.

do_vesa_int

This is the VESA interrupt handler.

It is called from base/bios/int10.c::int10(). The VESA interrupt is called with 0x4f in AH and the function number (0x00 ... 0x10) in AL.

5.12 env/video/vesabios.S Information

The VGA/VESA BIOS for VGAEmu.

This is what DOS applications see as their video BIOS. It will be mapped at 0xc000:0x0000 and typically be less than one page in size. This video BIOS is write-protected, write accesses to this memory are emulated by vesa_emu_fault() in env/video/vesa.c.

It doesn't have much functionality, just stores the VESA mode table and the protected mode interface necessary for VESA BIOS Extension (VBE) support.

Note that some parts of the video BIOS are added by vbe_init() in env/video/vesa.c.

5.13 env/video/vesabios_pm.S Information

5.14 env/video/attremu.c Information

The protected mode code for the VESA BIOS Extensions.

We define some functions here that are required to support the VBE 2.0 protected mode interface.

The whole code _must_ be fully relocatable. It will be copied into the video BIOS during VBE initialization (cf. vbe_init()).

The Attribute Controller emulator for VGAemu.

5.15 Functions in env/video/attremu.c

These are the functions defined in env/video/attremu.c.

Attr_init

Initializes the attribute controller.

Attr_write_value

Emulates writes to attribute controller combined index and data register. Read vgadoc3 for details. This is a hardware emulation function.

Attr_read_value

Emulates reads from the attribute controller. This is a hardware emulation function.

Attr_get_index

Returns the current index of the attribute controller. This is a hardware emulation function, though in fact this function is undefined in a real attribute controller.

Attr_get_input_status_1

5.16 env/video/dacemu.c Information

The DAC emulator for DOSemu.

5.17 Functions in env/video/dacemu.c

These are the functions defined in env/video/dacemu.c.

DAC_init

Initializes the DAC.

DAC_dirty_all

Dirty all DAC entries. Usefull for a mode set.

DAC_set_read_index

Specifies which palette entry is read. This is a hardware emulation function.

DAC_set_write_index

Specifies which palette entry is written. This is a hardware emulation function.

DAC_read_value

Read a value from the DAC. Each read will cycle through the registers for red, green and blue. After a ``blue read'' the read index will be incremented. Read vgadoc3 if you want to know more about the DAC. This is a hardware emulation function.

DAC_write_value

Write a value to the DAC. Each write will cycle through the registers for red, green and blue. After a ``blue write'' the write index will be incremented. This is a hardware emulation function.

DAC_set_pel_mask

Sets the pel mask and marks all DAC entries as dirty. This is a hardware emulation function.

DAC_get_entry

Returns a complete DAC entry (r,g,b). Color values are AND-ed with the pel mask. This is an interface function.

DAC_read_entry

Returns a complete DAC entry (r,g,b), doesn't un-dirty it. Color values are _not_ maked. This is an interface function.

DAC_get_dirty_entry

Searches the DAC_dirty list for the first dirty entry. Returns the changed entrynumber and fills in the entry if a dirty entry is found or returns -1 otherwise. This is an interface function.

DAC_set_entry

Sets a complete DAC entry (r,g,b). This is an interface function for the int 10 handler.

DAC_get_pel_mask

Returns the current pel mask. Drawing functions should get the pel mask and AND it with the pixel values to get the correct pixel value. This is *very* slow to implement and fortunately this register is used very rare. Maybe the implementation should be in vgaemu, maybe in the vgaemu client... This is an interface function.

DAC_get_state

Returns the current state of the DAC This is an interface function.

5.18 env/video/seqemu.c Information

5.19 env/video/crtcemu.c Information

The VGA sequencer for VGAemu. The VGA CRT controller emulator for VGAEmu.

This emulates a very basic CRT controller. Just the start address registers (0xc, 0xd).

5.20 env/video/remap.c Information

Transform a 2D image (rescale and color space conversion).

Here are functions to adapt the VGA graphics to various X displays.

5.21 env/video/remap_asm.S Information

Low-level assembler functions for remapping 2D images.

Note that these functions mostly call other functions that have been calculated in remap.c.

5.22 env/video/console.c Information

5.23 env/video/dualmon.c Information

5.24 Functions in env/video/dualmon.c

These are the functions defined in env/video/dualmon.c.

MDA_init

Initializes the monochrome card. First detects which monochrome card is used, because the Hercules RamFont and the Hercules InColor need one more register to be initialized. If there is no monochrome card at all, we just think there is one and poke an peek in the void. After the detection the card is initialized.

returns: nothing

Arguments are:

  • none

5.25 Remarks in env/video/dualmon.c

After MDA_init() the VGA is configured, something in video.c or console.c "reprograms" the monochrome card again in such a way that I always have to run hgc.com before I can use any program that uses the monochrome card. I've spent a day trying to find it, but I can't figure out. Something is writing to one of the following ports: 0x3b4, 0x3b5, 0x3b8, 0x3b9, 0x3ba, 0x3bb, 0x3bf. The problem occurs at (at least) the following 2 systems:

- AMD 386DX40, Trident 9000/512Kb ISA, Hercules Graphics Card Plus - Intel 486DX2/66, Cirrus Logic 5426/1Mb VLB, Hercules clone

The problem doesn't occur when I start dosemu from a telnet connection or from a VT100 terminal. (Erik Mouw, jakmouw@et.tudelft.nl)

5.26 env/video/et4000.c Information

5.27 env/video/hgc.c Information

5.28 base/bios/int10.c Information

Video BIOS implementation.

This module handles the int10 video functions. Most functions here change only the video memory and status variables; the actual screen is then rendered asynchronously after these by Video->update_screen.

5.29 env/video/s3.c Information

5.30 env/video/terminal.c Information

5.31 env/video/trident.c Information

5.32 env/video/vga.c Information

5.33 env/video/vgaemu.c Information

The VGA emulator for DOSEmu.

Emulated are the video memory and the VGA register set (CRTC, DAC, etc.). Parts of the hardware emulation is done in separate files (attremu.c, crtcemu.c, dacemu.c and seqemu.c).

VGAEmu uses the video BIOS code in base/bios/int10.c and env/video/vesa.c.

For an excellent reference to programming SVGA cards see Finn Thøgersen's VGADOC4, available at http://www.datashopper.dk/ finth

5.34 Functions in env/video/vgaemu.c

These are the functions defined in env/video/vgaemu.c.

VGA_emulate_outb

Emulates writes to VGA ports. This is a hardware emulation function.

Arguments are:

  • port - The port being written to.
  • value - The value written,

VGA_emulate_inb

Emulates reads from VGA ports. This is a hardware emulation function.

Arguments are:

  • port - The port being read from.

vga_emu_fault

vga_emu_fault() is used to catch video access, and handle it. This function is called from arch/linux/async/sigsegv.c::dosemu_fault1(). The sigcontext_struct is defined in include/cpu.h. Now it catches only changes in a 4K page, but maybe it is useful to catch each video access. The problem when you do that is, you have to simulate each instruction which could write to the video memory. It is easy to get the place where the exception happens (scp->cr2), but what are those changes? An other problem is, it could eat a lot of time, but it does now also.

Arguments are:

  • scp - A pointer to a struct sigcontext_struct holding some relevant data.

vga_emu_init

vga_emu_init() must be called before using the VGAEmu functions. It is only called from env/video/X.c::X_init() at the moment. This function basically initializes the global variable `vga' and allocates the VGA memory.

It does in particular *not* map any memory into the range 0xa0000 - 0xc0000, this is done as part of a VGA mode switch.

There should be an accompanying vga_emu_done().

Arguments are:

  • vedt - Pointer to struct describing the type of display we are actually
  • attached to.

vga_emu_update

vga_emu_update() scans the VGA memory for dirty (= written to since last update) pages and returns the changed area in *veut. See the definition of vga_emu_update_type in env/video/vgaemu_inside.h for details.

You will need to call this function repeatedly until it returns 0 to grab all changes. You can specify an upper limit for the size of the area that will be returned using `veut->max_max_len' and `veut->max_len'. See the example in env/video/X.c how this works.

If the return value of vga_emu_update() is >= 0, it is the number of changed pages, -1 means there are still changed pages but the maximum update chunk size (`veut->max_max_len') was exceeded.

This function does in its current form not work for Hercules modes; it does, however work for text modes, although this feature is currently not used.

Arguments are:

  • veut - A pointer to a vga_emu_update_type object holding all relevant info.

vga_emu_switch_bank

vga_emu_switch_bank() is used to emulate video-bankswitching.

This function returns True on success and False on error, usually indicating an invalid bank number.

Arguments are:

  • bank - The bank to switch to.

vga_emu_find_mode

Searches a video mode with the requested mode number.

The search starts with the mode *after* the mode `vmi' points to. If `vmi' == NULL, starts at the beginning of the internal mode table. `mode' may be a standard VGA mode number (0 ... 0x7f) or a VESA mode number (>= 0x100). The mode number may have its don't-clear-bit (bit 7 or bit 15) or its use-lfb-bit (bit 14) set. The special mode number -1 will match any mode and may be used to scan through the whole table.

Returns NULL if no mode was found and a pointer into the mode table otherwise. The returned pointer is a suitable argument for subsequent calls to this function.

You should (and can) access the mode table only through this function.

Arguments are:

  • mode - video mode.
  • vmi - pointer into internal mode list

vga_emu_setmode

Set a video mode.

Switches to `mode' with text sizes `width' and `height' or (if no such mode was found) at least `width' and `height'.

Arguments are:

  • mode - The new video mode.
  • width - Number of text columns.
  • height - Number of text rows.

dirty_all_video_pages

Marks the whole VGA memory as modified.

vga_emu_set_text_page

Set visible text page.

`vga.display_start' is set to `page' * `page_size'. This function works only in text modes.

Arguments are:

  • page - Number of the text page.
  • page_size - Size of one text page.

5.35 include/vgaemu.h Information

Header file for the VGA emulator for DOSEmu.

This file describes the interface to the VGA emulator. Have a look at env/video/vgaemu.c and env/video/vesa.c for details.


Next Previous Contents
 
The DOSEMU team