david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[bios] Allow librm to be compiled for x86_64

This commit does not make librm functional for x86_64; it merely
allows it to compile without errors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2016-02-16 16:45:12 +00:00
parent 8819a34c0e
commit 1a457e933a
3 changed files with 30 additions and 15 deletions

View File

@ -173,17 +173,24 @@ extern uint16_t __text16 ( rm_ds );
extern uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size );
extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
/* CODE_DEFAULT: restore default .code32/.code64 directive */
#ifdef __x86_64__
#define CODE_DEFAULT ".code64"
#else
#define CODE_DEFAULT ".code32"
#endif
/* TEXT16_CODE: declare a fragment of code that resides in .text16 */
#define TEXT16_CODE( asm_code_str ) \
".section \".text16\", \"ax\", @progbits\n\t" \
".code16\n\t" \
asm_code_str "\n\t" \
".code32\n\t" \
CODE_DEFAULT "\n\t" \
".previous\n\t"
/* REAL_CODE: declare a fragment of code that executes in real mode */
#define REAL_CODE( asm_code_str ) \
"pushl $1f\n\t" \
"push $1f\n\t" \
"call real_call\n\t" \
"addl $4, %%esp\n\t" \
TEXT16_CODE ( "\n1:\n\t" \
@ -194,8 +201,10 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
/* PHYS_CODE: declare a fragment of code that executes in flat physical mode */
#define PHYS_CODE( asm_code_str ) \
"call _virt_to_phys\n\t" \
".code32\n\t" \
asm_code_str \
"call _phys_to_virt\n\t"
"call _phys_to_virt\n\t" \
CODE_DEFAULT "\n\t"
/** Number of interrupts */
#define NUM_INT 256

View File

@ -80,8 +80,8 @@ void set_interrupt_vector ( unsigned int intr, void *vector ) {
idte = &idt[intr];
idte->segment = VIRTUAL_CS;
idte->attr = ( vector ? ( IDTE_PRESENT | IDTE_TYPE_IRQ32 ) : 0 );
idte->low = ( ( ( uint32_t ) vector ) & 0xffff );
idte->high = ( ( ( uint32_t ) vector ) >> 16 );
idte->low = ( ( ( intptr_t ) vector ) & 0xffff );
idte->high = ( ( ( intptr_t ) vector ) >> 16 );
}
/**
@ -99,8 +99,8 @@ void init_idt ( void ) {
vec->movb = MOVB_INSN;
vec->intr = intr;
vec->jmp = JMP_INSN;
vec->offset = ( ( uint32_t ) interrupt_wrapper -
( uint32_t ) vec->next );
vec->offset = ( ( intptr_t ) interrupt_wrapper -
( intptr_t ) vec->next );
set_interrupt_vector ( intr, vec );
}
DBGC ( &intr_vec[0], "INTn vector at %p+%zxn (phys %#lx+%zxn)\n",
@ -132,7 +132,7 @@ static struct profiler * interrupt_profiler ( int intr ) {
*
* @v intr Interrupt number
*/
void __attribute__ (( cdecl, regparm ( 1 ) )) interrupt ( int intr ) {
void __attribute__ (( regparm ( 1 ) )) interrupt ( int intr ) {
struct profiler *profiler = interrupt_profiler ( intr );
uint32_t discard_eax;

View File

@ -69,9 +69,11 @@ static void librm_test_prot_call ( void ) {
static void librm_test_exec ( void ) {
unsigned int i;
unsigned long timestamp;
unsigned long started;
unsigned long stopped;
unsigned int discard_d;
uint32_t timestamp_lo;
uint32_t timestamp_hi;
uint32_t started;
uint32_t stopped;
uint32_t discard_d;
/* Profile mode transitions. We want to profile each
* direction of the transition separately, so perform an RDTSC
@ -81,8 +83,12 @@ static void librm_test_exec ( void ) {
for ( i = 0 ; i < PROFILE_COUNT ; i++ ) {
profile_start ( &p2r_profiler );
__asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t" )
: "=a" ( timestamp ), "=d" ( discard_d )
: "=a" ( timestamp_lo ),
"=d" ( timestamp_hi )
: );
timestamp = timestamp_lo;
if ( sizeof ( timestamp ) > sizeof ( timestamp_lo ) )
timestamp |= ( ( ( uint64_t ) timestamp_hi ) << 32 );
profile_start_at ( &r2p_profiler, timestamp );
profile_stop ( &r2p_profiler );
profile_stop_at ( &p2r_profiler, timestamp );
@ -98,14 +104,14 @@ static void librm_test_exec ( void ) {
/* Profile complete protected-mode call cycle */
for ( i = 0 ; i < PROFILE_COUNT ; i++ ) {
__asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t"
"movl %0, %2\n\t"
"pushl %3\n\t"
"movl %k0, %k2\n\t"
"pushl %k3\n\t"
"pushw %%cs\n\t"
"call prot_call\n\t"
"addw $4, %%sp\n\t"
"rdtsc\n\t" )
: "=a" ( stopped ), "=d" ( discard_d ),
"=r" ( started )
"=R" ( started )
: "i" ( librm_test_prot_call ) );
profile_start_at ( &prot_call_profiler, started );
profile_stop_at ( &prot_call_profiler, stopped );