12 * Data structures and type definitions
16 /* All i386 registers, as passed in by prot_call or kir_call */
17 struct real_mode_regs {
21 /* Segment:offset structure. Note that the order within the structure
29 /* Macro hackery needed to stringify bits of inline assembly */
31 #define RM_STR(x) RM_XSTR(x)
33 /* Drag in the selected real-mode transition library header */
41 * The API to some functions is identical between librm and libkir, so
42 * they are documented here, even though the prototypes are in librm.h
48 * void copy_to_real ( uint16_t dest_seg, uint16_t dest_off,
49 * void *src, size_t n )
50 * void copy_from_real ( void *dest, uint16_t src_seg, uint16_t src_off,
53 * These functions can be used to copy data to and from arbitrary
54 * locations in base memory.
58 * put_real ( variable, uint16_t dest_seg, uint16_t dest_off )
59 * get_real ( variable, uint16_t src_seg, uint16_t src_off )
61 * These macros can be used to read or write single variables to and
62 * from arbitrary locations in base memory. "variable" must be a
63 * variable of either 1, 2 or 4 bytes in length.
67 * REAL_CALL ( routine, num_out_constraints, out_constraints,
68 * in_constraints, clobber )
69 * REAL_EXEC ( name, asm_code_str, num_out_constraints, out_constraints,
70 * in_constraints, clobber )
72 * If you have a pre-existing real-mode routine that you want to make
73 * a far call to, use REAL_CALL. If you have a code fragment that you
74 * want to copy down to base memory, execute, and then remove, use
77 * out_constraints must be of the form OUT_CONSTRAINTS(constraints),
78 * and in_constraints must be of the form IN_CONSTRAINTS(constraints),
79 * where "constraints" is a constraints list as would be used in an
82 * clobber must be of the form CLOBBER ( clobber_list ), where
83 * "clobber_list" is a clobber list as would be used in an inline
86 * These are best illustrated by example. To write a character to the
87 * console using INT 10, you would do something like:
89 * REAL_EXEC ( rm_test_librm,
92 * OUT_CONSTRAINTS ( "=a" ( discard ) ),
93 * IN_CONSTRAINTS ( "a" ( 0x0e00 + character ),
95 * CLOBBER ( "ebx", "ecx", "edx", "ebp", "esi", "edi" ) );
97 * IMPORTANT: gcc does not automatically assume that input operands
98 * get clobbered. The only way to specify that an input operand may
99 * be modified is to also specify it as an output operand; hence the
100 * "(discard)" in the above code.
103 #warning "realmode.h contains placeholders for obsolete macros"
107 #define SEGMENT(x) ( virt_to_phys ( x ) >> 4 )
108 #define OFFSET(x) ( virt_to_phys ( x ) & 0xf )
109 #define SEGOFF(x) { OFFSET(x), SEGMENT(x) }
111 /* To make basemem.c compile */
112 extern int lock_real_mode_stack;
113 extern char *real_mode_stack;
114 extern char real_mode_stack_size[];
116 #define RM_FRAGMENT(name,asm) \
117 void name ( void ) {} \
118 extern char name ## _size[];
122 #endif /* ASSEMBLY */
124 #endif /* REALMODE_H */