summaryrefslogtreecommitdiffstats
path: root/src/arch/i386
diff options
context:
space:
mode:
authorMichael Brown2016-02-16 17:45:12 +0100
committerMichael Brown2016-02-16 20:32:32 +0100
commit1a457e933a5e6c61fe08e1a6813f4514978b4c1d (patch)
tree545472e02bdfa5730fd53214b653f2252a4dd11b /src/arch/i386
parent[bios] Allow memmap.c to be compiled for x86_64 (diff)
downloadipxe-1a457e933a5e6c61fe08e1a6813f4514978b4c1d.tar.gz
ipxe-1a457e933a5e6c61fe08e1a6813f4514978b4c1d.tar.xz
ipxe-1a457e933a5e6c61fe08e1a6813f4514978b4c1d.zip
[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>
Diffstat (limited to 'src/arch/i386')
-rw-r--r--src/arch/i386/include/librm.h15
-rw-r--r--src/arch/i386/transitions/librm_mgmt.c10
-rw-r--r--src/arch/i386/transitions/librm_test.c20
3 files changed, 30 insertions, 15 deletions
diff --git a/src/arch/i386/include/librm.h b/src/arch/i386/include/librm.h
index a8a578a3..44d931ea 100644
--- a/src/arch/i386/include/librm.h
+++ b/src/arch/i386/include/librm.h
@@ -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
diff --git a/src/arch/i386/transitions/librm_mgmt.c b/src/arch/i386/transitions/librm_mgmt.c
index becb0267..32695ae0 100644
--- a/src/arch/i386/transitions/librm_mgmt.c
+++ b/src/arch/i386/transitions/librm_mgmt.c
@@ -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;
diff --git a/src/arch/i386/transitions/librm_test.c b/src/arch/i386/transitions/librm_test.c
index f1a517ed..496d5612 100644
--- a/src/arch/i386/transitions/librm_test.c
+++ b/src/arch/i386/transitions/librm_test.c
@@ -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 );