Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2000-10

GPF when accessing DOS memory

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sebastian Schuberth

Hi there!

I'm currently modifiying some of my TMT Pascal sources so they to work with
Free Pascal, too. Unfortunately I get a GPF (runtime error 216) when executing
to following code, which works fine under TMT:

--8<--(BEGIN vbe.pas)--

Const
  VBE2=$32454256;
Type
  PDOSMemoryBlock=^DOSMemoryBlock;
  DOSMemoryBlock=Record
    Segment,Selector:Word;
  End;
  PCtrlInfoBlock=^CtrlInfoBlock;
  CtrlInfoBlock=Packed Record
    Signature:Cardinal;
    Version:Word;
    OEMStringPtr:PChar;
    Capabilities:Cardinal;
    VideoModePtr:PWord;
    TotalMemory:Word;
    OEMSoftwareRev:Word;
    OEMVendorNamePtr:PChar;
    OEMProductNamePtr:PChar;
    OEMProductRevPtr:PChar;
    Reserved_222:Array[0..221] Of Byte;
    OEMData:Array[0..255] Of Byte;
  End;
Var
  CIB:PCtrlInfoBlock
  CIBMem:PDOSMemoryBlock;

{ ... }

New(CIBMem);
{ Allocate DOS memory block and save segment / selector }
If Not dpmiAllocDOSMem(SizeOf(CIB^),@CIBMem^.Segment,@CIBMem^.Selector)
Then Exit;
{ Make CIB point to DOS memory }
CIB:=Ptr(CIBMem^.Segment,0);
{ Write 'VBE2' signature into DOS memory, THIS IS WHERE FPC CRASHES }
CIB^.Signature:=VBE2;

{ ... }

--8<--(END vbe.pas)--

For some reason FPC (or better: GO32V2?) won't let me write into the allocated DOS
memory area. But why, it works under TMT (which uses PMODE/W). Is there any DPMI
call I need to insert for FPC? BTW: I don't want to use functions from the GO32 unit
if possible, because the code should be fully portable. I'd rather recode the needed
functions myself.

Thanks in advance.

Sebastian Schuberth
Michael Knapp
to Sebastian Schuberth
Sebastian Schuberth wrote 7 lines
New(CIBMem); { Allocate DOS memory block and save segment / selector } If Not dpmiAllocDOSMem(SizeOf(CIB^),@CIBMem^.Segment,@CIBMem^.Selector) Then Exit; { Make CIB point to DOS memory } CIB:=Ptr(CIBMem^.Segment,0);

there is the error - Ptr() does not convert a real-mode adress to a protected-mode offset
there should be a "real2protected" dpmi/go32v2 call

{ Write 'VBE2' signature into DOS memory, THIS IS WHERE FPC CRASHES } CIB^.Signature:=VBE2;

of course it crashes there

Michael

+--------------------------------------------------------------------+ | Michael Knapp - Mauerbach - Niederösterreich - Austria - Europe | | E-Mail: ICQ: 36542787 | +--------------------------------------------------------------------+ | G r a p h i X http://programmierer.freepage.de/graphix/ | | Graphics Library for Freepascal, Virtual Pascal and Borland Pascal | | http://graphix4pascal.cjb.net/ http://www.graphix4pascal.de.vu/ | +--------------------------------------------------------------------+