EMM386
EMM386
EMM386
�����������������http://www.mdgx.com/������������������
��������������������
MS-DOS 6.xx/7.xx/8.00 + Windows 3.1x/95/98/ME
���������������������������������������������
EMM386.EXE + MEMORY MANAGEMENT TECHNICAL DETAILS
������������������������������������������������
NOTES: - Only the EMM386.EXE 16-bit MS-DOS mode memory management part of
Windows 95/98/ME is discussed here.
- For memory management guide + optimization tips see MEMORY.TXT
(included).
- For abbreviations + terms explanations see GLOSSARY.TXT (included):
http://www.mdgx.com/glossary.htm
- For DOS memory types, architecture + mapping technical details see
REGIONS.TXT (included).
- For Microsoft EMM386.EXE + HIMEM.SYS undocumented parameters see
related topics in SECRETS.TXT (included):
http://www.mdgx.com/secrets.htm
EMM386.TXT Contents:
There are a total of 6 different types of memory (RAM) that can be installed
in your X86/X86-X64 compatible IBM PC/AT computer PC (clone) by using a
Microsoft Operating System (MS OS: MS-DOS or MS Windows):
1. Conventional Memory Area (CMA) = a 1024 KB (1 MB) region, also IMPROPERLY
called "low" memory, consisting of:
A. Low Memory Area (LMA) = a 640 KB region.
B. Upper Memory Area (UMA) = a 384 KB region, also IMPROPERLY called
"high" memory. Must be mapped by a dedicated UMA manager.
2. Extended Memory Area (XMS) = a region of size which matches the amount of
total system RAM minus the CMA. Must be mapped by a dedicated XMS manager.
Abides by the XMS 3.0 standard.
3. Expanded Memory Area (EMS) = a 32-64 MB region within XMS. Must be mapped
by a dedicated EMS manager. Abides by the LIM 4.0 standard.
4. High Memory Area (HMA) = a 64 KB region within XMS located right above CMA.
Must be mapped by a dedicated XMS manager.
See REGIONS.TXT (included) for more details.
Conventional memory is the first 640 KB of memory in your machine. MS-DOS has
a limit of 1024 KB of addressable memory (conventional memory plus the UMA),
and all MS-DOS applications must run within this memory space. Windows shares
this limitation for running MS-DOS applications, but breaks the 640 KB
limitation for running native Windows applications.
Windows 3.1x/95/98/ME can create multiple DOS Virtual Machines (VMs) and also
allow MS-DOS applications to break the 640 KB barrier if they are written to
use the Microsoft DOS Protected Mode Interface (DPMI) specification. DPMI
allows MS-DOS applications to run in protected mode under Windows, using up to
16 MegaBytes (MB) of extended memory (XMS) directly.
Such DOS programs must be specifically written for DPMI to take advantage of
this feature.
Between the top of conventional memory at 640K and the start of extended
memory at 1024K lies the 384K UMA. This area doesn't contain physical memory.
Mapped into the 384K UMA are the system BIOS (Basic Input/Output System) ROM
chips and the display adapter memory. When you install other accessory cards,
such as network adapters, video or disk controllers, they may also occupy
space within the 384K UMA. The 384K UMA is always located in the same area of
the IBM compatible computer's address space: from 640K to 1024K (A000-FFFF
hex). There are no exceptions to this rule.
This means that a standard IBM compatible machine with 640K of conventional
memory installed really has 1 MB of address space. The system memory occupies
the first 640K and the 384K UMA occupies the area from 640K to 1M (1024K).
This does not mean that the machine has 1M of memory. A machine with 1M of
physical memory has an address space of 1408K. This consists of the 640K of
conventional memory, the 384K UMA and the 384K of extended memory starting at
1024K.
LIMulators
LIM 3.2/4.0 expanded memory requires a page frame to work and the page frame
is located within the 384K UMA of your machine. Unfortunately, your EMM is not
the only competitor for that memory space. Add-on boards like: network cards,
SCSI/ESDI/RAID/(E)IDE disk controllers, SVGA video adapters, can all contend
for this address space. Several potential difficulties can arise due to this
contention:
1. LACK OF SPACE. The major problem is simply finding at least 64K of
contiguous free space in which to locate the LIM 3.2 page frame. LIM 4.0 does
not require a 64K page frame but is almost useless without it, as very few
applications have been written to take advantage of the LIM 4.0 specification.
Frequently, the address areas of various adapter cards need to be shuffled to
open a contiguous 64K page frame.
2. MAPPING CONFLICTS. Most 386 EMMs (such as EMM386.EXE) use a search
algorithm to find unused memory addresses between C000 and DFFF located in the
384K UMA to use as page frames. Some adapters do not reserve their address
space until you access the card, so the memory manager can inadvertently map
EMS pages on top of an address the card will request.
This is often true of Token Ring network adapters and can cause hanging and/or
intermittent operation.
In case of problems, the first thing to do is disable expanded memory. This
procedure will determine whether a page conflict is causing your difficulty.
If the problem goes away without expanded memory, the memory manager must be
told to exclude the address the adapter is occupying from consideration as a
page location. Consult your memory manager's manual for info on how to exclude
an address range. The adapter may also have to be moved. This is done in
different ways with different memory managers.
______________________________________________________________________________
B. MICROSOFT EMM386.EXE MEMORY MANAGER
You can use the DEVICEHIGH + LOADHIGH switches /S and /L together to control
where programs are loaded in upper memory blocks (UMBs) and how much space
they allocate. Both switches affect the way programs interpret UMBs.
If you load a program with the /L switch, the program only recognizes the
memory regions you specify in the /L parameters. If you load a program with
the /S switch, the program only recognizes the regions you specify and the
amount of memory you specify. These switches are useful if you are optimizing
conventional memory because you can restrict the way a program uses a
particular memory region.
For example, the SMARTDrive utility has the ability to load itself into UMBs:
it is first loaded and initialized in conventional memory and then is
relocated to the largest available UMB it finds. By default SMARTDrive
attempts to load as much of itself as it can into UMBs; other programs will
not be able to use free UMBs because SMARTDrive has used too much space.
Since SMARTDrive does not have to reside in one memory area, you can use your
UMBs more efficiently by forcing SMARTDrive to use only a certain amount of
UMB space. You can accomplish this by using the /L and /S switches together.
The following command line (from AUTOEXEC.BAT) tells SMARTDrive that only
region 0 (located in conventional memory) and 3 (located in upper memory) are
free:
LOADHIGH /L:0;3,42416 /S drive:\path\SMARTDRV.EXE
SMARTDrive is first loaded and initialized in conventional memory (region 0)
and then relocates itself to region 3. Since the /L switch specifies a
minimum size of 42416 Bytes and the /S switch changes this minimum to the
absolute value free in region 3, SMARTDrive only recognizes region 0 and 3 as
free and only recognizes 42416 Bytes available in region 3. Therefore,
SMARTDrive loads 42416 Bytes of itself into region 3 and the rest in region 0.
This loading process results in more free memory in region 3 because
SMARTDrive is not able to relocate all of itself in that region. The next
program you load with the LOADHIGH command has enough space to load completely
into upper memory, and your available conventional memory is increased.
EMM386.EXE can now scan the F000h-F7FFh region when the system Read Only
Memory (ROM) is duplicated between F000h-F7FFh and F800h-FFFFh. Also,
EMM386.EXE will include the ROM BASIC area on IBM PS/2 systems.
To enable advanced upper memory scanning, add the HIGHSCAN switch to the
EMM386.EXE line in CONFIG.SYS:
DEVICE=drive:\path\EMM386.EXE HIGHSCAN
On some machines with older BIOSes, specifying HIGHSCAN on the EMM386.EXE
line could hang the system. In such cases replace HIGHSCAN with the less
aggressive RAM switch, which does a similar job in identifying usable Upper
Memory Blocks (UMBs).
EMM386.EXE older than 4.45 do not load if expanded memory support is enabled
and there is not enough contiguous available address space for an expanded
memeory page frame. To support MEMMAKER.EXE, EMM386.EXE 4.49/4.95 display a
warning message and continue to load when this situation occurs:
DEVICE=drive:\path\EMM386.EXE FRAME=NONE
1. Turn your machine off, and then turn it back on (cold boot) to fully
reinitialize the system.
5. Cold boot the machine after making above changes. If the problem persists,
the system may have faulty RAM chips or may require a special machine switch
for HIMEM.SYS. In addition, any BIOS/CMOS settings (such as shadow RAM) may
need to be disabled, or the system ROM BIOS may need to be upgraded for
compatibility with MS-DOS/Windows. Consult your system vendor for information
on CMOS settings and availability of BIOS upgrades.
7. If above procedure does not correct the problem, remove each EMM386.EXE
command line option one by one, and then cold boot the machine each time.
If the problem reappears, see further below to find a resolution.
X=A000-F7FF
If excluding the entire Upper Memory Area (UMA) resolves a system problem,
EMM386.EXE may be scanning too aggressively and setting up Upper Memory
Blocks (UMBs) on top of some adapter ROM or RAM. Use any available hardware
documentation (including documentation on the add-on hardware devices such as
video, network and disk controller cards) to identify any ROM or RAM present
in the UMA for that device and exclude all pertinent regions (example):
DEVICE=drive:\path\EMM386.EXE X=D800-DFFF
The MicroSoft Diagnostic utility (MSD.EXE) may also be useful in identifying
various mapped memory regions. Run:
MSD
from any DOS prompt, and then press M to display the memory screen.
FYI: See MSD9X.TXT (part of W95-11D.EXE):
http://www.mdgx.com/95.htm
or MSD62.TXT (part of W31-11D.ZIP):
http://www.mdgx.com/31.htm
for MSD usage details.
NOHI
EMM386.EXE has the ability to load a portion of itself into UMBs (Upper Memory
Blocks). If the NOHI option corrects the problem with EMM386.EXE, EMM386.EXE
may be loading into an occupied UMB. Excluding the appropriate ranges in the
UMA may correct this problem (see the "X=A000-F7FF" section above). If all
such regions are excluded, EMM386.EXE cannot be loaded high on the system, and
the NOHI switch must be used:
DEVICE=drive:\path\EMM386.EXE NOHI
Contact your system manufacturer/vendor for additional info on compatibility
with EMM386.EXE.
NOEMS
If the NOEMS parameter corrects the problem with EMM386.EXE, EMM386.EXE may
be inadvertently conflicting with some hardware ROM or RAM address in the UMA
when attempting to establish an expanded memory (EMS) page frame. If EMS is
required to run MS-DOS-based applications, use the parameter FRAME=xxxx or Mx
(where xxxx and respectively x is the defined hex address) to explicitly
specify the placement of the EMS page frame in a nonconflicting region
(using the E000-F000 64K region to allocate the page frame in this example):
DEVICE=drive:\path\EMM386.EXE FRAME=E000
or (example using the same region for the page frame):
DEVICE=drive:\path\EMM386.EXE M9
If no applications/games require expanded memory (EMS), simply continue to use
the NOEMS parameter:
DEVICE=drive:\path\EMM386.EXE NOEMS
NOVCPI
The NOVCPI switch disables Virtual Control Program Interface (VCPI) support
and can be used only in conjunction with the NOEMS parameter. If using NOVCPI
corrects the problem, the application may not be fully compatible with the
EMM386.EXE VCPI allocation scheme. Either continue using NOVCPI, or do not
load EMM386.EXE when using the application:
DEVICE=drive:\path\EMM386.EXE NOVCPI
NOMOVEXBDA
Some (older) machines use the last KiloByte of conventional memory for an
Extended BIOS Data Area (EBDA). By default EMM386.EXE remaps this memory area
into the UMA (Upper Memory Area) instead of conventional memory. If this
causes unexpected system behavior, the NOMOVEXBDA parameter MUST be used:
DEVICE=drive:\path\EMM386.EXE NOMOVEXBDA
NOTR
The EMM386.EXE detection code searches for the presence of a Token Ring
network adapter. This detection code may cause some computers to hang. The
NOTR switch can be used to disable this search in such cases:
DEVICE=drive:\path\EMM386.EXE NOTR
V. MS-DOS BUFFERS
A BUFFER is a portion of memory that DOS sets aside for buffering disk I/O
(Input/Output).
DOS stores directories and partial blocks here. DOS must read a full sector
of information from the disk. If the application asks for an amount of
information that is not an exact multiple of the sector size then the whole
sector must be stored somewhere while DOS gives the partial amount asked for
to the application that asked for it. DOS uses the BUFFERS to store
directories because it needs somewhere to store information for its own use.
DOS keeps one BUFFER in the kernel to make sure that it has at least one at
all times. The rest are loaded as "Added Data".
In MS-DOS 4.xx up to 8.00 [a.k.a. Windows ME] the size of each BUFFER is
fixed at 528 Bytes.
You actually need only one BUFFER. Any program that claims it needs more is
really only making a recommendation. Of course, your system will probably run
slower if you have only one BUFFER, but no more than one is actually needed
to operate. Consult your OS/software manuals for suggestions on how many
BUFFERS you should allocate.
Disk cache tools (like Microsoft SMARTDRV.EXE) may perform some of the same
services as DOS BUFFERS. If you use a disk cache consult the disk cache
documentation when deciding how many BUFFERS to allocate.
BUFFERS is actually an area of RAM which is available for buffering disk I/O
(In/Out).
They are not used by the count. Having 20 BUFFERS means that you allow 10 KB
(20 x 528 Bytes) of disk buffering.
The BUFFERS line can be specified only in CONFIG.SYS.
If you are using Microsoft SmartDrive 4.xx/5.xx (SMARTDRV.SYS/SMARTDRV.EXE)
to cache your disk(s) reads/writes and Windows/WfWG 3.1x or Windows 95/98/ME
32-bit Fast Disk Access (FBDA), you need ONLY 11 BUFFERS, specified by this
CONFIG.SYS line:
BUFFERS=11
especially on Pentium class or newer CPUs equipped with
(E)IDE/(U)ATA/RAID/SCSI drive controllers.
More info @ MSKB:
http://support.microsoft.com/kb/156332
More than that is not needed and won't fit into the High Memory Area (HMA),
forcing any additional BUFFERS to load into conventional RAM, thus decreasing
the amount of memory available to DOS programs/games.
More info @ MSKB:
http://support.microsoft.com/kb/78434
* Identify the program involved. See if the error occurs when the program is
not running. If you suspect a memory resident program/TSR/device driver:
- try bypassing it when your computer starts,
- get an updated (current) version from your program vendor,
- REMark the offending command line by adding:
- REM or ; (semicolon) in front of it in your CONFIG.SYS,
- REM or :: (double colon) in front of it in your AUTOEXEC.BAT,
and then cold reboot your computer.
Code Meaning
------------------------------------
0 Divide error
1 Debugger interrupt
2 Nonmaskable interrupt
3 Breakpoint
4 Overflow interrupt
5 Array boundary violation
6 Invalid opcode
7 Coprocessor not available
8 Double fault
9 Coprocessor segment overrun
10 Invalid task state segment
11 Segment not present
12 Stack exception
13 General protection violation
14 Page fault
16 Coprocessor error