HalAllocateCommonBuffer

We have developed a kernel mode driver to control the boards that have also developed by our company. The board is an audio switch matrix that uses the ISA bus. It is also able to use DMA transfers by using the hardware of a computer. The DMA transfers are used to generate and save audio in real time by using the driver that we designed following the CommonBuffer Slave DMA model.

We use the following parameters to call HalGetAdapter:

DmaDescription.Version = DEVICE_DESCRIPTION_VERSION1;
DmaDescription.Master = FALSE;
DmaDescription.ScatterGather = FALSE;
DmaDescription.DemandMode = TRUE;
DmaDescription.AutoInitialize = TRUE;
DmaDescription.IgnoreCount = FALSE;
DmaDescription.Dma32BitAddresses = FALSE;
DmaDescription.InterfaceType = Isa;
DmaDescription.BusNumber = 0;
DmaDescription.DmaChannel = 0, 1, 6 or 7;
DmaDescription.MaximumLength = CommonBufferSize;
DmaDescription.DmaWidth = Width8Bits or Width16Bits;
DmaDescription.DmaSpeed = MaximumDmaSpeed;

AdapterObject = HalGetAdapter(&DmaDescription, &MaxMapRegisterCount);

Where CommonBuffersize is one of 32, 64 or 128KB.

In order to obtain the necessary memory buffers for the continuous transfer and after obtaining the Adapter Object, we use the HalAllocateCommonBuffer as follows:

DMACommonBuffer = HalAllocateCommonBuffer(AdapterObject, CommonBufferSize, &DMAPA, TRUE or FALSE);

It is there where we find the problems. Although all functions are executed when the driver initialites (in DriverEntry), HalAllocateCommonBuffer always fails for 64KB or 128KB buffers. It also fails for 32 KB buffers in several cases.

This is a big problem for us since our system is supposed to support 2 boards by using DMA simultaneously in different channels. We are now

Try setting DmaDescription.MaximumLength to a number larger than
CommonBufferSize, such as the largest POSSIBLE DMA transfer size. Note that
SCSI drivers set this to something like 0xFFFFFFF.

By defining your max length to the same size as your common buffer, you
immediately run out of resources (map registers) as soon as you allocate a
buffer. The value you set in MaximumLength gives you the TOTAL number of map
registers available for ALL DMA transfers on that device. Setting it to
something like 4Meg gives you 1025 map registers. If CommonBuffersSize is
128K, then you would need 33 map registers to satisfy that request, leaving
you resources available for starting another DMA transfer.

-----Original Message-----
From: Juli?n Rodr?guez Bajo [mailto:xxxxx@fedetec.es]
Sent: Friday, June 09, 2000 3:19 AM
To: NT Developers Interest List
Subject: [ntdev] HalAllocateCommonBuffer

We have developed a kernel mode driver to control the boards
that have also developed by our company. The board is an audio switch
matrix that uses the ISA bus. It is also able to use DMA transfers by using
the hardware of a computer. The DMA transfers are used to generate and save
audio in real time by using the driver that we designed following the
CommonBuffer Slave DMA model.

We use the following parameters to call HalGetAdapter:

DmaDescription.Version =
DEVICE_DESCRIPTION_VERSION1;
DmaDescription.Master =
FALSE;
DmaDescription.ScatterGather =
FALSE;
DmaDescription.DemandMode =
TRUE;
DmaDescription.AutoInitialize
= TRUE;
DmaDescription.IgnoreCount =
FALSE;
DmaDescription.Dma32BitAddresses =
FALSE;
DmaDescription.InterfaceType =
Isa;
DmaDescription.BusNumber = 0;
DmaDescription.DmaChannel = 0,
1, 6 or 7;
DmaDescription.MaximumLength =
CommonBufferSize;
DmaDescription.DmaWidth =
Width8Bits or Width16Bits;
DmaDescription.DmaSpeed =
MaximumDmaSpeed;

AdapterObject = HalGetAdapter(&DmaDescription,
&MaxMapRegisterCount);

Where CommonBuffersize is one of 32, 64 or 128KB.

In order to obtain the necessary memory buffers for the
continuous transfer and after obtaining the Adapter Object, we use the
HalAllocateCommonBuffer as follows:

DMACommonBuffer =
HalAllocateCommonBuffer(AdapterObject, CommonBufferSize, &DMAPA, TRUE or
FALSE);

It is there where we find the problems. Although all
functions are executed when the driver initialites (in DriverEntry),
HalAllocateCommonBuffer always fails for 64KB or 128KB buffers. It also
fails for 32 KB buffers in several cases.

This is a big problem for us since our system is supposed to
support 2 boards by using DMA simultaneously in different channels. We are
now


You are currently subscribed to ntdev as:
xxxxx@delphieng.com
To unsubscribe send a blank email to
$subst(‘Email.Unsub’)

> Try setting DmaDescription.MaximumLength to a number larger than

CommonBufferSize, such as the largest POSSIBLE DMA transfer size. Note
that
SCSI drivers set this to something like 0xFFFFFFF.

By defining your max length to the same size as your common buffer, you
immediately run out of resources (map registers) as soon as you allocate a
buffer. The value you set in MaximumLength gives you the TOTAL number
of map registers available for ALL DMA transfers on that device. Setting
it to
something like 4Meg gives you 1025 map registers. If CommonBuffersSize is
128K, then you would need 33 map registers to satisfy that request,
leaving
you resources available for starting another DMA transfer.

I try this, but no success.

I find that HalGetAdapter allways returns 16 in MaxMapRegisters param,
either
I use 128K, 1MB, 2MB or any value in DmaDescription.MaximumLength.

Thanks for your reply.