]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Clipboard.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / HexEdit / Clipboard.c
1 /** @file
2 Functions to deal with Clip Board
3
4 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. <BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "HexEditor.h"
10
11 typedef struct {
12 UINT8 *Buffer;
13 UINTN Size;
14 } HEFI_EDITOR_CLIPBOARD;
15
16 HEFI_EDITOR_CLIPBOARD HClipBoard;
17
18 //
19 // for basic initialization of HClipBoard
20 //
21 HEFI_EDITOR_CLIPBOARD HClipBoardConst = {
22 NULL,
23 0
24 };
25
26 /**
27 Initialization function for HDiskImage.
28
29 @param[in] EFI_SUCCESS The operation was successful.
30 @param[in] EFI_LOAD_ERROR A load error occurred.
31 **/
32 EFI_STATUS
33 HClipBoardInit (
34 VOID
35 )
36 {
37 //
38 // basiclly initialize the HDiskImage
39 //
40 CopyMem (&HClipBoard, &HClipBoardConst, sizeof (HClipBoard));
41
42 return EFI_SUCCESS;
43 }
44
45 /**
46 Initialization function for HDiskImage.
47
48 @param[in] EFI_SUCCESS The operation was successful.
49 @param[in] EFI_LOAD_ERROR A load error occurred.
50 **/
51 EFI_STATUS
52 HClipBoardCleanup (
53 VOID
54 )
55 {
56 SHELL_FREE_NON_NULL (HClipBoard.Buffer);
57
58 return EFI_SUCCESS;
59 }
60
61 /**
62 Set a buffer into the clipboard.
63
64 @param[in] Buffer The buffer to add to the clipboard.
65 @param[in] Size The size of Buffer in bytes.
66
67 @retval EFI_SUCCESS The operation was successful.
68 **/
69 EFI_STATUS
70 HClipBoardSet (
71 IN UINT8 *Buffer,
72 IN UINTN Size
73 )
74 {
75 //
76 // free the old clipboard buffer
77 // and set new clipboard buffer
78 //
79 SHELL_FREE_NON_NULL (HClipBoard.Buffer);
80 HClipBoard.Buffer = Buffer;
81
82 HClipBoard.Size = Size;
83
84 return EFI_SUCCESS;
85 }
86
87 /**
88 Get a buffer from the clipboard.
89
90 @param[out] Buffer The pointer to the buffer to add to the clipboard.
91
92 @return the size of the buffer.
93 **/
94 UINTN
95 HClipBoardGet (
96 OUT UINT8 **Buffer
97 )
98 {
99 //
100 // return the clipboard buffer
101 //
102 *Buffer = HClipBoard.Buffer;
103
104 return HClipBoard.Size;
105 }