🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #16376

Re: Memory block at specified physical address

#16376
From: Daniel Pfeffer
Date: Tue, 20 May 2003 07:14
48 lines
2848 bytes
"Roelof Steyn" <roelof@imaginet.co.za> wrote in message
news:3ec9c524@newsgroups.borland.com...
> Hi
>
> I need to assign a block of memory at a specified address in physical
memory
> (I'm using dual port RAM on an EISA card).
> I need to do something like this:
> #define BufSize 2048
> #define Address 0xB8000
> volatile WORD *mem = malloc(BufSize,Address);
> Can anybody help?
> I'm working on Win2000.
>
> I have tried doing this:
>   volatile WORD *mem[BufSize];
>   for(int i=0; i<BufSize; i++)
>   {
>    (int*)AA[i] = (int*)(Address + i*2); // Assign address
>    *(AA[i])    = 0x0000; // Initialize to 0
>   }
>
> Problems with this:
> 1. I'm not confident that Win2000 assigned this block to actual, real
> physical address B8000.
> 2. It works OK, until I quit the program, then I get the error "Invalid
> pointer operation" - how do I "free" this memory block?

Windows NT/2000/XP does not allow ordinary application programs direct
access to hardware, the idea being to ensure that a single malicious program
cannot bring down the O/S (or corrupt other programs). If you wish to access
specific hardware addresses, the best way is to write a device driver that
performs the access for you, or (not recommended!) returns a pointer to the
hardware memory buffer.

The reason that the second option is not recommended is that there is no way
to ensure that different processes accessing the driver will not
simultaneously try to use the hardware memory buffer. Such simultaneous
access will at best - produce erroneous results and at worst - may crash the
system.

Note that writing a device driver is not for the faint of heart. Start by
downloading the Windows 2000 DDK, and expect a steep learning curve
including quite a few system crashes.


HTH,
Daniel Pfeffer
Technical Details
Message-ID: <3ec9d604@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!38.144.126.75.MISMATCH!feed1.newsreader.com!newsreader.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3ec9c524@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,b16a167e1c27ccab
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-20 00:22:11 PST
From: "Daniel Pfeffer" <pfefferd@hotmail.co.il>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3ec9c524@newsgroups.borland.com>
Subject: Re: Memory block at specified physical address
Date: Tue, 20 May 2003 10:14:49 +0300
Lines: 50
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 192.114.161.154
Message-ID: <3ec9d604@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1053414916 192.114.161.154 (20 May 2003 00:15:16 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!38.144.126.75.MISMATCH!feed1.newsreader.com!newsreader.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail