ArmPlatformPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the ArmPlatformPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Andrew Fish <afish@apple.com>
This commit is contained in:
committed by
mergify[bot]
parent
429309e0c6
commit
40b0b23ed3
@ -34,7 +34,7 @@ VideoCopyNoHorizontalOverlap (
|
||||
IN UINTN DestinationY,
|
||||
IN UINTN Width,
|
||||
IN UINTN Height
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN SourceLine;
|
||||
@ -47,7 +47,7 @@ VideoCopyNoHorizontalOverlap (
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
if( DestinationY <= SourceY ) {
|
||||
if ( DestinationY <= SourceY ) {
|
||||
// scrolling up (or horizontally but without overlap)
|
||||
SourceLine = SourceY;
|
||||
DestinationLine = DestinationY;
|
||||
@ -60,23 +60,23 @@ VideoCopyNoHorizontalOverlap (
|
||||
}
|
||||
|
||||
switch (BitsPerPixel) {
|
||||
|
||||
case LcdBitsPerPixel_24:
|
||||
|
||||
WidthInBytes = Width * 4;
|
||||
|
||||
for( LineCount = 0; LineCount < Height; LineCount++ ) {
|
||||
for ( LineCount = 0; LineCount < Height; LineCount++ ) {
|
||||
// Update the start addresses of source & destination using 32bit pointer arithmetic
|
||||
SourceAddr = (VOID *)((UINT32 *)FrameBufferBase + SourceLine * HorizontalResolution + SourceX );
|
||||
SourceAddr = (VOID *)((UINT32 *)FrameBufferBase + SourceLine * HorizontalResolution + SourceX);
|
||||
DestinationAddr = (VOID *)((UINT32 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationX);
|
||||
|
||||
// Copy the entire line Y from video ram to the temp buffer
|
||||
CopyMem( DestinationAddr, SourceAddr, WidthInBytes);
|
||||
CopyMem (DestinationAddr, SourceAddr, WidthInBytes);
|
||||
|
||||
// Update the line numbers
|
||||
SourceLine += Step;
|
||||
DestinationLine += Step;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_16_555:
|
||||
@ -85,18 +85,19 @@ VideoCopyNoHorizontalOverlap (
|
||||
|
||||
WidthInBytes = Width * 2;
|
||||
|
||||
for( LineCount = 0; LineCount < Height; LineCount++ ) {
|
||||
for ( LineCount = 0; LineCount < Height; LineCount++ ) {
|
||||
// Update the start addresses of source & destination using 16bit pointer arithmetic
|
||||
SourceAddr = (VOID *)((UINT16 *)FrameBufferBase + SourceLine * HorizontalResolution + SourceX );
|
||||
SourceAddr = (VOID *)((UINT16 *)FrameBufferBase + SourceLine * HorizontalResolution + SourceX);
|
||||
DestinationAddr = (VOID *)((UINT16 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationX);
|
||||
|
||||
// Copy the entire line Y from video ram to the temp buffer
|
||||
CopyMem( DestinationAddr, SourceAddr, WidthInBytes);
|
||||
CopyMem (DestinationAddr, SourceAddr, WidthInBytes);
|
||||
|
||||
// Update the line numbers
|
||||
SourceLine += Step;
|
||||
DestinationLine += Step;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_8:
|
||||
@ -105,14 +106,13 @@ VideoCopyNoHorizontalOverlap (
|
||||
case LcdBitsPerPixel_1:
|
||||
default:
|
||||
// Can't handle this case
|
||||
DEBUG((DEBUG_ERROR, "ArmVeGraphics_Blt: EfiBltVideoToVideo: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
|
||||
DEBUG ((DEBUG_ERROR, "ArmVeGraphics_Blt: EfiBltVideoToVideo: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto EXIT;
|
||||
// break;
|
||||
|
||||
}
|
||||
|
||||
EXIT:
|
||||
EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ VideoCopyHorizontalOverlap (
|
||||
IN UINTN DestinationY,
|
||||
IN UINTN Width,
|
||||
IN UINTN Height
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
@ -148,11 +148,10 @@ VideoCopyHorizontalOverlap (
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
switch (BitsPerPixel) {
|
||||
|
||||
case LcdBitsPerPixel_24:
|
||||
// Allocate a temporary buffer
|
||||
|
||||
PixelBuffer32bit = (UINT32 *) AllocatePool((Height * Width) * sizeof(UINT32));
|
||||
PixelBuffer32bit = (UINT32 *)AllocatePool ((Height * Width) * sizeof (UINT32));
|
||||
|
||||
if (PixelBuffer32bit == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -170,7 +169,7 @@ VideoCopyHorizontalOverlap (
|
||||
SourcePixel32bit = (UINT32 *)FrameBufferBase + SourcePixelY * HorizontalResolution + SourceX;
|
||||
|
||||
// Copy the entire line Y from video ram to the temp buffer
|
||||
CopyMem( (VOID *)DestinationPixel32bit, (CONST VOID *)SourcePixel32bit, SizeIn32Bits);
|
||||
CopyMem ((VOID *)DestinationPixel32bit, (CONST VOID *)SourcePixel32bit, SizeIn32Bits);
|
||||
}
|
||||
|
||||
// Copy from the temp buffer to the video ram (destination region)
|
||||
@ -182,20 +181,19 @@ VideoCopyHorizontalOverlap (
|
||||
DestinationPixel32bit = (UINT32 *)FrameBufferBase + DestinationPixelY * HorizontalResolution + DestinationX;
|
||||
|
||||
// Copy the entire line Y from the temp buffer to video ram
|
||||
CopyMem( (VOID *)DestinationPixel32bit, (CONST VOID *)SourcePixel32bit, SizeIn32Bits);
|
||||
CopyMem ((VOID *)DestinationPixel32bit, (CONST VOID *)SourcePixel32bit, SizeIn32Bits);
|
||||
}
|
||||
|
||||
// Free up the allocated memory
|
||||
FreePool((VOID *) PixelBuffer32bit);
|
||||
FreePool ((VOID *)PixelBuffer32bit);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case LcdBitsPerPixel_16_555:
|
||||
case LcdBitsPerPixel_16_565:
|
||||
case LcdBitsPerPixel_12_444:
|
||||
// Allocate a temporary buffer
|
||||
PixelBuffer16bit = (UINT16 *) AllocatePool((Height * Width) * sizeof(UINT16));
|
||||
PixelBuffer16bit = (UINT16 *)AllocatePool ((Height * Width) * sizeof (UINT16));
|
||||
|
||||
if (PixelBuffer16bit == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -214,7 +212,7 @@ VideoCopyHorizontalOverlap (
|
||||
SourcePixel16bit = (UINT16 *)FrameBufferBase + SourcePixelY * HorizontalResolution + SourceX;
|
||||
|
||||
// Copy the entire line Y from Video to the temp buffer
|
||||
CopyMem( (VOID *)DestinationPixel16bit, (CONST VOID *)SourcePixel16bit, SizeIn16Bits);
|
||||
CopyMem ((VOID *)DestinationPixel16bit, (CONST VOID *)SourcePixel16bit, SizeIn16Bits);
|
||||
}
|
||||
|
||||
// Copy from the temp buffer into the destination area of the Video Memory
|
||||
@ -227,26 +225,24 @@ VideoCopyHorizontalOverlap (
|
||||
DestinationPixel16bit = (UINT16 *)FrameBufferBase + (DestinationPixelY * HorizontalResolution + DestinationX);
|
||||
|
||||
// Copy the entire line Y from the temp buffer to Video
|
||||
CopyMem( (VOID *)DestinationPixel16bit, (CONST VOID *)SourcePixel16bit, SizeIn16Bits);
|
||||
CopyMem ((VOID *)DestinationPixel16bit, (CONST VOID *)SourcePixel16bit, SizeIn16Bits);
|
||||
}
|
||||
|
||||
// Free the allocated memory
|
||||
FreePool((VOID *) PixelBuffer16bit);
|
||||
FreePool ((VOID *)PixelBuffer16bit);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case LcdBitsPerPixel_8:
|
||||
case LcdBitsPerPixel_4:
|
||||
case LcdBitsPerPixel_2:
|
||||
case LcdBitsPerPixel_1:
|
||||
default:
|
||||
// Can't handle this case
|
||||
DEBUG((DEBUG_ERROR, "ArmVeGraphics_Blt: EfiBltVideoToVideo: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
|
||||
DEBUG ((DEBUG_ERROR, "ArmVeGraphics_Blt: EfiBltVideoToVideo: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto EXIT;
|
||||
// break;
|
||||
|
||||
}
|
||||
|
||||
EXIT:
|
||||
@ -267,7 +263,7 @@ BltVideoFill (
|
||||
IN UINTN Delta OPTIONAL // Number of BYTES in a row of the BltBuffer
|
||||
)
|
||||
{
|
||||
EFI_PIXEL_BITMASK* PixelInformation;
|
||||
EFI_PIXEL_BITMASK *PixelInformation;
|
||||
EFI_STATUS Status;
|
||||
UINT32 HorizontalResolution;
|
||||
LCD_BPP BitsPerPixel;
|
||||
@ -284,7 +280,7 @@ BltVideoFill (
|
||||
FrameBufferBase = (UINTN *)((UINTN)(This->Mode->FrameBufferBase));
|
||||
HorizontalResolution = This->Mode->Info->HorizontalResolution;
|
||||
|
||||
LcdPlatformGetBpp (This->Mode->Mode,&BitsPerPixel);
|
||||
LcdPlatformGetBpp (This->Mode->Mode, &BitsPerPixel);
|
||||
|
||||
switch (BitsPerPixel) {
|
||||
case LcdBitsPerPixel_24:
|
||||
@ -301,15 +297,16 @@ BltVideoFill (
|
||||
// Fill the entire line
|
||||
SetMem32 (DestinationAddr, WidthInBytes, *((UINT32 *)EfiSourcePixel));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_16_555:
|
||||
// Convert the EFI pixel at the start of the BltBuffer(0,0) into a video display pixel
|
||||
Pixel16bit = (UINT16) (
|
||||
( (EfiSourcePixel->Red << 7) & PixelInformation->RedMask )
|
||||
| ( (EfiSourcePixel->Green << 2) & PixelInformation->GreenMask )
|
||||
| ( (EfiSourcePixel->Blue >> 3) & PixelInformation->BlueMask )
|
||||
// | ( 0 & PixelInformation->ReservedMask )
|
||||
Pixel16bit = (UINT16)(
|
||||
((EfiSourcePixel->Red << 7) & PixelInformation->RedMask)
|
||||
| ((EfiSourcePixel->Green << 2) & PixelInformation->GreenMask)
|
||||
| ((EfiSourcePixel->Blue >> 3) & PixelInformation->BlueMask)
|
||||
// | ( 0 & PixelInformation->ReservedMask )
|
||||
);
|
||||
|
||||
// Copy the SourcePixel into every pixel inside the target rectangle
|
||||
@ -328,14 +325,15 @@ BltVideoFill (
|
||||
*DestinationPixel16bit = Pixel16bit;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_16_565:
|
||||
// Convert the EFI pixel at the start of the BltBuffer(0,0) into a video display pixel
|
||||
Pixel16bit = (UINT16) (
|
||||
( (EfiSourcePixel->Red << 8) & PixelInformation->RedMask )
|
||||
| ( (EfiSourcePixel->Green << 3) & PixelInformation->GreenMask )
|
||||
| ( (EfiSourcePixel->Blue >> 3) & PixelInformation->BlueMask )
|
||||
Pixel16bit = (UINT16)(
|
||||
((EfiSourcePixel->Red << 8) & PixelInformation->RedMask)
|
||||
| ((EfiSourcePixel->Green << 3) & PixelInformation->GreenMask)
|
||||
| ((EfiSourcePixel->Blue >> 3) & PixelInformation->BlueMask)
|
||||
);
|
||||
|
||||
// Copy the SourcePixel into every pixel inside the target rectangle
|
||||
@ -354,14 +352,15 @@ BltVideoFill (
|
||||
*DestinationPixel16bit = Pixel16bit;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_12_444:
|
||||
// Convert the EFI pixel at the start of the BltBuffer(0,0) into a video display pixel
|
||||
Pixel16bit = (UINT16) (
|
||||
( (EfiSourcePixel->Red >> 4) & PixelInformation->RedMask )
|
||||
| ( (EfiSourcePixel->Green ) & PixelInformation->GreenMask )
|
||||
| ( (EfiSourcePixel->Blue << 4) & PixelInformation->BlueMask )
|
||||
Pixel16bit = (UINT16)(
|
||||
((EfiSourcePixel->Red >> 4) & PixelInformation->RedMask)
|
||||
| ((EfiSourcePixel->Green) & PixelInformation->GreenMask)
|
||||
| ((EfiSourcePixel->Blue << 4) & PixelInformation->BlueMask)
|
||||
);
|
||||
|
||||
// Copy the SourcePixel into every pixel inside the target rectangle
|
||||
@ -380,6 +379,7 @@ BltVideoFill (
|
||||
*DestinationPixel16bit = Pixel16bit;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_8:
|
||||
@ -388,7 +388,7 @@ BltVideoFill (
|
||||
case LcdBitsPerPixel_1:
|
||||
default:
|
||||
// Can't handle this case
|
||||
DEBUG((DEBUG_ERROR, "LcdGraphicsBlt: EfiBltVideoFill: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
|
||||
DEBUG ((DEBUG_ERROR, "LcdGraphicsBlt: EfiBltVideoFill: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
@ -432,15 +432,15 @@ BltVideoToBltBuffer (
|
||||
HorizontalResolution = This->Mode->Info->HorizontalResolution;
|
||||
FrameBufferBase = (UINTN *)((UINTN)(This->Mode->FrameBufferBase));
|
||||
|
||||
if(( Delta != 0 ) && ( Delta != Width * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL))) {
|
||||
if ((Delta != 0) && (Delta != Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))) {
|
||||
// Delta is not zero and it is different from the width.
|
||||
// Divide it by the size of a pixel to find out the buffer's horizontal resolution.
|
||||
BltBufferHorizontalResolution = (UINT32) (Delta / sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
||||
BltBufferHorizontalResolution = (UINT32)(Delta / sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
||||
} else {
|
||||
BltBufferHorizontalResolution = Width;
|
||||
}
|
||||
|
||||
LcdPlatformGetBpp (This->Mode->Mode,&BitsPerPixel);
|
||||
LcdPlatformGetBpp (This->Mode->Mode, &BitsPerPixel);
|
||||
|
||||
switch (BitsPerPixel) {
|
||||
case LcdBitsPerPixel_24:
|
||||
@ -452,12 +452,13 @@ BltVideoToBltBuffer (
|
||||
SourceLine++, DestinationLine++)
|
||||
{
|
||||
// Calculate the source and target addresses using 32bit pointer arithmetic:
|
||||
SourceAddr = (VOID *)((UINT32 *)FrameBufferBase + SourceLine * HorizontalResolution + SourceX );
|
||||
SourceAddr = (VOID *)((UINT32 *)FrameBufferBase + SourceLine * HorizontalResolution + SourceX);
|
||||
DestinationAddr = (VOID *)((UINT32 *)BltBuffer + DestinationLine * BltBufferHorizontalResolution + DestinationX);
|
||||
|
||||
// Copy the entire line
|
||||
CopyMem( DestinationAddr, SourceAddr, WidthInBytes);
|
||||
CopyMem (DestinationAddr, SourceAddr, WidthInBytes);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_16_555:
|
||||
@ -479,12 +480,13 @@ BltVideoToBltBuffer (
|
||||
Pixel16bit = *SourcePixel16bit;
|
||||
|
||||
// Copy the pixel into the new target
|
||||
EfiDestinationPixel->Red = (UINT8) ( (Pixel16bit & PixelInformation->RedMask ) >> 7 );
|
||||
EfiDestinationPixel->Green = (UINT8) ( (Pixel16bit & PixelInformation->GreenMask ) >> 2);
|
||||
EfiDestinationPixel->Blue = (UINT8) ( (Pixel16bit & PixelInformation->BlueMask ) << 3 );
|
||||
EfiDestinationPixel->Red = (UINT8)((Pixel16bit & PixelInformation->RedMask) >> 7);
|
||||
EfiDestinationPixel->Green = (UINT8)((Pixel16bit & PixelInformation->GreenMask) >> 2);
|
||||
EfiDestinationPixel->Blue = (UINT8)((Pixel16bit & PixelInformation->BlueMask) << 3);
|
||||
// EfiDestinationPixel->Reserved = (UINT8) 0;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_16_565:
|
||||
@ -507,12 +509,13 @@ BltVideoToBltBuffer (
|
||||
|
||||
// Copy the pixel into the new target
|
||||
// There is no info for the Reserved byte, so we set it to zero
|
||||
EfiDestinationPixel->Red = (UINT8) ( (Pixel16bit & PixelInformation->RedMask ) >> 8 );
|
||||
EfiDestinationPixel->Green = (UINT8) ( (Pixel16bit & PixelInformation->GreenMask ) >> 3);
|
||||
EfiDestinationPixel->Blue = (UINT8) ( (Pixel16bit & PixelInformation->BlueMask ) << 3 );
|
||||
EfiDestinationPixel->Red = (UINT8)((Pixel16bit & PixelInformation->RedMask) >> 8);
|
||||
EfiDestinationPixel->Green = (UINT8)((Pixel16bit & PixelInformation->GreenMask) >> 3);
|
||||
EfiDestinationPixel->Blue = (UINT8)((Pixel16bit & PixelInformation->BlueMask) << 3);
|
||||
// EfiDestinationPixel->Reserved = (UINT8) 0;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_12_444:
|
||||
@ -534,12 +537,13 @@ BltVideoToBltBuffer (
|
||||
Pixel16bit = *SourcePixel16bit;
|
||||
|
||||
// Copy the pixel into the new target
|
||||
EfiDestinationPixel->Red = (UINT8) ( (Pixel16bit & PixelInformation->RedMask ) >> 4 );
|
||||
EfiDestinationPixel->Green = (UINT8) ( (Pixel16bit & PixelInformation->GreenMask ) );
|
||||
EfiDestinationPixel->Blue = (UINT8) ( (Pixel16bit & PixelInformation->BlueMask ) << 4 );
|
||||
EfiDestinationPixel->Red = (UINT8)((Pixel16bit & PixelInformation->RedMask) >> 4);
|
||||
EfiDestinationPixel->Green = (UINT8)((Pixel16bit & PixelInformation->GreenMask));
|
||||
EfiDestinationPixel->Blue = (UINT8)((Pixel16bit & PixelInformation->BlueMask) << 4);
|
||||
// EfiDestinationPixel->Reserved = (UINT8) 0;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_8:
|
||||
@ -548,10 +552,11 @@ BltVideoToBltBuffer (
|
||||
case LcdBitsPerPixel_1:
|
||||
default:
|
||||
// Can't handle this case
|
||||
DEBUG((DEBUG_ERROR, "LcdGraphicsBlt: EfiBltVideoToBltBuffer: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
|
||||
DEBUG ((DEBUG_ERROR, "LcdGraphicsBlt: EfiBltVideoToBltBuffer: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -590,15 +595,15 @@ BltBufferToVideo (
|
||||
HorizontalResolution = This->Mode->Info->HorizontalResolution;
|
||||
FrameBufferBase = (UINTN *)((UINTN)(This->Mode->FrameBufferBase));
|
||||
|
||||
if(( Delta != 0 ) && ( Delta != Width * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL))) {
|
||||
if ((Delta != 0) && (Delta != Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))) {
|
||||
// Delta is not zero and it is different from the width.
|
||||
// Divide it by the size of a pixel to find out the buffer's horizontal resolution.
|
||||
BltBufferHorizontalResolution = (UINT32) (Delta / sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
||||
BltBufferHorizontalResolution = (UINT32)(Delta / sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
|
||||
} else {
|
||||
BltBufferHorizontalResolution = Width;
|
||||
}
|
||||
|
||||
LcdPlatformGetBpp (This->Mode->Mode,&BitsPerPixel);
|
||||
LcdPlatformGetBpp (This->Mode->Mode, &BitsPerPixel);
|
||||
|
||||
switch (BitsPerPixel) {
|
||||
case LcdBitsPerPixel_24:
|
||||
@ -610,20 +615,21 @@ BltBufferToVideo (
|
||||
SourceLine++, DestinationLine++)
|
||||
{
|
||||
// Calculate the source and target addresses using 32bit pointer arithmetic:
|
||||
SourceAddr = (VOID *)((UINT32 *)BltBuffer + SourceLine * BltBufferHorizontalResolution + SourceX );
|
||||
SourceAddr = (VOID *)((UINT32 *)BltBuffer + SourceLine * BltBufferHorizontalResolution + SourceX);
|
||||
DestinationAddr = (VOID *)((UINT32 *)FrameBufferBase + DestinationLine * HorizontalResolution + DestinationX);
|
||||
|
||||
// Copy the entire row Y
|
||||
CopyMem( DestinationAddr, SourceAddr, WidthInBytes);
|
||||
CopyMem (DestinationAddr, SourceAddr, WidthInBytes);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_16_555:
|
||||
// Access each pixel inside the BltBuffer Memory
|
||||
for (SourceLine = SourceY, DestinationLine = DestinationY;
|
||||
SourceLine < SourceY + Height;
|
||||
SourceLine++, DestinationLine++) {
|
||||
|
||||
SourceLine++, DestinationLine++)
|
||||
{
|
||||
for (SourcePixelX = SourceX, DestinationPixelX = DestinationX;
|
||||
SourcePixelX < SourceX + Width;
|
||||
SourcePixelX++, DestinationPixelX++)
|
||||
@ -635,22 +641,23 @@ BltBufferToVideo (
|
||||
// Copy the pixel into the new target
|
||||
// Only the most significant bits will be copied across:
|
||||
// To convert from 8 bits to 5 bits per pixel we throw away the 3 least significant bits
|
||||
*DestinationPixel16bit = (UINT16) (
|
||||
( (EfiSourcePixel->Red << 7) & PixelInformation->RedMask )
|
||||
| ( (EfiSourcePixel->Green << 2) & PixelInformation->GreenMask )
|
||||
| ( (EfiSourcePixel->Blue >> 3) & PixelInformation->BlueMask )
|
||||
*DestinationPixel16bit = (UINT16)(
|
||||
((EfiSourcePixel->Red << 7) & PixelInformation->RedMask)
|
||||
| ((EfiSourcePixel->Green << 2) & PixelInformation->GreenMask)
|
||||
| ((EfiSourcePixel->Blue >> 3) & PixelInformation->BlueMask)
|
||||
// | ( 0 & PixelInformation->ReservedMask )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_16_565:
|
||||
// Access each pixel inside the BltBuffer Memory
|
||||
for (SourceLine = SourceY, DestinationLine = DestinationY;
|
||||
SourceLine < SourceY + Height;
|
||||
SourceLine++, DestinationLine++) {
|
||||
|
||||
SourceLine++, DestinationLine++)
|
||||
{
|
||||
for (SourcePixelX = SourceX, DestinationPixelX = DestinationX;
|
||||
SourcePixelX < SourceX + Width;
|
||||
SourcePixelX++, DestinationPixelX++)
|
||||
@ -663,21 +670,22 @@ BltBufferToVideo (
|
||||
// Only the most significant bits will be copied across:
|
||||
// To convert from 8 bits to 5 or 6 bits per pixel we throw away the 3 or 2 least significant bits
|
||||
// There is no room for the Reserved byte so we ignore that completely
|
||||
*DestinationPixel16bit = (UINT16) (
|
||||
( (EfiSourcePixel->Red << 8) & PixelInformation->RedMask )
|
||||
| ( (EfiSourcePixel->Green << 3) & PixelInformation->GreenMask )
|
||||
| ( (EfiSourcePixel->Blue >> 3) & PixelInformation->BlueMask )
|
||||
*DestinationPixel16bit = (UINT16)(
|
||||
((EfiSourcePixel->Red << 8) & PixelInformation->RedMask)
|
||||
| ((EfiSourcePixel->Green << 3) & PixelInformation->GreenMask)
|
||||
| ((EfiSourcePixel->Blue >> 3) & PixelInformation->BlueMask)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_12_444:
|
||||
// Access each pixel inside the BltBuffer Memory
|
||||
for (SourceLine = SourceY, DestinationLine = DestinationY;
|
||||
SourceLine < SourceY + Height;
|
||||
SourceLine++, DestinationLine++) {
|
||||
|
||||
SourceLine++, DestinationLine++)
|
||||
{
|
||||
for (SourcePixelX = SourceX, DestinationPixelX = DestinationX;
|
||||
SourcePixelX < SourceX + Width;
|
||||
SourcePixelX++, DestinationPixelX++)
|
||||
@ -689,14 +697,15 @@ BltBufferToVideo (
|
||||
// Copy the pixel into the new target
|
||||
// Only the most significant bits will be copied across:
|
||||
// To convert from 8 bits to 5 bits per pixel we throw away the 3 least significant bits
|
||||
*DestinationPixel16bit = (UINT16) (
|
||||
( (EfiSourcePixel->Red << 4) & PixelInformation->RedMask )
|
||||
| ( (EfiSourcePixel->Green ) & PixelInformation->GreenMask )
|
||||
| ( (EfiSourcePixel->Blue >> 4) & PixelInformation->BlueMask )
|
||||
*DestinationPixel16bit = (UINT16)(
|
||||
((EfiSourcePixel->Red << 4) & PixelInformation->RedMask)
|
||||
| ((EfiSourcePixel->Green) & PixelInformation->GreenMask)
|
||||
| ((EfiSourcePixel->Blue >> 4) & PixelInformation->BlueMask)
|
||||
// | ( 0 & PixelInformation->ReservedMask )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case LcdBitsPerPixel_8:
|
||||
@ -705,10 +714,11 @@ BltBufferToVideo (
|
||||
case LcdBitsPerPixel_1:
|
||||
default:
|
||||
// Can't handle this case
|
||||
DEBUG((DEBUG_ERROR, "LcdGraphicsBlt: EfiBltBufferToVideo: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
|
||||
DEBUG ((DEBUG_ERROR, "LcdGraphicsBlt: EfiBltBufferToVideo: INVALID Number of Bits Per Pixel: %d\n", BitsPerPixel));
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -740,27 +750,27 @@ BltVideoToVideo (
|
||||
// Source is the Video Memory,
|
||||
// Destination is the Video Memory
|
||||
|
||||
LcdPlatformGetBpp (This->Mode->Mode,&BitsPerPixel);
|
||||
LcdPlatformGetBpp (This->Mode->Mode, &BitsPerPixel);
|
||||
FrameBufferBase = (UINTN *)((UINTN)(This->Mode->FrameBufferBase));
|
||||
|
||||
// The UEFI spec currently states:
|
||||
// "There is no limitation on the overlapping of the source and destination rectangles"
|
||||
// Therefore, we must be careful to avoid overwriting the source data
|
||||
if( SourceY == DestinationY ) {
|
||||
if ( SourceY == DestinationY ) {
|
||||
// Copying within the same height, e.g. horizontal shift
|
||||
if( SourceX == DestinationX ) {
|
||||
if ( SourceX == DestinationX ) {
|
||||
// Nothing to do
|
||||
Status = EFI_SUCCESS;
|
||||
} else if( ((SourceX>DestinationX)?(SourceX - DestinationX):(DestinationX - SourceX)) < Width ) {
|
||||
} else if (((SourceX > DestinationX) ? (SourceX - DestinationX) : (DestinationX - SourceX)) < Width ) {
|
||||
// There is overlap
|
||||
Status = VideoCopyHorizontalOverlap (BitsPerPixel, FrameBufferBase, HorizontalResolution, SourceX, SourceY, DestinationX, DestinationY, Width, Height );
|
||||
Status = VideoCopyHorizontalOverlap (BitsPerPixel, FrameBufferBase, HorizontalResolution, SourceX, SourceY, DestinationX, DestinationY, Width, Height);
|
||||
} else {
|
||||
// No overlap
|
||||
Status = VideoCopyNoHorizontalOverlap (BitsPerPixel, FrameBufferBase, HorizontalResolution, SourceX, SourceY, DestinationX, DestinationY, Width, Height );
|
||||
Status = VideoCopyNoHorizontalOverlap (BitsPerPixel, FrameBufferBase, HorizontalResolution, SourceX, SourceY, DestinationX, DestinationY, Width, Height);
|
||||
}
|
||||
} else {
|
||||
// Copying from different heights
|
||||
Status = VideoCopyNoHorizontalOverlap (BitsPerPixel, FrameBufferBase, HorizontalResolution, SourceX, SourceY, DestinationX, DestinationY, Width, Height );
|
||||
Status = VideoCopyNoHorizontalOverlap (BitsPerPixel, FrameBufferBase, HorizontalResolution, SourceX, SourceY, DestinationX, DestinationY, Width, Height);
|
||||
}
|
||||
|
||||
return Status;
|
||||
@ -790,14 +800,14 @@ LcdGraphicsBlt (
|
||||
EFI_STATUS Status;
|
||||
UINT32 HorizontalResolution;
|
||||
UINT32 VerticalResolution;
|
||||
LCD_INSTANCE* Instance;
|
||||
LCD_INSTANCE *Instance;
|
||||
|
||||
Instance = LCD_INSTANCE_FROM_GOP_THIS(This);
|
||||
Instance = LCD_INSTANCE_FROM_GOP_THIS (This);
|
||||
|
||||
// Setup the hardware if not already done
|
||||
if (!mDisplayInitialized) {
|
||||
Status = InitializeDisplay (Instance);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto EXIT;
|
||||
}
|
||||
}
|
||||
@ -805,18 +815,27 @@ LcdGraphicsBlt (
|
||||
HorizontalResolution = This->Mode->Info->HorizontalResolution;
|
||||
VerticalResolution = This->Mode->Info->VerticalResolution;
|
||||
|
||||
DEBUG((DEBUG_INFO, "LcdGraphicsBlt (BltOperation:%d,DestX:%d,DestY:%d,Width:%d,Height:%d) res(%d,%d)\n",
|
||||
BltOperation,DestinationX,DestinationY,Width,Height,HorizontalResolution,VerticalResolution));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"LcdGraphicsBlt (BltOperation:%d,DestX:%d,DestY:%d,Width:%d,Height:%d) res(%d,%d)\n",
|
||||
BltOperation,
|
||||
DestinationX,
|
||||
DestinationY,
|
||||
Width,
|
||||
Height,
|
||||
HorizontalResolution,
|
||||
VerticalResolution
|
||||
));
|
||||
|
||||
// Check we have reasonable parameters
|
||||
if (Width == 0 || Height == 0) {
|
||||
DEBUG((DEBUG_ERROR, "LcdGraphicsBlt: ERROR - Invalid dimension: Zero size area.\n" ));
|
||||
if ((Width == 0) || (Height == 0)) {
|
||||
DEBUG ((DEBUG_ERROR, "LcdGraphicsBlt: ERROR - Invalid dimension: Zero size area.\n"));
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
if ((BltOperation == EfiBltVideoFill) || (BltOperation == EfiBltBufferToVideo) || (BltOperation == EfiBltVideoToBltBuffer)) {
|
||||
ASSERT( BltBuffer != NULL);
|
||||
ASSERT (BltBuffer != NULL);
|
||||
}
|
||||
|
||||
/*if ((DestinationX >= HorizontalResolution) || (DestinationY >= VerticalResolution)) {
|
||||
@ -828,9 +847,9 @@ LcdGraphicsBlt (
|
||||
// If we are reading data out of the video buffer, check that the source area is within the display limits
|
||||
if ((BltOperation == EfiBltVideoToBltBuffer) || (BltOperation == EfiBltVideoToVideo)) {
|
||||
if ((SourceY + Height > VerticalResolution) || (SourceX + Width > HorizontalResolution)) {
|
||||
DEBUG((DEBUG_INFO, "LcdGraphicsBlt: ERROR - Invalid source resolution.\n" ));
|
||||
DEBUG((DEBUG_INFO, " - SourceY=%d + Height=%d > VerticalResolution=%d.\n", SourceY, Height, VerticalResolution ));
|
||||
DEBUG((DEBUG_INFO, " - SourceX=%d + Width=%d > HorizontalResolution=%d.\n", SourceX, Width, HorizontalResolution ));
|
||||
DEBUG ((DEBUG_INFO, "LcdGraphicsBlt: ERROR - Invalid source resolution.\n"));
|
||||
DEBUG ((DEBUG_INFO, " - SourceY=%d + Height=%d > VerticalResolution=%d.\n", SourceY, Height, VerticalResolution));
|
||||
DEBUG ((DEBUG_INFO, " - SourceX=%d + Width=%d > HorizontalResolution=%d.\n", SourceX, Width, HorizontalResolution));
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto EXIT;
|
||||
}
|
||||
@ -839,9 +858,9 @@ LcdGraphicsBlt (
|
||||
// If we are writing data into the video buffer, that the destination area is within the display limits
|
||||
if ((BltOperation == EfiBltVideoFill) || (BltOperation == EfiBltBufferToVideo) || (BltOperation == EfiBltVideoToVideo)) {
|
||||
if ((DestinationY + Height > VerticalResolution) || (DestinationX + Width > HorizontalResolution)) {
|
||||
DEBUG((DEBUG_INFO, "LcdGraphicsBlt: ERROR - Invalid destination resolution.\n" ));
|
||||
DEBUG((DEBUG_INFO, " - DestinationY=%d + Height=%d > VerticalResolution=%d.\n", DestinationY, Height, VerticalResolution ));
|
||||
DEBUG((DEBUG_INFO, " - DestinationX=%d + Width=%d > HorizontalResolution=%d.\n", DestinationX, Width, HorizontalResolution ));
|
||||
DEBUG ((DEBUG_INFO, "LcdGraphicsBlt: ERROR - Invalid destination resolution.\n"));
|
||||
DEBUG ((DEBUG_INFO, " - DestinationY=%d + Height=%d > VerticalResolution=%d.\n", DestinationY, Height, VerticalResolution));
|
||||
DEBUG ((DEBUG_INFO, " - DestinationX=%d + Width=%d > HorizontalResolution=%d.\n", DestinationX, Width, HorizontalResolution));
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto EXIT;
|
||||
}
|
||||
@ -870,7 +889,7 @@ LcdGraphicsBlt (
|
||||
|
||||
case EfiGraphicsOutputBltOperationMax:
|
||||
default:
|
||||
DEBUG((DEBUG_ERROR, "LcdGraphicsBlt: Invalid Operation\n"));
|
||||
DEBUG ((DEBUG_ERROR, "LcdGraphicsBlt: Invalid Operation\n"));
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
@ -75,10 +75,10 @@ LCD_INSTANCE mLcdTemplate = {
|
||||
|
||||
EFI_STATUS
|
||||
LcdInstanceContructor (
|
||||
OUT LCD_INSTANCE** NewInstance
|
||||
OUT LCD_INSTANCE **NewInstance
|
||||
)
|
||||
{
|
||||
LCD_INSTANCE* Instance;
|
||||
LCD_INSTANCE *Instance;
|
||||
|
||||
Instance = AllocateCopyPool (sizeof (LCD_INSTANCE), &mLcdTemplate);
|
||||
if (Instance == NULL) {
|
||||
@ -99,7 +99,7 @@ LcdInstanceContructor (
|
||||
|
||||
EFI_STATUS
|
||||
InitializeDisplay (
|
||||
IN LCD_INSTANCE* Instance
|
||||
IN LCD_INSTANCE *Instance
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@ -149,7 +149,7 @@ LcdGraphicsOutputDxeInitialize (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
LCD_INSTANCE* Instance;
|
||||
LCD_INSTANCE *Instance;
|
||||
|
||||
Status = LcdIdentify ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -263,7 +263,8 @@ LcdGraphicsQueryMode (
|
||||
if ((This == NULL) ||
|
||||
(Info == NULL) ||
|
||||
(SizeOfInfo == NULL) ||
|
||||
(ModeNumber >= This->Mode->MaxMode)) {
|
||||
(ModeNumber >= This->Mode->MaxMode))
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "LcdGraphicsQueryMode: ERROR - For mode number %d : Invalid Parameter.\n", ModeNumber));
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto EXIT;
|
||||
@ -298,7 +299,7 @@ LcdGraphicsSetMode (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL FillColour;
|
||||
LCD_INSTANCE* Instance;
|
||||
LCD_INSTANCE *Instance;
|
||||
LCD_BPP Bpp;
|
||||
|
||||
Instance = LCD_INSTANCE_FROM_GOP_THIS (This);
|
||||
@ -333,6 +334,7 @@ LcdGraphicsSetMode (
|
||||
DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Couldn't get bytes per pixel, status: %r\n", Status));
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
This->Mode->FrameBufferSize = Instance->ModeInfo.VerticalResolution
|
||||
* Instance->ModeInfo.PixelsPerScanLine
|
||||
* GetBytesPerPixel (Bpp);
|
||||
|
@ -48,7 +48,7 @@ VOID
|
||||
LcdGraphicsExitBootServicesEvent (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@ -57,14 +57,14 @@ LcdGraphicsQueryMode (
|
||||
IN UINT32 ModeNumber,
|
||||
OUT UINTN *SizeOfInfo,
|
||||
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
|
||||
);
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
LcdGraphicsSetMode (
|
||||
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
|
||||
IN UINT32 ModeNumber
|
||||
);
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@ -79,7 +79,7 @@ LcdGraphicsBlt (
|
||||
IN UINTN Width,
|
||||
IN UINTN Height,
|
||||
IN UINTN Delta OPTIONAL
|
||||
);
|
||||
);
|
||||
|
||||
UINTN
|
||||
GetBytesPerPixel (
|
||||
@ -91,11 +91,11 @@ EFIAPI
|
||||
GraphicsOutputDxeInitialize (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
InitializeDisplay (
|
||||
IN LCD_INSTANCE* Instance
|
||||
);
|
||||
IN LCD_INSTANCE *Instance
|
||||
);
|
||||
|
||||
#endif /* LCD_GRAPHICS_OUTPUT_DXE_H_ */
|
||||
|
@ -41,13 +41,13 @@ NorFlashBlockIsLocked (
|
||||
SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID);
|
||||
|
||||
// Read block lock status
|
||||
LockStatus = MmioRead32 (CREATE_NOR_ADDRESS(BlockAddress, 2));
|
||||
LockStatus = MmioRead32 (CREATE_NOR_ADDRESS (BlockAddress, 2));
|
||||
|
||||
// Decode block lock status
|
||||
LockStatus = FOLD_32BIT_INTO_16BIT(LockStatus);
|
||||
LockStatus = FOLD_32BIT_INTO_16BIT (LockStatus);
|
||||
|
||||
if ((LockStatus & 0x2) != 0) {
|
||||
DEBUG((DEBUG_ERROR, "NorFlashBlockIsLocked: WARNING: Block LOCKED DOWN\n"));
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashBlockIsLocked: WARNING: Block LOCKED DOWN\n"));
|
||||
}
|
||||
|
||||
return ((LockStatus & 0x1) != 0);
|
||||
@ -77,10 +77,10 @@ NorFlashUnlockSingleBlock (
|
||||
SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID);
|
||||
|
||||
// Read block lock status
|
||||
LockStatus = MmioRead32 (CREATE_NOR_ADDRESS(BlockAddress, 2));
|
||||
LockStatus = MmioRead32 (CREATE_NOR_ADDRESS (BlockAddress, 2));
|
||||
|
||||
// Decode block lock status
|
||||
LockStatus = FOLD_32BIT_INTO_16BIT(LockStatus);
|
||||
LockStatus = FOLD_32BIT_INTO_16BIT (LockStatus);
|
||||
} while ((LockStatus & 0x1) == 1);
|
||||
} else {
|
||||
// Request a lock setup
|
||||
@ -98,7 +98,7 @@ NorFlashUnlockSingleBlock (
|
||||
// Put device back into Read Array mode
|
||||
SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_READ_ARRAY);
|
||||
|
||||
DEBUG((DEBUG_BLKIO, "UnlockSingleBlock: BlockAddress=0x%08x\n", BlockAddress));
|
||||
DEBUG ((DEBUG_BLKIO, "UnlockSingleBlock: BlockAddress=0x%08x\n", BlockAddress));
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -120,7 +120,6 @@ NorFlashUnlockSingleBlockIfNecessary (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The following function presumes that the block has already been unlocked.
|
||||
**/
|
||||
@ -136,8 +135,8 @@ NorFlashEraseSingleBlock (
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
// Request a block erase and then confirm it
|
||||
SEND_NOR_COMMAND(BlockAddress, 0, P30_CMD_BLOCK_ERASE_SETUP);
|
||||
SEND_NOR_COMMAND(BlockAddress, 0, P30_CMD_BLOCK_ERASE_CONFIRM);
|
||||
SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_BLOCK_ERASE_SETUP);
|
||||
SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_BLOCK_ERASE_CONFIRM);
|
||||
|
||||
// Wait until the status register gives us the all clear
|
||||
do {
|
||||
@ -145,27 +144,27 @@ NorFlashEraseSingleBlock (
|
||||
} while ((StatusRegister & P30_SR_BIT_WRITE) != P30_SR_BIT_WRITE);
|
||||
|
||||
if (StatusRegister & P30_SR_BIT_VPP) {
|
||||
DEBUG((DEBUG_ERROR,"EraseSingleBlock(BlockAddress=0x%08x: VPP Range Error\n", BlockAddress));
|
||||
DEBUG ((DEBUG_ERROR, "EraseSingleBlock(BlockAddress=0x%08x: VPP Range Error\n", BlockAddress));
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if ((StatusRegister & (P30_SR_BIT_ERASE | P30_SR_BIT_PROGRAM)) == (P30_SR_BIT_ERASE | P30_SR_BIT_PROGRAM)) {
|
||||
DEBUG((DEBUG_ERROR,"EraseSingleBlock(BlockAddress=0x%08x: Command Sequence Error\n", BlockAddress));
|
||||
DEBUG ((DEBUG_ERROR, "EraseSingleBlock(BlockAddress=0x%08x: Command Sequence Error\n", BlockAddress));
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (StatusRegister & P30_SR_BIT_ERASE) {
|
||||
DEBUG((DEBUG_ERROR,"EraseSingleBlock(BlockAddress=0x%08x: Block Erase Error StatusRegister:0x%X\n", BlockAddress, StatusRegister));
|
||||
DEBUG ((DEBUG_ERROR, "EraseSingleBlock(BlockAddress=0x%08x: Block Erase Error StatusRegister:0x%X\n", BlockAddress, StatusRegister));
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (StatusRegister & P30_SR_BIT_BLOCK_LOCKED) {
|
||||
// The debug level message has been reduced because a device lock might happen. In this case we just retry it ...
|
||||
DEBUG((DEBUG_INFO,"EraseSingleBlock(BlockAddress=0x%08x: Block Locked Error\n", BlockAddress));
|
||||
DEBUG ((DEBUG_INFO, "EraseSingleBlock(BlockAddress=0x%08x: Block Locked Error\n", BlockAddress));
|
||||
Status = EFI_WRITE_PROTECTED;
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
// Clear the Status Register
|
||||
SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_CLEAR_STATUS_REGISTER);
|
||||
}
|
||||
@ -189,7 +188,7 @@ NorFlashWriteSingleWord (
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
// Request a write single word command
|
||||
SEND_NOR_COMMAND(WordAddress, 0, P30_CMD_WORD_PROGRAM_SETUP);
|
||||
SEND_NOR_COMMAND (WordAddress, 0, P30_CMD_WORD_PROGRAM_SETUP);
|
||||
|
||||
// Store the word into NOR Flash;
|
||||
MmioWrite32 (WordAddress, WriteData);
|
||||
@ -201,27 +200,26 @@ NorFlashWriteSingleWord (
|
||||
// The chip is busy while the WRITE bit is not asserted
|
||||
} while ((StatusRegister & P30_SR_BIT_WRITE) != P30_SR_BIT_WRITE);
|
||||
|
||||
|
||||
// Perform a full status check:
|
||||
// Mask the relevant bits of Status Register.
|
||||
// Everything should be zero, if not, we have a problem
|
||||
|
||||
if (StatusRegister & P30_SR_BIT_VPP) {
|
||||
DEBUG((DEBUG_ERROR,"NorFlashWriteSingleWord(WordAddress:0x%X): VPP Range Error\n",WordAddress));
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleWord(WordAddress:0x%X): VPP Range Error\n", WordAddress));
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (StatusRegister & P30_SR_BIT_PROGRAM) {
|
||||
DEBUG((DEBUG_ERROR,"NorFlashWriteSingleWord(WordAddress:0x%X): Program Error\n",WordAddress));
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleWord(WordAddress:0x%X): Program Error\n", WordAddress));
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (StatusRegister & P30_SR_BIT_BLOCK_LOCKED) {
|
||||
DEBUG((DEBUG_ERROR,"NorFlashWriteSingleWord(WordAddress:0x%X): Device Protect Error\n",WordAddress));
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleWord(WordAddress:0x%X): Device Protect Error\n", WordAddress));
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
if (!EFI_ERROR (Status)) {
|
||||
// Clear the Status Register
|
||||
SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_CLEAR_STATUS_REGISTER);
|
||||
}
|
||||
@ -294,7 +292,7 @@ NorFlashWriteBuffer (
|
||||
// Check the availability of the buffer
|
||||
do {
|
||||
// Issue the Buffered Program Setup command
|
||||
SEND_NOR_COMMAND(TargetAddress, 0, P30_CMD_BUFFERED_PROGRAM_SETUP);
|
||||
SEND_NOR_COMMAND (TargetAddress, 0, P30_CMD_BUFFERED_PROGRAM_SETUP);
|
||||
|
||||
// Read back the status register bit#7 from the same address
|
||||
if (((*Data) & P30_SR_BIT_WRITE) == P30_SR_BIT_WRITE) {
|
||||
@ -303,7 +301,6 @@ NorFlashWriteBuffer (
|
||||
|
||||
// Update the loop counter
|
||||
WaitForBuffer--;
|
||||
|
||||
} while ((WaitForBuffer > 0) && (BufferAvailable == FALSE));
|
||||
|
||||
// The buffer was not available for writing
|
||||
@ -317,10 +314,10 @@ NorFlashWriteBuffer (
|
||||
|
||||
// Write the word count, which is (buffer_size_in_words - 1),
|
||||
// because word count 0 means one word.
|
||||
SEND_NOR_COMMAND(TargetAddress, 0, (BufferSizeInWords - 1));
|
||||
SEND_NOR_COMMAND (TargetAddress, 0, (BufferSizeInWords - 1));
|
||||
|
||||
// Write the data to the NOR Flash, advancing each address by 4 bytes
|
||||
for(Count=0; Count < BufferSizeInWords; Count++, Data++, Buffer++) {
|
||||
for (Count = 0; Count < BufferSizeInWords; Count++, Data++, Buffer++) {
|
||||
MmioWrite32 ((UINTN)Data, *Buffer);
|
||||
}
|
||||
|
||||
@ -333,7 +330,6 @@ NorFlashWriteBuffer (
|
||||
// The chip is busy while the WRITE bit is not asserted
|
||||
} while ((StatusRegister & P30_SR_BIT_WRITE) != P30_SR_BIT_WRITE);
|
||||
|
||||
|
||||
// Perform a full status check:
|
||||
// Mask the relevant bits of Status Register.
|
||||
// Everything should be zero, if not, we have a problem
|
||||
@ -341,21 +337,21 @@ NorFlashWriteBuffer (
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
if (StatusRegister & P30_SR_BIT_VPP) {
|
||||
DEBUG((DEBUG_ERROR,"NorFlashWriteBuffer(TargetAddress:0x%X): VPP Range Error\n", TargetAddress));
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashWriteBuffer(TargetAddress:0x%X): VPP Range Error\n", TargetAddress));
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (StatusRegister & P30_SR_BIT_PROGRAM) {
|
||||
DEBUG((DEBUG_ERROR,"NorFlashWriteBuffer(TargetAddress:0x%X): Program Error\n", TargetAddress));
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashWriteBuffer(TargetAddress:0x%X): Program Error\n", TargetAddress));
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (StatusRegister & P30_SR_BIT_BLOCK_LOCKED) {
|
||||
DEBUG((DEBUG_ERROR,"NorFlashWriteBuffer(TargetAddress:0x%X): Device Protect Error\n",TargetAddress));
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashWriteBuffer(TargetAddress:0x%X): Device Protect Error\n", TargetAddress));
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
if (!EFI_ERROR (Status)) {
|
||||
// Clear the Status Register
|
||||
SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_CLEAR_STATUS_REGISTER);
|
||||
}
|
||||
@ -389,29 +385,29 @@ NorFlashWriteBlocks (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if(Instance->Media.ReadOnly == TRUE) {
|
||||
if (Instance->Media.ReadOnly == TRUE) {
|
||||
return EFI_WRITE_PROTECTED;
|
||||
}
|
||||
|
||||
// We must have some bytes to read
|
||||
DEBUG((DEBUG_BLKIO, "NorFlashWriteBlocks: BufferSizeInBytes=0x%x\n", BufferSizeInBytes));
|
||||
if(BufferSizeInBytes == 0) {
|
||||
DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BufferSizeInBytes=0x%x\n", BufferSizeInBytes));
|
||||
if (BufferSizeInBytes == 0) {
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
// The size of the buffer must be a multiple of the block size
|
||||
DEBUG((DEBUG_BLKIO, "NorFlashWriteBlocks: BlockSize in bytes =0x%x\n", Instance->Media.BlockSize));
|
||||
DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BlockSize in bytes =0x%x\n", Instance->Media.BlockSize));
|
||||
if ((BufferSizeInBytes % Instance->Media.BlockSize) != 0) {
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
// All blocks must be within the device
|
||||
NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize ;
|
||||
NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize;
|
||||
|
||||
DEBUG((DEBUG_BLKIO, "NorFlashWriteBlocks: NumBlocks=%d, LastBlock=%ld, Lba=%ld.\n", NumBlocks, Instance->Media.LastBlock, Lba));
|
||||
DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: NumBlocks=%d, LastBlock=%ld, Lba=%ld.\n", NumBlocks, Instance->Media.LastBlock, Lba));
|
||||
|
||||
if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) {
|
||||
DEBUG((DEBUG_ERROR, "NorFlashWriteBlocks: ERROR - Write will exceed last block.\n"));
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashWriteBlocks: ERROR - Write will exceed last block.\n"));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -422,18 +418,17 @@ NorFlashWriteBlocks (
|
||||
pWriteBuffer = (UINT32 *)Buffer;
|
||||
|
||||
CurrentBlock = Lba;
|
||||
for (BlockCount=0; BlockCount < NumBlocks; BlockCount++, CurrentBlock++, pWriteBuffer = pWriteBuffer + BlockSizeInWords) {
|
||||
|
||||
DEBUG((DEBUG_BLKIO, "NorFlashWriteBlocks: Writing block #%d\n", (UINTN)CurrentBlock));
|
||||
for (BlockCount = 0; BlockCount < NumBlocks; BlockCount++, CurrentBlock++, pWriteBuffer = pWriteBuffer + BlockSizeInWords) {
|
||||
DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: Writing block #%d\n", (UINTN)CurrentBlock));
|
||||
|
||||
Status = NorFlashWriteFullBlock (Instance, CurrentBlock, pWriteBuffer, BlockSizeInWords);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG((DEBUG_BLKIO, "NorFlashWriteBlocks: Exit Status = \"%r\".\n", Status));
|
||||
DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: Exit Status = \"%r\".\n", Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -466,7 +461,7 @@ AlignedCopyMem (
|
||||
UINT64 *Destination64;
|
||||
CONST UINT64 *Source64;
|
||||
|
||||
if (BOTH_ALIGNED(DestinationBuffer, SourceBuffer, 8) && Length >= 8) {
|
||||
if (BOTH_ALIGNED (DestinationBuffer, SourceBuffer, 8) && (Length >= 8)) {
|
||||
Destination64 = DestinationBuffer;
|
||||
Source64 = SourceBuffer;
|
||||
while (Length >= 8) {
|
||||
@ -476,7 +471,7 @@ AlignedCopyMem (
|
||||
|
||||
Destination8 = (UINT8 *)Destination64;
|
||||
Source8 = (CONST UINT8 *)Source64;
|
||||
} else if (BOTH_ALIGNED(DestinationBuffer, SourceBuffer, 4) && Length >= 4) {
|
||||
} else if (BOTH_ALIGNED (DestinationBuffer, SourceBuffer, 4) && (Length >= 4)) {
|
||||
Destination32 = DestinationBuffer;
|
||||
Source32 = SourceBuffer;
|
||||
while (Length >= 4) {
|
||||
@ -490,9 +485,11 @@ AlignedCopyMem (
|
||||
Destination8 = DestinationBuffer;
|
||||
Source8 = SourceBuffer;
|
||||
}
|
||||
|
||||
while (Length-- != 0) {
|
||||
*Destination8++ = *Source8++;
|
||||
}
|
||||
|
||||
return DestinationBuffer;
|
||||
}
|
||||
|
||||
@ -507,8 +504,14 @@ NorFlashReadBlocks (
|
||||
UINT32 NumBlocks;
|
||||
UINTN StartAddress;
|
||||
|
||||
DEBUG((DEBUG_BLKIO, "NorFlashReadBlocks: BufferSize=0x%xB BlockSize=0x%xB LastBlock=%ld, Lba=%ld.\n",
|
||||
BufferSizeInBytes, Instance->Media.BlockSize, Instance->Media.LastBlock, Lba));
|
||||
DEBUG ((
|
||||
DEBUG_BLKIO,
|
||||
"NorFlashReadBlocks: BufferSize=0x%xB BlockSize=0x%xB LastBlock=%ld, Lba=%ld.\n",
|
||||
BufferSizeInBytes,
|
||||
Instance->Media.BlockSize,
|
||||
Instance->Media.LastBlock,
|
||||
Lba
|
||||
));
|
||||
|
||||
// The buffer must be valid
|
||||
if (Buffer == NULL) {
|
||||
@ -526,15 +529,16 @@ NorFlashReadBlocks (
|
||||
}
|
||||
|
||||
// All blocks must be within the device
|
||||
NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize ;
|
||||
NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize;
|
||||
|
||||
if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) {
|
||||
DEBUG((DEBUG_ERROR, "NorFlashReadBlocks: ERROR - Read will exceed last block\n"));
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashReadBlocks: ERROR - Read will exceed last block\n"));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// Get the address to start reading from
|
||||
StartAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress,
|
||||
StartAddress = GET_NOR_BLOCK_ADDRESS (
|
||||
Instance->RegionBaseAddress,
|
||||
Lba,
|
||||
Instance->Media.BlockSize
|
||||
);
|
||||
@ -575,7 +579,8 @@ NorFlashRead (
|
||||
}
|
||||
|
||||
// Get the address to start reading from
|
||||
StartAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress,
|
||||
StartAddress = GET_NOR_BLOCK_ADDRESS (
|
||||
Instance->RegionBaseAddress,
|
||||
Lba,
|
||||
Instance->Media.BlockSize
|
||||
);
|
||||
@ -631,16 +636,17 @@ NorFlashWriteSingleBlock (
|
||||
|
||||
// The write must not span block boundaries.
|
||||
// We need to check each variable individually because adding two large values together overflows.
|
||||
if ( ( Offset >= BlockSize ) ||
|
||||
( *NumBytes > BlockSize ) ||
|
||||
( (Offset + *NumBytes) > BlockSize ) ) {
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleBlock: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", Offset, *NumBytes, BlockSize ));
|
||||
if ((Offset >= BlockSize) ||
|
||||
(*NumBytes > BlockSize) ||
|
||||
((Offset + *NumBytes) > BlockSize))
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleBlock: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", Offset, *NumBytes, BlockSize));
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
// We must have some bytes to write
|
||||
if (*NumBytes == 0) {
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleBlock: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", Offset, *NumBytes, BlockSize ));
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleBlock: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", Offset, *NumBytes, BlockSize));
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
@ -659,16 +665,19 @@ NorFlashWriteSingleBlock (
|
||||
while (BytesToWrite > 0) {
|
||||
// Read full word from NOR, splice as required. A word is the smallest
|
||||
// unit we can write.
|
||||
TempStatus = NorFlashRead (Instance, Lba, CurOffset & ~(0x3), sizeof(Tmp), &Tmp);
|
||||
TempStatus = NorFlashRead (Instance, Lba, CurOffset & ~(0x3), sizeof (Tmp), &Tmp);
|
||||
if (EFI_ERROR (TempStatus)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
// Physical address of word in NOR to write.
|
||||
WordAddr = (CurOffset & ~(0x3)) + GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress,
|
||||
Lba, BlockSize);
|
||||
WordAddr = (CurOffset & ~(0x3)) + GET_NOR_BLOCK_ADDRESS (
|
||||
Instance->RegionBaseAddress,
|
||||
Lba,
|
||||
BlockSize
|
||||
);
|
||||
// The word of data that is to be written.
|
||||
TmpBuf = *((UINT32*)(Buffer + (*NumBytes - BytesToWrite)));
|
||||
TmpBuf = *((UINT32 *)(Buffer + (*NumBytes - BytesToWrite)));
|
||||
|
||||
// First do word aligned chunks.
|
||||
if ((CurOffset & 0x3) == 0) {
|
||||
@ -681,10 +690,11 @@ NorFlashWriteSingleBlock (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Write this word to NOR
|
||||
WordToWrite = TmpBuf;
|
||||
CurOffset += sizeof(TmpBuf);
|
||||
BytesToWrite -= sizeof(TmpBuf);
|
||||
CurOffset += sizeof (TmpBuf);
|
||||
BytesToWrite -= sizeof (TmpBuf);
|
||||
} else {
|
||||
// BytesToWrite < 4. Do small writes and left-overs
|
||||
Mask = ~((~0) << (BytesToWrite * 8));
|
||||
@ -698,6 +708,7 @@ NorFlashWriteSingleBlock (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Merge old and new data. Write merged word to NOR
|
||||
WordToWrite = (Tmp & ~Mask) | TmpBuf;
|
||||
CurOffset += BytesToWrite;
|
||||
@ -717,6 +728,7 @@ NorFlashWriteSingleBlock (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Merge old and new data. Write merged word to NOR
|
||||
WordToWrite = (Tmp & ~Mask) | TmpBuf;
|
||||
BytesToWrite -= (4 - (CurOffset & 0x3));
|
||||
@ -734,6 +746,7 @@ NorFlashWriteSingleBlock (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Merge old and new data. Write merged word to NOR
|
||||
WordToWrite = (Tmp & ~Mask) | TmpBuf;
|
||||
CurOffset += BytesToWrite;
|
||||
@ -751,13 +764,16 @@ NorFlashWriteSingleBlock (
|
||||
if (EFI_ERROR (TempStatus)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
PrevBlockAddress = BlockAddress;
|
||||
}
|
||||
|
||||
TempStatus = NorFlashWriteSingleWord (Instance, WordAddr, WordToWrite);
|
||||
if (EFI_ERROR (TempStatus)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// Exit if we got here and could write all the data. Otherwise do the
|
||||
// Erase-Write cycle.
|
||||
if (!DoErase) {
|
||||
@ -779,7 +795,7 @@ NorFlashWriteSingleBlock (
|
||||
}
|
||||
|
||||
// Put the data at the appropriate location inside the buffer area
|
||||
CopyMem ((VOID*)((UINTN)Instance->ShadowBuffer + Offset), Buffer, *NumBytes);
|
||||
CopyMem ((VOID *)((UINTN)Instance->ShadowBuffer + Offset), Buffer, *NumBytes);
|
||||
|
||||
// Write the modified buffer back to the NorFlash
|
||||
TempStatus = NorFlashWriteBlocks (Instance, Lba, BlockSize, Instance->ShadowBuffer);
|
||||
@ -831,14 +847,14 @@ NorFlashDiskIoReadDisk (
|
||||
UINT32 BlockOffset;
|
||||
EFI_LBA Lba;
|
||||
|
||||
Instance = INSTANCE_FROM_DISKIO_THIS(This);
|
||||
Instance = INSTANCE_FROM_DISKIO_THIS (This);
|
||||
|
||||
if (MediaId != Instance->Media.MediaId) {
|
||||
return EFI_MEDIA_CHANGED;
|
||||
}
|
||||
|
||||
BlockSize = Instance->Media.BlockSize;
|
||||
Lba = (EFI_LBA) DivU64x32Remainder (DiskOffset, BlockSize, &BlockOffset);
|
||||
Lba = (EFI_LBA)DivU64x32Remainder (DiskOffset, BlockSize, &BlockOffset);
|
||||
|
||||
return NorFlashRead (Instance, Lba, BlockOffset, BufferSize, Buffer);
|
||||
}
|
||||
@ -879,14 +895,14 @@ NorFlashDiskIoWriteDisk (
|
||||
UINTN WriteSize;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Instance = INSTANCE_FROM_DISKIO_THIS(This);
|
||||
Instance = INSTANCE_FROM_DISKIO_THIS (This);
|
||||
|
||||
if (MediaId != Instance->Media.MediaId) {
|
||||
return EFI_MEDIA_CHANGED;
|
||||
}
|
||||
|
||||
BlockSize = Instance->Media.BlockSize;
|
||||
Lba = (EFI_LBA) DivU64x32Remainder (DiskOffset, BlockSize, &BlockOffset);
|
||||
Lba = (EFI_LBA)DivU64x32Remainder (DiskOffset, BlockSize, &BlockOffset);
|
||||
|
||||
RemainingBytes = BufferSize;
|
||||
|
||||
@ -904,12 +920,14 @@ NorFlashDiskIoWriteDisk (
|
||||
// Write a partial block
|
||||
Status = NorFlashWriteSingleBlock (Instance, Lba, BlockOffset, &WriteSize, Buffer);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
// Now continue writing either all the remaining bytes or single blocks.
|
||||
RemainingBytes -= WriteSize;
|
||||
Buffer = (UINT8 *) Buffer + WriteSize;
|
||||
Buffer = (UINT8 *)Buffer + WriteSize;
|
||||
Lba++;
|
||||
BlockOffset = 0;
|
||||
WriteSize = MIN (RemainingBytes, BlockSize);
|
||||
@ -946,26 +964,26 @@ NorFlashVirtualNotifyEvent (
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Index < mNorFlashDeviceCount; Index++) {
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->DeviceBaseAddress);
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->RegionBaseAddress);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->DeviceBaseAddress);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->RegionBaseAddress);
|
||||
|
||||
// Convert BlockIo protocol
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->BlockIoProtocol.FlushBlocks);
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->BlockIoProtocol.ReadBlocks);
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->BlockIoProtocol.Reset);
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->BlockIoProtocol.WriteBlocks);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->BlockIoProtocol.FlushBlocks);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->BlockIoProtocol.ReadBlocks);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->BlockIoProtocol.Reset);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->BlockIoProtocol.WriteBlocks);
|
||||
|
||||
// Convert Fvb
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->FvbProtocol.EraseBlocks);
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->FvbProtocol.GetAttributes);
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->FvbProtocol.GetBlockSize);
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->FvbProtocol.GetPhysicalAddress);
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->FvbProtocol.Read);
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->FvbProtocol.SetAttributes);
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->FvbProtocol.Write);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.EraseBlocks);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.GetAttributes);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.GetBlockSize);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.GetPhysicalAddress);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.Read);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.SetAttributes);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.Write);
|
||||
|
||||
if (mNorFlashInstances[Index]->ShadowBuffer != NULL) {
|
||||
EfiConvertPointer (0x0, (VOID**)&mNorFlashInstances[Index]->ShadowBuffer);
|
||||
EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->ShadowBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#ifndef __NOR_FLASH_H__
|
||||
#define __NOR_FLASH_H__
|
||||
|
||||
|
||||
#include <Base.h>
|
||||
#include <PiDxe.h>
|
||||
|
||||
@ -41,10 +40,10 @@
|
||||
|
||||
// Each command must be sent simultaneously to both chips,
|
||||
// i.e. at the lower 16 bits AND at the higher 16 bits
|
||||
#define CREATE_NOR_ADDRESS(BaseAddr,OffsetAddr) ((BaseAddr) + ((OffsetAddr) << 2))
|
||||
#define CREATE_NOR_ADDRESS(BaseAddr, OffsetAddr) ((BaseAddr) + ((OffsetAddr) << 2))
|
||||
#define CREATE_DUAL_CMD(Cmd) ( ( Cmd << 16) | ( Cmd & LOW_16_BITS) )
|
||||
#define SEND_NOR_COMMAND(BaseAddr,Offset,Cmd) MmioWrite32 (CREATE_NOR_ADDRESS(BaseAddr,Offset), CREATE_DUAL_CMD(Cmd))
|
||||
#define GET_NOR_BLOCK_ADDRESS(BaseAddr,Lba,LbaSize)( BaseAddr + (UINTN)((Lba) * LbaSize) )
|
||||
#define SEND_NOR_COMMAND(BaseAddr, Offset, Cmd) MmioWrite32 (CREATE_NOR_ADDRESS(BaseAddr,Offset), CREATE_DUAL_CMD(Cmd))
|
||||
#define GET_NOR_BLOCK_ADDRESS(BaseAddr, Lba, LbaSize) ( BaseAddr + (UINTN)((Lba) * LbaSize) )
|
||||
|
||||
// Status Register Bits
|
||||
#define P30_SR_BIT_WRITE (BIT7 << 16 | BIT7)
|
||||
@ -138,7 +137,7 @@ struct _NOR_FLASH_INSTANCE {
|
||||
EFI_DISK_IO_PROTOCOL DiskIoProtocol;
|
||||
|
||||
EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL FvbProtocol;
|
||||
VOID* ShadowBuffer;
|
||||
VOID *ShadowBuffer;
|
||||
|
||||
NOR_FLASH_DEVICE_PATH DevicePath;
|
||||
};
|
||||
@ -180,7 +179,7 @@ NorFlashBlockIoReadBlocks (
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSizeInBytes,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
);
|
||||
|
||||
//
|
||||
// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.WriteBlocks
|
||||
@ -193,7 +192,7 @@ NorFlashBlockIoWriteBlocks (
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSizeInBytes,
|
||||
IN VOID *Buffer
|
||||
);
|
||||
);
|
||||
|
||||
//
|
||||
// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.FlushBlocks
|
||||
@ -202,7 +201,7 @@ EFI_STATUS
|
||||
EFIAPI
|
||||
NorFlashBlockIoFlushBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This
|
||||
);
|
||||
);
|
||||
|
||||
//
|
||||
// DiskIO Protocol function EFI_DISK_IO_PROTOCOL.ReadDisk
|
||||
@ -236,28 +235,28 @@ NorFlashDiskIoWriteDisk (
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbGetAttributes(
|
||||
FvbGetAttributes (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
|
||||
OUT EFI_FVB_ATTRIBUTES_2 *Attributes
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbSetAttributes(
|
||||
FvbSetAttributes (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
|
||||
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbGetPhysicalAddress(
|
||||
FvbGetPhysicalAddress (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
|
||||
OUT EFI_PHYSICAL_ADDRESS *Address
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbGetBlockSize(
|
||||
FvbGetBlockSize (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
|
||||
IN EFI_LBA Lba,
|
||||
OUT UINTN *BlockSize,
|
||||
@ -266,7 +265,7 @@ FvbGetBlockSize(
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbRead(
|
||||
FvbRead (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset,
|
||||
@ -276,7 +275,7 @@ FvbRead(
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbWrite(
|
||||
FvbWrite (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN Offset,
|
||||
@ -286,7 +285,7 @@ FvbWrite(
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbEraseBlocks(
|
||||
FvbEraseBlocks (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
|
||||
...
|
||||
);
|
||||
@ -334,16 +333,15 @@ NorFlashCreateInstance (
|
||||
IN UINT32 Index,
|
||||
IN UINT32 BlockSize,
|
||||
IN BOOLEAN SupportFvb,
|
||||
OUT NOR_FLASH_INSTANCE** NorFlashInstance
|
||||
OUT NOR_FLASH_INSTANCE **NorFlashInstance
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
NorFlashFvbInitialize (
|
||||
IN NOR_FLASH_INSTANCE* Instance
|
||||
IN NOR_FLASH_INSTANCE *Instance
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// NorFlash.c
|
||||
//
|
||||
|
@ -23,7 +23,7 @@ NorFlashBlockIoReset (
|
||||
{
|
||||
NOR_FLASH_INSTANCE *Instance;
|
||||
|
||||
Instance = INSTANCE_FROM_BLKIO_THIS(This);
|
||||
Instance = INSTANCE_FROM_BLKIO_THIS (This);
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoReset(MediaId=0x%x)\n", This->Media->MediaId));
|
||||
|
||||
@ -51,7 +51,7 @@ NorFlashBlockIoReadBlocks (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Instance = INSTANCE_FROM_BLKIO_THIS(This);
|
||||
Instance = INSTANCE_FROM_BLKIO_THIS (This);
|
||||
Media = This->Media;
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoReadBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes (%d kB), BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, Buffer));
|
||||
@ -87,18 +87,18 @@ NorFlashBlockIoWriteBlocks (
|
||||
NOR_FLASH_INSTANCE *Instance;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Instance = INSTANCE_FROM_BLKIO_THIS(This);
|
||||
Instance = INSTANCE_FROM_BLKIO_THIS (This);
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoWriteBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes (%d kB), BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, Buffer));
|
||||
|
||||
if( !This->Media->MediaPresent ) {
|
||||
if ( !This->Media->MediaPresent ) {
|
||||
Status = EFI_NO_MEDIA;
|
||||
} else if( This->Media->MediaId != MediaId ) {
|
||||
} else if ( This->Media->MediaId != MediaId ) {
|
||||
Status = EFI_MEDIA_CHANGED;
|
||||
} else if( This->Media->ReadOnly ) {
|
||||
} else if ( This->Media->ReadOnly ) {
|
||||
Status = EFI_WRITE_PROTECTED;
|
||||
} else {
|
||||
Status = NorFlashWriteBlocks (Instance,Lba,BufferSizeInBytes,Buffer);
|
||||
Status = NorFlashWriteBlocks (Instance, Lba, BufferSizeInBytes, Buffer);
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
@ -56,7 +56,7 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = {
|
||||
0, // LastBlock ... NEED TO BE FILLED
|
||||
0, // LowestAlignedLba
|
||||
1, // LogicalBlocksPerPhysicalBlock
|
||||
}, //Media;
|
||||
}, // Media;
|
||||
|
||||
{
|
||||
EFI_DISK_IO_PROTOCOL_REVISION, // Revision
|
||||
@ -72,7 +72,7 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = {
|
||||
FvbRead, // Read
|
||||
FvbWrite, // Write
|
||||
FvbEraseBlocks, // EraseBlocks
|
||||
NULL, //ParentHandle
|
||||
NULL, // ParentHandle
|
||||
}, // FvbProtoccol;
|
||||
NULL, // ShadowBuffer
|
||||
{
|
||||
@ -85,7 +85,8 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = {
|
||||
(UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End) >> 8)
|
||||
}
|
||||
},
|
||||
{ 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }, // GUID ... NEED TO BE FILLED
|
||||
{ 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }
|
||||
}, // GUID ... NEED TO BE FILLED
|
||||
},
|
||||
0, // Index
|
||||
{
|
||||
@ -104,15 +105,15 @@ NorFlashCreateInstance (
|
||||
IN UINT32 Index,
|
||||
IN UINT32 BlockSize,
|
||||
IN BOOLEAN SupportFvb,
|
||||
OUT NOR_FLASH_INSTANCE** NorFlashInstance
|
||||
OUT NOR_FLASH_INSTANCE **NorFlashInstance
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
NOR_FLASH_INSTANCE* Instance;
|
||||
NOR_FLASH_INSTANCE *Instance;
|
||||
|
||||
ASSERT(NorFlashInstance != NULL);
|
||||
ASSERT (NorFlashInstance != NULL);
|
||||
|
||||
Instance = AllocateRuntimeCopyPool (sizeof(NOR_FLASH_INSTANCE),&mNorFlashInstanceTemplate);
|
||||
Instance = AllocateRuntimeCopyPool (sizeof (NOR_FLASH_INSTANCE), &mNorFlashInstanceTemplate);
|
||||
if (Instance == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -129,7 +130,7 @@ NorFlashCreateInstance (
|
||||
CopyGuid (&Instance->DevicePath.Vendor.Guid, &gEfiCallerIdGuid);
|
||||
Instance->DevicePath.Index = (UINT8)Index;
|
||||
|
||||
Instance->ShadowBuffer = AllocateRuntimePool (BlockSize);;
|
||||
Instance->ShadowBuffer = AllocateRuntimePool (BlockSize);
|
||||
if (Instance->ShadowBuffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -139,24 +140,30 @@ NorFlashCreateInstance (
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Instance->Handle,
|
||||
&gEfiDevicePathProtocolGuid, &Instance->DevicePath,
|
||||
&gEfiBlockIoProtocolGuid, &Instance->BlockIoProtocol,
|
||||
&gEfiFirmwareVolumeBlockProtocolGuid, &Instance->FvbProtocol,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
&Instance->DevicePath,
|
||||
&gEfiBlockIoProtocolGuid,
|
||||
&Instance->BlockIoProtocol,
|
||||
&gEfiFirmwareVolumeBlockProtocolGuid,
|
||||
&Instance->FvbProtocol,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Instance);
|
||||
return Status;
|
||||
}
|
||||
} else {
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Instance->Handle,
|
||||
&gEfiDevicePathProtocolGuid, &Instance->DevicePath,
|
||||
&gEfiBlockIoProtocolGuid, &Instance->BlockIoProtocol,
|
||||
&gEfiDiskIoProtocolGuid, &Instance->DiskIoProtocol,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
&Instance->DevicePath,
|
||||
&gEfiBlockIoProtocolGuid,
|
||||
&Instance->BlockIoProtocol,
|
||||
&gEfiDiskIoProtocolGuid,
|
||||
&Instance->DiskIoProtocol,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Instance);
|
||||
return Status;
|
||||
}
|
||||
@ -196,12 +203,13 @@ NorFlashUnlockAndEraseSingleBlock (
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Status = NorFlashEraseSingleBlock (Instance, BlockAddress);
|
||||
Index++;
|
||||
} while ((Index < NOR_FLASH_ERASE_RETRY) && (Status == EFI_WRITE_PROTECTED));
|
||||
|
||||
if (Index == NOR_FLASH_ERASE_RETRY) {
|
||||
DEBUG((DEBUG_ERROR,"EraseSingleBlock(BlockAddress=0x%08x: Block Locked Error (try to erase %d times)\n", BlockAddress,Index));
|
||||
DEBUG ((DEBUG_ERROR, "EraseSingleBlock(BlockAddress=0x%08x: Block Locked Error (try to erase %d times)\n", BlockAddress, Index));
|
||||
}
|
||||
|
||||
if (!EfiAtRuntime ()) {
|
||||
@ -248,8 +256,8 @@ NorFlashWriteFullBlock (
|
||||
}
|
||||
|
||||
Status = NorFlashUnlockAndEraseSingleBlock (Instance, BlockAddress);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((DEBUG_ERROR, "WriteSingleBlock: ERROR - Failed to Unlock and Erase the single block at 0x%X\n", BlockAddress));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "WriteSingleBlock: ERROR - Failed to Unlock and Erase the single block at 0x%X\n", BlockAddress));
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
@ -257,25 +265,30 @@ NorFlashWriteFullBlock (
|
||||
|
||||
// Check that the address starts at a 32-word boundary, i.e. last 7 bits must be zero
|
||||
if ((WordAddress & BOUNDARY_OF_32_WORDS) == 0x00) {
|
||||
|
||||
// First, break the entire block into buffer-sized chunks.
|
||||
BuffersInBlock = (UINTN)(BlockSizeInWords * 4) / P30_MAX_BUFFER_SIZE_IN_BYTES;
|
||||
|
||||
// Then feed each buffer chunk to the NOR Flash
|
||||
// If a buffer does not contain any data, don't write it.
|
||||
for(BufferIndex=0;
|
||||
for (BufferIndex = 0;
|
||||
BufferIndex < BuffersInBlock;
|
||||
BufferIndex++, WordAddress += P30_MAX_BUFFER_SIZE_IN_BYTES, DataBuffer += P30_MAX_BUFFER_SIZE_IN_WORDS
|
||||
) {
|
||||
)
|
||||
{
|
||||
// Check the buffer to see if it contains any data (not set all 1s).
|
||||
for (Cnt = 0; Cnt < P30_MAX_BUFFER_SIZE_IN_WORDS; Cnt++) {
|
||||
if (~DataBuffer[Cnt] != 0 ) {
|
||||
// Some data found, write the buffer.
|
||||
Status = NorFlashWriteBuffer (Instance, WordAddress, P30_MAX_BUFFER_SIZE_IN_BYTES,
|
||||
DataBuffer);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Status = NorFlashWriteBuffer (
|
||||
Instance,
|
||||
WordAddress,
|
||||
P30_MAX_BUFFER_SIZE_IN_BYTES,
|
||||
DataBuffer
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -284,20 +297,19 @@ NorFlashWriteFullBlock (
|
||||
// Finally, finish off any remaining words that are less than the maximum size of the buffer
|
||||
RemainingWords = BlockSizeInWords % P30_MAX_BUFFER_SIZE_IN_WORDS;
|
||||
|
||||
if(RemainingWords != 0) {
|
||||
if (RemainingWords != 0) {
|
||||
Status = NorFlashWriteBuffer (Instance, WordAddress, (RemainingWords * 4), DataBuffer);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// For now, use the single word programming algorithm
|
||||
// It is unlikely that the NOR Flash will exist in an address which falls within a 32 word boundary range,
|
||||
// i.e. which ends in the range 0x......01 - 0x......7F.
|
||||
for(WordIndex=0; WordIndex<BlockSizeInWords; WordIndex++, DataBuffer++, WordAddress = WordAddress + 4) {
|
||||
for (WordIndex = 0; WordIndex < BlockSizeInWords; WordIndex++, DataBuffer++, WordAddress = WordAddress + 4) {
|
||||
Status = NorFlashWriteSingleWord (Instance, WordAddress, *DataBuffer);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto EXIT;
|
||||
}
|
||||
}
|
||||
@ -309,9 +321,10 @@ EXIT:
|
||||
gBS->RestoreTPL (OriginalTPL);
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((DEBUG_ERROR, "NOR FLASH Programming [WriteSingleBlock] failed at address 0x%08x. Exit Status = \"%r\".\n", WordAddress, Status));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "NOR FLASH Programming [WriteSingleBlock] failed at address 0x%08x. Exit Status = \"%r\".\n", WordAddress, Status));
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -324,22 +337,22 @@ NorFlashInitialise (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 Index;
|
||||
NOR_FLASH_DESCRIPTION* NorFlashDevices;
|
||||
NOR_FLASH_DESCRIPTION *NorFlashDevices;
|
||||
BOOLEAN ContainVariableStorage;
|
||||
|
||||
Status = NorFlashPlatformInitialization ();
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((DEBUG_ERROR,"NorFlashInitialise: Fail to initialize Nor Flash devices\n"));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashInitialise: Fail to initialize Nor Flash devices\n"));
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = NorFlashPlatformGetDevices (&NorFlashDevices, &mNorFlashDeviceCount);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((DEBUG_ERROR,"NorFlashInitialise: Fail to get Nor Flash devices\n"));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashInitialise: Fail to get Nor Flash devices\n"));
|
||||
return Status;
|
||||
}
|
||||
|
||||
mNorFlashInstances = AllocateRuntimePool (sizeof(NOR_FLASH_INSTANCE*) * mNorFlashDeviceCount);
|
||||
mNorFlashInstances = AllocateRuntimePool (sizeof (NOR_FLASH_INSTANCE *) * mNorFlashDeviceCount);
|
||||
|
||||
for (Index = 0; Index < mNorFlashDeviceCount; Index++) {
|
||||
// Check if this NOR Flash device contain the variable storage region
|
||||
@ -365,8 +378,8 @@ NorFlashInitialise (
|
||||
ContainVariableStorage,
|
||||
&mNorFlashInstances[Index]
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((DEBUG_ERROR,"NorFlashInitialise: Fail to create instance for NorFlash[%d]\n",Index));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashInitialise: Fail to create instance for NorFlash[%d]\n", Index));
|
||||
}
|
||||
}
|
||||
|
||||
@ -389,7 +402,7 @@ NorFlashInitialise (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
NorFlashFvbInitialize (
|
||||
IN NOR_FLASH_INSTANCE* Instance
|
||||
IN NOR_FLASH_INSTANCE *Instance
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@ -397,8 +410,8 @@ NorFlashFvbInitialize (
|
||||
EFI_BOOT_MODE BootMode;
|
||||
UINTN RuntimeMmioRegionSize;
|
||||
|
||||
DEBUG((DEBUG_BLKIO,"NorFlashFvbInitialize\n"));
|
||||
ASSERT((Instance != NULL));
|
||||
DEBUG ((DEBUG_BLKIO, "NorFlashFvbInitialize\n"));
|
||||
ASSERT ((Instance != NULL));
|
||||
|
||||
//
|
||||
// Declare the Non-Volatile storage as EFI_MEMORY_RUNTIME
|
||||
@ -412,14 +425,17 @@ NorFlashFvbInitialize (
|
||||
|
||||
Status = gDS->AddMemorySpace (
|
||||
EfiGcdMemoryTypeMemoryMappedIo,
|
||||
Instance->DeviceBaseAddress, RuntimeMmioRegionSize,
|
||||
Instance->DeviceBaseAddress,
|
||||
RuntimeMmioRegionSize,
|
||||
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = gDS->SetMemorySpaceAttributes (
|
||||
Instance->DeviceBaseAddress, RuntimeMmioRegionSize,
|
||||
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME);
|
||||
Instance->DeviceBaseAddress,
|
||||
RuntimeMmioRegionSize,
|
||||
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
mFlashNvStorageVariableBase = (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0) ?
|
||||
@ -437,23 +453,26 @@ NorFlashFvbInitialize (
|
||||
}
|
||||
|
||||
// Install the Default FVB header if required
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
// There is no valid header, so time to install one.
|
||||
DEBUG ((DEBUG_INFO, "%a: The FVB Header is not valid.\n", __FUNCTION__));
|
||||
DEBUG ((DEBUG_INFO, "%a: Installing a correct one for this volume.\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Installing a correct one for this volume.\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
|
||||
// Erase all the NorFlash that is reserved for variable storage
|
||||
FvbNumLba = (PcdGet32(PcdFlashNvStorageVariableSize) + PcdGet32(PcdFlashNvStorageFtwWorkingSize) + PcdGet32(PcdFlashNvStorageFtwSpareSize)) / Instance->Media.BlockSize;
|
||||
FvbNumLba = (PcdGet32 (PcdFlashNvStorageVariableSize) + PcdGet32 (PcdFlashNvStorageFtwWorkingSize) + PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / Instance->Media.BlockSize;
|
||||
|
||||
Status = FvbEraseBlocks (&Instance->FvbProtocol, (EFI_LBA)0, FvbNumLba, EFI_LBA_LIST_TERMINATOR);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
// Install all appropriate headers
|
||||
Status = InitializeFvAndVariableStoreHeaders (Instance);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ InitializeFvAndVariableStoreHeaders (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID* Headers;
|
||||
VOID *Headers;
|
||||
UINTN HeadersLength;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FirmwareVolumeHeader;
|
||||
VARIABLE_STORE_HEADER *VariableStoreHeader;
|
||||
@ -55,8 +55,8 @@ InitializeFvAndVariableStoreHeaders (
|
||||
UINT64 NvStorageFtwWorkingBase;
|
||||
UINT64 NvStorageVariableBase;
|
||||
|
||||
HeadersLength = sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + sizeof(VARIABLE_STORE_HEADER);
|
||||
Headers = AllocateZeroPool(HeadersLength);
|
||||
HeadersLength = sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY) + sizeof (VARIABLE_STORE_HEADER);
|
||||
Headers = AllocateZeroPool (HeadersLength);
|
||||
|
||||
NvStorageFtwWorkingSize = PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
|
||||
NvStorageFtwSpareSize = PcdGet32 (PcdFlashNvStorageFtwSpareSize);
|
||||
@ -71,40 +71,59 @@ InitializeFvAndVariableStoreHeaders (
|
||||
|
||||
// FirmwareVolumeHeader->FvLength is declared to have the Variable area AND the FTW working area AND the FTW Spare contiguous.
|
||||
if ((NvStorageVariableBase + NvStorageVariableSize) != NvStorageFtwWorkingBase) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: NvStorageFtwWorkingBase is not contiguous with NvStorageVariableBase region\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: NvStorageFtwWorkingBase is not contiguous with NvStorageVariableBase region\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((NvStorageFtwWorkingBase + NvStorageFtwWorkingSize) != NvStorageFtwSpareBase) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: NvStorageFtwSpareBase is not contiguous with NvStorageFtwWorkingBase region\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: NvStorageFtwSpareBase is not contiguous with NvStorageFtwWorkingBase region\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// Check if the size of the area is at least one block size
|
||||
if ((NvStorageVariableSize <= 0) || (NvStorageVariableSize / Instance->Media.BlockSize <= 0)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: NvStorageVariableSize is 0x%x, should be atleast one block size\n", __FUNCTION__,
|
||||
NvStorageVariableSize));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: NvStorageVariableSize is 0x%x, should be atleast one block size\n",
|
||||
__FUNCTION__,
|
||||
NvStorageVariableSize
|
||||
));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((NvStorageFtwWorkingSize <= 0) || (NvStorageFtwWorkingSize / Instance->Media.BlockSize <= 0)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: NvStorageFtwWorkingSize is 0x%x, should be atleast one block size\n", __FUNCTION__,
|
||||
NvStorageFtwWorkingSize));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: NvStorageFtwWorkingSize is 0x%x, should be atleast one block size\n",
|
||||
__FUNCTION__,
|
||||
NvStorageFtwWorkingSize
|
||||
));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((NvStorageFtwSpareSize <= 0) || (NvStorageFtwSpareSize / Instance->Media.BlockSize <= 0)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: NvStorageFtwSpareSize is 0x%x, should be atleast one block size\n", __FUNCTION__,
|
||||
NvStorageFtwSpareSize));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: NvStorageFtwSpareSize is 0x%x, should be atleast one block size\n",
|
||||
__FUNCTION__,
|
||||
NvStorageFtwSpareSize
|
||||
));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// Ensure the Variable area Base Addresses are aligned on a block size boundaries
|
||||
if ((NvStorageVariableBase % Instance->Media.BlockSize != 0) ||
|
||||
(NvStorageFtwWorkingBase % Instance->Media.BlockSize != 0) ||
|
||||
(NvStorageFtwSpareBase % Instance->Media.BlockSize != 0)) {
|
||||
(NvStorageFtwSpareBase % Instance->Media.BlockSize != 0))
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "%a: NvStorage Base addresses must be aligned to block size boundaries", __FUNCTION__));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@ -112,14 +131,14 @@ InitializeFvAndVariableStoreHeaders (
|
||||
//
|
||||
// EFI_FIRMWARE_VOLUME_HEADER
|
||||
//
|
||||
FirmwareVolumeHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Headers;
|
||||
FirmwareVolumeHeader = (EFI_FIRMWARE_VOLUME_HEADER *)Headers;
|
||||
CopyGuid (&FirmwareVolumeHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid);
|
||||
FirmwareVolumeHeader->FvLength =
|
||||
PcdGet32(PcdFlashNvStorageVariableSize) +
|
||||
PcdGet32(PcdFlashNvStorageFtwWorkingSize) +
|
||||
PcdGet32(PcdFlashNvStorageFtwSpareSize);
|
||||
PcdGet32 (PcdFlashNvStorageVariableSize) +
|
||||
PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
|
||||
PcdGet32 (PcdFlashNvStorageFtwSpareSize);
|
||||
FirmwareVolumeHeader->Signature = EFI_FVH_SIGNATURE;
|
||||
FirmwareVolumeHeader->Attributes = (EFI_FVB_ATTRIBUTES_2) (
|
||||
FirmwareVolumeHeader->Attributes = (EFI_FVB_ATTRIBUTES_2)(
|
||||
EFI_FVB2_READ_ENABLED_CAP | // Reads may be enabled
|
||||
EFI_FVB2_READ_STATUS | // Reads are currently enabled
|
||||
EFI_FVB2_STICKY_WRITE | // A block erase is required to flip bits into EFI_FVB2_ERASE_POLARITY
|
||||
@ -128,20 +147,20 @@ InitializeFvAndVariableStoreHeaders (
|
||||
EFI_FVB2_WRITE_STATUS | // Writes are currently enabled
|
||||
EFI_FVB2_WRITE_ENABLED_CAP // Writes may be enabled
|
||||
);
|
||||
FirmwareVolumeHeader->HeaderLength = sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY);
|
||||
FirmwareVolumeHeader->HeaderLength = sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY);
|
||||
FirmwareVolumeHeader->Revision = EFI_FVH_REVISION;
|
||||
FirmwareVolumeHeader->BlockMap[0].NumBlocks = Instance->Media.LastBlock + 1;
|
||||
FirmwareVolumeHeader->BlockMap[0].Length = Instance->Media.BlockSize;
|
||||
FirmwareVolumeHeader->BlockMap[1].NumBlocks = 0;
|
||||
FirmwareVolumeHeader->BlockMap[1].Length = 0;
|
||||
FirmwareVolumeHeader->Checksum = CalculateCheckSum16 ((UINT16*)FirmwareVolumeHeader,FirmwareVolumeHeader->HeaderLength);
|
||||
FirmwareVolumeHeader->Checksum = CalculateCheckSum16 ((UINT16 *)FirmwareVolumeHeader, FirmwareVolumeHeader->HeaderLength);
|
||||
|
||||
//
|
||||
// VARIABLE_STORE_HEADER
|
||||
//
|
||||
VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)Headers + FirmwareVolumeHeader->HeaderLength);
|
||||
VariableStoreHeader = (VARIABLE_STORE_HEADER *)((UINTN)Headers + FirmwareVolumeHeader->HeaderLength);
|
||||
CopyGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid);
|
||||
VariableStoreHeader->Size = PcdGet32(PcdFlashNvStorageVariableSize) - FirmwareVolumeHeader->HeaderLength;
|
||||
VariableStoreHeader->Size = PcdGet32 (PcdFlashNvStorageVariableSize) - FirmwareVolumeHeader->HeaderLength;
|
||||
VariableStoreHeader->Format = VARIABLE_STORE_FORMATTED;
|
||||
VariableStoreHeader->State = VARIABLE_STORE_HEALTHY;
|
||||
|
||||
@ -172,10 +191,10 @@ ValidateFvHeader (
|
||||
UINTN VariableStoreLength;
|
||||
UINTN FvLength;
|
||||
|
||||
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Instance->RegionBaseAddress;
|
||||
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)Instance->RegionBaseAddress;
|
||||
|
||||
FvLength = PcdGet32(PcdFlashNvStorageVariableSize) + PcdGet32(PcdFlashNvStorageFtwWorkingSize) +
|
||||
PcdGet32(PcdFlashNvStorageFtwSpareSize);
|
||||
FvLength = PcdGet32 (PcdFlashNvStorageVariableSize) + PcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
|
||||
PcdGet32 (PcdFlashNvStorageFtwSpareSize);
|
||||
|
||||
//
|
||||
// Verify the header revision, header signature, length
|
||||
@ -187,40 +206,57 @@ ValidateFvHeader (
|
||||
|| (FwVolHeader->FvLength != FvLength)
|
||||
)
|
||||
{
|
||||
DEBUG ((DEBUG_INFO, "%a: No Firmware Volume header present\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: No Firmware Volume header present\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
// Check the Firmware Volume Guid
|
||||
if( CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid) == FALSE ) {
|
||||
DEBUG ((DEBUG_INFO, "%a: Firmware Volume Guid non-compatible\n",
|
||||
__FUNCTION__));
|
||||
if ( CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid) == FALSE ) {
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Firmware Volume Guid non-compatible\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
// Verify the header checksum
|
||||
Checksum = CalculateSum16((UINT16*)FwVolHeader, FwVolHeader->HeaderLength);
|
||||
Checksum = CalculateSum16 ((UINT16 *)FwVolHeader, FwVolHeader->HeaderLength);
|
||||
if (Checksum != 0) {
|
||||
DEBUG ((DEBUG_INFO, "%a: FV checksum is invalid (Checksum:0x%X)\n",
|
||||
__FUNCTION__, Checksum));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: FV checksum is invalid (Checksum:0x%X)\n",
|
||||
__FUNCTION__,
|
||||
Checksum
|
||||
));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)FwVolHeader + FwVolHeader->HeaderLength);
|
||||
VariableStoreHeader = (VARIABLE_STORE_HEADER *)((UINTN)FwVolHeader + FwVolHeader->HeaderLength);
|
||||
|
||||
// Check the Variable Store Guid
|
||||
if (!CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) &&
|
||||
!CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid)) {
|
||||
DEBUG ((DEBUG_INFO, "%a: Variable Store Guid non-compatible\n",
|
||||
__FUNCTION__));
|
||||
!CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid))
|
||||
{
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Variable Store Guid non-compatible\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
VariableStoreLength = PcdGet32 (PcdFlashNvStorageVariableSize) - FwVolHeader->HeaderLength;
|
||||
if (VariableStoreHeader->Size != VariableStoreLength) {
|
||||
DEBUG ((DEBUG_INFO, "%a: Variable Store Length does not match\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Variable Store Length does not match\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -242,7 +278,7 @@ ValidateFvHeader (
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbGetAttributes(
|
||||
FvbGetAttributes (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
|
||||
OUT EFI_FVB_ATTRIBUTES_2 *Attributes
|
||||
)
|
||||
@ -250,9 +286,9 @@ FvbGetAttributes(
|
||||
EFI_FVB_ATTRIBUTES_2 FlashFvbAttributes;
|
||||
NOR_FLASH_INSTANCE *Instance;
|
||||
|
||||
Instance = INSTANCE_FROM_FVB_THIS(This);
|
||||
Instance = INSTANCE_FROM_FVB_THIS (This);
|
||||
|
||||
FlashFvbAttributes = (EFI_FVB_ATTRIBUTES_2) (
|
||||
FlashFvbAttributes = (EFI_FVB_ATTRIBUTES_2)(
|
||||
|
||||
EFI_FVB2_READ_ENABLED_CAP | // Reads may be enabled
|
||||
EFI_FVB2_READ_STATUS | // Reads are currently enabled
|
||||
@ -264,7 +300,6 @@ FvbGetAttributes(
|
||||
|
||||
// Check if it is write protected
|
||||
if (Instance->Media.ReadOnly != TRUE) {
|
||||
|
||||
FlashFvbAttributes = FlashFvbAttributes |
|
||||
EFI_FVB2_WRITE_STATUS | // Writes are currently enabled
|
||||
EFI_FVB2_WRITE_ENABLED_CAP; // Writes may be enabled
|
||||
@ -298,12 +333,12 @@ FvbGetAttributes(
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FvbSetAttributes(
|
||||
FvbSetAttributes (
|
||||
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
|
||||
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
|
||||
)
|
||||
{
|
||||
DEBUG ((DEBUG_BLKIO, "FvbSetAttributes(0x%X) is not supported\n",*Attributes));
|
||||
DEBUG ((DEBUG_BLKIO, "FvbSetAttributes(0x%X) is not supported\n", *Attributes));
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -333,11 +368,11 @@ FvbGetPhysicalAddress (
|
||||
{
|
||||
NOR_FLASH_INSTANCE *Instance;
|
||||
|
||||
Instance = INSTANCE_FROM_FVB_THIS(This);
|
||||
Instance = INSTANCE_FROM_FVB_THIS (This);
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "FvbGetPhysicalAddress(BaseAddress=0x%08x)\n", Instance->RegionBaseAddress));
|
||||
|
||||
ASSERT(Address != NULL);
|
||||
ASSERT (Address != NULL);
|
||||
|
||||
*Address = mFlashNvStorageVariableBase;
|
||||
return EFI_SUCCESS;
|
||||
@ -381,7 +416,7 @@ FvbGetBlockSize (
|
||||
EFI_STATUS Status;
|
||||
NOR_FLASH_INSTANCE *Instance;
|
||||
|
||||
Instance = INSTANCE_FROM_FVB_THIS(This);
|
||||
Instance = INSTANCE_FROM_FVB_THIS (This);
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "FvbGetBlockSize(Lba=%ld, BlockSize=0x%x, LastBlock=%ld)\n", Lba, Instance->Media.BlockSize, Instance->Media.LastBlock));
|
||||
|
||||
@ -390,8 +425,8 @@ FvbGetBlockSize (
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
} else {
|
||||
// This is easy because in this platform each NorFlash device has equal sized blocks.
|
||||
*BlockSize = (UINTN) Instance->Media.BlockSize;
|
||||
*NumberOfBlocks = (UINTN) (Instance->Media.LastBlock - Lba + 1);
|
||||
*BlockSize = (UINTN)Instance->Media.BlockSize;
|
||||
*NumberOfBlocks = (UINTN)(Instance->Media.LastBlock - Lba + 1);
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "FvbGetBlockSize: *BlockSize=0x%x, *NumberOfBlocks=0x%x.\n", *BlockSize, *NumberOfBlocks));
|
||||
|
||||
@ -456,7 +491,7 @@ FvbRead (
|
||||
UINTN BlockSize;
|
||||
NOR_FLASH_INSTANCE *Instance;
|
||||
|
||||
Instance = INSTANCE_FROM_FVB_THIS(This);
|
||||
Instance = INSTANCE_FROM_FVB_THIS (This);
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "FvbRead(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Instance->StartLba + Lba, Offset, *NumBytes, Buffer));
|
||||
|
||||
@ -465,14 +500,15 @@ FvbRead (
|
||||
// Cache the block size to avoid de-referencing pointers all the time
|
||||
BlockSize = Instance->Media.BlockSize;
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "FvbRead: Check if (Offset=0x%x + NumBytes=0x%x) <= BlockSize=0x%x\n", Offset, *NumBytes, BlockSize ));
|
||||
DEBUG ((DEBUG_BLKIO, "FvbRead: Check if (Offset=0x%x + NumBytes=0x%x) <= BlockSize=0x%x\n", Offset, *NumBytes, BlockSize));
|
||||
|
||||
// The read must not span block boundaries.
|
||||
// We need to check each variable individually because adding two large values together overflows.
|
||||
if ((Offset >= BlockSize) ||
|
||||
(*NumBytes > BlockSize) ||
|
||||
((Offset + *NumBytes) > BlockSize)) {
|
||||
DEBUG ((DEBUG_ERROR, "FvbRead: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", Offset, *NumBytes, BlockSize ));
|
||||
((Offset + *NumBytes) > BlockSize))
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "FvbRead: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", Offset, *NumBytes, BlockSize));
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
@ -495,6 +531,7 @@ FvbRead (
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -626,7 +663,7 @@ FvbEraseBlocks (
|
||||
UINTN NumOfLba; // Number of Lba blocks to erase
|
||||
NOR_FLASH_INSTANCE *Instance;
|
||||
|
||||
Instance = INSTANCE_FROM_FVB_THIS(This);
|
||||
Instance = INSTANCE_FROM_FVB_THIS (This);
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks()\n"));
|
||||
|
||||
@ -648,7 +685,7 @@ FvbEraseBlocks (
|
||||
|
||||
// Have we reached the end of the list?
|
||||
if (StartingLba == EFI_LBA_LIST_TERMINATOR) {
|
||||
//Exit the while loop
|
||||
// Exit the while loop
|
||||
break;
|
||||
}
|
||||
|
||||
@ -670,6 +707,7 @@ FvbEraseBlocks (
|
||||
goto EXIT;
|
||||
}
|
||||
} while (TRUE);
|
||||
|
||||
VA_END (Args);
|
||||
|
||||
//
|
||||
@ -691,7 +729,6 @@ FvbEraseBlocks (
|
||||
|
||||
// Go through each one and erase it
|
||||
while (NumOfLba > 0) {
|
||||
|
||||
// Get the physical address of Lba to erase
|
||||
BlockAddress = GET_NOR_BLOCK_ADDRESS (
|
||||
Instance->RegionBaseAddress,
|
||||
@ -702,7 +739,7 @@ FvbEraseBlocks (
|
||||
// Erase it
|
||||
DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks: Erasing Lba=%ld @ 0x%08x.\n", Instance->StartLba + StartingLba, BlockAddress));
|
||||
Status = NorFlashUnlockAndEraseSingleBlock (Instance, BlockAddress);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
VA_END (Args);
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto EXIT;
|
||||
@ -713,6 +750,7 @@ FvbEraseBlocks (
|
||||
NumOfLba--;
|
||||
}
|
||||
} while (TRUE);
|
||||
|
||||
VA_END (Args);
|
||||
|
||||
EXIT:
|
||||
@ -734,6 +772,6 @@ FvbVirtualNotifyEvent (
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EfiConvertPointer (0x0, (VOID**)&mFlashNvStorageVariableBase);
|
||||
EfiConvertPointer (0x0, (VOID **)&mFlashNvStorageVariableBase);
|
||||
return;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = {
|
||||
0, // LastBlock ... NEED TO BE FILLED
|
||||
0, // LowestAlignedLba
|
||||
1, // LogicalBlocksPerPhysicalBlock
|
||||
}, //Media;
|
||||
}, // Media;
|
||||
|
||||
{
|
||||
EFI_DISK_IO_PROTOCOL_REVISION, // Revision
|
||||
@ -66,7 +66,7 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = {
|
||||
FvbRead, // Read
|
||||
FvbWrite, // Write
|
||||
FvbEraseBlocks, // EraseBlocks
|
||||
NULL, //ParentHandle
|
||||
NULL, // ParentHandle
|
||||
}, // FvbProtoccol;
|
||||
NULL, // ShadowBuffer
|
||||
{
|
||||
@ -79,7 +79,8 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = {
|
||||
(UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End) >> 8)
|
||||
}
|
||||
},
|
||||
{ 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }, // GUID ... NEED TO BE FILLED
|
||||
{ 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }
|
||||
}, // GUID ... NEED TO BE FILLED
|
||||
},
|
||||
0, // Index
|
||||
{
|
||||
@ -98,15 +99,15 @@ NorFlashCreateInstance (
|
||||
IN UINT32 Index,
|
||||
IN UINT32 BlockSize,
|
||||
IN BOOLEAN SupportFvb,
|
||||
OUT NOR_FLASH_INSTANCE** NorFlashInstance
|
||||
OUT NOR_FLASH_INSTANCE **NorFlashInstance
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
NOR_FLASH_INSTANCE* Instance;
|
||||
NOR_FLASH_INSTANCE *Instance;
|
||||
|
||||
ASSERT(NorFlashInstance != NULL);
|
||||
ASSERT (NorFlashInstance != NULL);
|
||||
|
||||
Instance = AllocateRuntimeCopyPool (sizeof(NOR_FLASH_INSTANCE),&mNorFlashInstanceTemplate);
|
||||
Instance = AllocateRuntimeCopyPool (sizeof (NOR_FLASH_INSTANCE), &mNorFlashInstanceTemplate);
|
||||
if (Instance == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -123,7 +124,7 @@ NorFlashCreateInstance (
|
||||
CopyGuid (&Instance->DevicePath.Vendor.Guid, &gEfiCallerIdGuid);
|
||||
Instance->DevicePath.Index = (UINT8)Index;
|
||||
|
||||
Instance->ShadowBuffer = AllocateRuntimePool (BlockSize);;
|
||||
Instance->ShadowBuffer = AllocateRuntimePool (BlockSize);
|
||||
if (Instance->ShadowBuffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -137,12 +138,12 @@ NorFlashCreateInstance (
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&Instance->FvbProtocol
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Instance);
|
||||
return Status;
|
||||
}
|
||||
} else {
|
||||
DEBUG((DEBUG_ERROR,"standalone MM NOR Flash driver only support FVB.\n"));
|
||||
DEBUG ((DEBUG_ERROR, "standalone MM NOR Flash driver only support FVB.\n"));
|
||||
FreePool (Instance);
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@ -171,12 +172,13 @@ NorFlashUnlockAndEraseSingleBlock (
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Status = NorFlashEraseSingleBlock (Instance, BlockAddress);
|
||||
Index++;
|
||||
} while ((Index < NOR_FLASH_ERASE_RETRY) && (Status == EFI_WRITE_PROTECTED));
|
||||
|
||||
if (Index == NOR_FLASH_ERASE_RETRY) {
|
||||
DEBUG((DEBUG_ERROR,"EraseSingleBlock(BlockAddress=0x%08x: Block Locked Error (try to erase %d times)\n", BlockAddress,Index));
|
||||
DEBUG ((DEBUG_ERROR, "EraseSingleBlock(BlockAddress=0x%08x: Block Locked Error (try to erase %d times)\n", BlockAddress, Index));
|
||||
}
|
||||
|
||||
return Status;
|
||||
@ -208,8 +210,8 @@ NorFlashWriteFullBlock (
|
||||
WordAddress = BlockAddress;
|
||||
|
||||
Status = NorFlashUnlockAndEraseSingleBlock (Instance, BlockAddress);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((DEBUG_ERROR, "WriteSingleBlock: ERROR - Failed to Unlock and Erase the single block at 0x%X\n", BlockAddress));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "WriteSingleBlock: ERROR - Failed to Unlock and Erase the single block at 0x%X\n", BlockAddress));
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
@ -217,25 +219,30 @@ NorFlashWriteFullBlock (
|
||||
|
||||
// Check that the address starts at a 32-word boundary, i.e. last 7 bits must be zero
|
||||
if ((WordAddress & BOUNDARY_OF_32_WORDS) == 0x00) {
|
||||
|
||||
// First, break the entire block into buffer-sized chunks.
|
||||
BuffersInBlock = (UINTN)(BlockSizeInWords * 4) / P30_MAX_BUFFER_SIZE_IN_BYTES;
|
||||
|
||||
// Then feed each buffer chunk to the NOR Flash
|
||||
// If a buffer does not contain any data, don't write it.
|
||||
for(BufferIndex=0;
|
||||
for (BufferIndex = 0;
|
||||
BufferIndex < BuffersInBlock;
|
||||
BufferIndex++, WordAddress += P30_MAX_BUFFER_SIZE_IN_BYTES, DataBuffer += P30_MAX_BUFFER_SIZE_IN_WORDS
|
||||
) {
|
||||
)
|
||||
{
|
||||
// Check the buffer to see if it contains any data (not set all 1s).
|
||||
for (Cnt = 0; Cnt < P30_MAX_BUFFER_SIZE_IN_WORDS; Cnt++) {
|
||||
if (~DataBuffer[Cnt] != 0 ) {
|
||||
// Some data found, write the buffer.
|
||||
Status = NorFlashWriteBuffer (Instance, WordAddress, P30_MAX_BUFFER_SIZE_IN_BYTES,
|
||||
DataBuffer);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Status = NorFlashWriteBuffer (
|
||||
Instance,
|
||||
WordAddress,
|
||||
P30_MAX_BUFFER_SIZE_IN_BYTES,
|
||||
DataBuffer
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -244,29 +251,29 @@ NorFlashWriteFullBlock (
|
||||
// Finally, finish off any remaining words that are less than the maximum size of the buffer
|
||||
RemainingWords = BlockSizeInWords % P30_MAX_BUFFER_SIZE_IN_WORDS;
|
||||
|
||||
if(RemainingWords != 0) {
|
||||
if (RemainingWords != 0) {
|
||||
Status = NorFlashWriteBuffer (Instance, WordAddress, (RemainingWords * 4), DataBuffer);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// For now, use the single word programming algorithm
|
||||
// It is unlikely that the NOR Flash will exist in an address which falls within a 32 word boundary range,
|
||||
// i.e. which ends in the range 0x......01 - 0x......7F.
|
||||
for(WordIndex=0; WordIndex<BlockSizeInWords; WordIndex++, DataBuffer++, WordAddress = WordAddress + 4) {
|
||||
for (WordIndex = 0; WordIndex < BlockSizeInWords; WordIndex++, DataBuffer++, WordAddress = WordAddress + 4) {
|
||||
Status = NorFlashWriteSingleWord (Instance, WordAddress, *DataBuffer);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto EXIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EXIT:
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((DEBUG_ERROR, "NOR FLASH Programming [WriteSingleBlock] failed at address 0x%08x. Exit Status = \"%r\".\n", WordAddress, Status));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "NOR FLASH Programming [WriteSingleBlock] failed at address 0x%08x. Exit Status = \"%r\".\n", WordAddress, Status));
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -279,22 +286,22 @@ NorFlashInitialise (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 Index;
|
||||
NOR_FLASH_DESCRIPTION* NorFlashDevices;
|
||||
NOR_FLASH_DESCRIPTION *NorFlashDevices;
|
||||
BOOLEAN ContainVariableStorage;
|
||||
|
||||
Status = NorFlashPlatformInitialization ();
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((DEBUG_ERROR,"NorFlashInitialise: Fail to initialize Nor Flash devices\n"));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashInitialise: Fail to initialize Nor Flash devices\n"));
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = NorFlashPlatformGetDevices (&NorFlashDevices, &mNorFlashDeviceCount);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((DEBUG_ERROR,"NorFlashInitialise: Fail to get Nor Flash devices\n"));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashInitialise: Fail to get Nor Flash devices\n"));
|
||||
return Status;
|
||||
}
|
||||
|
||||
mNorFlashInstances = AllocatePool (sizeof(NOR_FLASH_INSTANCE*) * mNorFlashDeviceCount);
|
||||
mNorFlashInstances = AllocatePool (sizeof (NOR_FLASH_INSTANCE *) * mNorFlashDeviceCount);
|
||||
|
||||
for (Index = 0; Index < mNorFlashDeviceCount; Index++) {
|
||||
// Check if this NOR Flash device contain the variable storage region
|
||||
@ -320,8 +327,8 @@ NorFlashInitialise (
|
||||
ContainVariableStorage,
|
||||
&mNorFlashInstances[Index]
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
DEBUG((DEBUG_ERROR,"NorFlashInitialise: Fail to create instance for NorFlash[%d]\n",Index));
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "NorFlashInitialise: Fail to create instance for NorFlash[%d]\n", Index));
|
||||
}
|
||||
}
|
||||
|
||||
@ -331,14 +338,13 @@ NorFlashInitialise (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
NorFlashFvbInitialize (
|
||||
IN NOR_FLASH_INSTANCE* Instance
|
||||
IN NOR_FLASH_INSTANCE *Instance
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT32 FvbNumLba;
|
||||
|
||||
ASSERT((Instance != NULL));
|
||||
|
||||
ASSERT ((Instance != NULL));
|
||||
|
||||
mFlashNvStorageVariableBase = (FixedPcdGet64 (PcdFlashNvStorageVariableBase64) != 0) ?
|
||||
FixedPcdGet64 (PcdFlashNvStorageVariableBase64) : FixedPcdGet32 (PcdFlashNvStorageVariableBase);
|
||||
@ -349,23 +355,26 @@ NorFlashFvbInitialize (
|
||||
Status = ValidateFvHeader (Instance);
|
||||
|
||||
// Install the Default FVB header if required
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
// There is no valid header, so time to install one.
|
||||
DEBUG ((DEBUG_INFO, "%a: The FVB Header is not valid.\n", __FUNCTION__));
|
||||
DEBUG ((DEBUG_INFO, "%a: Installing a correct one for this volume.\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Installing a correct one for this volume.\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
|
||||
// Erase all the NorFlash that is reserved for variable storage
|
||||
FvbNumLba = (PcdGet32(PcdFlashNvStorageVariableSize) + PcdGet32(PcdFlashNvStorageFtwWorkingSize) + PcdGet32(PcdFlashNvStorageFtwSpareSize)) / Instance->Media.BlockSize;
|
||||
FvbNumLba = (PcdGet32 (PcdFlashNvStorageVariableSize) + PcdGet32 (PcdFlashNvStorageFtwWorkingSize) + PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / Instance->Media.BlockSize;
|
||||
|
||||
Status = FvbEraseBlocks (&Instance->FvbProtocol, (EFI_LBA)0, FvbNumLba, EFI_LBA_LIST_TERMINATOR);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
// Install all appropriate headers
|
||||
Status = InitializeFvAndVariableStoreHeaders (Instance);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
@ -40,13 +39,15 @@ PL061Locate (
|
||||
for (Index = 0; Index < mPL061PlatformGpio->GpioControllerCount; Index++) {
|
||||
if ( (Gpio >= mPL061PlatformGpio->GpioController[Index].GpioIndex)
|
||||
&& (Gpio < mPL061PlatformGpio->GpioController[Index].GpioIndex
|
||||
+ mPL061PlatformGpio->GpioController[Index].InternalGpioCount)) {
|
||||
+ mPL061PlatformGpio->GpioController[Index].InternalGpioCount))
|
||||
{
|
||||
*ControllerIndex = Index;
|
||||
*ControllerOffset = Gpio % mPL061PlatformGpio->GpioController[Index].InternalGpioCount;
|
||||
*RegisterBase = mPL061PlatformGpio->GpioController[Index].RegisterBase;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_ERROR, "%a, failed to locate gpio %d\n", __func__, Gpio));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@ -105,7 +106,6 @@ PL061SetPins (
|
||||
/**
|
||||
Function implementations
|
||||
**/
|
||||
|
||||
EFI_STATUS
|
||||
PL061Identify (
|
||||
VOID
|
||||
@ -115,7 +115,8 @@ PL061Identify (
|
||||
UINTN RegisterBase;
|
||||
|
||||
if ( (mPL061PlatformGpio->GpioCount == 0)
|
||||
|| (mPL061PlatformGpio->GpioControllerCount == 0)) {
|
||||
|| (mPL061PlatformGpio->GpioControllerCount == 0))
|
||||
{
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -130,7 +131,8 @@ PL061Identify (
|
||||
if ( (MmioRead8 (RegisterBase + PL061_GPIO_PCELL_ID0) != 0x0D)
|
||||
|| (MmioRead8 (RegisterBase + PL061_GPIO_PCELL_ID1) != 0xF0)
|
||||
|| (MmioRead8 (RegisterBase + PL061_GPIO_PCELL_ID2) != 0x05)
|
||||
|| (MmioRead8 (RegisterBase + PL061_GPIO_PCELL_ID3) != 0xB1)) {
|
||||
|| (MmioRead8 (RegisterBase + PL061_GPIO_PCELL_ID3) != 0xB1))
|
||||
{
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -138,7 +140,8 @@ PL061Identify (
|
||||
if ( (MmioRead8 (RegisterBase + PL061_GPIO_PERIPH_ID0) != 0x61)
|
||||
|| (MmioRead8 (RegisterBase + PL061_GPIO_PERIPH_ID1) != 0x10)
|
||||
|| ((MmioRead8 (RegisterBase + PL061_GPIO_PERIPH_ID2) & 0xF) != 0x04)
|
||||
|| (MmioRead8 (RegisterBase + PL061_GPIO_PERIPH_ID3) != 0x00)) {
|
||||
|| (MmioRead8 (RegisterBase + PL061_GPIO_PERIPH_ID3) != 0x00))
|
||||
{
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
@ -181,7 +184,7 @@ Get (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (PL061GetPins (RegisterBase, GPIO_PIN_MASK(Offset)) != 0) {
|
||||
if (PL061GetPins (RegisterBase, GPIO_PIN_MASK (Offset)) != 0) {
|
||||
*Value = 1;
|
||||
} else {
|
||||
*Value = 0;
|
||||
@ -222,26 +225,27 @@ Set (
|
||||
Status = PL061Locate (Gpio, &Index, &Offset, &RegisterBase);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
switch (Mode)
|
||||
{
|
||||
switch (Mode) {
|
||||
case GPIO_MODE_INPUT:
|
||||
// Set the corresponding direction bit to LOW for input
|
||||
MmioAnd8 (RegisterBase + PL061_GPIO_DIR_REG,
|
||||
~GPIO_PIN_MASK(Offset) & 0xFF);
|
||||
MmioAnd8 (
|
||||
RegisterBase + PL061_GPIO_DIR_REG,
|
||||
~GPIO_PIN_MASK(Offset) & 0xFF
|
||||
);
|
||||
break;
|
||||
|
||||
case GPIO_MODE_OUTPUT_0:
|
||||
// Set the corresponding direction bit to HIGH for output
|
||||
MmioOr8 (RegisterBase + PL061_GPIO_DIR_REG, GPIO_PIN_MASK(Offset));
|
||||
MmioOr8 (RegisterBase + PL061_GPIO_DIR_REG, GPIO_PIN_MASK (Offset));
|
||||
// Set the corresponding data bit to LOW for 0
|
||||
PL061SetPins (RegisterBase, GPIO_PIN_MASK(Offset), 0);
|
||||
PL061SetPins (RegisterBase, GPIO_PIN_MASK (Offset), 0);
|
||||
break;
|
||||
|
||||
case GPIO_MODE_OUTPUT_1:
|
||||
// Set the corresponding direction bit to HIGH for output
|
||||
MmioOr8 (RegisterBase + PL061_GPIO_DIR_REG, GPIO_PIN_MASK(Offset));
|
||||
MmioOr8 (RegisterBase + PL061_GPIO_DIR_REG, GPIO_PIN_MASK (Offset));
|
||||
// Set the corresponding data bit to HIGH for 1
|
||||
PL061SetPins (RegisterBase, GPIO_PIN_MASK(Offset), 0xff);
|
||||
PL061SetPins (RegisterBase, GPIO_PIN_MASK (Offset), 0xff);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -290,9 +294,9 @@ GetMode (
|
||||
}
|
||||
|
||||
// Check if it is input or output
|
||||
if (MmioRead8 (RegisterBase + PL061_GPIO_DIR_REG) & GPIO_PIN_MASK(Offset)) {
|
||||
if (MmioRead8 (RegisterBase + PL061_GPIO_DIR_REG) & GPIO_PIN_MASK (Offset)) {
|
||||
// Pin set to output
|
||||
if (PL061GetPins (RegisterBase, GPIO_PIN_MASK(Offset)) != 0) {
|
||||
if (PL061GetPins (RegisterBase, GPIO_PIN_MASK (Offset)) != 0) {
|
||||
*Mode = GPIO_MODE_OUTPUT_1;
|
||||
} else {
|
||||
*Mode = GPIO_MODE_OUTPUT_0;
|
||||
@ -381,27 +385,28 @@ PL061InstallProtocol (
|
||||
|
||||
mPL061PlatformGpio->GpioCount = PL061_GPIO_PINS;
|
||||
mPL061PlatformGpio->GpioControllerCount = 1;
|
||||
mPL061PlatformGpio->GpioController = (GPIO_CONTROLLER *)((UINTN) mPL061PlatformGpio + sizeof (PLATFORM_GPIO_CONTROLLER));
|
||||
mPL061PlatformGpio->GpioController = (GPIO_CONTROLLER *)((UINTN)mPL061PlatformGpio + sizeof (PLATFORM_GPIO_CONTROLLER));
|
||||
|
||||
GpioController = mPL061PlatformGpio->GpioController;
|
||||
GpioController->RegisterBase = (UINTN) PcdGet32 (PcdPL061GpioBase);
|
||||
GpioController->RegisterBase = (UINTN)PcdGet32 (PcdPL061GpioBase);
|
||||
GpioController->GpioIndex = 0;
|
||||
GpioController->InternalGpioCount = PL061_GPIO_PINS;
|
||||
}
|
||||
|
||||
Status = PL061Identify();
|
||||
if (EFI_ERROR(Status)) {
|
||||
Status = PL061Identify ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
// Install the Embedded GPIO Protocol onto a new handle
|
||||
Handle = NULL;
|
||||
Status = gBS->InstallMultipleProtocolInterfaces(
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Handle,
|
||||
&gEmbeddedGpioProtocolGuid, &gGpio,
|
||||
&gEmbeddedGpioProtocolGuid,
|
||||
&gGpio,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef __PL061_GPIO_H__
|
||||
#define __PL061_GPIO_H__
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
@ -175,11 +174,11 @@ SP805RegisterHandler (
|
||||
IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction
|
||||
)
|
||||
{
|
||||
if (mWatchdogNotify == NULL && NotifyFunction == NULL) {
|
||||
if ((mWatchdogNotify == NULL) && (NotifyFunction == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (mWatchdogNotify != NULL && NotifyFunction != NULL) {
|
||||
if ((mWatchdogNotify != NULL) && (NotifyFunction != NULL)) {
|
||||
return EFI_ALREADY_STARTED;
|
||||
}
|
||||
|
||||
@ -363,8 +362,11 @@ SP805Initialize (
|
||||
EFI_HANDLE Handle;
|
||||
|
||||
// Find the interrupt controller protocol. ASSERT if not found.
|
||||
Status = gBS->LocateProtocol (&gHardwareInterruptProtocolGuid, NULL,
|
||||
(VOID **)&mInterrupt);
|
||||
Status = gBS->LocateProtocol (
|
||||
&gHardwareInterruptProtocolGuid,
|
||||
NULL,
|
||||
(VOID **)&mInterrupt
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
// Unlock access to the SP805 registers
|
||||
@ -386,17 +388,26 @@ SP805Initialize (
|
||||
SP805Lock ();
|
||||
|
||||
if (PcdGet32 (PcdSP805WatchdogInterrupt) > 0) {
|
||||
Status = mInterrupt->RegisterInterruptSource (mInterrupt,
|
||||
Status = mInterrupt->RegisterInterruptSource (
|
||||
mInterrupt,
|
||||
PcdGet32 (PcdSP805WatchdogInterrupt),
|
||||
SP805InterruptHandler);
|
||||
SP805InterruptHandler
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to register watchdog interrupt - %r\n",
|
||||
__FUNCTION__, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: failed to register watchdog interrupt - %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
} else {
|
||||
DEBUG ((DEBUG_WARN, "%a: no interrupt specified, running in RESET mode only\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: no interrupt specified, running in RESET mode only\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
}
|
||||
|
||||
//
|
||||
@ -406,8 +417,13 @@ SP805Initialize (
|
||||
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiWatchdogTimerArchProtocolGuid);
|
||||
|
||||
// Register for an ExitBootServicesEvent
|
||||
Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY,
|
||||
ExitBootServicesEvent, NULL, &mEfiExitBootServicesEvent);
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_SIGNAL_EXIT_BOOT_SERVICES,
|
||||
TPL_NOTIFY,
|
||||
ExitBootServicesEvent,
|
||||
NULL,
|
||||
&mEfiExitBootServicesEvent
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto EXIT;
|
||||
@ -417,7 +433,8 @@ SP805Initialize (
|
||||
Handle = NULL;
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Handle,
|
||||
&gEfiWatchdogTimerArchProtocolGuid, &mWatchdogTimer,
|
||||
&gEfiWatchdogTimerArchProtocolGuid,
|
||||
&mWatchdogTimer,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef __SP805_WATCHDOG_H__
|
||||
#define __SP805_WATCHDOG_H__
|
||||
|
||||
|
@ -117,7 +117,7 @@ ArmPlatformInitialize (
|
||||
**/
|
||||
VOID
|
||||
ArmPlatformGetVirtualMemoryMap (
|
||||
OUT ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap
|
||||
OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -242,8 +242,8 @@ LcdPlatformInitializeDisplay (
|
||||
**/
|
||||
EFI_STATUS
|
||||
LcdPlatformGetVram (
|
||||
OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
|
||||
OUT UINTN* VramSize
|
||||
OUT EFI_PHYSICAL_ADDRESS *VramBaseAddress,
|
||||
OUT UINTN *VramSize
|
||||
);
|
||||
|
||||
/** Return total number of modes supported.
|
||||
@ -321,7 +321,7 @@ LcdPlatformGetTimings (
|
||||
EFI_STATUS
|
||||
LcdPlatformGetBpp (
|
||||
IN UINT32 ModeNumber,
|
||||
OUT LCD_BPP* Bpp
|
||||
OUT LCD_BPP *Bpp
|
||||
);
|
||||
|
||||
#endif /* LCD_PLATFORM_LIB_H_ */
|
||||
|
@ -25,7 +25,9 @@ STATIC UINT32 mDpDeviceId;
|
||||
**/
|
||||
STATIC
|
||||
VOID
|
||||
LayerGraphicsDisable (VOID)
|
||||
LayerGraphicsDisable (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
MmioAnd32 (DP_BASE + DP_DE_LG_CONTROL, ~DP_DE_LG_ENABLE);
|
||||
}
|
||||
@ -36,7 +38,9 @@ LayerGraphicsDisable (VOID)
|
||||
**/
|
||||
STATIC
|
||||
VOID
|
||||
LayerGraphicsEnable (VOID)
|
||||
LayerGraphicsEnable (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
MmioOr32 (DP_BASE + DP_DE_LG_CONTROL, DP_DE_LG_ENABLE);
|
||||
}
|
||||
@ -134,8 +138,8 @@ LayerGraphicsConfig (
|
||||
STATIC
|
||||
VOID
|
||||
SetDisplayEngineTiming (
|
||||
IN CONST SCAN_TIMINGS * CONST Horizontal,
|
||||
IN CONST SCAN_TIMINGS * CONST Vertical
|
||||
IN CONST SCAN_TIMINGS *CONST Horizontal,
|
||||
IN CONST SCAN_TIMINGS *CONST Vertical
|
||||
)
|
||||
{
|
||||
UINTN RegHIntervals;
|
||||
@ -227,9 +231,12 @@ ArmMaliDpGetCoreId (
|
||||
on the platform.
|
||||
**/
|
||||
EFI_STATUS
|
||||
LcdIdentify (VOID)
|
||||
LcdIdentify (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
DEBUG ((DEBUG_WARN,
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"Probing ARM Mali DP500/DP550/DP650 at base address 0x%p\n",
|
||||
DP_BASE
|
||||
));
|
||||
@ -266,8 +273,11 @@ LcdInitialize (
|
||||
}
|
||||
|
||||
if (mDpDeviceId == MALIDP_NOT_PRESENT) {
|
||||
DEBUG ((DEBUG_ERROR, "ARM Mali DP initialization failed,"
|
||||
"no ARM Mali DP present\n"));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"ARM Mali DP initialization failed,"
|
||||
"no ARM Mali DP present\n"
|
||||
));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -285,7 +295,9 @@ LcdInitialize (
|
||||
**/
|
||||
STATIC
|
||||
VOID
|
||||
SetConfigurationMode (VOID)
|
||||
SetConfigurationMode (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
// Request configuration Mode.
|
||||
if (mDpDeviceId == MALIDP_500) {
|
||||
@ -303,7 +315,9 @@ SetConfigurationMode (VOID)
|
||||
**/
|
||||
STATIC
|
||||
VOID
|
||||
SetNormalMode (VOID)
|
||||
SetNormalMode (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
// Disable configuration Mode.
|
||||
if (mDpDeviceId == MALIDP_500) {
|
||||
@ -321,7 +335,9 @@ SetNormalMode (VOID)
|
||||
**/
|
||||
STATIC
|
||||
VOID
|
||||
SetConfigValid (VOID)
|
||||
SetConfigValid (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
if (mDpDeviceId == MALIDP_500) {
|
||||
MmioOr32 (DP_BASE + DP_DP500_CONFIG_VALID, DP_DC_CONFIG_VALID);
|
||||
@ -396,7 +412,9 @@ LcdSetMode (
|
||||
|
||||
**/
|
||||
VOID
|
||||
LcdShutdown (VOID)
|
||||
LcdShutdown (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
// Disable graphics layer.
|
||||
LayerGraphicsDisable ();
|
||||
|
@ -6,6 +6,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef ARMMALIDP_H_
|
||||
#define ARMMALIDP_H_
|
||||
|
||||
@ -180,7 +181,7 @@
|
||||
#define DP_DE_BG_R_PIXEL_SHIFT 16
|
||||
#define DP_DE_BG_G_PIXEL_SHIFT 8
|
||||
|
||||
//Graphics layer LG_FORMAT Pixel Format
|
||||
// Graphics layer LG_FORMAT Pixel Format
|
||||
#define DP_PIXEL_FORMAT_ARGB_8888 0x8
|
||||
#define DP_PIXEL_FORMAT_ABGR_8888 0x9
|
||||
#define DP_PIXEL_FORMAT_RGBA_8888 0xA
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include <Ppi/ArmMpCoreInfo.h>
|
||||
|
||||
|
||||
ARM_CORE_INFO mArmPlatformNullMpCoreInfoTable[] = {
|
||||
{
|
||||
// Cluster 0, Core 0
|
||||
@ -95,7 +94,7 @@ ArmPlatformInitialize (
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
//TODO: Implement me
|
||||
// TODO: Implement me
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
@ -106,8 +105,8 @@ PrePeiCoreGetMpCoreInfo (
|
||||
OUT ARM_CORE_INFO **ArmCoreTable
|
||||
)
|
||||
{
|
||||
if (ArmIsMpCore()) {
|
||||
*CoreCount = sizeof(mArmPlatformNullMpCoreInfoTable) / sizeof(ARM_CORE_INFO);
|
||||
if (ArmIsMpCore ()) {
|
||||
*CoreCount = sizeof (mArmPlatformNullMpCoreInfoTable) / sizeof (ARM_CORE_INFO);
|
||||
*ArmCoreTable = mArmPlatformNullMpCoreInfoTable;
|
||||
return EFI_SUCCESS;
|
||||
} else {
|
||||
@ -131,12 +130,11 @@ ArmPlatformGetPlatformPpiList (
|
||||
OUT EFI_PEI_PPI_DESCRIPTOR **PpiList
|
||||
)
|
||||
{
|
||||
if (ArmIsMpCore()) {
|
||||
*PpiListSize = sizeof(gPlatformPpiTable);
|
||||
if (ArmIsMpCore ()) {
|
||||
*PpiListSize = sizeof (gPlatformPpiTable);
|
||||
*PpiList = gPlatformPpiTable;
|
||||
} else {
|
||||
*PpiListSize = 0;
|
||||
*PpiList = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
**/
|
||||
VOID
|
||||
ArmPlatformGetVirtualMemoryMap (
|
||||
IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap
|
||||
IN ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
|
||||
)
|
||||
{
|
||||
ASSERT(0);
|
||||
ASSERT (0);
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ LcdPlatformInitializeDisplay (
|
||||
**/
|
||||
EFI_STATUS
|
||||
LcdPlatformGetVram (
|
||||
OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
|
||||
OUT UINTN* VramSize
|
||||
OUT EFI_PHYSICAL_ADDRESS *VramBaseAddress,
|
||||
OUT UINTN *VramSize
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
@ -137,7 +137,7 @@ LcdPlatformGetTimings (
|
||||
EFI_STATUS
|
||||
LcdPlatformGetBpp (
|
||||
IN UINT32 ModeNumber,
|
||||
OUT LCD_BPP* Bpp
|
||||
OUT LCD_BPP *Bpp
|
||||
)
|
||||
{
|
||||
ASSERT (FALSE);
|
||||
|
@ -39,11 +39,11 @@ SerialPortInitialize (
|
||||
ReceiveFifoDepth = 0; // Use default FIFO depth
|
||||
Parity = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity);
|
||||
DataBits = FixedPcdGet8 (PcdUartDefaultDataBits);
|
||||
StopBits = (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefaultStopBits);
|
||||
StopBits = (EFI_STOP_BITS_TYPE)FixedPcdGet8 (PcdUartDefaultStopBits);
|
||||
|
||||
return PL011UartInitializePort (
|
||||
(UINTN)PcdGet64 (PcdSerialRegisterBase),
|
||||
PL011UartClockGetFreq(),
|
||||
PL011UartClockGetFreq (),
|
||||
&BaudRate,
|
||||
&ReceiveFifoDepth,
|
||||
&Parity,
|
||||
@ -87,7 +87,7 @@ EFIAPI
|
||||
SerialPortRead (
|
||||
OUT UINT8 *Buffer,
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
)
|
||||
{
|
||||
return PL011UartRead ((UINTN)PcdGet64 (PcdSerialRegisterBase), Buffer, NumberOfBytes);
|
||||
}
|
||||
@ -107,6 +107,7 @@ SerialPortPoll (
|
||||
{
|
||||
return PL011UartPoll ((UINTN)PcdGet64 (PcdSerialRegisterBase));
|
||||
}
|
||||
|
||||
/**
|
||||
Set new attributes to PL011.
|
||||
|
||||
@ -151,7 +152,7 @@ SerialPortSetAttributes (
|
||||
{
|
||||
return PL011UartInitializePort (
|
||||
(UINTN)PcdGet64 (PcdSerialRegisterBase),
|
||||
PL011UartClockGetFreq(),
|
||||
PL011UartClockGetFreq (),
|
||||
BaudRate,
|
||||
ReceiveFifoDepth,
|
||||
Parity,
|
||||
|
@ -116,7 +116,7 @@ PL011UartInitializePort (
|
||||
LineControl |= PL011_UARTLCR_H_PEN;
|
||||
break;
|
||||
case MarkParity:
|
||||
LineControl |= ( PL011_UARTLCR_H_PEN \
|
||||
LineControl |= (PL011_UARTLCR_H_PEN \
|
||||
| PL011_UARTLCR_H_SPS \
|
||||
| PL011_UARTLCR_H_EPS);
|
||||
break;
|
||||
@ -188,6 +188,7 @@ PL011UartInitializePort (
|
||||
return RETURN_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == UartClkInHz) {
|
||||
return RETURN_INVALID_PARAMETER;
|
||||
}
|
||||
@ -204,13 +205,15 @@ PL011UartInitializePort (
|
||||
if (((MmioRead32 (UartBase + UARTCR) & PL011_UARTCR_UARTEN) != 0) &&
|
||||
(MmioRead32 (UartBase + UARTLCR_H) == LineControl) &&
|
||||
(MmioRead32 (UartBase + UARTIBRD) == Integer) &&
|
||||
(MmioRead32 (UartBase + UARTFBRD) == Fractional)) {
|
||||
(MmioRead32 (UartBase + UARTFBRD) == Fractional))
|
||||
{
|
||||
// Nothing to do - already initialized with correct attributes
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
// Wait for the end of transmission
|
||||
while ((MmioRead32 (UartBase + UARTFR) & PL011_UARTFR_TXFE) == 0);
|
||||
while ((MmioRead32 (UartBase + UARTFR) & PL011_UARTFR_TXFE) == 0) {
|
||||
}
|
||||
|
||||
// Disable UART: "The UARTLCR_H, UARTIBRD, and UARTFBRD registers must not be changed
|
||||
// when the UART is enabled"
|
||||
@ -227,8 +230,10 @@ PL011UartInitializePort (
|
||||
MmioWrite32 (UartBase + UARTECR, 0);
|
||||
|
||||
// Enable Tx, Rx, and UART overall
|
||||
MmioWrite32 (UartBase + UARTCR,
|
||||
PL011_UARTCR_RXE | PL011_UARTCR_TXE | PL011_UARTCR_UARTEN);
|
||||
MmioWrite32 (
|
||||
UartBase + UARTCR,
|
||||
PL011_UARTCR_RXE | PL011_UARTCR_TXE | PL011_UARTCR_UARTEN
|
||||
);
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
@ -347,7 +352,6 @@ PL011UartGetControl (
|
||||
UINT32 FlagRegister;
|
||||
UINT32 ControlRegister;
|
||||
|
||||
|
||||
FlagRegister = MmioRead32 (UartBase + UARTFR);
|
||||
ControlRegister = MmioRead32 (UartBase + UARTCR);
|
||||
|
||||
@ -386,7 +390,8 @@ PL011UartGetControl (
|
||||
}
|
||||
|
||||
if ((ControlRegister & (PL011_UARTCR_CTSEN | PL011_UARTCR_RTSEN))
|
||||
== (PL011_UARTCR_CTSEN | PL011_UARTCR_RTSEN)) {
|
||||
== (PL011_UARTCR_CTSEN | PL011_UARTCR_RTSEN))
|
||||
{
|
||||
*Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;
|
||||
}
|
||||
|
||||
@ -415,11 +420,12 @@ PL011UartWrite (
|
||||
IN UINTN NumberOfBytes
|
||||
)
|
||||
{
|
||||
UINT8* CONST Final = &Buffer[NumberOfBytes];
|
||||
UINT8 *CONST Final = &Buffer[NumberOfBytes];
|
||||
|
||||
while (Buffer < Final) {
|
||||
// Wait until UART able to accept another char
|
||||
while ((MmioRead32 (UartBase + UARTFR) & UART_TX_FULL_FLAG_MASK));
|
||||
while ((MmioRead32 (UartBase + UARTFR) & UART_TX_FULL_FLAG_MASK)) {
|
||||
}
|
||||
|
||||
MmioWrite8 (UartBase + UARTDR, *Buffer++);
|
||||
}
|
||||
@ -448,7 +454,9 @@ PL011UartRead (
|
||||
UINTN Count;
|
||||
|
||||
for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) {
|
||||
while ((MmioRead32 (UartBase + UARTFR) & UART_RX_EMPTY_FLAG_MASK) != 0);
|
||||
while ((MmioRead32 (UartBase + UARTFR) & UART_RX_EMPTY_FLAG_MASK) != 0) {
|
||||
}
|
||||
|
||||
*Buffer = MmioRead8 (UartBase + UARTDR);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef __PL031_REAL_TIME_CLOCK_H__
|
||||
#define __PL031_REAL_TIME_CLOCK_H__
|
||||
|
||||
|
@ -46,7 +46,8 @@ IdentifyPL031 (
|
||||
if ( (MmioRead8 (mPL031RtcBase + PL031_RTC_PCELL_ID0) != 0x0D)
|
||||
|| (MmioRead8 (mPL031RtcBase + PL031_RTC_PCELL_ID1) != 0xF0)
|
||||
|| (MmioRead8 (mPL031RtcBase + PL031_RTC_PCELL_ID2) != 0x05)
|
||||
|| (MmioRead8 (mPL031RtcBase + PL031_RTC_PCELL_ID3) != 0xB1)) {
|
||||
|| (MmioRead8 (mPL031RtcBase + PL031_RTC_PCELL_ID3) != 0xB1))
|
||||
{
|
||||
Status = EFI_NOT_FOUND;
|
||||
goto EXIT;
|
||||
}
|
||||
@ -55,14 +56,15 @@ IdentifyPL031 (
|
||||
if ( (MmioRead8 (mPL031RtcBase + PL031_RTC_PERIPH_ID0) != 0x31)
|
||||
|| (MmioRead8 (mPL031RtcBase + PL031_RTC_PERIPH_ID1) != 0x10)
|
||||
|| ((MmioRead8 (mPL031RtcBase + PL031_RTC_PERIPH_ID2) & 0xF) != 0x04)
|
||||
|| (MmioRead8 (mPL031RtcBase + PL031_RTC_PERIPH_ID3) != 0x00)) {
|
||||
|| (MmioRead8 (mPL031RtcBase + PL031_RTC_PERIPH_ID3) != 0x00))
|
||||
{
|
||||
Status = EFI_NOT_FOUND;
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
EXIT:
|
||||
EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -74,7 +76,7 @@ InitializePL031 (
|
||||
EFI_STATUS Status;
|
||||
|
||||
// Prepare the hardware
|
||||
Status = IdentifyPL031();
|
||||
Status = IdentifyPL031 ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto EXIT;
|
||||
}
|
||||
@ -96,7 +98,7 @@ InitializePL031 (
|
||||
|
||||
mPL031Initialized = TRUE;
|
||||
|
||||
EXIT:
|
||||
EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -164,7 +166,6 @@ LibGetTime (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sets the current local time and date information.
|
||||
|
||||
@ -217,7 +218,6 @@ LibSetTime (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns the current wakeup alarm clock setting.
|
||||
|
||||
@ -242,7 +242,6 @@ LibGetWakeupTime (
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sets the system wakeup alarm clock time.
|
||||
|
||||
@ -288,7 +287,7 @@ LibRtcVirtualNotifyEvent (
|
||||
// to virtual address. After the OS transitions to calling in virtual mode, all future
|
||||
// runtime calls will be made in virtual mode.
|
||||
//
|
||||
EfiConvertPointer (0x0, (VOID**)&mPL031RtcBase);
|
||||
EfiConvertPointer (0x0, (VOID **)&mPL031RtcBase);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -318,7 +317,8 @@ LibRtcInitialize (
|
||||
// Declare the controller as EFI_MEMORY_RUNTIME
|
||||
Status = gDS->AddMemorySpace (
|
||||
EfiGcdMemoryTypeMemoryMappedIo,
|
||||
mPL031RtcBase, SIZE_4KB,
|
||||
mPL031RtcBase,
|
||||
SIZE_4KB,
|
||||
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -334,7 +334,8 @@ LibRtcInitialize (
|
||||
Handle = NULL;
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Handle,
|
||||
&gEfiRealTimeClockArchProtocolGuid, NULL,
|
||||
&gEfiRealTimeClockArchProtocolGuid,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
@ -26,20 +26,25 @@ LcdIdentify (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
DEBUG ((DEBUG_WARN, "Probing ID registers at 0x%lx for a PL111\n",
|
||||
PL111_REG_CLCD_PERIPH_ID_0));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"Probing ID registers at 0x%lx for a PL111\n",
|
||||
PL111_REG_CLCD_PERIPH_ID_0
|
||||
));
|
||||
|
||||
// Check if this is a PL111
|
||||
if (MmioRead8 (PL111_REG_CLCD_PERIPH_ID_0) == PL111_CLCD_PERIPH_ID_0 &&
|
||||
MmioRead8 (PL111_REG_CLCD_PERIPH_ID_1) == PL111_CLCD_PERIPH_ID_1 &&
|
||||
(MmioRead8 (PL111_REG_CLCD_PERIPH_ID_2) & 0xf) == PL111_CLCD_PERIPH_ID_2 &&
|
||||
MmioRead8 (PL111_REG_CLCD_PERIPH_ID_3) == PL111_CLCD_PERIPH_ID_3 &&
|
||||
MmioRead8 (PL111_REG_CLCD_P_CELL_ID_0) == PL111_CLCD_P_CELL_ID_0 &&
|
||||
MmioRead8 (PL111_REG_CLCD_P_CELL_ID_1) == PL111_CLCD_P_CELL_ID_1 &&
|
||||
MmioRead8 (PL111_REG_CLCD_P_CELL_ID_2) == PL111_CLCD_P_CELL_ID_2 &&
|
||||
MmioRead8 (PL111_REG_CLCD_P_CELL_ID_3) == PL111_CLCD_P_CELL_ID_3) {
|
||||
if ((MmioRead8 (PL111_REG_CLCD_PERIPH_ID_0) == PL111_CLCD_PERIPH_ID_0) &&
|
||||
(MmioRead8 (PL111_REG_CLCD_PERIPH_ID_1) == PL111_CLCD_PERIPH_ID_1) &&
|
||||
((MmioRead8 (PL111_REG_CLCD_PERIPH_ID_2) & 0xf) == PL111_CLCD_PERIPH_ID_2) &&
|
||||
(MmioRead8 (PL111_REG_CLCD_PERIPH_ID_3) == PL111_CLCD_PERIPH_ID_3) &&
|
||||
(MmioRead8 (PL111_REG_CLCD_P_CELL_ID_0) == PL111_CLCD_P_CELL_ID_0) &&
|
||||
(MmioRead8 (PL111_REG_CLCD_P_CELL_ID_1) == PL111_CLCD_P_CELL_ID_1) &&
|
||||
(MmioRead8 (PL111_REG_CLCD_P_CELL_ID_2) == PL111_CLCD_P_CELL_ID_2) &&
|
||||
(MmioRead8 (PL111_REG_CLCD_P_CELL_ID_3) == PL111_CLCD_P_CELL_ID_3))
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -148,6 +153,7 @@ LcdSetMode (
|
||||
if (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
|
||||
LcdControl |= PL111_CTRL_BGR;
|
||||
}
|
||||
|
||||
MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
@ -61,10 +61,10 @@
|
||||
/**********************************************************************/
|
||||
|
||||
// Register: PL111_REG_LCD_TIMING_0
|
||||
#define HOR_AXIS_PANEL(hbp,hfp,hsw,hor_res) (UINT32)(((UINT32)(hbp) << 24) | ((UINT32)(hfp) << 16) | ((UINT32)(hsw) << 8) | (((UINT32)((hor_res)/16)-1) << 2))
|
||||
#define HOR_AXIS_PANEL(hbp, hfp, hsw, hor_res) (UINT32)(((UINT32)(hbp) << 24) | ((UINT32)(hfp) << 16) | ((UINT32)(hsw) << 8) | (((UINT32)((hor_res)/16)-1) << 2))
|
||||
|
||||
// Register: PL111_REG_LCD_TIMING_1
|
||||
#define VER_AXIS_PANEL(vbp,vfp,vsw,ver_res) (UINT32)(((UINT32)(vbp) << 24) | ((UINT32)(vfp) << 16) | ((UINT32)(vsw) << 10) | ((ver_res)-1))
|
||||
#define VER_AXIS_PANEL(vbp, vfp, vsw, ver_res) (UINT32)(((UINT32)(vbp) << 24) | ((UINT32)(vfp) << 16) | ((UINT32)(vsw) << 10) | ((ver_res)-1))
|
||||
|
||||
// Register: PL111_REG_LCD_TIMING_2
|
||||
#define PL111_BIT_SHIFT_PCD_HI 27
|
||||
|
@ -25,11 +25,9 @@ PrePeiGetHobList (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return (VOID *)ArmReadTpidrurw();
|
||||
return (VOID *)ArmReadTpidrurw ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Updates the pointer to the HOB list.
|
||||
|
||||
@ -42,7 +40,7 @@ PrePeiSetHobList (
|
||||
IN VOID *HobList
|
||||
)
|
||||
{
|
||||
ArmWriteTpidrurw((UINTN)HobList);
|
||||
ArmWriteTpidrurw ((UINTN)HobList);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -26,12 +26,11 @@ InitMmu (
|
||||
IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable
|
||||
)
|
||||
{
|
||||
|
||||
VOID *TranslationTableBase;
|
||||
UINTN TranslationTableSize;
|
||||
RETURN_STATUS Status;
|
||||
|
||||
//Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table resides in
|
||||
// Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table resides in
|
||||
// DRAM (even at the top of DRAM as it is the first permanent memory allocation)
|
||||
Status = ArmConfigureMmu (MemoryTable, &TranslationTableBase, &TranslationTableSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -102,6 +101,7 @@ MemoryPeim (
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
NextHob.Raw = GET_NEXT_HOB (NextHob);
|
||||
}
|
||||
|
||||
@ -142,21 +142,25 @@ MemoryPeim (
|
||||
if (PcdGet64 (PcdFdBaseAddress) == NextHob.ResourceDescriptor->PhysicalStart) {
|
||||
if (SystemMemoryTop != FdTop) {
|
||||
// Create the System Memory HOB for the firmware
|
||||
BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
BuildResourceDescriptorHob (
|
||||
EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
ResourceAttributes,
|
||||
PcdGet64 (PcdFdBaseAddress),
|
||||
PcdGet32 (PcdFdSize));
|
||||
PcdGet32 (PcdFdSize)
|
||||
);
|
||||
|
||||
// Top of the FD is system memory available for UEFI
|
||||
NextHob.ResourceDescriptor->PhysicalStart += PcdGet32(PcdFdSize);
|
||||
NextHob.ResourceDescriptor->ResourceLength -= PcdGet32(PcdFdSize);
|
||||
NextHob.ResourceDescriptor->PhysicalStart += PcdGet32 (PcdFdSize);
|
||||
NextHob.ResourceDescriptor->ResourceLength -= PcdGet32 (PcdFdSize);
|
||||
}
|
||||
} else {
|
||||
// Create the System Memory HOB for the firmware
|
||||
BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
BuildResourceDescriptorHob (
|
||||
EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
ResourceAttributes,
|
||||
PcdGet64 (PcdFdBaseAddress),
|
||||
PcdGet32 (PcdFdSize));
|
||||
PcdGet32 (PcdFdSize)
|
||||
);
|
||||
|
||||
// Update the HOB
|
||||
NextHob.ResourceDescriptor->ResourceLength = PcdGet64 (PcdFdBaseAddress) - NextHob.ResourceDescriptor->PhysicalStart;
|
||||
@ -164,25 +168,30 @@ MemoryPeim (
|
||||
// If there is some memory available on the top of the FD then create a HOB
|
||||
if (FdTop < NextHob.ResourceDescriptor->PhysicalStart + ResourceLength) {
|
||||
// Create the System Memory HOB for the remaining region (top of the FD)
|
||||
BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
BuildResourceDescriptorHob (
|
||||
EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
ResourceAttributes,
|
||||
FdTop,
|
||||
ResourceTop - FdTop);
|
||||
ResourceTop - FdTop
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the memory covering the Firmware Device as boot services data
|
||||
BuildMemoryAllocationHob (PcdGet64 (PcdFdBaseAddress),
|
||||
BuildMemoryAllocationHob (
|
||||
PcdGet64 (PcdFdBaseAddress),
|
||||
PcdGet32 (PcdFdSize),
|
||||
EfiBootServicesData);
|
||||
EfiBootServicesData
|
||||
);
|
||||
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
NextHob.Raw = GET_NEXT_HOB (NextHob);
|
||||
}
|
||||
|
||||
ASSERT(Found);
|
||||
ASSERT (Found);
|
||||
}
|
||||
|
||||
// Build Memory Allocation Hob
|
||||
|
@ -106,6 +106,7 @@ InitializeMemory (
|
||||
if (SystemMemoryTop - 1 > MAX_ALLOC_ADDRESS) {
|
||||
SystemMemoryTop = (UINT64)MAX_ALLOC_ADDRESS + 1;
|
||||
}
|
||||
|
||||
FdBase = (UINTN)PcdGet64 (PcdFdBaseAddress);
|
||||
FdTop = FdBase + (UINTN)PcdGet32 (PcdFdSize);
|
||||
|
||||
|
@ -23,24 +23,24 @@ PeiCommonExceptionEntry (
|
||||
|
||||
switch (Entry) {
|
||||
case EXCEPT_AARCH64_SYNCHRONOUS_EXCEPTIONS:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Synchronous Exception at 0x%X\n\r", LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "Synchronous Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
case EXCEPT_AARCH64_IRQ:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"IRQ Exception at 0x%X\n\r", LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "IRQ Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
case EXCEPT_AARCH64_FIQ:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"FIQ Exception at 0x%X\n\r", LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "FIQ Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
case EXCEPT_AARCH64_SERROR:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"SError/Abort Exception at 0x%X\n\r", LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "SError/Abort Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
default:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Unknown Exception at 0x%X\n\r", LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "Unknown Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
}
|
||||
|
||||
SerialPortWrite ((UINT8 *) Buffer, CharCount);
|
||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||
|
||||
while(1);
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,34 +23,35 @@ PeiCommonExceptionEntry (
|
||||
|
||||
switch (Entry) {
|
||||
case 0:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Reset Exception at 0x%X\n\r",LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "Reset Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
case 1:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Undefined Exception at 0x%X\n\r",LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "Undefined Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
case 2:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"SWI Exception at 0x%X\n\r",LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "SWI Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
case 3:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"PrefetchAbort Exception at 0x%X\n\r",LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "PrefetchAbort Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
case 4:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"DataAbort Exception at 0x%X\n\r",LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "DataAbort Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
case 5:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Reserved Exception at 0x%X\n\r",LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "Reserved Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
case 6:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"IRQ Exception at 0x%X\n\r",LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "IRQ Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
case 7:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"FIQ Exception at 0x%X\n\r",LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "FIQ Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
default:
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Unknown Exception at 0x%X\n\r",LR);
|
||||
CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "Unknown Exception at 0x%X\n\r", LR);
|
||||
break;
|
||||
}
|
||||
SerialPortWrite ((UINT8 *) Buffer, CharCount);
|
||||
while(1);
|
||||
}
|
||||
|
||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
@ -37,18 +37,21 @@ SecondaryMain (
|
||||
ARM_CORE_INFO *ArmCoreInfoTable;
|
||||
UINT32 ClusterId;
|
||||
UINT32 CoreId;
|
||||
VOID (*SecondaryStart)(VOID);
|
||||
|
||||
VOID (*SecondaryStart)(
|
||||
VOID
|
||||
);
|
||||
UINTN SecondaryEntryAddr;
|
||||
UINTN AcknowledgeInterrupt;
|
||||
UINTN InterruptId;
|
||||
|
||||
ClusterId = GET_CLUSTER_ID(MpId);
|
||||
CoreId = GET_CORE_ID(MpId);
|
||||
ClusterId = GET_CLUSTER_ID (MpId);
|
||||
CoreId = GET_CORE_ID (MpId);
|
||||
|
||||
// Get the gArmMpCoreInfoPpiGuid
|
||||
PpiListSize = 0;
|
||||
ArmPlatformGetPlatformPpiList (&PpiListSize, &PpiList);
|
||||
PpiListCount = PpiListSize / sizeof(EFI_PEI_PPI_DESCRIPTOR);
|
||||
PpiListCount = PpiListSize / sizeof (EFI_PEI_PPI_DESCRIPTOR);
|
||||
for (Index = 0; Index < PpiListCount; Index++, PpiList++) {
|
||||
if (CompareGuid (PpiList->Guid, &gArmMpCoreInfoPpiGuid) == TRUE) {
|
||||
break;
|
||||
@ -92,11 +95,11 @@ SecondaryMain (
|
||||
} while (SecondaryEntryAddr == 0);
|
||||
|
||||
// Jump to secondary core entry point.
|
||||
SecondaryStart = (VOID (*)())SecondaryEntryAddr;
|
||||
SecondaryStart();
|
||||
SecondaryStart = (VOID (*)()) SecondaryEntryAddr;
|
||||
SecondaryStart ();
|
||||
|
||||
// The secondaries shouldn't reach here
|
||||
ASSERT(FALSE);
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
VOID
|
||||
@ -114,17 +117,17 @@ PrimaryMain (
|
||||
CreatePpiList (&PpiListSize, &PpiList);
|
||||
|
||||
// Enable the GIC Distributor
|
||||
ArmGicEnableDistributor (PcdGet64(PcdGicDistributorBase));
|
||||
ArmGicEnableDistributor (PcdGet64 (PcdGicDistributorBase));
|
||||
|
||||
// If ArmVe has not been built as Standalone then we need to wake up the secondary cores
|
||||
if (FeaturePcdGet (PcdSendSgiToBringUpSecondaryCores)) {
|
||||
// Sending SGI to all the Secondary CPU interfaces
|
||||
ArmGicSendSgiTo (PcdGet64(PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));
|
||||
ArmGicSendSgiTo (PcdGet64 (PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));
|
||||
}
|
||||
|
||||
// Adjust the Temporary Ram as the new Ppi List (Common + Platform Ppi Lists) is created at
|
||||
// the base of the primary core stack
|
||||
PpiListSize = ALIGN_VALUE(PpiListSize, CPU_STACK_ALIGNMENT);
|
||||
PpiListSize = ALIGN_VALUE (PpiListSize, CPU_STACK_ALIGNMENT);
|
||||
TemporaryRamBase = (UINTN)PcdGet64 (PcdCPUCoresStackBase) + PpiListSize;
|
||||
TemporaryRamSize = (UINTN)PcdGet32 (PcdCPUCorePrimaryStackSize) - PpiListSize;
|
||||
|
||||
@ -133,7 +136,7 @@ PrimaryMain (
|
||||
// Note: this must be in sync with the stuff in the asm file
|
||||
// Note also: HOBs (pei temp ram) MUST be above stack
|
||||
//
|
||||
SecCoreData.DataSize = sizeof(EFI_SEC_PEI_HAND_OFF);
|
||||
SecCoreData.DataSize = sizeof (EFI_SEC_PEI_HAND_OFF);
|
||||
SecCoreData.BootFirmwareVolumeBase = (VOID *)(UINTN)PcdGet64 (PcdFvBaseAddress);
|
||||
SecCoreData.BootFirmwareVolumeSize = PcdGet32 (PcdFvSize);
|
||||
SecCoreData.TemporaryRamBase = (VOID *)TemporaryRamBase; // We run on the primary core (and so we use the first stack)
|
||||
|
@ -14,7 +14,7 @@ SecondaryMain (
|
||||
IN UINTN MpId
|
||||
)
|
||||
{
|
||||
ASSERT(FALSE);
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
VOID
|
||||
@ -33,7 +33,7 @@ PrimaryMain (
|
||||
|
||||
// Adjust the Temporary Ram as the new Ppi List (Common + Platform Ppi Lists) is created at
|
||||
// the base of the primary core stack
|
||||
PpiListSize = ALIGN_VALUE(PpiListSize, CPU_STACK_ALIGNMENT);
|
||||
PpiListSize = ALIGN_VALUE (PpiListSize, CPU_STACK_ALIGNMENT);
|
||||
TemporaryRamBase = (UINTN)PcdGet64 (PcdCPUCoresStackBase) + PpiListSize;
|
||||
TemporaryRamSize = (UINTN)PcdGet32 (PcdCPUCorePrimaryStackSize) - PpiListSize;
|
||||
|
||||
@ -42,7 +42,7 @@ PrimaryMain (
|
||||
// Note: this must be in sync with the stuff in the asm file
|
||||
// Note also: HOBs (pei temp ram) MUST be above stack
|
||||
//
|
||||
SecCoreData.DataSize = sizeof(EFI_SEC_PEI_HAND_OFF);
|
||||
SecCoreData.DataSize = sizeof (EFI_SEC_PEI_HAND_OFF);
|
||||
SecCoreData.BootFirmwareVolumeBase = (VOID *)(UINTN)PcdGet64 (PcdFvBaseAddress);
|
||||
SecCoreData.BootFirmwareVolumeSize = PcdGet32 (PcdFvSize);
|
||||
SecCoreData.TemporaryRamBase = (VOID *)TemporaryRamBase; // We run on the primary core (and so we use the first stack)
|
||||
|
@ -20,7 +20,7 @@ CONST EFI_PEI_PPI_DESCRIPTOR gCommonPpiTable[] = {
|
||||
{
|
||||
EFI_PEI_PPI_DESCRIPTOR_PPI,
|
||||
&gEfiTemporaryRamSupportPpiGuid,
|
||||
(VOID *) &mTemporaryRamSupportPpi
|
||||
(VOID *)&mTemporaryRamSupportPpi
|
||||
}
|
||||
};
|
||||
|
||||
@ -41,15 +41,15 @@ CreatePpiList (
|
||||
|
||||
// Copy the Common and Platform PPis in Temporary Memory
|
||||
ListBase = PcdGet64 (PcdCPUCoresStackBase);
|
||||
CopyMem ((VOID*)ListBase, gCommonPpiTable, sizeof(gCommonPpiTable));
|
||||
CopyMem ((VOID*)(ListBase + sizeof(gCommonPpiTable)), PlatformPpiList, PlatformPpiListSize);
|
||||
CopyMem ((VOID *)ListBase, gCommonPpiTable, sizeof (gCommonPpiTable));
|
||||
CopyMem ((VOID *)(ListBase + sizeof (gCommonPpiTable)), PlatformPpiList, PlatformPpiListSize);
|
||||
|
||||
// Set the Terminate flag on the last PPI entry
|
||||
LastPpi = (EFI_PEI_PPI_DESCRIPTOR*)ListBase + ((sizeof(gCommonPpiTable) + PlatformPpiListSize) / sizeof(EFI_PEI_PPI_DESCRIPTOR)) - 1;
|
||||
LastPpi = (EFI_PEI_PPI_DESCRIPTOR *)ListBase + ((sizeof (gCommonPpiTable) + PlatformPpiListSize) / sizeof (EFI_PEI_PPI_DESCRIPTOR)) - 1;
|
||||
LastPpi->Flags |= EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
|
||||
|
||||
*PpiList = (EFI_PEI_PPI_DESCRIPTOR*)ListBase;
|
||||
*PpiListSize = sizeof(gCommonPpiTable) + PlatformPpiListSize;
|
||||
*PpiList = (EFI_PEI_PPI_DESCRIPTOR *)ListBase;
|
||||
*PpiListSize = sizeof (gCommonPpiTable) + PlatformPpiListSize;
|
||||
}
|
||||
|
||||
VOID
|
||||
@ -65,8 +65,10 @@ CEntryPoint (
|
||||
// Enable Instruction Caches on all cores.
|
||||
ArmEnableInstructionCache ();
|
||||
|
||||
InvalidateDataCacheRange ((VOID *)(UINTN)PcdGet64 (PcdCPUCoresStackBase),
|
||||
PcdGet32 (PcdCPUCorePrimaryStackSize));
|
||||
InvalidateDataCacheRange (
|
||||
(VOID *)(UINTN)PcdGet64 (PcdCPUCoresStackBase),
|
||||
PcdGet32 (PcdCPUCorePrimaryStackSize)
|
||||
);
|
||||
|
||||
//
|
||||
// Note: Doesn't have to Enable CPU interface in non-secure world,
|
||||
@ -84,7 +86,7 @@ CEntryPoint (
|
||||
ArmEnableVFP ();
|
||||
}
|
||||
|
||||
//Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on.
|
||||
// Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on.
|
||||
|
||||
// If not primary Jump to Secondary Main
|
||||
if (ArmPlatformIsPrimaryCore (MpId)) {
|
||||
@ -122,11 +124,11 @@ PrePeiCoreTemporaryRamSupport (
|
||||
|
||||
HeapSize = ALIGN_VALUE (CopySize / 2, CPU_STACK_ALIGNMENT);
|
||||
|
||||
OldHeap = (VOID*)(UINTN)TemporaryMemoryBase;
|
||||
NewHeap = (VOID*)((UINTN)PermanentMemoryBase + (CopySize - HeapSize));
|
||||
OldHeap = (VOID *)(UINTN)TemporaryMemoryBase;
|
||||
NewHeap = (VOID *)((UINTN)PermanentMemoryBase + (CopySize - HeapSize));
|
||||
|
||||
OldStack = (VOID*)((UINTN)TemporaryMemoryBase + HeapSize);
|
||||
NewStack = (VOID*)(UINTN)PermanentMemoryBase;
|
||||
OldStack = (VOID *)((UINTN)TemporaryMemoryBase + HeapSize);
|
||||
NewStack = (VOID *)(UINTN)PermanentMemoryBase;
|
||||
|
||||
//
|
||||
// Migrate the temporary memory stack to permanent memory stack.
|
||||
|
@ -6,6 +6,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __PREPEICORE_H_
|
||||
#define __PREPEICORE_H_
|
||||
|
||||
@ -40,7 +41,10 @@ SecSwitchStack (
|
||||
);
|
||||
|
||||
// Vector Table for Pei Phase
|
||||
VOID PeiVectorTable (VOID);
|
||||
VOID
|
||||
PeiVectorTable (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
|
@ -20,4 +20,3 @@ ArchInitialize (
|
||||
ArmEnableVFP ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,18 +20,18 @@ PrimaryMain (
|
||||
)
|
||||
{
|
||||
// Enable the GIC Distributor
|
||||
ArmGicEnableDistributor(PcdGet64(PcdGicDistributorBase));
|
||||
ArmGicEnableDistributor (PcdGet64 (PcdGicDistributorBase));
|
||||
|
||||
// In some cases, the secondary cores are waiting for an SGI from the next stage boot loader to resume their initialization
|
||||
if (!FixedPcdGet32(PcdSendSgiToBringUpSecondaryCores)) {
|
||||
if (!FixedPcdGet32 (PcdSendSgiToBringUpSecondaryCores)) {
|
||||
// Sending SGI to all the Secondary CPU interfaces
|
||||
ArmGicSendSgiTo (PcdGet64(PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));
|
||||
ArmGicSendSgiTo (PcdGet64 (PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId));
|
||||
}
|
||||
|
||||
PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);
|
||||
|
||||
// We must never return
|
||||
ASSERT(FALSE);
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
VOID
|
||||
@ -46,16 +46,19 @@ SecondaryMain (
|
||||
ARM_CORE_INFO *ArmCoreInfoTable;
|
||||
UINT32 ClusterId;
|
||||
UINT32 CoreId;
|
||||
VOID (*SecondaryStart)(VOID);
|
||||
|
||||
VOID (*SecondaryStart)(
|
||||
VOID
|
||||
);
|
||||
UINTN SecondaryEntryAddr;
|
||||
UINTN AcknowledgeInterrupt;
|
||||
UINTN InterruptId;
|
||||
|
||||
ClusterId = GET_CLUSTER_ID(MpId);
|
||||
CoreId = GET_CORE_ID(MpId);
|
||||
ClusterId = GET_CLUSTER_ID (MpId);
|
||||
CoreId = GET_CORE_ID (MpId);
|
||||
|
||||
// On MP Core Platform we must implement the ARM MP Core Info PPI (gArmMpCoreInfoPpiGuid)
|
||||
Status = GetPlatformPpi (&gArmMpCoreInfoPpiGuid, (VOID**)&ArmMpCoreInfoPpi);
|
||||
Status = GetPlatformPpi (&gArmMpCoreInfoPpiGuid, (VOID **)&ArmMpCoreInfoPpi);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
ArmCoreCount = 0;
|
||||
@ -91,9 +94,9 @@ SecondaryMain (
|
||||
} while (SecondaryEntryAddr == 0);
|
||||
|
||||
// Jump to secondary core entry point.
|
||||
SecondaryStart = (VOID (*)())SecondaryEntryAddr;
|
||||
SecondaryStart();
|
||||
SecondaryStart = (VOID (*)()) SecondaryEntryAddr;
|
||||
SecondaryStart ();
|
||||
|
||||
// The secondaries shouldn't reach here
|
||||
ASSERT(FALSE);
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ PrimaryMain (
|
||||
PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);
|
||||
|
||||
// We must never return
|
||||
ASSERT(FALSE);
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
VOID
|
||||
@ -27,6 +27,5 @@ SecondaryMain (
|
||||
)
|
||||
{
|
||||
// We must never get into this function on UniCore system
|
||||
ASSERT(FALSE);
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
|
@ -22,11 +22,11 @@
|
||||
|
||||
#include "PrePi.h"
|
||||
|
||||
#define IS_XIP() (((UINT64)FixedPcdGet64 (PcdFdBaseAddress) > mSystemMemoryEnd) || \
|
||||
#define IS_XIP() (((UINT64)FixedPcdGet64 (PcdFdBaseAddress) > mSystemMemoryEnd) ||\
|
||||
((FixedPcdGet64 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= FixedPcdGet64 (PcdSystemMemoryBase)))
|
||||
|
||||
UINT64 mSystemMemoryEnd = FixedPcdGet64(PcdSystemMemoryBase) +
|
||||
FixedPcdGet64(PcdSystemMemorySize) - 1;
|
||||
UINT64 mSystemMemoryEnd = FixedPcdGet64 (PcdSystemMemoryBase) +
|
||||
FixedPcdGet64 (PcdSystemMemorySize) - 1;
|
||||
|
||||
EFI_STATUS
|
||||
GetPlatformPpi (
|
||||
@ -41,7 +41,7 @@ GetPlatformPpi (
|
||||
|
||||
PpiListSize = 0;
|
||||
ArmPlatformGetPlatformPpiList (&PpiListSize, &PpiList);
|
||||
PpiListCount = PpiListSize / sizeof(EFI_PEI_PPI_DESCRIPTOR);
|
||||
PpiListCount = PpiListSize / sizeof (EFI_PEI_PPI_DESCRIPTOR);
|
||||
for (Index = 0; Index < PpiListCount; Index++, PpiList++) {
|
||||
if (CompareGuid (PpiList->Guid, PpiGuid) == TRUE) {
|
||||
*Ppi = PpiList->Ppi;
|
||||
@ -59,10 +59,10 @@ PrePiMain (
|
||||
IN UINT64 StartTimeStamp
|
||||
)
|
||||
{
|
||||
EFI_HOB_HANDOFF_INFO_TABLE* HobList;
|
||||
ARM_MP_CORE_INFO_PPI* ArmMpCoreInfoPpi;
|
||||
EFI_HOB_HANDOFF_INFO_TABLE *HobList;
|
||||
ARM_MP_CORE_INFO_PPI *ArmMpCoreInfoPpi;
|
||||
UINTN ArmCoreCount;
|
||||
ARM_CORE_INFO* ArmCoreInfoTable;
|
||||
ARM_CORE_INFO *ArmCoreInfoTable;
|
||||
EFI_STATUS Status;
|
||||
CHAR8 Buffer[100];
|
||||
UINTN CharCount;
|
||||
@ -70,18 +70,26 @@ PrePiMain (
|
||||
FIRMWARE_SEC_PERFORMANCE Performance;
|
||||
|
||||
// If ensure the FD is either part of the System Memory or totally outside of the System Memory (XIP)
|
||||
ASSERT (IS_XIP() ||
|
||||
ASSERT (
|
||||
IS_XIP () ||
|
||||
((FixedPcdGet64 (PcdFdBaseAddress) >= FixedPcdGet64 (PcdSystemMemoryBase)) &&
|
||||
((UINT64)(FixedPcdGet64 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= (UINT64)mSystemMemoryEnd)));
|
||||
((UINT64)(FixedPcdGet64 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= (UINT64)mSystemMemoryEnd))
|
||||
);
|
||||
|
||||
// Initialize the architecture specific bits
|
||||
ArchInitialize ();
|
||||
|
||||
// Initialize the Serial Port
|
||||
SerialPortInitialize ();
|
||||
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"UEFI firmware (version %s built at %a on %a)\n\r",
|
||||
(CHAR16*)PcdGetPtr(PcdFirmwareVersionString), __TIME__, __DATE__);
|
||||
SerialPortWrite ((UINT8 *) Buffer, CharCount);
|
||||
CharCount = AsciiSPrint (
|
||||
Buffer,
|
||||
sizeof (Buffer),
|
||||
"UEFI firmware (version %s built at %a on %a)\n\r",
|
||||
(CHAR16 *)PcdGetPtr (PcdFirmwareVersionString),
|
||||
__TIME__,
|
||||
__DATE__
|
||||
);
|
||||
SerialPortWrite ((UINT8 *)Buffer, CharCount);
|
||||
|
||||
// Initialize the Debug Agent for Source Level Debugging
|
||||
InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL);
|
||||
@ -89,10 +97,10 @@ PrePiMain (
|
||||
|
||||
// Declare the PI/UEFI memory region
|
||||
HobList = HobConstructor (
|
||||
(VOID*)UefiMemoryBase,
|
||||
(VOID *)UefiMemoryBase,
|
||||
FixedPcdGet32 (PcdSystemMemoryUefiRegionSize),
|
||||
(VOID*)UefiMemoryBase,
|
||||
(VOID*)StacksBase // The top of the UEFI Memory is reserved for the stacks
|
||||
(VOID *)UefiMemoryBase,
|
||||
(VOID *)StacksBase // The top of the UEFI Memory is reserved for the stacks
|
||||
);
|
||||
PrePeiSetHobList (HobList);
|
||||
|
||||
@ -107,14 +115,15 @@ PrePiMain (
|
||||
} else {
|
||||
StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
|
||||
}
|
||||
|
||||
BuildStackHob (StacksBase, StacksSize);
|
||||
|
||||
//TODO: Call CpuPei as a library
|
||||
// TODO: Call CpuPei as a library
|
||||
BuildCpuHob (ArmGetPhysicalAddressBits (), PcdGet8 (PcdPrePiCpuIoSize));
|
||||
|
||||
if (ArmIsMpCore ()) {
|
||||
// Only MP Core platform need to produce gArmMpCoreInfoPpiGuid
|
||||
Status = GetPlatformPpi (&gArmMpCoreInfoPpiGuid, (VOID**)&ArmMpCoreInfoPpi);
|
||||
Status = GetPlatformPpi (&gArmMpCoreInfoPpiGuid, (VOID **)&ArmMpCoreInfoPpi);
|
||||
|
||||
// On MP Core Platform we must implement the ARM MP Core Info PPI (gArmMpCoreInfoPpiGuid)
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
@ -122,7 +131,7 @@ PrePiMain (
|
||||
// Build the MP Core Info Table
|
||||
ArmCoreCount = 0;
|
||||
Status = ArmMpCoreInfoPpi->GetMpCoreInfo (&ArmCoreCount, &ArmCoreInfoTable);
|
||||
if (!EFI_ERROR(Status) && (ArmCoreCount > 0)) {
|
||||
if (!EFI_ERROR (Status) && (ArmCoreCount > 0)) {
|
||||
// Build MPCore Info HOB
|
||||
BuildGuidDataHob (&gArmMpCoreInfoGuid, ArmCoreInfoTable, sizeof (ARM_CORE_INFO) * ArmCoreCount);
|
||||
}
|
||||
@ -185,9 +194,9 @@ CEntryPoint (
|
||||
ArmEnableInstructionCache ();
|
||||
|
||||
// Define the Global Variable region when we are not running in XIP
|
||||
if (!IS_XIP()) {
|
||||
if (!IS_XIP ()) {
|
||||
if (ArmPlatformIsPrimaryCore (MpId)) {
|
||||
if (ArmIsMpCore()) {
|
||||
if (ArmIsMpCore ()) {
|
||||
// Signal the Global Variable Region is defined (event: ARM_CPU_EVENT_DEFAULT)
|
||||
ArmCallSEV ();
|
||||
}
|
||||
@ -199,9 +208,10 @@ CEntryPoint (
|
||||
|
||||
// If not primary Jump to Secondary Main
|
||||
if (ArmPlatformIsPrimaryCore (MpId)) {
|
||||
|
||||
InvalidateDataCacheRange ((VOID *)UefiMemoryBase,
|
||||
FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
|
||||
InvalidateDataCacheRange (
|
||||
(VOID *)UefiMemoryBase,
|
||||
FixedPcdGet32 (PcdSystemMemoryUefiRegionSize)
|
||||
);
|
||||
|
||||
// Goto primary Main.
|
||||
PrimaryMain (UefiMemoryBase, StacksBase, StartTimeStamp);
|
||||
|
Reference in New Issue
Block a user