X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: "Rod Pemberton" Newsgroups: comp.os.msdos.djgpp Subject: Re: Using outportb() with djgpp Date: Thu, 10 Jul 2014 22:08:13 -0400 Organization: Aioe.org NNTP Server Lines: 34 Message-ID: References: NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse AT aioe DOT org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Bytes: 2308 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Thu, 10 Jul 2014 16:20:13 -0400, Mateusz Viste wrote: > 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? I'm not familiar with your port. I use outportb() extensively in my OS project for keyboard, mouse, RTC, PIT, PICs, VGA registers, etc. Typically, I have both hardware interrupts and software interrupts disabled when using outportb(). In at least one instance, only software interrupts are disabled. Software interrupts are disabled with the x86 CLI instruction, but with C compilers you should use the provided function. Sometimes they do more than just clear the interrupt. For DJGPP, you should use disable(). Other C compilers have similar functions. Hardware interrupts (NMI - Non-Maskable Interrupts) are disabled or enabled by changing a bit in CMOS memory, i.e., using out_portb() and in_portb(). "Non Maskable Interrupt" http://wiki.osdev.org/Non_Maskable_Interrupt alt.os.development FAQ on NMI http://aodfaq.wikispaces.com/boot#How%20do%20I%20disable%20NMI%20on%20a%20PC? Rod Pemberton