Home | History | Annotate | Download | only in DxeEmuStdErrSerialPortLib
      1 /** @file
      2   Serial Port Lib that thunks back to Emulator services to write to StdErr.
      3   All read functions are stubed out.
      4 
      5   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
      6   Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>
      7   This program and the accompanying materials
      8   are licensed and made available under the terms and conditions of the BSD License
      9   which accompanies this distribution.  The full text of the license may be found at
     10   http://opensource.org/licenses/bsd-license.php.
     11 
     12   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     13   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     14 
     15 **/
     16 
     17 
     18 #include <PiDxe.h>
     19 #include <Library/SerialPortLib.h>
     20 #include <Library/EmuThunkLib.h>
     21 
     22 
     23 
     24 
     25 /**
     26   Initialize the serial device hardware.
     27 
     28   If no initialization is required, then return RETURN_SUCCESS.
     29   If the serial device was successfully initialized, then return RETURN_SUCCESS.
     30   If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
     31 
     32   @retval RETURN_SUCCESS        The serial device was initialized.
     33   @retval RETURN_DEVICE_ERROR   The serial device could not be initialized.
     34 
     35 **/
     36 RETURN_STATUS
     37 EFIAPI
     38 SerialPortInitialize (
     39   VOID
     40   )
     41 {
     42   return RETURN_SUCCESS;
     43 }
     44 
     45 /**
     46   Write data from buffer to serial device.
     47 
     48   Writes NumberOfBytes data bytes from Buffer to the serial device.
     49   The number of bytes actually written to the serial device is returned.
     50   If the return value is less than NumberOfBytes, then the write operation failed.
     51   If Buffer is NULL, then ASSERT().
     52   If NumberOfBytes is zero, then return 0.
     53 
     54   @param  Buffer           The pointer to the data buffer to be written.
     55   @param  NumberOfBytes    The number of bytes to written to the serial device.
     56 
     57   @retval 0                NumberOfBytes is 0.
     58   @retval >0               The number of bytes written to the serial device.
     59                            If this value is less than NumberOfBytes, then the read operation failed.
     60 
     61 **/
     62 UINTN
     63 EFIAPI
     64 SerialPortWrite (
     65   IN UINT8     *Buffer,
     66   IN UINTN     NumberOfBytes
     67   )
     68 {
     69   if (gEmuThunk == NULL) {
     70     return NumberOfBytes;
     71   }
     72 
     73   return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);
     74 }
     75 
     76 
     77 /**
     78   Read data from serial device and save the datas in buffer.
     79 
     80   Reads NumberOfBytes data bytes from a serial device into the buffer
     81   specified by Buffer. The number of bytes actually read is returned.
     82   If the return value is less than NumberOfBytes, then the rest operation failed.
     83   If Buffer is NULL, then ASSERT().
     84   If NumberOfBytes is zero, then return 0.
     85 
     86   @param  Buffer           The pointer to the data buffer to store the data read from the serial device.
     87   @param  NumberOfBytes    The number of bytes which will be read.
     88 
     89   @retval 0                Read data failed; No data is to be read.
     90   @retval >0               The actual number of bytes read from serial device.
     91 
     92 **/
     93 UINTN
     94 EFIAPI
     95 SerialPortRead (
     96   OUT UINT8     *Buffer,
     97   IN  UINTN     NumberOfBytes
     98   )
     99 {
    100   return 0;
    101 }
    102 
    103 /**
    104   Polls a serial device to see if there is any data waiting to be read.
    105 
    106   Polls a serial device to see if there is any data waiting to be read.
    107   If there is data waiting to be read from the serial device, then TRUE is returned.
    108   If there is no data waiting to be read from the serial device, then FALSE is returned.
    109 
    110   @retval TRUE             Data is waiting to be read from the serial device.
    111   @retval FALSE            There is no data waiting to be read from the serial device.
    112 
    113 **/
    114 BOOLEAN
    115 EFIAPI
    116 SerialPortPoll (
    117   VOID
    118   )
    119 {
    120   return FALSE;
    121 }
    122 
    123 
    124