Article View: comp.os.os2.programmer
Article #2197Re: Allocating a 64k chunk in a device driver...
From: z_kupkams
Date: Wed, 30 Sep 1992 04:52
Date: Wed, 30 Sep 1992 04:52
46 lines
2408 bytes
2408 bytes
In article <1992Sep29.070357.23292@CS.ORST.EDU>, @prism.cs.orst.edu writes:
> I need to allocate two 64k buffers in ram from a 16bit device driver. Each of
> the buffers must be completely contained in a segment. They cannot cross a
> segment boundary. Does anyone know of a way to do this?
>
> Thanks
>
> Keith
Well, It sounds like you need a DMA buffer. You can use DevHelp VMAlloc
to allocate a large block of virtual memory( Specify non-swappable ).
Allocate at least 192K( you will waste a total of 64K if you want to allign
it on a 64K boundary, there will be some wasted above and below the range that
you want). The address that you get back will be Linear, so use DevHelp
LinToPagelist to get the physical address. take the Physical address you
recieve and adjust it to align on a 64K boundary. Then do a PhysToVirt of
the adjusted physical address to obtain a 16:16 addressable address of each
block
The physical memory you want will look like this:
___________________________________________________
| Low | | | High |
| Wasted | Block #1 | Block #2 | Wasted |
| Area | =64Kb | =64Kb | Area |
| < 64Kb | | | < 64Kb |
-----------------------------------------------------
| | |
64K 64K 64K
Boundary Boundary Boundary
Low Wasted Area + Block#1 + Block#2 + High Wasted Area = 192Kb
(size < 64K ) + 64K + 64K + ( size < 64K ) = 192Kb
I hope that this help you. You may want to read up on VMAlloc, LintoPageList,
and PhysToLin in the IBM Physical Device Driver reference manual.
Michael Kupka
=========================================================================
(Happy Father of an OS/2 QIC-40/80 Driver)
Coming to a Desktop near you
-------------------------------------------------------------------------
Technical Details
Message-ID:
<1992Sep29.225212.1267@ccsvax.sfasu.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!zaphod.mps.ohio-state.edu!menudo.uh.edu!ccsvax.sfasu.edu!z_kupkamsReferences:
<1992Sep29.070357.23292@CS.ORST.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!zaphod.mps.ohio-state.edu!menudo.uh.edu!ccsvax.sfasu.edu!z_kupkams From: z_kupkams@ccsvax.sfasu.edu Newsgroups: comp.os.os2.programmer Subject: Re: Allocating a 64k chunk in a device driver... Message-ID: <1992Sep29.225212.1267@ccsvax.sfasu.edu> Date: 29 Sep 92 22:52:11 CST References: <1992Sep29.070357.23292@CS.ORST.EDU> Organization: Stephen F. Austin State University Lines: 46