delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/10/16:42:53

From: "Jonathan Villani" <jonathan DOT villani AT videotron DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Question regarding the use of __djgpp_nearptr_enable()
Lines: 78
X-Newsreader: Microsoft Outlook Express 4.72.3007.0
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3007.0
Message-ID: <so222.447$4S.2902@weber.videotron.net>
Date: Tue, 10 Nov 1998 16:39:44 -0500
NNTP-Posting-Host: 207.96.203.144
X-Complaints-To: abuse AT videotron DOT net
X-Trace: weber.videotron.net 910733976 207.96.203.144 (Tue, 10 Nov 1998 16:39:36 EDT)
NNTP-Posting-Date: Tue, 10 Nov 1998 16:39:36 EDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello I am currently programming a sound player for soundblaster cards and I
have a question regarding the
__djgpp_nearptr_enable() function.

I have seen tutorials on the web for programming the DMA but all them use
the __djgpp_nearptr_enable function.
I don't want to use that because it disable the memory protection.

Here's some code from the tutorials:
--------------------------------------------------

void *MK_FP(DWORD seg, DWORD ofs)
{
 if (!(_crt0_startup_flags & _CRT0_FLAG_NEARPTR))
  if
(!__djgpp_nearptr_enable()) ------------------------------------------------
> Oh no ! no memory protection!
   return (void*)0;
  return (void *) (seg*16+ofs+__djgpp_conventional_base);
}



void Set_DMA()
{
 SegInfo.size = BUFFSIZE*2/16;
 _go32_dpmi_allocate_dos_memory(&SegInfo); ------------> Allocate some dos
memory
 phys = SegInfo.rm_segment<<4;
 if ((phys >> 16) != ((phys+BUFFSIZE)>>16))
 {
  phys+=BUFFSIZE;
  printf(" Warning: Hit page division!\n");
 }
 memset((BYTE *)MK_FP(SegInfo.rm_segment,0),0,BUFFSIZE); ----------> Set
buffer to 0 using nearpointer!

 /* Re-enable memory protection */
 __djgpp_nearptr_disable();            -------------------> This is a line
that I have put to return to the protected mem.
}


/* This function is called often!*/
void Fill_DMA_buffer()
{

/* if I put: */
(A)  __djgpp_nearptr_enable();     ------------------> Does this line will
slow down my real time app.??

....
/* COPY using DOS memory using Nearpointers */
 memset(...[DMAbuffer -> in DOS memory])
....
(B)  __djgpp_nearptr_disable();   ------------------> Does this line will
slow down my real time app.??

}


If I want to have memory protection can I add the two lines (A) and (B) with
no major speed down??
Or is there a better method to allocate DOS memory for the DMA transfert and
for Copying sound sample to DMA buffer (This mean copying dpmi memory to DOS
memory) without disabling memory protection.


Any suggestions or piece of code for the allocation and copy function will
be greatly appreciated!

Thank you!

Jonathan Villani
jonathan DOT villani AT videotron DOT ca



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019