Exemple #1
0
        private static unsafe void TimerHandler(IDT.ISRData data)
        {
            ticks++;

            for (int x = 0; x < EntryModule.MaxEventHandlers; ++x)
            {
                if (timerEvent[x] == 0)
                {
                    continue;
                }

                MemoryUtil.Call(timerEvent[x], ticks);
            }


            SharpOS.Kernel.ADC.Thread thread = Dispatcher.Dispatch((void *)data.Stack);
            if (thread != null)
            {
                IDT.Stack *newStack = (IDT.Stack *)thread.StackPointer;
                newStack->IrqIndex = data.Stack->IrqIndex;
                data.Stack         = newStack;
            }
        }
Exemple #2
0
        internal static unsafe void *CreateStack(uint function_address)
        {
            IDT.Stack *stack = (IDT.Stack *)
                                   (((byte *)MemoryManager.Allocate(STACK_SIZE))
                                   + (STACK_SIZE - (uint)sizeof(IDT.Stack)));

            if (stack == null)
            {
                return(null);
            }

            // ... temp code
            stack->FS = GDT.DataSelector;
            stack->GS = GDT.DataSelector;
            stack->ES = GDT.DataSelector;
            stack->DS = GDT.DataSelector;
            stack->SS = GDT.DataSelector;
            stack->CS = GDT.CodeSelector;

            stack->EIP = function_address;

            stack->UserESP     =
                stack->EBP     =
                    stack->ESP = (uint)stack;           // stack pointer

            stack->EFlags = 0x00000202;

            // |------| start of stack memory
            // |      |
            // |      |  = ESP
            // | DATA |
            // | DATA |  = EBP
            // | DATA |
            // |------| end of stack memory

            return((void *)stack);
        }