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

inbvport.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS Kernel
00003  * LICENSE:         BSD - See COPYING.ARM in the top level directory
00004  * FILE:            ntoskrnl/inbv/inbvport.c
00005  * PURPOSE:         Serial Port Boot Driver for Headless Terminal Support
00006  * PROGRAMMERS:     ReactOS Portable Systems Group
00007  */
00008 
00009 /* INCLUDES ******************************************************************/
00010 
00011 #include <ntoskrnl.h>
00012 #include <debug.h>
00013 
00014 /* GLOBALS *******************************************************************/
00015 
00016 CPPORT Port[4] =
00017 {
00018     {NULL, 0, TRUE},
00019     {NULL, 0, TRUE},
00020     {NULL, 0, TRUE},
00021     {NULL, 0, TRUE}
00022 };
00023 
00024 /* FUNCTIONS *****************************************************************/
00025 
00026 VOID
00027 NTAPI
00028 InbvPortEnableFifo(
00029     IN ULONG PortId,
00030     IN BOOLEAN Enable
00031     )
00032 {
00033     /* Set FIFO as requested */
00034     CpEnableFifo(Port[PortId].Address, Enable);
00035 }
00036 
00037 VOID
00038 NTAPI
00039 InbvPortPutByte(
00040     IN ULONG PortId,
00041     IN BOOLEAN Output
00042     )
00043 {
00044     /* Send the byte */
00045     CpPutByte(&Port[PortId], Output);
00046 }
00047 
00048 VOID
00049 NTAPI
00050 InbvPortTerminate(
00051     IN ULONG PortId
00052     )
00053 {
00054     /* The port is now available */
00055     Port[PortId].Address = NULL;
00056 }
00057 
00058 BOOLEAN
00059 NTAPI
00060 InbvPortInitialize(
00061     IN ULONG BaudRate,
00062     IN ULONG PortNumber,
00063     IN PUCHAR PortAddress,
00064     OUT PULONG PortId,
00065     IN BOOLEAN IsMMIODevice
00066     )
00067 {
00068     /* Not yet supported */
00069     ASSERT(IsMMIODevice == FALSE);
00070 
00071     /* Set default baud rate */
00072     if (BaudRate == 0) BaudRate = 19200;
00073 
00074     /* Check if port or address given */
00075     if (PortNumber)
00076     {
00077         /* Pick correct address for port */
00078        if (!PortAddress)
00079         {
00080             switch (PortNumber)
00081             {
00082                 case 1:
00083                     PortAddress = (PUCHAR)0x3F8;
00084                     break;
00085 
00086                 case 2:
00087                     PortAddress = (PUCHAR)0x2F8;
00088                     break;
00089 
00090                 case 3:
00091                     PortAddress = (PUCHAR)0x3E8;
00092                     break;
00093 
00094                 default:
00095                     PortNumber = 4;
00096                     PortAddress = (PUCHAR)0x2E8;
00097             }
00098         }
00099     }
00100     else
00101     {
00102         /* Pick correct port for address */
00103         PortAddress = (PUCHAR)0x2F8;
00104         if (CpDoesPortExist(PortAddress))
00105         {
00106             PortNumber = 2;
00107         }
00108         else
00109         {
00110             PortAddress = (PUCHAR)0x3F8;
00111             if (!CpDoesPortExist(PortAddress)) return FALSE;
00112             PortNumber = 1;
00113         }
00114     }
00115 
00116     /* Initialize the port unless it's already up, and then return it */
00117     if (Port[PortNumber - 1].Address) return FALSE;
00118     CpInitialize(&Port[PortNumber - 1], PortAddress, BaudRate);
00119     *PortId = PortNumber - 1;
00120     return TRUE;
00121 }

Generated on Sun May 27 2012 04:37:12 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.