Skip to content

Commit 43de7a4

Browse files
committed
Merge branch 'master' into jwt27
2 parents 00de7d2 + d13082b commit 43de7a4

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

include/dpmi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ int __dpmi_resize_linear_memory(__dpmi_meminfo *_info, int _commit); /* DPMI 1
203203
int __dpmi_get_page_attributes(__dpmi_meminfo *_info, short *_buffer); /* DPMI 1.0 AX=0506 */
204204
int __dpmi_set_page_attributes(__dpmi_meminfo *_info, short *_buffer); /* DPMI 1.0 AX=0507 */
205205
int __dpmi_map_device_in_memory_block(__dpmi_meminfo *_info, unsigned long _physaddr); /* DPMI 1.0 AX=0508 */
206-
int __dpmi_map_conventional_memory_in_memory_block(__dpmi_meminfo *_info, unsigned long _physaddr); /* DPMI 1.0 AX=0509 */
206+
int __dpmi_map_conventional_memory_in_memory_block(__dpmi_meminfo *_info, unsigned long _linaddr); /* DPMI 1.0 AX=0509 */
207207
int __dpmi_get_memory_block_size_and_base(__dpmi_meminfo *_info); /* DPMI 1.0 AX=050a */
208208
int __dpmi_get_memory_information(__dpmi_memory_info *_buffer); /* DPMI 1.0 AX=050b */
209209

src/libc/dpmi/api/d0509.txh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <dpmi.h>
77

88
int __dpmi_map_conventional_memory_in_memory_block(
9-
__dpmi_meminfo *info, unsigned long physaddr
9+
__dpmi_meminfo *info, unsigned long linaddr
1010
);
1111
@end smallexample
1212

@@ -19,8 +19,11 @@ the DPMI Overview (@pxref{DPMI Overview}) for general information.
1919
DPMI function AX = 0x0509 (DPMI 1.0 only). Supported by CWSDPMI, but
2020
not by Windows.
2121

22-
This function maps conventional memory (even when virtualized) to
23-
virtual memory. Pass the handle, offset, and number of pages.
22+
This function maps/aliases conventional memory specified by the linear
23+
address @var{linaddr} (even when virtualized) to virtual memory
24+
specified by the handle and offset fields in @var{info}. Pass the
25+
handle, offset relative to the start of the block, and number of
26+
pages to map.
2427

2528
@subheading Return Value
2629

src/libc/dpmi/helper/mapmem.txh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ be set to @code{EINVAL} and the routine will fail.
2121
This routine properly handles memory ranges that span multiple DPMI
2222
handles, while @code{__dpmi_map_device_in_memory_block} does not.
2323

24+
Every page in the specified address range @var{out_addr}, @var{num_bytes}
25+
must belong to some DPMI handle in @code{__djgpp_memory_handle_list}
26+
allocated by @code{sbrk}.
27+
28+
To accommodate page-aligning and existence of DPMI handle for memory
29+
@var{out_addr}, the easiest option is to allocate page-aligned memory
30+
by @code{valloc} function (which internally uses @code{sbrk}) and
31+
then pass it to @code{__djgpp_map_physical_memory}.
32+
33+
To unmap physical memory range created by @code{__djgpp_map_physical_memory},
34+
use @code{__djgpp_set_page_attributes} function and change page
35+
attributes of every page to committed type and read/write access
36+
without setting initial page access and dirty bits. After that
37+
@var{our_addr} memory allocated by @code{valloc} can be returned
38+
back to the memory pool by @code{free}.
39+
2440
Consult DPMI documentation on function 0508H for details on how this
2541
function works. Note: since 0508H is a DPMI service new with DPMI
2642
1.0, this call will fail on most DPMI 0.9 servers. For your program
@@ -42,7 +58,30 @@ DPMI server rejected the mapping request.
4258
@subheading Example
4359

4460
@example
61+
void *my_page_aligned_memory = valloc (16384);
62+
if (!my_page_aligned_memory)
63+
{
64+
printf ("Failed to allocate page-aligned memory!\n");
65+
return;
66+
}
67+
4568
if (__djgpp_map_physical_memory (my_page_aligned_memory, 16384,
4669
0x40000000))
70+
{
4771
printf ("Failed to map physical addresses!\n");
72+
}
73+
else
74+
{
75+
/* code which access mapped my_page_aligned_memory */
76+
}
77+
78+
if (__djgpp_set_page_attributes (my_page_aligned_memory, 16384,
79+
(0<<4) | (1<<3) | 1))
80+
{
81+
printf ("Failed to unmap physical addresses!\n");
82+
}
83+
else
84+
{
85+
free (my_page_aligned_memory);
86+
}
4887
@end example

0 commit comments

Comments
 (0)