FDOS / kernel

FreeDOS kernel - implements the core MS-DOS/PC-DOS (R) compatible operating system. It is derived from Pat Villani's DOS-C kernel and released under the GPL v2 or later. Please see http://www.freedos.org/ for more details about the FreeDOS (TM) Project.
http://kernel.fdos.org/
GNU General Public License v2.0
803 stars 143 forks source link

Int2f/1217 incorrect return value for CDS #3

Closed andrewbird closed 5 years ago

andrewbird commented 6 years ago

I'm seeing an odd effect with current GIT compiled with gcc-ia16-elf. If I use the int2f/1217 function to get a drive's CDS entry (from within a int2f/11 redirector call so I have a valid DOS stack) I get an incorrect value for the CDS returned. I also notice that the value never changes if a different drive is queried. I've pushed a test patch to https://github.com/andrewbird/fdkernel/tree/int2f-12-issue which makes it work for me. It seems normal that a (struct *) should be used for exchanging registers with the called function, but I can find no problem with the Watcom compiled FreeDOS 1.20 release which presumably uses the (struct).

These snippets of log from Dosemu2's redirector show the values returned by two differing
methods of obtaining CDS:
    The drive_cds() function returns the CDS by means of the int21/52 SYSVARS/LOL function.
    The GetCDSInDOS() function uses int2f/1217 (with DOS stack).

Previously with gcc-ia16-elf compiled git the return value would always be the same fixed
address:
    MFS: GetCDSInDOS for C:
    MFS: GetCDSInDOS ret 1:
    MFS: GetCDSInDOS CDS ptr is 0x0xb01e4000
    MFS: drive_cds ptr is       0x0xb017b640

    MFS: GetCDSInDOS for D:
    MFS: GetCDSInDOS ret 1:
    MFS: GetCDSInDOS CDS ptr is 0x0xb01e4000
    MFS: drive_cds ptr is       0x0xb017b698

With this patch the return values are identical:
    MFS: GetCDSInDOS for C:
    MFS: GetCDSInDOS ret 1:
    MFS: GetCDSInDOS CDS ptr is 0x0xb017b2f0
    MFS: drive_cds ptr is       0x0xb017b2f0

    MFS: GetCDSInDOS for D:
    MFS: GetCDSInDOS ret 1:
    MFS: GetCDSInDOS CDS ptr is 0x0xb017b348
    MFS: drive_cds ptr is       0x0xb017b348
andrewbird commented 6 years ago

Since this is a new issues list and not many people are subscribed, I'll shout out to @bartoldeman and @tkchia as it seems to be specific to the gcc build. This is the compiler I'm using:

Using built-in specs.
COLLECT_GCC=ia16-elf-gcc
COLLECT_LTO_WRAPPER=/usr/lib/i386-linux-gnu/gcc/ia16-elf/6.3.0/lto-wrapper
Target: ia16-elf
Configured with: ../configure --build=i686-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir='/usr/lib/i386-linux-gnu' --libexecdir='/usr/lib/i386-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --target=ia16-elf --infodir=/usr/ia16-elf/info --enable-libssp --enable-languages=c,c++ --with-newlib --disable-libstdcxx-dual-abi --disable-extern-template --disable-wchar_t --disable-libstdcxx-verbose
Thread model: single
gcc version 6.3.0 (GCC) 

$ dpkg -l gcc-ia16-elf
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                      Version                   Architecture              Description
+++-=========================================-=========================-=========================-========================================================================================
ii  gcc-ia16-elf                              6.3.0-20181013.16-ppa1810 i386                      GNU C and C++ compilers for ia16-elf target