Vijai,
You didn’t send the definition of mNorFlashInstanceTemplate, so I can only
assume you’ve correctly initialized the other fields of your block I/O protocol
there. You may want to double check.
I see this comment:
//Removed Device path as already there is a device path associated with PCIIO:
by Andrew Fish
Status = gBS->InstallMultipleProtocolInterfaces (
&Instance->Handle,
&gEfiBlockIoProtocolGuid, &Instance->BlockIoProtocol,
&gEfiDevicePathProtocolGuid, Instance->DevPath,
NULL
);
But the device path does not appear to be removed.
Anyway, you should use ControllerHandle here. It looks like Instance->Handle is
probably null, which will allocate a new handle, rather than installing on the
existing handle (the one you found PCI I/O on). Try adding this line above:
Instance->Handle = ControllerHandle;
Also note that if there is no file system, you will not see fs0/fs1/etc. for
this device after you do “map -r”. But if your block I/O protocol is installed
correctly, you will see blk0/blk1/etc. for it.
Deric Cole
Sr. Customer Engineer
Phoenix Technologies Ltd.
From: vijaikumar k [mailto:vijaikuma...@mistralsolutions.com]
Sent: Thursday, June 12, 2014 3:43 AM
To: edk2-devel@lists.sourceforge.net
Subject: [edk2] NOR Flash Driver
Hi All,
I am a newbie to EFI. I have the following problem
Problem: We have Atom Processor connected to a PCIe to PCI bridge. On the other
side of the PCI bridge we have a PCI device which gives Memory Mapped access to
NOR Flash via BAR0. I have written a driver to boot from the NOR flash. The
driver is registered successfully but I am not able to see my device when I do
"Map -r".
By the way the NOR has no File System associated with it. It is still RAW.
Following are the line of code written by me for start routine.
Code:
EFI_STATUS
EFIAPI
NorFlashDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
NOR_FLASH_INSTANCE *Instance;
UINT8 CmdSts;
Instance=NULL;
Print(L"\nInside Start of NorFlash");
Status = gBS->OpenProtocol(
ControllerHandle,
&gEfiPciIoProtocolGuid,
(VOID **)&PciIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
goto Error;
}
Print(L"\nPCI IO Protocol opened successfully");
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
(VOID **) &ParentDevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
Print(L"\nDevice Path Protocol Failed to register");
goto Error;
}
Print(L"\nDevice Path Protocol Registered Successfully");
Instance = AllocateCopyPool
(sizeof(NOR_FLASH_INSTANCE),&mNorFlashInstanceTemplate);
if (Instance == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Print(L"\nResource Pool has been allocated");
Instance->Signature=NOR_FLASH_SIGNATURE;
Instance->Size = NOR_SIZE;
Instance->PciIo=PciIo;
Instance->BlockIoProtocol.Media = &Instance->Media;
Instance->Media.MediaId = NOR_MEDIA_ID;
Instance->Media.BlockSize = NOR_BLOCK_SIZE;
Instance->Media.LastBlock = (NOR_SIZE / NOR_BLOCK_SIZE)-1;
Instance->Initialized = TRUE;
Print(L"\nBefore Installing multiple protocols");
//Set Command register to enable Bus Master and MemorySpace
PciIo->Pci.Read (
PciIo,
EfiPciIoWidthUint8,
PCI_COMMAND_OFFSET,
sizeof (UINT8),
&CmdSts
);
CmdSts |= EFI_PCI_COMMAND_MEMORY_SPACE |
EFI_PCI_COMMAND_BUS_MASTER;
PciIo->Pci.Write(
PciIo,
EfiPciIoWidthUint8,
PCI_COMMAND_OFFSET,
sizeof (UINT8),
&CmdSts
);
//Removed Device path as already there is a device path associated with PCIIO:
by Andrew Fish
Status = gBS->InstallMultipleProtocolInterfaces (
&Instance->Handle,
&gEfiBlockIoProtocolGuid, &Instance->BlockIoProtocol,
&gEfiDevicePathProtocolGuid, Instance->DevPath,
NULL
);
if (EFI_ERROR(Status)) {
Print(L"\nFailedInstalling multiple protocols");
FreePool(Instance);
return Status;
}
Print(L"\nAfter Installing multiple protocols");
return Status;
Error:
gBS->CloseProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
gBS->CloseProtocol (
ControllerHandle,
&gEfiPciIoProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
if (Instance->DevPath != NULL) {
FreePool (Instance->DevPath);
}
FreePool (Instance);
return Status;
}
Regards
Vijai Kumar K
+918095863361
Ext:699
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel