1 /** @file 2 Defines BufferImage - the view of the file that is visible at any point, 3 as well as the event handlers for editing the file 4 5 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR> 6 This program and the accompanying materials 7 are licensed and made available under the terms and conditions of the BSD License 8 which accompanies this distribution. The full text of the license may be found at 9 http://opensource.org/licenses/bsd-license.php 10 11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13 14 **/ 15 16 #ifndef _LIB_BUFFER_IMAGE_H_ 17 #define _LIB_BUFFER_IMAGE_H_ 18 19 #include "HexEditor.h" 20 21 /** 22 Initialization function for HBufferImage 23 24 @retval EFI_SUCCESS The operation was successful. 25 @retval EFI_LOAD_ERROR A load error occured. 26 **/ 27 EFI_STATUS 28 HBufferImageInit ( 29 VOID 30 ); 31 32 /** 33 Cleanup function for HBufferImage 34 35 @retval EFI_SUCCESS The operation was successful. 36 **/ 37 EFI_STATUS 38 HBufferImageCleanup ( 39 VOID 40 ); 41 42 /** 43 Refresh function for HBufferImage. 44 45 @retval EFI_SUCCESS The operation was successful. 46 @retval EFI_LOAD_ERROR A Load error occured. 47 48 **/ 49 EFI_STATUS 50 HBufferImageRefresh ( 51 VOID 52 ); 53 54 /** 55 Dispatch input to different handler 56 57 @param[in] Key The input key: 58 the keys can be: 59 ASCII KEY 60 Backspace/Delete 61 Direction key: up/down/left/right/pgup/pgdn 62 Home/End 63 INS 64 65 @retval EFI_SUCCESS The operation was successful. 66 @retval EFI_LOAD_ERROR A load error occured. 67 @retval EFI_OUT_OF_RESOURCES A Memory allocation failed. 68 **/ 69 EFI_STATUS 70 HBufferImageHandleInput ( 71 IN EFI_INPUT_KEY *Key 72 ); 73 74 /** 75 Backup function for HBufferImage. Only a few fields need to be backup. 76 This is for making the file buffer refresh as few as possible. 77 78 @retval EFI_SUCCESS The operation was successful. 79 **/ 80 EFI_STATUS 81 HBufferImageBackup ( 82 VOID 83 ); 84 85 /** 86 Read an image into a buffer friom a source. 87 88 @param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer. 89 @param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer. 90 @param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer. 91 @param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer. 92 @param[in] MemOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer. 93 @param[in] MemSize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer. 94 @param[in] BufferType The type of buffer to save. IGNORED. 95 @param[in] Recover TRUE for recovermode, FALSE otherwise. 96 97 @return EFI_SUCCESS The operation was successful. 98 **/ 99 EFI_STATUS 100 EFIAPI 101 HBufferImageRead ( 102 IN CONST CHAR16 *FileName, 103 IN CONST CHAR16 *DiskName, 104 IN UINTN DiskOffset, 105 IN UINTN DiskSize, 106 IN UINTN MemOffset, 107 IN UINTN MemSize, 108 IN EDIT_FILE_TYPE BufferType, 109 IN BOOLEAN Recover 110 ); 111 112 /** 113 Save the current image. 114 115 @param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer. 116 @param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer. 117 @param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer. 118 @param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer. 119 @param[in] MemOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer. 120 @param[in] MemSize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer. 121 @param[in] BufferType The type of buffer to save. IGNORED. 122 123 @return EFI_SUCCESS The operation was successful. 124 **/ 125 EFI_STATUS 126 HBufferImageSave ( 127 IN CHAR16 *FileName, 128 IN CHAR16 *DiskName, 129 IN UINTN DiskOffset, 130 IN UINTN DiskSize, 131 IN UINTN MemOffset, 132 IN UINTN MemSize, 133 IN EDIT_FILE_TYPE BufferType 134 ); 135 136 /** 137 According to cursor's file position, adjust screen display. 138 139 @param[in] NewFilePosRow Row of file position ( start from 1 ). 140 @param[in] NewFilePosCol Column of file position ( start from 1 ). 141 @param[in] HighBits Cursor will on high4 bits or low4 bits. 142 **/ 143 VOID 144 HBufferImageMovePosition ( 145 IN UINTN NewFilePosRow, 146 IN UINTN NewFilePosCol, 147 IN BOOLEAN HighBits 148 ); 149 150 151 /** 152 Create a new line and append it to the line list. 153 Fields affected: 154 NumLines 155 Lines 156 157 @retval NULL create line failed. 158 @return the line created. 159 160 **/ 161 HEFI_EDITOR_LINE * 162 HBufferImageCreateLine ( 163 VOID 164 ); 165 166 /** 167 Free the current image. 168 169 @retval EFI_SUCCESS The operation was successful. 170 **/ 171 EFI_STATUS 172 HBufferImageFree ( 173 VOID 174 ); 175 176 /** 177 Delete character from buffer. 178 179 @param[in] Pos Position, Pos starting from 0. 180 @param[in] Count The Count of characters to delete. 181 @param[out] DeleteBuffer The DeleteBuffer. 182 183 @retval EFI_SUCCESS Success 184 **/ 185 EFI_STATUS 186 HBufferImageDeleteCharacterFromBuffer ( 187 IN UINTN Pos, 188 IN UINTN Count, 189 OUT UINT8 *DeleteBuffer 190 ); 191 192 /** 193 Add character to buffer, add before pos. 194 195 @param[in] Pos Position, Pos starting from 0. 196 @param[in] Count Count of characters to add. 197 @param[in] AddBuffer Add buffer. 198 199 @retval EFI_SUCCESS Success. 200 **/ 201 EFI_STATUS 202 HBufferImageAddCharacterToBuffer ( 203 IN UINTN Pos, 204 IN UINTN Count, 205 IN UINT8 *AddBuffer 206 ); 207 208 /** 209 Change the raw buffer to a list of lines for the UI. 210 211 @param[in] Buffer The pointer to the buffer to fill. 212 @param[in] Bytes The size of the buffer in bytes. 213 214 @retval EFI_SUCCESS The operation was successful. 215 @retval EFI_OUT_OF_RESOURCES A memory allocation failed. 216 **/ 217 EFI_STATUS 218 EFIAPI 219 HBufferImageBufferToList ( 220 IN VOID *Buffer, 221 IN UINTN Bytes 222 ); 223 224 /** 225 Change the list of lines from the UI to a raw buffer. 226 227 @param[in] Buffer The pointer to the buffer to fill. 228 @param[in] Bytes The size of the buffer in bytes. 229 230 @retval EFI_SUCCESS The operation was successful. 231 **/ 232 EFI_STATUS 233 EFIAPI 234 HBufferImageListToBuffer ( 235 IN VOID *Buffer, 236 IN UINTN Bytes 237 ); 238 239 /** 240 Move the mouse in the image buffer. 241 242 @param[in] TextX The x-coordinate. 243 @param[in] TextY The y-coordinate. 244 **/ 245 VOID 246 EFIAPI 247 HBufferImageAdjustMousePosition ( 248 IN INT32 TextX, 249 IN INT32 TextY 250 ); 251 252 /** 253 Function to decide if a column number is stored in the high bits. 254 255 @param[in] Column The column to examine. 256 @param[out] FCol The actual column number. 257 258 @retval TRUE The actual column was in high bits and is now in FCol. 259 @retval FALSE There was not a column number in the high bits. 260 **/ 261 BOOLEAN 262 HBufferImageIsAtHighBits ( 263 IN UINTN Column, 264 OUT UINTN *FCol 265 ); 266 267 /** 268 Get the size of the open buffer. 269 270 @retval The size in bytes. 271 **/ 272 UINTN 273 HBufferImageGetTotalSize ( 274 VOID 275 ); 276 277 #endif 278