DOS/16M FAQ: Memory Management
[Previous Section] *
[Index of FAQ] *
[Next Section]
-
How do I address super-VGA video memory?
-
Can I move a segment at runtime
that was loaded into extended memory at load time?
-
Does d16ReallocSeg() physically copy everything
in the segment?
-
Can I pass a pointer in the middle of the segment
to d16ReallocSeg() and get the whole segment?
-
Why can't I access all 128MB of physical memory
available on my machine?
-
How can I allocate a block of memory in protected mode that doesn't
cross a page boundary?
1.
How do I address super-VGA video memory?
Just as in a real-mode DOS program:
Base the addressing at 0xA000 << 4 rather than 0xB800 << 4.
2.
Can I move a segment at runtime
that was loaded into extended memory at load time?
Yes, use the d16ReallocSeg() API.
3.
Does d16ReallocSeg() physically copy everything
in the segment?
Yes.
4.
Can I pass a pointer in the middle of the segment
to d16ReallocSeg() and get the whole segment?
Yes. Pass any function name; the whole segment goes.
5.
Why can't I access all 128MB of physical memory
available on my machine?
DOS/16M is currently limited to 64MB of physical memory. We expect to
be updating the DOS extender to use the extended XMS and VCPI calls
that allow access to greater than 64MB but currently, you must use
virtual memory if you need access to more than 64MB of memory.
6.
How can I allocate a block of memory in protected mode that doesn't
cross a page boundary?
If you want to access full pages on page boundaries, you can try:
typedef unsigned long ulong;
int *bufp;
int *blockp:
#define BLOCKSIZE_I_WANT 8092 /* or whatever */
#define PAGESIZE 4096 /* must be power of 2 */
#define PSM1 (PAGESIZE - 1)
bufp = malloc(BLOCKSIZE_I_WANT + PSM1);
blockp = (int *) (((ulong) bufp + PSM1) & ~PSM1);
Then blockp will point to a page aligned buffer. When
you are through with the block, be sure to free(bufp);,
rather than blockp, since bufp is what malloc
returned.
|