]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/ExtendedIfrSupportLib/IfrOpCodeCreation.c
43297743301f03e655052fb63430d35ef3577e4c
[mirror_edk2.git] / MdeModulePkg / Library / ExtendedIfrSupportLib / IfrOpCodeCreation.c
1 /** @file
2 Library Routines to create IFR independent of string data - assume tokens already exist
3 Primarily to be used for exporting op-codes at a label in pre-defined forms.
4
5 Copyright (c) 2007 - 2008, Intel Corporation. <BR>
6 All rights reserved. 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 #include "LibraryInternal.h"
17
18 /**
19 Create GUIDed opcode for banner. Banner opcode
20 EFI_IFR_EXTEND_OP_BANNER is extended opcode specific
21 to Intel's implementation.
22
23 @param Title String ID for title
24 @param LineNumber Line number for this banner
25 @param Alignment Alignment for this banner, left, center or right
26 @param Data Destination for the created opcode binary
27
28 @retval EFI_SUCCESS Opcode create success
29 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
30
31 **/
32 EFI_STATUS
33 EFIAPI
34 CreateBannerOpCode (
35 IN EFI_STRING_ID Title,
36 IN UINT16 LineNumber,
37 IN UINT8 Alignment,
38 IN OUT EFI_HII_UPDATE_DATA *Data
39 )
40 {
41 EFI_IFR_GUID_BANNER Banner;
42 UINT8 *LocalBuffer;
43
44 ASSERT (Data != NULL && Data->Data != NULL);
45
46 if (Data->Offset + sizeof (EFI_IFR_GUID_BANNER) > Data->BufferSize) {
47 return EFI_BUFFER_TOO_SMALL;
48 }
49
50 Banner.Header.OpCode = EFI_IFR_GUID_OP;
51 Banner.Header.Length = sizeof (EFI_IFR_GUID_BANNER);
52 Banner.Header.Scope = 0;
53 CopyMem (&Banner.Guid, &mIfrVendorGuid, sizeof (EFI_IFR_GUID));
54 Banner.ExtendOpCode = EFI_IFR_EXTEND_OP_BANNER;
55 Banner.Title = Title;
56 Banner.LineNumber = LineNumber;
57 Banner.Alignment = Alignment;
58
59 LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
60 CopyMem (LocalBuffer, &Banner, sizeof (EFI_IFR_GUID_BANNER));
61 Data->Offset += sizeof (EFI_IFR_GUID_BANNER);
62
63 return EFI_SUCCESS;
64 }
65