mirror of
https://github.com/xcat2/xNBA.git
synced 2025-01-20 22:43:14 +00:00
[i386] Change semantics of __from_data16 and __from_text16
__from_data16 and __from_text16 now take a pointer to a .data16/.text16 variable, and return the real-mode offset within the appropriate segment. This matches the use case for every occurrence of these macros, and prevents potential future bugs such as that fixed in commit d51d80f. (The bug arose essentially because "&pointer" is still syntactically valid.)
This commit is contained in:
parent
d51d80f785
commit
4fbbf651d7
@ -93,8 +93,8 @@ int undi_load ( struct undi_device *undi, struct undi_rom *undirom ) {
|
||||
"lcall *%c2\n\t"
|
||||
"addw $4, %%sp\n\t" )
|
||||
: "=a" ( exit )
|
||||
: "a" ( & __from_data16 ( undi_loader ) ),
|
||||
"p" ( & __from_data16 ( undi_loader_entry ) )
|
||||
: "a" ( __from_data16 ( &undi_loader ) ),
|
||||
"p" ( __from_data16 ( &undi_loader_entry ) )
|
||||
: "ebx", "ecx", "edx", "esi", "edi", "ebp" );
|
||||
|
||||
/* UNDI API calls may rudely change the status of A20 and not
|
||||
|
@ -176,9 +176,9 @@ static int undinet_call ( struct undi_nic *undinic, unsigned int function,
|
||||
"addw $6, %%sp\n\t" )
|
||||
: "=a" ( exit ), "=b" ( discard_b ),
|
||||
"=D" ( discard_D )
|
||||
: "p" ( &__from_data16 ( undinet_entry_point )),
|
||||
: "p" ( __from_data16 ( &undinet_entry_point )),
|
||||
"b" ( function ),
|
||||
"D" ( &__from_data16 ( undinet_params ) )
|
||||
"D" ( __from_data16 ( &undinet_params ) )
|
||||
: "ecx", "edx", "esi", "ebp" );
|
||||
|
||||
/* UNDI API calls may rudely change the status of A20 and not
|
||||
@ -211,7 +211,7 @@ static int undinet_call ( struct undi_nic *undinic, unsigned int function,
|
||||
if ( rc != 0 ) {
|
||||
SEGOFF16_t rm_params = {
|
||||
.segment = rm_ds,
|
||||
.offset = (intptr_t) &__from_data16 ( undinet_params ),
|
||||
.offset = __from_data16 ( &undinet_params ),
|
||||
};
|
||||
|
||||
DBGC ( undinic, "UNDINIC %p %s failed: %s\n", undinic,
|
||||
@ -357,17 +357,14 @@ static int undinet_transmit ( struct net_device *netdev,
|
||||
/* Create PXENV_UNDI_TRANSMIT data structure */
|
||||
memset ( &undi_transmit, 0, sizeof ( undi_transmit ) );
|
||||
undi_transmit.DestAddr.segment = rm_ds;
|
||||
undi_transmit.DestAddr.offset
|
||||
= ( ( unsigned ) & __from_data16 ( undinet_tbd ) );
|
||||
undi_transmit.DestAddr.offset = __from_data16 ( &undinet_tbd );
|
||||
undi_transmit.TBD.segment = rm_ds;
|
||||
undi_transmit.TBD.offset
|
||||
= ( ( unsigned ) & __from_data16 ( undinet_tbd ) );
|
||||
undi_transmit.TBD.offset = __from_data16 ( &undinet_tbd );
|
||||
|
||||
/* Create PXENV_UNDI_TBD data structure */
|
||||
undinet_tbd.ImmedLength = len;
|
||||
undinet_tbd.Xmit.segment = rm_ds;
|
||||
undinet_tbd.Xmit.offset
|
||||
= ( ( unsigned ) & __from_data16 ( basemem_packet ) );
|
||||
undinet_tbd.Xmit.offset = __from_data16 ( basemem_packet );
|
||||
|
||||
/* Issue PXE API call */
|
||||
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_TRANSMIT,
|
||||
|
@ -147,7 +147,7 @@ static int meme820 ( struct memory_map *memmap ) {
|
||||
"=b" ( next ), "=D" ( discard_D ),
|
||||
"=c" ( discard_c ), "=d" ( discard_d )
|
||||
: "a" ( 0xe820 ), "b" ( next ),
|
||||
"D" ( &__from_data16 ( e820buf ) ),
|
||||
"D" ( __from_data16 ( &e820buf ) ),
|
||||
"c" ( sizeof ( e820buf ) ),
|
||||
"d" ( SMAP )
|
||||
: "memory" );
|
||||
|
@ -19,8 +19,8 @@
|
||||
#define __text16_array( variable,array ) variable array
|
||||
#define __use_data16( variable ) variable
|
||||
#define __use_text16( variable ) variable
|
||||
#define __from_data16( variable ) variable
|
||||
#define __from_text16( variable ) variable
|
||||
#define __from_data16( pointer ) pointer
|
||||
#define __from_text16( pointer ) pointer
|
||||
|
||||
/* Real-mode data and code segments */
|
||||
static inline __attribute__ (( always_inline )) unsigned int _rm_cs ( void ) {
|
||||
|
@ -51,13 +51,13 @@ extern char *text16;
|
||||
( * ( ( typeof ( _text16_ ## variable ) * ) \
|
||||
& ( text16 [ ( size_t ) & ( _text16_ ## variable ) ] ) ) )
|
||||
|
||||
#define __from_data16( variable ) \
|
||||
( * ( ( typeof ( variable ) * ) \
|
||||
( ( ( void * ) &(variable) ) - ( ( void * ) data16 ) ) ) )
|
||||
#define __from_data16( pointer ) \
|
||||
( ( unsigned int ) \
|
||||
( ( ( void * ) (pointer) ) - ( ( void * ) data16 ) ) )
|
||||
|
||||
#define __from_text16( variable ) \
|
||||
( * ( ( typeof ( variable ) * ) \
|
||||
( ( ( void * ) &(variable) ) - ( ( void * ) text16 ) ) ) )
|
||||
#define __from_text16( pointer ) \
|
||||
( ( unsigned int ) \
|
||||
( ( ( void * ) (pointer) ) - ( ( void * ) text16 ) ) )
|
||||
|
||||
/* Variables in librm.S, present in the normal data segment */
|
||||
extern uint16_t __data16 ( rm_cs );
|
||||
|
@ -441,8 +441,8 @@ int pxe_start_nbp ( void ) {
|
||||
"addw $4, %%sp\n\t" )
|
||||
: "=a" ( rc ), "=b" ( discard_b ),
|
||||
"=c" ( discard_c )
|
||||
: "a" ( & __from_text16 ( ppxe ) ),
|
||||
"b" ( & __from_text16 ( pxenv ) ),
|
||||
: "a" ( __from_text16 ( &ppxe ) ),
|
||||
"b" ( __from_text16 ( &pxenv ) ),
|
||||
"c" ( rm_cs )
|
||||
: "edx", "esi", "edi", "ebp", "memory" );
|
||||
|
||||
|
@ -42,11 +42,9 @@ PXENV_EXIT_t undi_loader ( struct s_UNDI_LOADER *undi_loader ) {
|
||||
|
||||
/* Fill in UNDI loader structure */
|
||||
undi_loader->PXEptr.segment = rm_cs;
|
||||
undi_loader->PXEptr.offset =
|
||||
( ( unsigned ) & __from_text16 ( ppxe ) );
|
||||
undi_loader->PXEptr.offset = __from_text16 ( &ppxe );
|
||||
undi_loader->PXENVptr.segment = rm_cs;
|
||||
undi_loader->PXENVptr.offset =
|
||||
( ( unsigned ) & __from_text16 ( pxenv ) );
|
||||
undi_loader->PXENVptr.offset = __from_text16 ( &pxenv );
|
||||
|
||||
undi_loader->Status = PXENV_STATUS_SUCCESS;
|
||||
return PXENV_EXIT_SUCCESS;
|
||||
|
@ -196,8 +196,7 @@ PXENV_EXIT_t pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO
|
||||
* fill it in.
|
||||
*/
|
||||
get_cached_info->Buffer.segment = rm_ds;
|
||||
get_cached_info->Buffer.offset =
|
||||
( unsigned ) ( & __from_data16 ( *info ) );
|
||||
get_cached_info->Buffer.offset = __from_data16 ( info );
|
||||
get_cached_info->BufferSize = sizeof ( *info );
|
||||
DBG ( " returning %04x:%04x+%04x['%x']",
|
||||
get_cached_info->Buffer.segment,
|
||||
|
@ -597,8 +597,7 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
|
||||
undi_isr->FrameHeaderLength =
|
||||
pxe_netdev->ll_protocol->ll_header_len;
|
||||
undi_isr->Frame.segment = rm_ds;
|
||||
undi_isr->Frame.offset =
|
||||
( ( unsigned ) & __from_data16 ( basemem_packet ) );
|
||||
undi_isr->Frame.offset = __from_data16 ( basemem_packet );
|
||||
/* Probably ought to fill in packet type */
|
||||
undi_isr->ProtType = P_UNKNOWN;
|
||||
undi_isr->PktType = XMT_DESTADDR;
|
||||
|
Loading…
x
Reference in New Issue
Block a user