Date: Wed, 13 Nov 1996 16:09:21 GMT From: kvhk AT ivs4 DOT barco DOT com (Koen Van Herck) Message-Id: <9611131609.AA20023@ivs4.> To: djgpp AT delorie DOT com Subject: Accessing memory above 1MB Reply-To: Koen DOT VanHerck AT barco DOT com I have a question about answer 18.7 in the FAQ: 18.7 Accessing absolute address above 1MB **Q*: How can I access memory-mapped peripheral devices (or any other absolute address) above 1 MByte mark?* *A* : Use the `__dpmi_physical_address_mapping' library function. ... If you prefer to create the mapping yourself, these are the DPMI calls that you will have to use: - allocate an LDT descriptor (Int 31h/AX=0); - map selector to physical address (Int 31h/AX=0800h); - lock linear address (Int 31h/AX=0600h); - set segment base address (Int 31h/AX=7); - set segment limit (Int 31h/AX=8). Now, what is meant exactly with "doing it yourself" ? Does this mean that I use either __dpmi_physical_address_mapping or the five points above. If so, then how do I do point 2 ? Isn't this what __dpmi_physical_address_mapping does ? Or is __dpmi_physical_address_mapping equivalent to all 5 points together? As an illustration, I have include my memmap() function, which I use to map a 32MB chunk on a PCI device. Please send me your comments on this code. /* memmap map's a chunk of memory */ /* returns -1 on error, else descriptor */ int memmap(unsigned int base, unsigned int size) { int desc; __dpmi_meminfo meminfo; desc = __dpmi_allocate_ldt_descriptors(1); if (desc==-1) { fprintf(stderr, "ERROR: Unable to allocate descriptor\n"); return -1; } meminfo.address = base; meminfo.size = size; if (__dpmi_physical_address_mapping(&meminfo)) { fprintf(stderr, "ERROR: Unable to map physical address\n"); return -1; } if (__dpmi_lock_linear_region(&meminfo)) { fprintf(stderr, "ERROR: Unable to lock linear region\n"); /* Don't return when this gives an error ! */ } if (__dpmi_set_segment_base_address(desc, meminfo.address)) { fprintf(stderr, "ERROR: Unable to set segment base\n"); return -1; } if (__dpmi_set_segment_limit(desc, meminfo.size - 1)) { fprintf(stderr, "ERROR: Unable to set segment limit\n"); return -1; } return desc; } ---- Koen Van Herck Electronic Design Engineer E-mail: Koen DOT VanHerck AT barco DOT com BBBB AAA RRRR CCC OOO B A R C O V I S U A L S Y S T E M S B B A A R R C O O A division of Barco Projection Systems B BB A AAA R RR C OO O OO B B A A R R C O O Noordlaan 5 Tel +32 (0)56 36 85 71 BBBB A A R R CCC OOO B-8520 Kuurne Fax +32 (0)56 36 83 55