1 /*++
2 
3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution.  The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8 
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 
12 Module Name:
13 
14   LegacyBiosThunk.h
15 
16 Abstract:
17 
18   The EFI Legacy BIOS Thunk Protocol is used to abstract Thunk16 call.
19 
20   Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow
21   well known naming conventions.
22 
23   Thunk - A thunk is a transition from one processor mode to another. A Thunk
24           is a transition from native EFI mode to 16-bit mode. A reverse thunk
25           would be a transition from 16-bit mode to native EFI mode.
26 
27 
28   Note: Note: Note: Note: Note: Note: Note:
29 
30   You most likely should not use this protocol! Find the EFI way to solve the
31   problem to make your code portable
32 
33   Note: Note: Note: Note: Note: Note: Note:
34 
35 Revision History
36 
37 --*/
38 
39 #ifndef _EFI_LEGACY_BIOS_THUNK_H_
40 #define _EFI_LEGACY_BIOS_THUNK_H_
41 
42 #include EFI_PROTOCOL_DEFINITION (LegacyBios)
43 
44 #define EFI_LEGACY_BIOS_THUNK_PROTOCOL_GUID \
45   { \
46     0x4c51a7ba, 0x7195, 0x442d, {0x87, 0x92, 0xbe, 0xea, 0x6e, 0x2f, 0xf6, 0xec} \
47   }
48 
49 EFI_FORWARD_DECLARATION (EFI_LEGACY_BIOS_THUNK_PROTOCOL);
50 
51 typedef
52 BOOLEAN
53 (EFIAPI *EFI_LEGACY_BIOS_THUNK_INT86) (
54   IN EFI_LEGACY_BIOS_THUNK_PROTOCOL   * This,
55   IN  UINT8                           BiosInt,
56   IN OUT  EFI_IA32_REGISTER_SET       * Regs
57   )
58 /*++
59 
60   Routine Description:
61     Thunk to 16-bit real mode and execute a software interrupt with a vector
62     of BiosInt. Regs will contain the 16-bit register context on entry and
63     exit.
64 
65   Arguments:
66     This    - Protocol instance pointer.
67     BiosInt - Processor interrupt vector to invoke
68     Reg     - Register contexted passed into (and returned) from thunk to
69               16-bit mode
70 
71   Returns:
72     FALSE   - Thunk completed, and there were no BIOS errors in the target code.
73               See Regs for status.
74     TRUE    - There was a BIOS erro in the target code.
75 
76 --*/
77 ;
78 
79 typedef
80 BOOLEAN
81 (EFIAPI *EFI_LEGACY_BIOS_THUNK_FARCALL86) (
82   IN EFI_LEGACY_BIOS_THUNK_PROTOCOL   * This,
83   IN  UINT16                          Segment,
84   IN  UINT16                          Offset,
85   IN  EFI_IA32_REGISTER_SET           * Regs,
86   IN  VOID                            *Stack,
87   IN  UINTN                           StackSize
88   )
89 /*++
90 
91   Routine Description:
92     Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the
93     16-bit register context on entry and exit. Arguments can be passed on
94     the Stack argument
95 
96   Arguments:
97     This      - Protocol instance pointer.
98     Segment   - Segemnt of 16-bit mode call
99     Offset    - Offset of 16-bit mdoe call
100     Reg       - Register contexted passed into (and returned) from thunk to
101                 16-bit mode
102     Stack     - Caller allocated stack used to pass arguments
103     StackSize - Size of Stack in bytes
104 
105   Returns:
106     FALSE     - Thunk completed, and there were no BIOS errors in the target code.
107                 See Regs for status.
108     TRUE      - There was a BIOS erro in the target code.
109 
110 --*/
111 ;
112 
113 struct _EFI_LEGACY_BIOS_THUNK_PROTOCOL {
114   EFI_LEGACY_BIOS_THUNK_INT86                 Int86;
115   EFI_LEGACY_BIOS_THUNK_FARCALL86             FarCall86;
116 };
117 
118 extern EFI_GUID gEfiLegacyBiosThunkProtocolGuid;
119 
120 #endif
121