delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/04/08/11:14:30

Message-ID: <271DBBEEA095D511B80D009027DE7D67020C8094@mcoexc01.mlm.maxtor.com>
From: "Dykstra, Sean" <Sean_Dykstra AT maxtor DOT com>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
Subject: RE: porting PCI card driver from NT to DOS
Date: Tue, 8 Apr 2003 09:12:27 -0600
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2653.19)
Reply-To: djgpp AT delorie DOT com

Octavi,

We have had great success in writing drivers for many PCI controllers in the
DOS environment.  My suggestion is that you should focus on developing DJGPP
layers for the following:

1.  Programmed IO 
2.  PCI Communication 
3.  Interrupts (PCI interrupts are almost always mapped to ISA interrupts
4.  DMA/UDMA
5.  Memory mapped IO

With the help of the documentation, and this mailing list, we have
successfully setup distinct sections of code supporting each of these.  We
have been using this compiler for about 1.5 years, and have nothing but good
things to say about it.

Notes:
1.  Programmed IO is just handled through simple inportX and outportX, where
X indicates the size (b, w, d)

2.  PCI Communication is best handled by writing your own routines, rather
than using BIOS calls, as some older BIOS' do not correctly support these
calls.  You will need to add PCI communication so you can tell what the
interrupt handler is, where the IO ports are, what memory mapped IO space
you will need, and get access to any of the PCI registers for the device.
//==================================================================
// ReadPCIDword
//    Reads a single dword the requested PCI card and register.
//                                                 
// Input:               SlotData:  The SlotData for the last PCI device
found.  
//                          This combined with the Bus Number provide us a
unique 
//                          handle to the PCI card. 
//                          BusNumber:  The BusNumber for the last PCI
device found.
//                          This combined with the SlotData provide us a
unique 
//                          handle to the PCI card.
//                          Register: 
//                          Register:  The PCI register to write
// Implied input: none
// Output:        32 bit value, indicating the dword read
// Globals affected:none
//==================================================================
dDWORD ReadPCIDwordSlot  (
        MX_PCI_SLOT_NUMBER      *SlotData,
        dDWORD                   BusNumber,
        dIOADDR                  Register)
{
     dDWORD DwordRead;
   dDWORD Handle;       //This is the final handle
   //Make sure the register being written is double-word aligned
   Register-=(Register%4);
   Handle=(0x080000000 | (SlotData->u.bits.FunctionNumber << 8) |
(SlotData->u.bits.DeviceNumber << 11) | ((BusNumber) << 16) | Register);
   outportl (0x0CF8,Handle);

   DwordRead=inportl (0x0CFC);
     return (DwordRead);
}

//==================================================================
// WritePCIDword
//    Writes a single dword the requested PCI card and register.
//                                                 
// Input:               SlotData:  The SlotData for the last PCI device
found.  
//                          This combined with the Bus Number provide us a
unique 
//                          handle to the PCI card. 
//                          BusNumber:  The BusNumber for the last PCI
device found.
//                          This combined with the SlotData provide us a
unique 
//                          handle to the PCI card.
//                          Register: 
//                          Register:  The PCI register to write
//                          Value:  The value to send to the PCI register.  
// Implied input: none
// Output:        none
// Globals affected:none
//==================================================================
dWORD WritePCIDwordSlot  (
        MX_PCI_SLOT_NUMBER  *SlotData,
        dDWORD               BusNumber,
        dIOADDR              Register,
        dDWORD               Value)
{
   dDWORD Handle;       //This is the final handle
   //Make sure the register being written is double-word aligned
   Register-=(Register%4);
   Handle=(0x080000000 | (SlotData->u.bits.FunctionNumber << 8) |
(SlotData->u.bits.DeviceNumber << 11) | ((BusNumber) << 16) | Register);
   outportl (0x0CF8,Handle);

   outportl (0x0CFC,Value);
   return (0);
}

3.  For interrupts, my suggestion is to use the sample assembly code on the
delorie web site.  The C code will get you quite a ways, but to really make
it work right you need to tackle the assembly.

4.  For DMA, my suggestion is to use the sample DMA code available via
CWSDPMI.  You will be restricted to this DPMI host, but is has worked
wonderfully on every system we have tested.

5.  Memory mapped IO help can also be attained via the
__dpmi_physical_address_mapping, __dpmi_allocate_ldt_descriptors,
__dpmi_set_segment_base_address, 
   __dpmi_set_segment_limit, and
__dpmi_set_descriptor_access_rights(selector, 0x01F3)
routined.  You will also probably want to unmap them via
__dpmi_free_ldt_descriptor and __dpmi_free_physical_address_mapping.


-----Original Message-----
From: Octavi Fors [mailto:ofors AT am DOT ub DOT es]
Sent: Tuesday, April 08, 2003 3:25 AM
To: djgpp AT delorie DOT com
Subject: porting PCI card driver from NT to DOS


Hi all,

this is my first email to the list and first time I heard from djgpp.

We have recently purchased a Heidenhain PCI card which counts revolutions
from a rotary encoder. Heidenhain only supplies Windows9x and NT driver,
but not DOS or Win 3.11. We dispose of C source code of such driver (take
a look below my message).  
However, our telescope control software is built and running under
DOS/Win3.11. 

This is why I became interested with djgpp, as it seems this compilator is
able to compile 32 bits C code for being run under DOS.

With this in mind, I would be grateful if anybody can bring me some light 
on the following questions:

-Could be possible to compile C source code of NT driver shown below with
djgpp? With how much effort? Minor changes of syntax or major changes?

Please, advice.

-Is there any other more straigh forward alternative for porting NT driver
for DOS instead of trying to compile it with djgpp?

Thanks in advance,

=================================================================

Octavi Fors

Astronomy Department
University of Barcelona
Barcelona
SPAIN

e-mail: ofors AT am DOT ub DOT es  

=================================================================

- Raw text -


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