Sign in Join

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

Mailing lists / fpc-pascal / 2003-09

BIOS PnP function far call (go32v2)

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Unknown author

Hi,

under GO32V2 i want to call BIOS PnP function with entry point

db $FF,$1E; dw PnP_EntryPoint
or
call DWord ptr [PnP_EntryPoint]

but always i got error "SIGSEGV - segmentation violation". PnP_EntryPoint (type pointer) is normally somewhere in BIOS area at F000:xxxxh.

In PnP specification i found this:

"If this function is called from protected mode the caller must create a data segment descriptor using the 16-bit Protected Mode data segment base address specified in the Plug and Play Installation Check data structure, a limit of 64k, and the descriptor must be readable and writable."

But i don't know how can i do that
-> "make a readable and writable data segment descriptor".

And the second problem is how can i make a pointer "PnP_EntryPoint" to this real memory area.

Under real DOS with BP7 it is O.K.

Sorry, i know this is not really question to FPC, but maybe somebody could help me. The same problem i got with calling ASPI entry point.

Thanks

Lubomir Cabla/CBL

Nikolay Nikolov
to Unknown author
Show quoted text 20 lines
Hi, under GO32V2 i want to call BIOS PnP function with entry point db $FF,$1E; dw PnP_EntryPoint or call DWord ptr [PnP_EntryPoint] but always i got error "SIGSEGV - segmentation violation". PnP_EntryPoint (type pointer) is normally somewhere in BIOS area at F000:xxxxh. But i don't know how can i do that -> "make a readable and writable data segment descriptor". And the second problem is how can i make a pointer "PnP_EntryPoint" to this real memory area. Under real DOS with BP7 it is O.K.

Read the docs for the go32 unit (in doc\units.pdf) or some protected mode / DPMI tutorial.

You can create descriptors with the allocate_ldt_descriptors function. Then you can use other functions to set the access rights and limit of the descriptor, etc...

In BP7 it works, because you're in real mode. In FPC/go32v2 you're in protected mode so you can't call directly code that was designed to run in real mode. You should use the DPMI services. Some newer BIOS functions can be called directly from protected mode (as well as real mode), but they require that you set up some special code and data segment descriptors. (the VBE3 functions support that, I guess the PnP functions are the same, although I never used them) All this can be done using DPMI (the go32 unit) but you should know how protected mode works. :)

Thomas Schatzl

[Note that I did a copy&paste from the list archives because the mail address I am subscribed to this list isn't working properly atm. I switched to another, but this means I couldn't reply to the original posting and so message threading is broken. Sorry.]

Hi,

Show quoted text 20 lines
under GO32V2 i want to call BIOS PnP function with entry point db $FF,$1E; dw PnP_EntryPoint or call DWord ptr [PnP_EntryPoint] but always i got error "SIGSEGV - segmentation violation". PnP_EntryPoint (type pointer) is normally somewhere in BIOS area at F000:xxxxh. In PnP specification i found this: "If this function is called from protected mode the caller must create a data segment descriptor using the 16-bit Protected Mode data segment base address specified in the Plug and Play Installation Check data structure, a limit of 64k, and the descriptor must be readable and writable." But i don't know how can i do that -> "make a readable and writable data segment descriptor".

Probably the easiest way to accomplish that (at least worth a try) is using a method provided by the DPMI server which allows you to call a real mode procedure directly. The only problem is that the GO32 function does not include this call, so you have to use a more complete DPMI interface I did long ago (uploaded at http://members.yline.com/~tom_at_work/dpmidist.zip , for the example programs you may need another one of my units, called MEMORY, grab a copy at
http://members.yline.com/~tom_at_work/memorydist.zip). See the included documentation for dpmi_call_rm_procedure_with_retf_frame and the dcall16.pas and call16.pas example programs which are included. They show how to call a real mode procedure and pass real mode parameters (e.g. buffer addresses) to those.

Btw, the DPMI zip also includes a good DPMI specification =) if you're interested and/or have more detailed questions about it.

If you want to try the way described in the PnP description, have a look at the dpmi_segment_to_descriptor() method which is exactly suited for this purpose (again, see the docs for details). You simply have to provide a base address and it returns you a selector to real mode memory with a limit of 64k. The short example program for this method is called vgasel.pas. (Note that the go32 provides this call too, and there *should* be a similar example program around*).

Then you probably have to pass this selector somehow to the PnP subsystem, but don't ask me how...

* Eg. somewhere lost in the examples directory of the fpc distro. At least there were in some 0.99.x distro... ;-)

And the second problem is how can i make a pointer "PnP_EntryPoint" to this real memory area.

You can read/write this real mode data by first creating a selector/descriptor to this memory area and use the seg_* methods.

Descriptor creation process:
- use dpmi_allocate_ldt_descriptors
- then set the base address/length of the descriptor (dpmi_set_segment_base_address, dpmi_set_segment_limit)

The other mail already mentioned the names of the corresponding GO32 functions.

As usual there should be an example program around (both for the GO32 unit and the DPMI units)

Under real DOS with BP7 it is O.K.

As another reader already pointed out, FPC programs always runs in protected mode, so it's quite common that such programs won't work (actually it'd be quite surprising if they worked right away).

Sorry, i know this is not really question to FPC, but maybe somebody could help me. The same problem i got with calling ASPI entry point.

I believe that the reasons/solutions are the same for both problems.

Note that as you may notice these units are older (never thought they'd be of much use again), e.g. ~3 years, so there might be small problems when compiling.

Hope this helps.

Regards,
Thomas

Unknown author

Hi Thomas,

thanks for your help, i hope i find a solution in yours files.

Then you probably have to pass this selector somehow to the PnP subsystem, but don't ask me how...

... that's the problem :()

Lubomir Cabla/CBL

Unknown author
to Unknown author

From:
To:
Subject: RE: [fpc-pascal]BIOS PnP function far call (go32v2) Send reply to:

Date sent: Wed, 10 Sep 2003 14:09:14 +0200

Hi,

Show quoted text 6 lines
thanks for your help, i hope i find a solution in yours files. >Then you probably have to pass this selector somehow to the PnP >subsystem, but don't ask me how... ... that's the problem :()

I think that you just need to save the original contents of the DS register somewhere, place your newly allocated selector in DS just before calling the PnP routine, and restoring the DS value immediately after return.

Tomas