mirror of https://github.com/ipxe/ipxe.git
(Redoing check-in lost by SourceForge's failure.)
Use .text16.data section with "aw" attributes, to avoid section type conflicts when placing both code and data into .text16. Add __from_{text16,data16}.pull/1/head
parent
97d265f8dc
commit
f7b963da51
|
@ -15,6 +15,8 @@
|
||||||
#define __text16( variable ) variable
|
#define __text16( variable ) variable
|
||||||
#define __use_data16( variable ) variable
|
#define __use_data16( variable ) variable
|
||||||
#define __use_text16( variable ) variable
|
#define __use_text16( variable ) variable
|
||||||
|
#define __from_data16( variable ) variable
|
||||||
|
#define __from_text16( variable ) variable
|
||||||
|
|
||||||
/* Copy to/from base memory */
|
/* Copy to/from base memory */
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ extern char *text16;
|
||||||
|
|
||||||
#define __text16( variable ) \
|
#define __text16( variable ) \
|
||||||
_text16_ ## variable __asm__ ( #variable ) \
|
_text16_ ## variable __asm__ ( #variable ) \
|
||||||
__attribute__ (( section ( ".text16" ) ))
|
__attribute__ (( section ( ".text16.data" ) ))
|
||||||
|
|
||||||
#define __use_data16( variable ) \
|
#define __use_data16( variable ) \
|
||||||
( * ( ( typeof ( _data16_ ## variable ) * ) \
|
( * ( ( typeof ( _data16_ ## variable ) * ) \
|
||||||
|
@ -35,6 +35,14 @@ extern char *text16;
|
||||||
( * ( ( typeof ( _text16_ ## variable ) * ) \
|
( * ( ( typeof ( _text16_ ## variable ) * ) \
|
||||||
& ( text16 [ ( size_t ) & ( _text16_ ## variable ) ] ) ) )
|
& ( text16 [ ( size_t ) & ( _text16_ ## variable ) ] ) ) )
|
||||||
|
|
||||||
|
#define __from_data16( variable ) \
|
||||||
|
( * ( ( typeof ( variable ) * ) \
|
||||||
|
( ( ( void * ) &(variable) ) - ( ( void * ) data16 ) ) ) )
|
||||||
|
|
||||||
|
#define __from_text16( variable ) \
|
||||||
|
( * ( ( typeof ( variable ) * ) \
|
||||||
|
( ( ( void * ) &(variable) ) - ( ( void * ) text16 ) ) ) )
|
||||||
|
|
||||||
/* Variables in librm.S, present in the normal data segment */
|
/* Variables in librm.S, present in the normal data segment */
|
||||||
extern uint16_t rm_sp;
|
extern uint16_t rm_sp;
|
||||||
extern uint16_t rm_ss;
|
extern uint16_t rm_ss;
|
||||||
|
@ -58,13 +66,14 @@ extern void gateA20_set ( void );
|
||||||
#define VIRTUAL(x,y) ( phys_to_virt ( ( ( x ) << 4 ) + ( y ) ) )
|
#define VIRTUAL(x,y) ( phys_to_virt ( ( ( x ) << 4 ) + ( y ) ) )
|
||||||
|
|
||||||
/* Copy to/from base memory */
|
/* Copy to/from base memory */
|
||||||
static inline void copy_to_real_librm ( uint16_t dest_seg, uint16_t dest_off,
|
static inline __attribute__ (( always_inline )) void
|
||||||
void *src, size_t n ) {
|
copy_to_real_librm ( unsigned int dest_seg, unsigned int dest_off,
|
||||||
|
void *src, size_t n ) {
|
||||||
memcpy ( VIRTUAL ( dest_seg, dest_off ), src, n );
|
memcpy ( VIRTUAL ( dest_seg, dest_off ), src, n );
|
||||||
}
|
}
|
||||||
static inline void copy_from_real_librm ( void *dest,
|
static inline __attribute__ (( always_inline )) void
|
||||||
uint16_t src_seg, uint16_t src_off,
|
copy_from_real_librm ( void *dest, unsigned int src_seg,
|
||||||
size_t n ) {
|
unsigned int src_off, size_t n ) {
|
||||||
memcpy ( dest, VIRTUAL ( src_seg, src_off ), n );
|
memcpy ( dest, VIRTUAL ( src_seg, src_off ), n );
|
||||||
}
|
}
|
||||||
#define put_real_librm( var, dest_seg, dest_off ) \
|
#define put_real_librm( var, dest_seg, dest_off ) \
|
||||||
|
|
|
@ -15,10 +15,12 @@
|
||||||
/* Segment:offset structure. Note that the order within the structure
|
/* Segment:offset structure. Note that the order within the structure
|
||||||
* is offset:segment.
|
* is offset:segment.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
struct segoff {
|
||||||
uint16_t offset;
|
uint16_t offset;
|
||||||
uint16_t segment;
|
uint16_t segment;
|
||||||
} __attribute__ (( packed )) segoff_t;
|
} __attribute__ (( packed ));
|
||||||
|
|
||||||
|
typedef struct segoff segoff_t;
|
||||||
|
|
||||||
/* Macro hackery needed to stringify bits of inline assembly */
|
/* Macro hackery needed to stringify bits of inline assembly */
|
||||||
#define RM_XSTR(x) #x
|
#define RM_XSTR(x) #x
|
||||||
|
@ -50,8 +52,8 @@ typedef struct {
|
||||||
* extern uint32_t __data16 ( bar );
|
* extern uint32_t __data16 ( bar );
|
||||||
* #define bar __use_data16 ( bar );
|
* #define bar __use_data16 ( bar );
|
||||||
*
|
*
|
||||||
* extern long __data16 ( baz ) = 0xff000000UL;
|
* static long __data16 ( baz ) = 0xff000000UL;
|
||||||
* #define bar __use_data16 ( baz );
|
* #define baz __use_data16 ( baz );
|
||||||
*
|
*
|
||||||
* i.e. take a normal declaration, add __data16() around the variable
|
* i.e. take a normal declaration, add __data16() around the variable
|
||||||
* name, and add a line saying "#define <name> __use_data16 ( <name> )
|
* name, and add a line saying "#define <name> __use_data16 ( <name> )
|
||||||
|
@ -83,6 +85,12 @@ typedef struct {
|
||||||
* Variables may also be placed in .text16 using __text16 and
|
* Variables may also be placed in .text16 using __text16 and
|
||||||
* __use_text16. Some variables (e.g. chained interrupt vectors) fit
|
* __use_text16. Some variables (e.g. chained interrupt vectors) fit
|
||||||
* most naturally in .text16; most should be in .data16.
|
* most naturally in .text16; most should be in .data16.
|
||||||
|
*
|
||||||
|
* If you have only a pointer to a magic symbol within .data16 or
|
||||||
|
* .text16, rather than the symbol itself, you can attempt to extract
|
||||||
|
* the underlying symbol name using __from_data16() or
|
||||||
|
* __from_text16(). This is not for the faint-hearted; check the
|
||||||
|
* assembler output to make sure that it's doing the right thing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -19,7 +19,9 @@
|
||||||
#define SIZEOF_I386_ALL_REGS ( SIZEOF_REAL_MODE_REGS + SIZEOF_I386_FLAGS )
|
#define SIZEOF_I386_ALL_REGS ( SIZEOF_REAL_MODE_REGS + SIZEOF_I386_FLAGS )
|
||||||
|
|
||||||
.arch i386
|
.arch i386
|
||||||
.section ".text16", "awx", @progbits
|
.section ".text16", "ax", @progbits
|
||||||
|
.section ".text16.data", "aw", @progbits
|
||||||
|
.section ".data16", "aw", @progbits
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Global descriptor table
|
* Global descriptor table
|
||||||
|
@ -45,7 +47,7 @@
|
||||||
#else
|
#else
|
||||||
#define RM_LIMIT_16_19__AVL__SIZE__GRANULARITY 0x00
|
#define RM_LIMIT_16_19__AVL__SIZE__GRANULARITY 0x00
|
||||||
#endif
|
#endif
|
||||||
.section ".data16", "aw", @progbits
|
.section ".data16"
|
||||||
.align 16
|
.align 16
|
||||||
gdt:
|
gdt:
|
||||||
gdt_limit: .word gdt_length - 1
|
gdt_limit: .word gdt_length - 1
|
||||||
|
@ -308,7 +310,7 @@ p2r_jump_target:
|
||||||
p2r_jump_vector:
|
p2r_jump_vector:
|
||||||
.word p2r_jump_target
|
.word p2r_jump_target
|
||||||
rm_cs: .word 0
|
rm_cs: .word 0
|
||||||
.section ".text16"
|
.section ".text16.data"
|
||||||
rm_ds: .word 0
|
rm_ds: .word 0
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
Loading…
Reference in New Issue