Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!news.arc.nasa.gov!vsi1!altos!gumby!rcollins From: rcollins@gumby.Altos.COM (Robert Collins) Newsgroups: comp.os.msdos.programmer Subject: Re: Physical addresses in protected mode? Message-ID: <4948@gumby.Altos.COM> Date: 24 Jun 91 17:31:54 GMT References: Reply-To: rcollins@altos.COM (Robert Collins) Organization: Altos Computer Systems, San Jose, CA Lines: 25 In article cchapman@msd.gatech.edu (Chuck H. Chapman) writes: > >I'm new to assembly language programming on the PC. I need to do DMA transfers >to a device while running a protected mode program. How do I figure out what >the physical address of the data I want to transfer is so I can pass this >address to the DMA controller so it can access the data? It's easy in >real mode but how do you figure out physical addresses in protected mode? > First of all, you must be at IOPL=0. If you aren't, then you can't find the physical address. Assuming IOPL=0, SGDT to save the gdt base address. Build your own GDT (on the stack or memory) that has a data segment pointing to the original GDT. Now using whatever segment:offset you wanted to DMA into, (or out of) look in that GDT entry, and calculate the virtual address. If paging is not enabled, then the virtual address=physical address. If paging is enabled then you must use your virtual address to index into the page directory and page tables associated with that address. From those tables, you then calculate the physical address. If you are in V86 mode, then give it up because you are executing at IOPL=3 which makes it impossible to get the physical address. Since you are 'new' to assembly language programming...have fun. Robert Collins