]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c
Check the input VaraibleName for db/dbx when appending variables with formatted as...
[mirror_edk2.git] / ArmPlatformPkg / Drivers / NorFlashDxe / NorFlashBlockIoDxe.c
CommitLineData
1d5d0ae9 1/** @file NorFlashBlockIoDxe.c
2
68dda854 3 Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
4
1d5d0ae9 5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13**/
14
1d5d0ae9 15#include <Library/BaseMemoryLib.h>
16#include <Library/UefiBootServicesTableLib.h>
17
18#include "NorFlashDxe.h"
19
1d5d0ae9 20//
21// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.Reset
22//
23EFI_STATUS
24EFIAPI
25NorFlashBlockIoReset (
26 IN EFI_BLOCK_IO_PROTOCOL *This,
27 IN BOOLEAN ExtendedVerification
28 )
29{
1d5d0ae9 30 NOR_FLASH_INSTANCE *Instance;
31
32 Instance = INSTANCE_FROM_BLKIO_THIS(This);
33
34 DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoReset(MediaId=0x%x)\n", This->Media->MediaId));
35
68dda854 36 return NorFlashReset (Instance);
1d5d0ae9 37}
38
39//
40// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.ReadBlocks
41//
42EFI_STATUS
43EFIAPI
44NorFlashBlockIoReadBlocks (
45 IN EFI_BLOCK_IO_PROTOCOL *This,
46 IN UINT32 MediaId,
47 IN EFI_LBA Lba,
48 IN UINTN BufferSizeInBytes,
49 OUT VOID *Buffer
50 )
51{
d5e12da4 52 NOR_FLASH_INSTANCE *Instance;
53 EFI_STATUS Status;
1d5d0ae9 54
55 Instance = INSTANCE_FROM_BLKIO_THIS(This);
56
57 DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoReadBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes (%d kB), BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, Buffer));
58
d5e12da4 59 if( !This->Media->MediaPresent ) {
60 Status = EFI_NO_MEDIA;
61 } else if( This->Media->MediaId != MediaId ) {
62 Status = EFI_MEDIA_CHANGED;
63 } else {
68dda854 64 Status = NorFlashReadBlocks (Instance,Lba,BufferSizeInBytes,Buffer);
d5e12da4 65 }
66
67 return Status;
1d5d0ae9 68}
69
70//
71// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.WriteBlocks
72//
73EFI_STATUS
74EFIAPI
75NorFlashBlockIoWriteBlocks (
76 IN EFI_BLOCK_IO_PROTOCOL *This,
77 IN UINT32 MediaId,
78 IN EFI_LBA Lba,
79 IN UINTN BufferSizeInBytes,
80 IN VOID *Buffer
81 )
82{
d5e12da4 83 NOR_FLASH_INSTANCE *Instance;
84 EFI_STATUS Status;
1d5d0ae9 85
86 Instance = INSTANCE_FROM_BLKIO_THIS(This);
87
88 DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoWriteBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes (%d kB), BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, Buffer));
89
d5e12da4 90 if( !This->Media->MediaPresent ) {
91 Status = EFI_NO_MEDIA;
92 } else if( This->Media->MediaId != MediaId ) {
93 Status = EFI_MEDIA_CHANGED;
94 } else if( This->Media->ReadOnly ) {
95 Status = EFI_WRITE_PROTECTED;
96 } else {
68dda854 97 Status = NorFlashWriteBlocks (Instance,Lba,BufferSizeInBytes,Buffer);
d5e12da4 98 }
99
100 return Status;
1d5d0ae9 101}
102
103//
104// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.FlushBlocks
105//
106EFI_STATUS
107EFIAPI
108NorFlashBlockIoFlushBlocks (
109 IN EFI_BLOCK_IO_PROTOCOL *This
110 )
111{
112 // No Flush required for the NOR Flash driver
113 // because cache operations are not permitted.
114
115 DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoFlushBlocks: Function NOT IMPLEMENTED (not required).\n"));
116
117 // Nothing to do so just return without error
118 return EFI_SUCCESS;
119}