]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c
ARM Packages: Fixed line endings
[mirror_edk2.git] / ArmPlatformPkg / Drivers / NorFlashDxe / NorFlashBlockIoDxe.c
1 /** @file NorFlashBlockIoDxe.c
2
3 Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
4
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
15 #include <Library/BaseMemoryLib.h>
16 #include <Library/UefiBootServicesTableLib.h>
17
18 #include "NorFlashDxe.h"
19
20 //
21 // BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.Reset
22 //
23 EFI_STATUS
24 EFIAPI
25 NorFlashBlockIoReset (
26 IN EFI_BLOCK_IO_PROTOCOL *This,
27 IN BOOLEAN ExtendedVerification
28 )
29 {
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
36 return NorFlashReset (Instance);
37 }
38
39 //
40 // BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.ReadBlocks
41 //
42 EFI_STATUS
43 EFIAPI
44 NorFlashBlockIoReadBlocks (
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 {
52 NOR_FLASH_INSTANCE *Instance;
53 EFI_STATUS Status;
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
59 if( !This->Media->MediaPresent ) {
60 Status = EFI_NO_MEDIA;
61 } else if( This->Media->MediaId != MediaId ) {
62 Status = EFI_MEDIA_CHANGED;
63 } else {
64 Status = NorFlashReadBlocks (Instance,Lba,BufferSizeInBytes,Buffer);
65 }
66
67 return Status;
68 }
69
70 //
71 // BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.WriteBlocks
72 //
73 EFI_STATUS
74 EFIAPI
75 NorFlashBlockIoWriteBlocks (
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 {
83 NOR_FLASH_INSTANCE *Instance;
84 EFI_STATUS Status;
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
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 {
97 Status = NorFlashWriteBlocks (Instance,Lba,BufferSizeInBytes,Buffer);
98 }
99
100 return Status;
101 }
102
103 //
104 // BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.FlushBlocks
105 //
106 EFI_STATUS
107 EFIAPI
108 NorFlashBlockIoFlushBlocks (
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 }