VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/Etherboot-src/arch/i386/include/realmode.h@ 7558

Last change on this file since 7558 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/* Real-mode interface
2 */
3
4#ifndef ASSEMBLY
5
6#include "etherboot.h"
7#include "segoff.h"
8
9typedef union {
10 struct {
11 union {
12 uint8_t l;
13 uint8_t byte;
14 };
15 uint8_t h;
16 } PACKED;
17 uint16_t word;
18} PACKED reg16_t;
19
20typedef union {
21 reg16_t w;
22 uint32_t dword;
23} PACKED reg32_t;
24
25/* Macros to help with defining inline real-mode trampoline fragments.
26 */
27#ifdef VBOX
28#ifdef __WIN32__
29/* Switching to previous section is only supported with ELF format. */
30#define RM_SWITCH_PREV_SEGMENT ".section .text"
31#else /* __WIN32__ */
32#define RM_SWITCH_PREV_SEGMENT ".previous"
33#endif /* __WIN32__ */
34#else /* !VBOX */
35#define RM_XSTR(x) #x /* Macro hackery needed to stringify */
36#define RM_STR(x) RM_XSTR(x)
37#endif /* !VBOX */
38#ifdef VBOX
39#define RM_FRAGMENT(name, asm_code_str) \
40 extern void name ( void ); \
41 extern void name ## _end (void); \
42 __asm__( \
43 ".section .text16\n\t" \
44 ".code16\n\t" \
45 ".arch i386\n\t" \
46 ".globl " STRINGIFY(GSYM(name)) " \n\t" \
47 STRINGIFY(GSYM(name)) ":\n\t" \
48 asm_code_str "\n\t" \
49 ".globl " STRINGIFY(GSYM(name ## _end)) "\n\t" \
50 STRINGIFY(GSYM(name ## _end)) ":\n\t" \
51 ".code32\n\t" \
52 RM_SWITCH_PREV_SEGMENT "\n\t" \
53 )
54#else /* !VBOX */
55#define RM_FRAGMENT(name, asm_code_str) \
56 extern void name ( void ); \
57 extern void name ## _end (void); \
58 __asm__( \
59 ".section \".text16\"\n\t" \
60 ".code16\n\t" \
61 ".arch i386\n\t" \
62 ".globl " #name " \n\t" \
63 #name ":\n\t" \
64 asm_code_str "\n\t" \
65 ".globl " #name "_end\n\t" \
66 #name "_end:\n\t" \
67 ".code32\n\t" \
68 ".previous\n\t" \
69 )
70#endif /* !VBOX */
71
72#define FRAGMENT_SIZE(fragment) ( (size_t) ( ( (void*) fragment ## _end )\
73 - ( (void*) (fragment) ) ) )
74
75/* Data structures in _prot_to_real and _real_to_prot. These
76 * structures are accessed by assembly code as well as C code.
77 */
78typedef struct {
79 uint32_t esp;
80 uint16_t cs;
81 uint16_t ss;
82 uint32_t r2p_params;
83} PACKED prot_to_real_params_t;
84
85typedef struct {
86 uint32_t ret_addr;
87 uint32_t esp;
88 uint32_t ebx;
89 uint32_t esi;
90 uint32_t edi;
91 uint32_t ebp;
92 uint32_t out_stack;
93 uint32_t out_stack_len;
94} PACKED real_to_prot_params_t;
95
96/* Function prototypes: realmode.c
97 */
98#define real_call( fragment, in_stack, out_stack ) \
99 _real_call ( fragment, FRAGMENT_SIZE(fragment), \
100 (void*)(in_stack), \
101 ( (in_stack) == NULL ? 0 : sizeof(*(in_stack)) ), \
102 (void*)(out_stack), \
103 ( (out_stack) == NULL ? 0 : sizeof(*(out_stack)) ) )
104extern uint16_t _real_call ( void *fragment, int fragment_len,
105 void *in_stack, int in_stack_len,
106 void *out_stack, int out_stack_len );
107/* Function prototypes: realmode_asm.S
108 */
109extern void rm_callback_interface;
110extern uint16_t rm_callback_interface_size;
111extern uint32_t rm_etherboot_location;
112extern void _rm_in_call ( void );
113extern void _rm_in_call_far ( void );
114
115extern void _prot_to_real_prefix ( void );
116extern void _prot_to_real_prefix_end ( void );
117extern uint16_t prot_to_real_prefix_size;
118
119extern void _real_to_prot_suffix ( void );
120extern void _real_to_prot_suffix_end ( void );
121extern uint16_t real_to_prot_suffix_size;
122
123/* PXE assembler bits */
124extern void pxe_callback_interface;
125extern uint16_t pxe_callback_interface_size;
126extern void _pxe_in_call_far ( void );
127extern void _pxenv_in_call_far ( void );
128extern void _pxe_intercept_int1a ( void );
129extern segoff_t _pxe_intercepted_int1a;
130extern segoff_t _pxe_pxenv_location;
131
132/* Global variables
133 */
134extern uint32_t real_mode_stack;
135extern size_t real_mode_stack_size;
136extern int lock_real_mode_stack;
137
138
139/* Function prototypes from basemem.c
140 */
141#ifdef LINUXBIOS
142/* A silly hard code that let's the code compile and work.
143 * When this becomes a problem feel free to implement
144 * something better.
145 */
146static inline void allot_real_mode_stack(void) { real_mode_stack = 0x7c00; }
147#else
148void allot_real_mode_stack(void);
149#endif
150
151#endif /* ASSEMBLY */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette