Message-ID: From: "Isaacson, Tom" To: "'djgpp AT delorie DOT com'" Subject: Physical to virtual memory map problems Date: Thu, 21 Jan 1999 13:51:48 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2232.9) Content-Type: text/plain; charset="iso-8859-1" Reply-To: djgpp AT delorie DOT com I've just inherited some old code from a previous employee, but I can't get it to work. It's a test program, running under DOS, which initialises a PCI card and then attempts to perform a series of tests on it. The PCI initialisation code works fine and the card is configured correctly, but when I map the memory on the card the writes don't have any effect, and the reads return -1. I know the card works because we have a Windows NT driver for it that works fine. Here is the memory mapping code for the first buffer of 512 bytes: // Map physical address for S0 meminfo.handle = 0x0; meminfo.size = local_reg_range; // 512 bytes meminfo.address = s0_base_add; // base address // Allocate descriptor local_reg_selector_n = __dpmi_allocate_ldt_descriptors(1); if (local_reg_selector_n == -1) { printf("Allocate local_reg_selector_n FAILED\n"); } // This perform the Physical to Virtual memory map !! if (__dpmi_physical_address_mapping(&meminfo) == -1) { printf("Physical to linear address map of Internal Control Reg FAILED\n"); } // Set the limit if (__dpmi_set_segment_limit(local_reg_selector_n, local_reg_range - 1) == -1) { printf("Set segment limit of local_reg_selector_n FAILED\n"); } // Set the base address if (__dpmi_set_segment_base_address(local_reg_selector_n, meminfo.address) == -1) { printf("Set base address of local_reg_selector_n FAILED\n"); } This is repeated for a second buffer of 4MB. The reads are done like this: data_count_n = 0; for (i = 0; i < 0x200; i += 4) { temp = _farpeekl(local_reg_selector_n, i); data_ula[data_count_n++] = temp; } The writes use _farpeekl. Can anyone see anything wrong with this method? The only other problem I can think of is the original program was written to use the motherboard's PCI bus and the computer we are using now has a PCI extender chip, and DPMI cannot handle memory over the extended PCI bus, but this seems unlikely. Tom Isaacson mailto:TIsaacson AT ndsuk DOT com