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