ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

i386rtl.c
Go to the documentation of this file.
00001 /*
00002  *  FreeLoader
00003  *  Copyright (C) 1998-2003  Brian Palmer  <brianp@sginet.com>
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License along
00016  *  with this program; if not, write to the Free Software Foundation, Inc.,
00017  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  */
00019 
00020 #include <freeldr.h>
00021 
00022 void sound(int freq);
00023 void delay(unsigned msec);
00024 
00025 void PcBeep(void)
00026 {
00027     sound(700);
00028     delay(200);
00029     sound(0);
00030 }
00031 
00032 void delay(unsigned msec)
00033 {
00034     REGS        Regs;
00035     unsigned    usec;
00036     unsigned    msec_this;
00037 
00038     // Int 15h AH=86h
00039     // BIOS - WAIT (AT,PS)
00040     //
00041     // AH = 86h
00042     // CX:DX = interval in microseconds
00043     // Return:
00044     // CF clear if successful (wait interval elapsed)
00045     // CF set on error or AH=83h wait already in progress
00046     // AH = status (see #00496)
00047 
00048     // Note: The resolution of the wait period is 977 microseconds on
00049     // many systems because many BIOSes use the 1/1024 second fast
00050     // interrupt from the AT real-time clock chip which is available on INT 70;
00051     // because newer BIOSes may have much more precise timers available, it is
00052     // not possible to use this function accurately for very short delays unless
00053     // the precise behavior of the BIOS is known (or found through testing)
00054 
00055     while (msec)
00056     {
00057         msec_this = msec;
00058 
00059         if (msec_this > 4000)
00060         {
00061             msec_this = 4000;
00062         }
00063 
00064         usec = msec_this * 1000;
00065 
00066         Regs.b.ah = 0x86;
00067         Regs.w.cx = usec >> 16;
00068         Regs.w.dx = usec & 0xffff;
00069         Int386(0x15, &Regs, &Regs);
00070 
00071         msec -= msec_this;
00072     }
00073 }
00074 
00075 void sound(int freq)
00076 {
00077     int scale;
00078 
00079     if (freq == 0)
00080     {
00081         WRITE_PORT_UCHAR((PUCHAR)0x61, READ_PORT_UCHAR((PUCHAR)0x61) & ~3);
00082         return;
00083     }
00084 
00085     scale = 1193046 / freq;
00086     WRITE_PORT_UCHAR((PUCHAR)0x43, 0xb6);
00087     WRITE_PORT_UCHAR((PUCHAR)0x42, scale & 0xff);
00088     WRITE_PORT_UCHAR((PUCHAR)0x42, scale >> 8);
00089     WRITE_PORT_UCHAR((PUCHAR)0x61, READ_PORT_UCHAR((PUCHAR)0x61) | 3);
00090 }

Generated on Sun May 27 2012 04:19:08 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.