🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #2255

Allocating a 64k chunk in a device driver...

#2255
From: Andreas Kaiser
Date: Thu, 01 Oct 1992 21:40
36 lines
2275 bytes
In article <1992Sep29.225212.1267@ccsvax.sfasu.edu> z_kupkams@ccsvax.sfasu.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?

  > 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

It may perhaps be much easier to use the 1.x device helpers, such as
AllocPhys (with 192K). A 1.x device helper *must* return physically
contiguous memory below the 16MB line, which is enforced by the
mainboard DMA channels. Even a BASEDEV driver can run using only 1.x
device helpers for memory management.

Example: Try to check and use the physical memory of data areas passed
to a device driver. Using the 32-bit helpers, you have to handle the
memory on the page level, which needs either scatter/gather support or
a complex driver. Using the 16-bit helpers, the system itself has to
convert non-contiguous memory, perhaps above the 16MB line, to
contiguous memory below 16MB, else old 1.x drivers would not run in
2.0.

		Gruss, Andreas

:::::::::::::::::::: subnet:  ak@ananke.stgt.sub.org
:: Andreas Kaiser :: fidonet: 2:241/7220.9
::::::::::::::::::::
Technical Details
Message-ID: <717975656snx@ananke.stgt.sub.org>
Path: arc1-ca.pugleaf.net!sparky!uunet!ukma!darwin.sura.net!Sirius.dfn.de!news.uni-stuttgart.de!delos!ananke!ak
References: <1992Sep29.225212.1267@ccsvax.sfasu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ukma!darwin.sura.net!Sirius.dfn.de!news.uni-stuttgart.de!delos!ananke!ak
From: ak@ananke.stgt.sub.org (Andreas Kaiser)
Newsgroups: comp.os.os2.programmer
Subject: Allocating a 64k chunk in a device driver... 
Distribution: world
Message-ID: <717975656snx@ananke.stgt.sub.org>
References: <1992Sep29.225212.1267@ccsvax.sfasu.edu>
Date: Thu, 01 Oct 92 21:40:56 GMT
Organization: ananke
Lines: 36