From: Roberto Garza Subject: Re: IRQ trap with stack change, very intersting! Message-ID: Newsgroups: alt.msdos.programmer,comp.os.msdos.djgpp,comp.os.msdos.programmer Date: Fri, 04 Jul 1997 17:53:23 -0500 Lines: 41 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk text esto es una prueba ----------------------------------------------------- "Romano Signorelli" escribe: > Hi, > i'm using Borland C++ 4.52 with DOS powerpack which provide DPMI16 and > DPMI32 support. > I'm trying to trap IRQ 10 (interrupt 0x71), also IRQ 8 (interrupt 0x1c). > > I want to write a dual-task program. Each time the interrupt come, i want > to do a stack switch (íve provided 2 separated stacks, allocated at > start-time), save the registers, change the return CS:IP in the stack to > point to the next task and, then, do an IRET. > Here are some source code (simplified for debugging purposes): > -- Start code: > InitCode(); > #ifdef DEBUG_VERSION > geninterrupt(0x71); > #endif > do{ > while(1==1); > > -- Task1 code: > do{ > task1_counter++; > #ifdef DEBUG_VERSION > geninterrupt(0x71); > #endif > } while (1==1); > > -- Task2 code: > do{ > task2_counter++; > #ifdef DEBUG_VERSION > geninterrupt(0x71); > #endif > }while (1==1); > > With DEBUG_VERSION defined, my INT routine works well, it does a correct > stack switch and the 2 tasks take 50% CPU time each. > The problem comes when i try to install my INT routine over an hardware > interrupt (my IRQ 10 or the PC's IRQ 8). The stack isn't my program stack > (i think it is the DPMI server INT stack) and i cannot find the correct > return CS:IP in it. > Please HELP ME!!! > > Thanks in advance, bye. > Note: please don't flame with messages like "Why don't you use OS/2" or > similar. I have to do it in pure DOS. Thanks. > ip archive with the DJGPP cross compiling # stuff djcrx=~/ftp/pub/simtelnet/gnu/djgpp/v2/djcrx201.zip # I tested it on a PPro 200Mhz and there uname -m prints 'i686' which # is unknown for binutils host=i486-unknown-linux # this will be fixed in the future, but currently the targets for # DJGPP are named different in the binutils and gcc bnu_target=i386-coff-go32 gcc_target=i386-go32-msdos # this should be almost ${gcc_target}, because it is hardcoded # in gcc for directory searching install_target=${gcc_target} mkdir -p ${build_dir} cd ${build_dir} tar -xzvf ${bnu_src} mkdir dos-binutils cd dos-binutils ../binutils-${bnu_ver}/configure --host=${host} --target=${bnu_target} --prefix=${prefix_dir} # NOTE: The above is one long line make CFLAGS=-O2 mkdir -p ${prefix_dir}/i386-go32-msdos/bin cd binutils cp ar c++filt objcopy objdump size ${prefix_dir}/i386-go32-msdos/bin cp nm.new ${prefix_dir}/i386-go32-msdos/bin/nm cp strip.new ${prefix_dir}/i386-go32-msdos/bin/strip cd ../gas cp as.new ${prefix_dir}/i386-go32-msdos/bin/as cp gasp.new ${prefix_dir}/i386-go32-msdos/bin/gasp cd ../ld cp ld.new ${prefix_dir}/i386-go32-msdos/bin/ld cd ../.. # If you have not so much disk space, you can do now # rm -rf binutils-${bnu_ver} dos-binutils tar -xzvf ${gcc_src} mkdir dos-gcc cd dos-gcc ../gcc-${gcc_ver}/configure --host=i486-unknown-linux --target=${gcc_target} --prefix=${prefix_dir} # NOTE: the above is one long line make LANGUAGES="c c++" CFLAGS=-O2 mkdir -p ${prefix_dir}/bin cp xgcc ${prefix_dir}/bin/gcc-dos cp cc1 ${prefix_dir}/i386-go32-msdos/bin/cc1 cp cccp ${prefix_dir}/i386-go32-msdos/bin/cpp cp cc1plus ${prefix_dir}/i386-go32-msdos/bin/cc1plus cd ${prefix_dir} mkdir djgpp cd djgpp unzip -a ${djcrx} # this is a needed patch and can be removed from bnu 2.8.2 on cd lib cp djgpp.djl djgpp.djl.ori sed 's,coff-go32,coff-i386,g' djgpp.djl.ori > djgpp.djl cd .. # build the stubify program cd src/stub make stubify cp stubify ${prefix_dir}/i386-go32-msdos/bin mkdir -p ${prefix_dir}/lib/gcc-lib/i386-go32-msdos/${gcc_ver} # create some symbolic links cd ${prefix_dir}/lib/gcc-lib/i386-go32-msdos/${gcc_ver} ln -s ${prefix_dir}/djgpp/include . ln -s ${prefix_dir}/djgpp/lib/* . echo Now I am testing the installation. echo Errors will be redirected to ${build_dir}/Errs echo Output will be redirected to ${build_dir}/Out cd ${prefix_dir}/djgpp/src/stub ${prefix_dir}/bin/gcc-dos -v -o stubify.exe stubify.c 2>${build_dir}/Err >${build_dir}/Out # NOTE: the above is one long line rm stubify.exe echo Now I am ready. Do not forget to add ${prefix_dir}/bin to your PATH echo and then you can use gcc-dos to compile/link for DJGPP. -----------CUT here---------------------- BTW: I executed some minutes ago the following on a linux machine with a PPro 200Mhz and 256 MB RAM!! date > date1; cross.sh; date >> date1 and here is the contents of the file date1: Tue Jul 1 11:01:16 MET DST 1997 Tue Jul 1 11:10:37 MET DST 1997 As you can see it took me about 9 minutes!!!! Robert -- ***************************************************************** * Robert Hoehne, Fakultaet fuer Mathematik, TU-Chemnitz-Zwickau * * Post: Am Berg 3, D-09573 Dittmannsdorf * * e-Mail: Robert DOT Hoehne AT Mathematik DOT TU-Chemnitz DOT DE * * WWW: http://www.tu-chemnitz.de/~rho * *****************************************************************