github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/include/vmm_serial.h (about)

     1  /*
     2   * Copyright (c) 2013 Intel Corporation
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *     http://www.apache.org/licenses/LICENSE-2.0
     8   * Unless required by applicable law or agreed to in writing, software
     9   * distributed under the License is distributed on an "AS IS" BASIS,
    10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11   * See the License for the specific language governing permissions and
    12   * limitations under the License.
    13   */
    14  
    15  #ifndef _VMM_SERIAL_H_
    16  #define _VMM_SERIAL_H_
    17  
    18  #include "uart.h"
    19  
    20  // Initialize a new serial device's parameters
    21  
    22  void *                                  // Ret: Handle to the device
    23  vmm_serial_new(
    24      UINT16              io_base,        // In:  I/O Base Address
    25      UART_PROG_IF_TYPE   prog_if,        // In:  Programming interface
    26      UART_HANDSHAKE_MODE handshake_mode  // In:  Handshake mode
    27  );
    28  
    29  
    30  // Initialize a serial device
    31      
    32  void
    33  vmm_serial_init(void   *h_device);   // In:  Handle of the device
    34  
    35  void vmm_serial_reset(void *h_device);
    36  
    37  // Returns the I/O range occupied by the device
    38  
    39  void
    40  vmm_serial_get_io_range(void   *h_device,    // In:  Handle of the device
    41                          UINT16 *p_io_base,   // Out: Base of I/O range
    42                          UINT16 *p_io_end);   // Out: End of I/O range
    43  
    44  //
    45  // Write a single character to a serial device in a non-locked mode.
    46  // This function is reentrant, and can be safely called even while the normal
    47  // vmm_serial_putc() runs.  However, it is not optimized for performance and
    48  // should only be used when necessary, e.g., from an exception handler.
    49  
    50  char                                     // Ret: Character that was sent
    51  vmm_serial_putc_nolock(void *h_device,   // In:  Handle of the device
    52                         char  c);         // In:  Character to send
    53  
    54  
    55  // Write a single character to a serial device.
    56  // This function is not reentrant, and is for use in the normal case, where the
    57  // serial device has been previously locked.  It may be interrupted by
    58  // vmm_serial_putc_nolock().  The function attempts to use the full depth of
    59  // the UART's transmit FIFO to avoid busy loops.
    60  
    61  char                              // Ret: Character that was sent
    62  vmm_serial_putc(void *h_device,   // In:  Handle of the device
    63                  char  c);         // In:  Character to send
    64  
    65  
    66  // Write a string to a serial device in a non-locked mode.
    67  // This function is reentrant, and can be safely called even while the normal
    68  // vmm_serial_putc() runs.  However, it should be used only when necessary,
    69  // e.g. from an exception handler.
    70  
    71  int                                            // Ret: 0 if failed
    72  vmm_serial_puts_nolock(void       *h_device,   // In:  Handle of the device
    73                         const char  string[]);  // In:  String to send
    74  
    75  
    76  // Write a string to a serial device
    77  // This function is not reentrant, and is for use in the normal case, where the
    78  // serial device has been previously locked.  It may be interrupted by
    79  // vmm_serial_put*_nolock().
    80  
    81  int                                     // Ret: 0 if failed
    82  vmm_serial_puts(void       *h_device,   // In:  Handle of the device
    83                  const char  string[]);   // In:  String to send
    84  
    85  
    86  // Poll the serial device and read a single character if ready.
    87  // This function is not reentrant.  Calling it while it runs in another thread
    88  // may result in a junk character returned, but the s/w will not crash.
    89  
    90  char                              // Ret: Character read from the device, 0 if
    91                                    //      none.
    92  vmm_serial_getc(void *h_device);  // In:  Handle of the device
    93  
    94  // Initialize CLI command(s) for serial ports
    95  void vmm_serial_cli_init(void);
    96  
    97  #endif