X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Date: Wed, 30 Jul 2014 14:51:30 +0200 From: Mateusz Viste User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Using outportb() with djgpp References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Lines: 64 Message-ID: <53d8ea52$0$2077$426a74cc@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 30 Jul 2014 14:51:31 CEST NNTP-Posting-Host: 82.225.72.113 X-Trace: 1406724691 news-2.free.fr 2077 82.225.72.113:61529 X-Complaints-To: abuse AT proxad DOT net Bytes: 3688 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi all, My problem is somewhat solved (or at least I know exactly what is going wrong, and how to jump over it), so I felt it would be good to share my conclusions in this thread. First, I quickly dropped DJGPP for this project. Not because it's not working fine, or anything, but simply because doing such low-level stuff in real mode is a bit clearer, because it's closer to the machine (and having it running on a hypothetical 8086 is always sounding 'cool'). These of you who follow comp.os.msdos.programmer already know the whole story. For the others: I have written before that my problem was appearing only in DJGPP, but not in real mode. This was true... but only until I started using XMS memory from within my real mode program. Then, the exact same problem I had on DJGPP appeared (ie. wild reboots). I installed JemmEx hoping to catch the problem without triggering an immediate reboot, and it did show me the problem: an "exception 0D" was occuring when I was writing a midi note to port 0x330, and trying to move XMS blocks immediately after that. I am using a SoundBlaster 64 AWE card on an ISA slot. These cards require a magic TSR called "AWEUTIL" that emulates a standard MPU-401 interface on port 0x330 by catching notes that are sent to it via some obscure NMI magic. What I understood is that AWEUTIL is catching the note, and then performs some work to translate the MIDI message to a native command of the SB64 "EMU8000" synth chip. As it appears, if I happen to try using XMS memory when AWEUTIL is 'busy', a crash happens. If I don't load AWEUTIL, then my program works fine. Also, if I load AWEUTIL, but use low memory instead of XMS, again, it works. The workaround I found is simply to wait for 2ms after each time I write to port 0x330 (giving AWEUTIL enough time to do its work, I presume), then my program works fine, no crashes, everyone happy. So I think that the problem I had in DJGPP was exactly the same. But there, I couldn't control how (and when) my program used XMS, since it's handled automatically, so it would probably be much harder to locate the problem. cheers, Mateusz On 07/10/2014 10:20 PM, Mateusz Viste wrote: > Hi, > > I am trying to write to a hardware port from within djgpp, using > outportb(). It does work from time to time, but often outportb() will > make the whole PC reboot. Specifically I am writing to port 0x330 (to a > MPU401 adapter). If using the same code with turbo C, it works > perfectly. Hence I am wondering: are there any special "rules" I should > be aware of when trying to outportb() from within protected mode? > > regards, > Mateusz