Date: Fri, 7 Jul 95 17:14 MDT From: mat AT ardi DOT com (Mat Hostetter) To: sledz AT cs DOT tu-berlin DOT de (Steffen Sledz) Subject: Re: Physical Memory Access? Newsgroups: comp.os.msdos.djgpp References: <3tja1f$rp2 AT news DOT cs DOT tu-berlin DOT de> Cc: djgpp AT sun DOT soe DOT clarkson DOT edu >>>>> "Steffen" == Steffen Sledz writes: Steffen> How can I access physical under DJGPP? I tried the DPMI Steffen> calls of V2beta with Quarterdecks QDPMI, but this results Steffen> in an SIGSEGV (Stack overflow) at runtime. I just added linear frame buffer support to our Macintosh emulator, for systems that have a VBE 2.0-compatible video driver. It works, and our graphics are now much faster. Anyway, here's the routine we use to get a selector for the physical memory corresponding to the frame buffer. You might find interesting. Under DPMI 0.9 you have to use a special selector to reference such memory; see the farptr.h functions, and the `movedata' routine. You can't access this memory directly. -Mat #include int selector_for_phys_mem (unsigned long base, unsigned long num_bytes) { int sel; unsigned long seg_lim; __dpmi_meminfo minfo; /* Allocate a descriptor. */ sel = __dpmi_allocate_ldt_descriptors (1); if (sel == -1) return -1; seg_lim = ((num_bytes + 4095) & ~4095) - 1; /* Map the physical memory into our address space. */ minfo.handle = 0; /* unused */ minfo.size = seg_lim + 1; minfo.address = base; if (__dpmi_physical_address_mapping (&minfo) != 0) return -1; if (__dpmi_set_segment_base_address (sel, minfo.address) == -1) return -1; if (__dpmi_set_segment_limit (sel, seg_lim) == -1) return -1; return sel; }