cpcdos

FRANCE [Lyon], 17.03.2018, 18:41 (edited by cpcdos, 18.03.2018, 11:49) |
iret from dpmi interrupt handler (Developers) |
Hello everyone,
I've a strange problem with my ISR runtime under djgpp/G++.
My code for create interrupt handler
---------------------------- main.cpp -----------------------------------
extern "C" void end_Routine_ISR();
extern "C" void Routine_ISR();
_go32_dpmi_seginfo old_handle, new_handle;
/****** My "ISR handler" function in asm inline *******/
asm (".global _Routine_ISR n _Routine_ISR:n"
// "call _my_context_switching_function"
"iret"
);
asm (".global _end_Routine_ISR n _end_Routine_ISR:n"
"ret"
);
/*******************************************/
void Create_ISR() {
int Vecteur_initialisation = 0x08;
if(_go32_dpmi_get_protected_mode_interrupt_vector(Vecteur_initialisation, &old_handle)!=0)
printf(" ERROR P1n");
nouveau_handle.pm_offset = (long unsigned int) (void*) Routine_ISR;
nouveau_handle.pm_selector = _go32_my_cs();
if(_go32_dpmi_chain_protected_mode_interrupt_vector(Vecteur_initialisation, &new_handle)!=0)
printf(" ERROR P2n");
_go32_dpmi_lock_code((void*) Routine_ISR, (unsigned long) ((unsigned long) &end_Routine_ISR - (unsigned long) &Routine_ISR));
_go32_dpmi_lock_data((void*) Routine_ISR, (unsigned long) ((unsigned long) &end_Routine_ISR - (unsigned long) &Routine_ISR));
}
----------------------------------------------------------------------
I compile this,
gpp main.cpp -O0 -m32 -S
And this is my problem
---------------------------- main.s-----------------------------------
... generated code ...
.global _Routine_ISR
_Routine_ISR:
call _my_context_switching_function().
iret
.global _end_Routine_ISR
_end_Routine_ISR:
ret
... generated code ...
---------------------------------------------------------------------
During my _Routine_ISR interruption if i use this "iret" my program crash with SIGSEGV signal (with or without my "call function"). But if i use "ret" interrupt works.
I want use "iret" in my context switching function , but i can't
According to my Google friend, NT bit flag must set from EFLAG in my context structure, but it's an interrupt created by _go32_dpmi_chain_protected_mode_interrupt_vector() ... WTF 
Someone can help me?
Best regards, --- Sébastien FAVIER
ps: Excuse me for my English level, I'm a French student |
RayeR

CZ, 20.03.2018, 00:59
@ cpcdos
|
iret from dpmi interrupt handler |
You don't need to care about ret/iret in djgpp.
just define your ISR as simple C function:
void covox_playback_isr(void)
{}
and here is sample code how to install your new ISR:
//***************** install Covox playback ISR at timer interrupt ***********
void covox_playback_install(void)
{
printf("Installing new timer ISR for Covox playback...n");
// lock the functions and variables
_go32_dpmi_lock_code(covox_playback_isr,(DWord)sizeof(covox_playback_isr));
_go32_dpmi_lock_data((void *)&sound_buffer_cnt,(DWord)sizeof(sound_buffer_cnt));
_go32_dpmi_lock_data((void *)&sound_data_request,(DWord)sizeof(sound_data_request));
// load the address of the old timer ISR into the OldISR structure
_go32_dpmi_get_protected_mode_interrupt_vector(INT_TIMER,&timer_isr_old);
// point NewISR to the proper selector:offset for handler function
timer_isr_new.pm_offset=(DWord)covox_playback_isr;
timer_isr_new.pm_selector=_go32_my_cs();
// chain the new ISR onto the old one so that first the old INT_TIMER ISR will be called, then the new timer ISR
// _go32_dpmi_set_protected_mode_interrupt_vector(INT_TIMER,&timer_isr_new);
_go32_dpmi_chain_protected_mode_interrupt_vector(INT_TIMER,&timer_isr_new);
}
//***************** remove Covox playback ISR from timer interrupt chain ****
void covox_playback_uninstall(void)
{
printf("nRemoving new timer ISR for Covox playback...n");
// load the old timer ISR back without the new ISR chained on
_go32_dpmi_set_protected_mode_interrupt_vector(INT_TIMER,&timer_isr_old);
covox_playback_setup_fs(0); // set default timer speed
}
As I told, under DPMI host you cannot manipulate IVT on your own will but ratther use DPMI function wrappers to do things correctly. Read DJGPP FAQ documnt for more... --- DOS gives me freedom to unlimited HW access. |