X-Originating-IP: [192.136.8.201] From: "chris tsui" To: djgpp AT delorie DOT com Subject: Need help Date: Fri, 23 Mar 2001 13:44:03 -0800 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 23 Mar 2001 21:44:03.0890 (UTC) FILETIME=[6111A120:01C0B3E2] Reply-To: djgpp AT delorie DOT com Here's my problem. I am try to map physical memory for my PCI card so that I can excises the 24bit DMA engine. So I did some research on the DJ FAQ and found I can use XMS manager to allocate extended for me and map it to linear. So I use himem.sys as the XMS manager. Here is my code #include #include #include #include typedef unsigned char BYTE; typedef unsigned short WORD; typedef unsigned long DWORD; int main() { WORD XMSentryCS = 0; WORD XMSentryIP = 0; __dpmi_regs regs; __dpmi_memory_info meminfo; //Try int15/88 memset(®s, 0, sizeof(__dpmi_regs)); regs.h.ah = 0x88; __dpmi_int(0x15, ®s); printf("int15/88 ax = %d\n",regs.x.ax); //Determine if XMS is installed memset(®s, 0, sizeof(__dpmi_regs)); regs.x.ax = 0x4300; __dpmi_int(0x2F, ®s); if(regs.h.al != 0x80) printf("No XMS driver install\n"); //Get XMS driver entry point memset(®s, 0, sizeof(__dpmi_regs)); regs.x.ax = 0x4310; __dpmi_int(0x2F, ®s); if(regs.x.ax == 0) printf("Fail getting XMS entry point\n"); else { XMSentryCS = regs.x.es; XMSentryIP = regs.x.bx; printf("XMS driver found\n"); printf("Entry poing at %x:%x\n",regs.x.es, regs.x.bx); } //Get XMS version number memset(®s, 0, sizeof(__dpmi_regs)); regs.x.cs = XMSentryCS; regs.x.ip = XMSentryIP; printf("CS = 0x%x\n", regs.x.cs); printf("IP = 0x%x\n", regs.x.ip); __dpmi_simulate_real_mode_procedure_retf(®s); printf("XMS version number %d.%d\n",regs.h.ah, regs.h.al); printf("Driver internal reversion number %d.%d\n",regs.h.bh, regs.h.bl); if(regs.x.dx == 0x1) printf("HMA exists\n"); //query A20 memset(®s, 0, sizeof(__dpmi_regs)); regs.h.ah = 0x8; regs.x.cs = XMSentryCS; regs.x.ip = XMSentryIP; __dpmi_simulate_real_mode_procedure_retf(®s); if(regs.x.ax == 0x1) printf("A20 enable\n"); else { printf("A20 not enable\n"); printf("Try to enable A20 myself\n"); // Enable Local A20 line for extended memory memset(®s, 0, sizeof(__dpmi_regs)); regs.h.ah = 0x5; regs.x.cs = XMSentryCS; regs.x.ip = XMSentryIP; __dpmi_simulate_real_mode_procedure_retf(®s); if(regs.x.ax == 0x1) printf("A20 enable\n"); else { printf("A20 not enable\n"); printf("reason = 0x%x\n"); } } //query free extended memory memset(®s, 0, sizeof(__dpmi_regs)); regs.h.ah = 0x8; //query free extended memory regs.x.cs = XMSentryCS; regs.x.ip = XMSentryIP; __dpmi_simulate_real_mode_procedure_retf(®s); printf("BL = 0x%x\n",regs.h.bl); printf("Size of the largest free extended memory in %dKB\n",regs.x.ax); printf("Total amount of free extended memory in %dKB\n",regs.x.dx); //query any free extended memory memset(®s, 0, sizeof(__dpmi_regs)); regs.h.ah = 0x88; //query free extended memory regs.x.cs = XMSentryCS; regs.x.ip = XMSentryIP; __dpmi_simulate_real_mode_procedure_retf(®s); printf("EAX = 0x%x\n",regs.d.eax); printf("BL = 0x%x\n",regs.h.bl); printf("ECX = 0x%x\n",regs.d.ecx); printf("EDX = 0x%x\n",regs.d.edx); //Try to allocate a 2MB buffer memset(®s, 0, sizeof(__dpmi_regs)); regs.h.ah = 0x9; //allocate extended memory block regs.x.cs = XMSentryCS; regs.x.ip = XMSentryIP; regs.x.dx = 2048; __dpmi_simulate_real_mode_procedure_retf(®s); printf("BL = 0x%x\n",regs.h.bl); printf("AX = 0x%x\n",regs.x.ax); memset(&meminfo, 0, sizeof(__dpmi_memory_info)); __dpmi_get_memory_information(&meminfo); printf("total_allocated_bytes_of_physical_memory_host = 0x%x\n",meminfo.total_allocated_bytes_of_physical_memory_host); printf("total_allocated_bytes_of_virtual_memory_host = 0x%x\n",meminfo.total_allocated_bytes_of_virtual_memory_host); printf("total_available_bytes_of_virtual_memory_host = 0x%x\n",meminfo.total_available_bytes_of_virtual_memory_host); printf("total_allocated_bytes_of_virtual_memory_vcpu = 0x%x\n",meminfo.total_allocated_bytes_of_virtual_memory_vcpu); printf("total_available_bytes_of_virtual_memory_vcpu = 0x%x\n",meminfo.total_available_bytes_of_virtual_memory_vcpu); printf("total_allocated_bytes_of_virtual_memory_client = 0x%x\n",meminfo.total_allocated_bytes_of_virtual_memory_client); printf("total_available_bytes_of_virtual_memory_client = 0x%x\n",meminfo.total_available_bytes_of_virtual_memory_client); printf("total_locked_bytes_of_memory_client = 0x%x\n",meminfo.total_locked_bytes_of_memory_client); printf("max_locked_bytes_of_memory_client = 0x%x\n",meminfo.max_locked_bytes_of_memory_client); printf("highest_linear_address_available_to_client = 0x%x\n",meminfo.highest_linear_address_available_to_client); printf("size_in_bytes_of_largest_free_memory_block = 0x%x\n",meminfo.size_in_bytes_of_largest_free_memory_block); printf("size_of_minimum_allocation_unit_in_bytes = 0x%x\n",meminfo.size_of_minimum_allocation_unit_in_bytes); printf("size_of_allocation_alignment_unit_in_bytes = 0x%x\n",meminfo.size_of_allocation_alignment_unit_in_bytes); return 0; } I know I can talk to the xms driver because I got the version number right. The problem is I can never allocate any memory. function 08 or 88 kept telling me all the extended memory is allocated. Why?? I only have device=c:\dos\himem.sys should I use cwsdpmi or cwsdpr0. I just don't get it?? Chris Tsui _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com