For some reason its not working, i get all the way to iret, but its not calling my procedure that i wanna schedule.
here i initialize the stack and put "garbage" so that when the stack is used for the first time it has useful data
Code: Select all
void run()
{
//set a new stack, why cant i use 0x00100000?
procesos[indicePCB].ebpBackup = 0x000E0000;//malloc1MB();
//should they both be the same value?
procesos[indicePCB].espBackup = procesos[indicePCB].ebpBackup;
//i do a backup of the current stack
__asm__ ("mov eax, ebp" : "=a" (tempSS) :);
__asm__ ("mov eax, esp" : "=a" (tempSP) :);
//set the stack to run
__asm__ ( "mov ebp, eax" : : "a"(procesos[indicePCB].ebpBackup));
__asm__ ( "mov esp, eax" : : "a"(procesos[indicePCB].espBackup));
//push proc to call when program ends
__asm__ ( "push eax" : : "a"(&punteroEndProgram)); //
//program to call
__asm__ ( "push eax" : : "a"(&vectorProgramas[indice]));
//save registries with gargabe to pop out the 1st time, same with flags
__asm__ ( "pusha" ); //registros
__asm__ ( "pushf" ); //banderas
//put the call irq0 cont after an interrupt
__asm__ ( "push eax" : : "a"(&irq0Cont)); //
//update esp
__asm__ ("mov eax, esp" : "=a" (procesos[indicePCB].espBackup) :);
//print(" PRUEBA ");
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//restore old stack
__asm__ ( "mov ebp, eax" : : "a"(tempSS) );
__asm__ ( "mov esp, eax" : : "a"(tempSP) );
}
Code: Select all
_irq0:
pushad
pushfd
cli
call _schedule
_irq0Cont:
popfd
popad
sti
iretd
Code: Select all
void schedule ()
{
print("\n IRQ_0 INI ");
if (procesoActual == ultimoProceso)
{
procesoActual = primerProceso;
}
else
{
procesoActual++;
if (procesoActual >= 5)
{
procesoActual = 0;
}
}
//allow interrupts later on from PIT
out(0x20, 0x20);
//load EBP and ESP
__asm__ ( "mov ebp, eax" : : "a"(procesos[colaEnteros[procesoActual]].ebpBackup));
__asm__ ( "mov esp, eax" : : "a"(procesos[colaEnteros[procesoActual]].espBackup));
//NECESARY?
__asm__("push ebp");
__asm__("mov ebp, esp");
print("\n IRQ_0 END ");
}