[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 03/18] OvmfPkg/XenBusDxe: Add device state struct and create an ExitBoot services event.



On Wed, Sep 10, 2014 at 03:58:16PM -0400, Konrad Rzeszutek Wilk wrote:
> On Thu, Sep 04, 2014 at 05:50:58PM +0100, Anthony PERARD wrote:
> > The ExitBoot event is used to disconnect from the device before the
> > next operating system start using them.
> > 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
> > ---
> >  OvmfPkg/XenBusDxe/XenBusDxe.c | 38 ++++++++++++++++++++++++++++++++++++--
> >  OvmfPkg/XenBusDxe/XenBusDxe.h | 11 +++++++++++
> >  2 files changed, 47 insertions(+), 2 deletions(-)
> > 
> > diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.c b/OvmfPkg/XenBusDxe/XenBusDxe.c
> > index a272204..e125ed7 100644
> > --- a/OvmfPkg/XenBusDxe/XenBusDxe.c
> > +++ b/OvmfPkg/XenBusDxe/XenBusDxe.c
> > @@ -59,6 +59,8 @@ EFI_DRIVER_BINDING_PROTOCOL gXenBusDxeDriverBinding = {
> >  };
> >  
> >  
> > +XENBUS_DEVICE *mMyDevice;
> > +
> >  /**
> >    Unloads an image.
> >  
> > @@ -232,6 +234,19 @@ XenBusDxeDriverBindingSupported (
> >    return Status;
> >  }
> >  
> > +VOID
> > +EFIAPI
> > +NotifyExitBoot (
> > +  IN EFI_EVENT Event,
> > +  IN VOID *Context
> > +  )
> > +{
> > +  XENBUS_DEVICE *Dev = Context;
> > +
> > +  gBS->DisconnectController(Dev->ControllerHandle,
> > +                            Dev->This->DriverBindingHandle, NULL);
> > +}
> > +
> >  /**
> >    Starts a bus controller.
> >  
> > @@ -275,7 +290,22 @@ XenBusDxeDriverBindingStart (
> >    IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
> >    )
> >  {
> > -  return EFI_UNSUPPORTED;
> > +  EFI_STATUS Status;
> > +  XENBUS_DEVICE *Dev;
> > +
> > +  Dev = AllocateZeroPool (sizeof (*Dev));
> > +  Dev->Signature = XENBUS_DEVICE_SIGNATURE;
> > +  Dev->This = This;
> > +  Dev->ControllerHandle = ControllerHandle;
> > +
> > +  Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK,
> > +                             NotifyExitBoot,
> > +                             (VOID*) Dev,
> > +                             &Dev->ExitBootEvent);
> > +  ASSERT_EFI_ERROR (Status);
> > +
> > +  mMyDevice = Dev;
> > +  return EFI_SUCCESS;
> >  }
> >  
> >  /**
> > @@ -313,5 +343,9 @@ XenBusDxeDriverBindingStop (
> >    IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
> >    )
> >  {
> > -  return EFI_UNSUPPORTED;
> > +  XENBUS_DEVICE *Dev = mMyDevice;
> > +
> > +  gBS->CloseEvent (Dev->ExitBootEvent);
> > +
> 
> Don't want:
> 
> mMyDevice = NULL;
> 
> Not that it matters much, but more of a helper in case somebody does try
> to use 'myDevice' during shutdown/cleanup.

I think that can be usefull indeed. It could probably also be usefull if
the driver is started twice, for whatever reason.

I should also make the variable static.

-- 
Anthony PERARD

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.