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" \
/* 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
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 );
}
/**
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",
*
* @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;
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
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 );
/* 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 );