VirtualBox

Ignore:
Timestamp:
Oct 28, 2015 8:17:18 PM (9 years ago)
Author:
vboxsync
Message:

EFI/Firmware: 'svn merge /vendor/edk2/UDK2010.SR1 /vendor/edk2/current .', reverting and removing files+dirs listed in ReadMe.vbox, resolving conflicts with help from ../UDK2014.SP1/. This is a raw untested merge.

Location:
trunk/src/VBox/Devices/EFI/Firmware
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware

  • trunk/src/VBox/Devices/EFI/Firmware/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.c

    r48674 r58459  
    22  Debug Port Library implementation based on serial port.
    33
    4   Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    1919#include <Library/TimerLib.h>
    2020#include <Library/DebugLib.h>
     21#include <Library/BaseLib.h>
     22#include <Library/BaseMemoryLib.h>
     23
     24#pragma pack(1)
     25//
     26// The internal data structure of DEBUG_PORT_HANDLE, which stores some
     27// important datum which are used across various phases.
     28//
     29typedef struct _SERIAL_DEBUG_PORT_HANDLE{
     30  //
     31  // Timter settings
     32  //
     33  UINT64       TimerFrequency;
     34  UINT64       TimerCycle;
     35  BOOLEAN      TimerCountDown;
     36} SERIAL_DEBUG_PORT_HANDLE;
     37#pragma pack()
     38
     39//
     40// The global variable which can be used after memory is ready.
     41//
     42SERIAL_DEBUG_PORT_HANDLE     mSerialDebugPortHandle;
     43
     44/**
     45  Check if the timer is timeout.
     46 
     47  @param[in] SerialDebugPortHandle  Pointer to Serial Debug port handle
     48  @param[in] Timer                  The start timer from the begin.
     49  @param[in] TimeoutTicker          Ticker number need time out.
     50
     51  @return TRUE  Timer time out occurs.
     52  @retval FALSE Timer does not time out.
     53
     54**/
     55BOOLEAN
     56IsTimerTimeout (
     57  IN SERIAL_DEBUG_PORT_HANDLE   *SerialDebugPortHandle,
     58  IN UINT64                     Timer,
     59  IN UINT64                     TimeoutTicker
     60  )
     61{
     62  UINT64  CurrentTimer;
     63  UINT64  Delta;
     64
     65  CurrentTimer = GetPerformanceCounter ();
     66
     67  if (SerialDebugPortHandle->TimerCountDown) {
     68    //
     69    // The timer counter counts down.  Check for roll over condition.
     70    //
     71    if (CurrentTimer < Timer) {
     72      Delta = Timer - CurrentTimer;
     73    } else {
     74      //
     75      // Handle one roll-over.
     76      //
     77      Delta = SerialDebugPortHandle->TimerCycle - (CurrentTimer - Timer);
     78    }
     79  } else {
     80    //
     81    // The timer counter counts up.  Check for roll over condition.
     82    //
     83    if (CurrentTimer > Timer) {
     84      Delta = CurrentTimer - Timer;
     85    } else {
     86      //
     87      // Handle one roll-over.
     88      //
     89      Delta = SerialDebugPortHandle->TimerCycle - (Timer - CurrentTimer);
     90    }
     91  }
     92 
     93  return (BOOLEAN) (Delta >= TimeoutTicker);
     94}
    2195
    2296/**
     
    43117  b) If the instance does not understand, or does not want to continue use the
    44118     private data of the previous instance, it could ignore the input Context parameter
    45      and create the new hanlde to be returned.
     119     and create the new handle to be returned.
    46120
    47121  If Function() is NULL and Context is NULL, Debug Communication Library could create a
     
    63137  )
    64138{
    65   RETURN_STATUS      Status;
     139  RETURN_STATUS              Status;
     140  SERIAL_DEBUG_PORT_HANDLE   Handle;
     141  SERIAL_DEBUG_PORT_HANDLE   *SerialDebugPortHandle;
     142  UINT64                     TimerStartValue;
     143  UINT64                     TimerEndValue;
     144
     145  //
     146  // Validate the PCD PcdDebugPortHandleBufferSize value
     147  //
     148  ASSERT (PcdGet16 (PcdDebugPortHandleBufferSize) == sizeof (SERIAL_DEBUG_PORT_HANDLE));
     149
     150  if (Context != NULL && Function == NULL) {
     151    SerialDebugPortHandle = (SERIAL_DEBUG_PORT_HANDLE *)Context;
     152  } else {
     153    ZeroMem (&Handle, sizeof (SERIAL_DEBUG_PORT_HANDLE));
     154    SerialDebugPortHandle = &Handle;
     155  }
     156  SerialDebugPortHandle->TimerFrequency = GetPerformanceCounterProperties (
     157                                            &TimerStartValue,
     158                                            &TimerEndValue
     159                                            );
     160  DEBUG ((EFI_D_INFO, "Serial Debug Port: TimerFrequency  = 0x%lx\n", SerialDebugPortHandle->TimerFrequency));
     161  DEBUG ((EFI_D_INFO, "Serial Debug Port: TimerStartValue = 0x%lx\n", TimerStartValue));
     162  DEBUG ((EFI_D_INFO, "Serial Debug Port: TimerEndValue   = 0x%lx\n", TimerEndValue));
     163
     164  if (TimerEndValue < TimerStartValue) {
     165    SerialDebugPortHandle->TimerCountDown = TRUE;
     166    SerialDebugPortHandle->TimerCycle     = TimerStartValue - TimerEndValue;
     167  } else {
     168    SerialDebugPortHandle->TimerCountDown = FALSE;
     169    SerialDebugPortHandle->TimerCycle     = TimerEndValue - TimerStartValue;
     170  } 
     171
     172  if (Function == NULL && Context != NULL) {
     173    return (DEBUG_PORT_HANDLE *) Context;
     174  }
    66175
    67176  Status = SerialPortInitialize ();
     
    71180
    72181  if (Function != NULL) {
    73     Function (Context, NULL);
    74   }
    75 
    76   return NULL;
     182    Function (Context, SerialDebugPortHandle);
     183  } else {
     184    CopyMem(&mSerialDebugPortHandle, SerialDebugPortHandle, sizeof (SERIAL_DEBUG_PORT_HANDLE));
     185  }
     186
     187  return (DEBUG_PORT_HANDLE)(UINTN)&mSerialDebugPortHandle;
    77188}
    78189
     
    103214  )
    104215{
    105   UINTN                Index;
    106   INTN                 Elapsed;
    107 
    108   for (Index = 0; Index < NumberOfBytes; Index ++) {
    109     Elapsed = (INTN) Timeout;
    110     while (TRUE) {
    111       if (SerialPortPoll () || Timeout == 0) {
    112         SerialPortRead (Buffer + Index, 1);
    113         break;
    114       }
    115       MicroSecondDelay (1000);
    116       Elapsed -= 1000;
    117       if (Elapsed < 0) {
     216  SERIAL_DEBUG_PORT_HANDLE *SerialDebugPortHandle;
     217  UINTN                    Index;
     218  UINT64                   Begin;
     219  UINT64                   TimeoutTicker;
     220  UINT64                   TimerRound;
     221 
     222  //
     223  // If Handle is NULL, it means memory is ready for use.
     224  // Use global variable to store handle value.
     225  //
     226  if (Handle == NULL) {
     227    SerialDebugPortHandle = &mSerialDebugPortHandle;
     228  } else {
     229    SerialDebugPortHandle = (SERIAL_DEBUG_PORT_HANDLE *)Handle;
     230  }
     231
     232  Begin         = 0;
     233  TimeoutTicker = 0; 
     234  TimerRound    = 0;
     235  if (Timeout != 0) {
     236    Begin = GetPerformanceCounter ();
     237    TimeoutTicker = DivU64x32 (
     238                      MultU64x64 (
     239                        SerialDebugPortHandle->TimerFrequency,
     240                        Timeout
     241                        ),
     242                      1000000u
     243                      );
     244    TimerRound = DivU64x64Remainder (
     245                   TimeoutTicker,
     246                   DivU64x32 (SerialDebugPortHandle->TimerCycle, 2),
     247                   &TimeoutTicker
     248                   );
     249  }
     250  Index = 0;
     251  while (Index < NumberOfBytes) {
     252    if (SerialPortPoll () || Timeout == 0) {
     253      SerialPortRead (Buffer + Index, 1);
     254      Index ++;
     255      continue;
     256    }
     257    if (TimerRound == 0) {
     258      if (IsTimerTimeout (SerialDebugPortHandle, Begin, TimeoutTicker)) {
     259        //
     260        // If time out occurs.
     261        //
    118262        return 0;
    119263      }
     264    } else {
     265      if (IsTimerTimeout (SerialDebugPortHandle, Begin, DivU64x32 (SerialDebugPortHandle->TimerCycle, 2))) {
     266        TimerRound --;
     267      }
    120268    }
    121269  }
    122270
    123   return NumberOfBytes;
     271  return Index;
    124272}
    125273
  • trunk/src/VBox/Devices/EFI/Firmware/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf

    r48674 r58459  
    22#  Debug Communication Library instance based on serila port.
    33#
    4 #  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
     4#  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
    55#
    66#  This program and the accompanying materials
     
    1717  INF_VERSION                    = 0x00010005
    1818  BASE_NAME                      = DebugCommunicationLibSerialPort
     19  MODULE_UNI_FILE                = DebugCommunicationLibSerialPort.uni
    1920  FILE_GUID                      = 8CC435C5-6330-4269-B0C3-E3BD05C86FB8
    2021  MODULE_TYPE                    = BASE
     
    3738  TimerLib
    3839  DebugLib
    39  
     40  BaseMemoryLib
     41  BaseLib
     42
     43[PCD]
     44  # The value of data buffer size used for Serial debug port handle.
     45  # It should be equal to sizeof (SERIAL_DEBUG_PORT_HANDLE).
     46  gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugPortHandleBufferSize|17   ## SOMETIMES_CONSUMES
     47
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette