This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Real mode MS-DOS programs


On Wed, 1 Oct 1997, Anders Blomdell wrote:

> Is it possible to convince gcc (or djgpp) to produce real mode (as
> opposed
> to protected mode) programs for MS-DOS? Alternatively I would be very
> grateful if I could get some guidance on how to correct my problem
> stated
> below.
> 
> Regards
> 
> Anders Blomdell
> 
> ------------------------------------------------------------------------
> ------
>  Anders Blomdell
>  Department of Automatic Control        Email:
> anders.blomdell@control.lth.se
>  Lund Institute of Technology           Phone: +46 46 222 4625
>  Box 118, S-221 00 Lund, Sweden         Fax:   +46 46 138118
> 
> 
> 
> 
> If you are not interested in MS-DOS segmentation issues, please stop
> reading here.
> 
> Scenario:
> 
> In order to automagically configure all our Intel machines with Windows
> NT,
> I need a program that finds out which ethernet adapter a certain machine
> is
> equipped with. In order to do that, I borrowed some of the PCI-BIOS code
> from the Linux system, which worked fine on our older Pentium systems,
> but
> fails miserably on the latest batch of computers (Phoenix BIOS 4.0
> Release
> 6.0).
> 
> The problem is that the following call (to 0xfd9df)
> 
>     __asm__("lcall (%%edi)\n\t"
>             "jc 1f\n\t"
>             "xor %%ah, %%ah\n"
>             "1:\tshl $8, %%eax\n\t"
>             "movw %%bx, %%ax"
>             : "=d" (signature),
>               "=a" (pack)
>             : "1" (PCIBIOS_PCI_BIOS_PRESENT),
>               "D" (&pci_indirect)
>             : "bx", "cx");
> 
> 
> leads to the following segmentation fault
> 
> My guess (I'm not very good at the Intel segmented architecture) is that
> some of the segment descriptors should be modified prior to the call,
> but
> the only results I have achieved so far, is to move the segmentation
> fault
> to the call itself...
> 
Do you have a copy of the PCI-Bios Spec for Intel machines?
I think the mistake here is that you assume the entry point into 
BIOS32 is a fixed address for all BIOSes. It is not.
The correct procedure to find BIOS32 is to scan for some magic in
the BIOS ROM, after that there is a table describing the revision level
etc. and the entry point for BIOS32 services.
There is relocatable Protected Mode code, which can even be mmap-ed 
into you text segment and called as if it was a piece of your own
code.
That's the way I used BIOS32 under linux from an user mode application.

hope that helps,

ciao Rolf
+-----------------+----------------------------------------------------------+
|    _____        |  Rolf Fiedler                                            |
|   / ___/        |  Electronic Design Engineer                              |
|  / _/           |  Ferrari electronic GmbH                                 |
| /_/e/r/r/a/r/i/ |  phone: +49 3328 4559 0  E-Mail: Rolf.Fiedler@Ferrari.DE |
|   electronic    |  fax  : +49 3328 4559 60                                 |
+-----------------+----------------------------------------------------------+