How does emm386 work? And what is UMB?

Started by niko.farhi, November 16, 2007, 11:29:29 AM

Previous topic - Next topic

niko.farhi

Hi everybody,

I am a very sentimental guy and I really miss the old MS-DOS... So I have done a bit of research of my own about memory and memory management in real-mode and protected mode environment. I started looking for information about High Memory Area (HMA), Upper Memory Blocks (UMB), eXtended Memory, Expanded Memory, Unreal mode and so on. I think I've got most of the stuff but there are two questions that I was unable to answer:

1. What exactly is UMB? I think that those are RAM blocks accessible through high addresses (above 640K), does this mean that there was more RAM on the motherboard? And when accessing an address above 640K, how the computer "knows" whether I want to access some device mapped memory or just an UMB.

2. I stumbled upon emm386.exe (or emm386.sys) which, as I understand, can simulate Expanded memory using eXtended memory. I would really like to know HOW this is done. What exactly happens when I ask the emm386 expanded memory driver to map some mempry into the frame buffer? What kind of "magic" makes address below 1MB to be mapped into extended memory in real-mode?

I am pretty good in assembly and I am familiar with the 80386 protected mode and its features, so I would really appreciate detailed and technical answers. Please give me links to some technical reading material about the subject and other low-level howto's about the good old DOS days.

Thank you very much in advance,
Niko

eek

I never got that far in my DOS ramblings but I know that you needed a DOS extender to get out of DOS's limitations.

http://en.wikipedia.org/wiki/DOS_extender


eek

If you're really serious about DOS you should keep an eye out on ebay for old technical DOS publications, which pop up from time to time.

I would also recommend downloading everything useful you find on the net because more and more decent DOS stuff has been disappearing and has become a lot harder and more time consuming to find.


Wannabe

I guess browsing through the source code to the FreeDOS EMM386-clone could give som answers...
http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/dos/emm386/emms226.zip
Regards
  Wannabe

japheth


Hi,

for DOS questions, consider to use http://www.bttr-software.de/forum, which is the only active generic DOS forum in English language.



Larry Hammick

Just the other day I sent my DOS programmer's reference manual out with the recyclable paper.  :red
Anyway EMM386 is a thing that can be called by a 16-bit code segment, but will then switch to protected mode, read or write 32-bit memory (not the 36-bit address bus of the Pentium however), and then get back to the caller. Thus a DOS program can move chunks, of 4K each, in and out of what is visible at any one time in the 1MB area visible to DOS. An upper memory block (UMB) is a peculiar structure from the time of the 286; in those days the memory from 0 to 0x3FF was an interrupt vector table, 400 to 4FF was BIOS data, 500h through 9FFFF was command.com+io.sys+program+stack, and the top 6 chunks of 64K each (A0000 through FFFFF) were not writeable (bios ROM, video ROM, etc.). A UMB made it appear to a DOS program that it was writing somewhere in that area. At least, I think that's how it went. There was also a trick, now obsolete, for peeking at 64K above the 1MB limit, by exploiting some peculiarity of the hardware.

Anyways probably any DOS program can be written as a Windows console app, and for things like file filtering it has the same merit as DOS: no GUI consuming tons of memory and CPU time.

MichaelW

From DOS Internals, Geoff Chappell, Addison-Wesley, 1994:
Quote
By far the most complicated program loaded as a device driver and supplied as standard with DOS is EMM386.EXE. It constructs a protected-mode environment in which the DOS session runs as a virtual-8086 task. Careful use of the 80386 paging mechanism produces a situation in which pieces of memory from all over the 80386 address space are stitched together for the task â€" to be addressed as if the processor were still in 8086 real mode.

A UMB would be one of these pieces of memory mapped into the 8086 address space, typically in an otherwise unused area somewhere between 640KB and 1MB. With proper configuration DOS could be made to manage these UMBs and provide access to them.
eschew obfuscation