コード例 #1
0
ファイル: Clock.cpp プロジェクト: trapexit/Nebula
std::unique_ptr<ClockState>
Clock::run() {
    setActive();

    LOG( CLOCK, info ) << "Simulation is active.";

    while ( isActive() ) {
        if ( ! _state.isOn ) {
            // Do nothing until the clock is triggered by the processor.
            LOG( CLOCK, info ) << "Off. Waiting for interrupt.";

            _procInt->waitForTriggerOrDeath( *this );
        }

        auto now = std::chrono::system_clock::now();

        if ( _procInt->isActive() ) {
            LOG( CLOCK, info ) << "Got interrupt.";

            auto proc = _procInt->state();
            auto a = proc->read( Register::A );

            switch ( a ) {
            case 0:
                handleInterrupt( ClockOperation::SetDivider, proc );
                break;
            case 1:
                handleInterrupt( ClockOperation::StoreElapsed, proc );
                break;
            case 2:
                handleInterrupt( ClockOperation::EnableInterrupts, proc );
                break;
            }
            
            _procInt->respond();

            LOG( CLOCK, info ) << "Handled interrupt.";
        }

        std::this_thread::sleep_until( now + (sim::CLOCK_BASE_PERIOD * _state.divider) );
        _state.elapsed += 1;

        if ( _state.interruptsEnabled ) {
            _computer.queue().push( _state.message );
        }
    }

    LOG( CLOCK, info ) << "Shutting down.";
    return make_unique<ClockState>( _state );
}
コード例 #2
0
ファイル: syscall.c プロジェクト: G-VAR/seL4
exception_t
handleInterruptEntry(void)
{
    irq_t irq;

    irq = getActiveIRQ();
#if defined(DEBUG) || defined(CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES)
    ksKernelEntry.path = Entry_Interrupt;
    ksKernelEntry.word = irq;
#endif /* DEBUG */

#ifdef CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES
    benchmark_track_start();
#endif

    if (irq != irqInvalid) {
        handleInterrupt(irq);
    } else {
#ifdef CONFIG_IRQ_REPORTING
        printf("Spurious interrupt\n");
#endif
        handleSpuriousIRQ();
    }

    schedule();
    activateThread();

#ifdef CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES
    benchmark_track_exit();
#endif

    return EXCEPTION_NONE;
}
コード例 #3
0
bool SpeechRecognizerModule::respond(const Bottle& cmd, Bottle& reply) 
{
	reply.addString("ACK");
    string firstVocab = cmd.get(0).asString().c_str();

    if (firstVocab == "tts")
    {
        string sentence = cmd.get(1).asString().c_str();
        say(sentence);
        reply.addString("OK");
    }
    else if (firstVocab == "RGM" || firstVocab == "rgm" )
    {    
        string secondVocab = cmd.get(1).asString().c_str();
        if (secondVocab=="vocabulory")
            handleRGMCmd(cmd.tail().tail(), reply);
    }
    else if (firstVocab == "recog")
    {
        handleRecognitionCmd(cmd.tail(), reply);
    }
    else if (firstVocab == "asyncrecog")
    {
        handleAsyncRecognitionCmd(cmd.tail(), reply);
    }
    else if (firstVocab == "interrupt")
    {
        handleInterrupt(cmd.tail(), reply);
    }
    else
        reply.addString("UNKNOWN");

    return true;
}
コード例 #4
0
ファイル: processor.cpp プロジェクト: archshift/decaf-emu
// Entry point of CPU Core threads
void
Processor::coreEntryPoint(Core *core)
{
    tCurrentCore = core;

    platform::ui::initialiseCore(core->id);

    core->primaryFiber = ConvertThreadToFiber(NULL);

    while (mRunning) {
        // Intentionally do this before the lock...
        gDebugControl.maybeBreak(0, nullptr, core->id);

        std::unique_lock<std::mutex> lock { mMutex };

        // Free any fibers which need to be deleted
        for (auto fiber : core->mFiberDeleteList) {
            delete fiber;
        }

        core->mFiberDeleteList.clear();

        if (auto fiber = peekNextFiberNoLock(core->id)) {
            // Remove fiber from schedule queue
            mFiberQueue.erase(std::remove(mFiberQueue.begin(), mFiberQueue.end(), fiber), mFiberQueue.end());

            // Switch to fiber
            core->currentFiber = fiber;
            fiber->coreID = core->id;
            fiber->parentFiber = core->primaryFiber;
            fiber->thread->state = OSThreadState::Running;
            lock.unlock();

            gLog->trace("Core {} enter thread {}", core->id, fiber->thread->id);
            SwitchToFiber(fiber->handle);
        } else if (core->interrupt) {
            // Switch to the interrupt thread for any waiting interrupts
            lock.unlock();
            handleInterrupt();
        } else {
            // Wait for a valid fiber
            gLog->trace("Core {} wait for thread", core->id);
            mCondition.wait(lock);
        }
    }
}
コード例 #5
0
ファイル: syscall.c プロジェクト: dnm/seL4
exception_t
handleInterruptEntry(void)
{
    irq_t irq;

    irq = getActiveIRQ();
    if (irq != irqInvalid) {
        handleInterrupt(irq);
    } else {
        printf("Spurious interrupt\n");
        handleSpuriousIRQ();
    }

    schedule();
    activateThread();

    return EXCEPTION_NONE;
}
コード例 #6
0
ファイル: syscall.c プロジェクト: buaakq/RefOS
exception_t
handleInterruptEntry(void)
{
    irq_t irq;
    //printf("==in handleInterruptEntry function===\n");
    irq = getActiveIRQ();
    if (irq != irqInvalid) {
        //printf("will call hanleInterrupt function\n");
        handleInterrupt(irq);
    } else {
        //printf("Spurious interrupt\n");
        handleSpuriousIRQ();
    }
    //printf("will schedule\n");
    schedule();
    activateThread();

    return EXCEPTION_NONE;
}
コード例 #7
0
ファイル: syscall.c プロジェクト: SummerSnail2014/seL4
exception_t
handleInterruptEntry(void)
{
    irq_t irq;

    irq = getActiveIRQ();
#ifdef DEBUG
    ksKernelEntry.path = Debug_Interrupt;
    ksKernelEntry.irq = irq;
#endif /* DEBUG */
    if (irq != irqInvalid) {
        handleInterrupt(irq);
    } else {
#ifdef CONFIG_IRQ_REPORTING
        printf("Spurious interrupt\n");
#endif
        handleSpuriousIRQ();
    }

    schedule();
    activateThread();

    return EXCEPTION_NONE;
}
コード例 #8
0
ファイル: syscall.c プロジェクト: dnm/seL4
exception_t
handleSyscall(syscall_t syscall)
{
    exception_t ret;
    irq_t irq;

    switch (syscall) {
    case SysSend:
        ret = handleInvocation(false, true);
        if (unlikely(ret != EXCEPTION_NONE)) {
            irq = getActiveIRQ();
            if (irq != irqInvalid) {
                handleInterrupt(irq);
            }
        }
        break;

    case SysNBSend:
        ret = handleInvocation(false, false);
        if (unlikely(ret != EXCEPTION_NONE)) {
            irq = getActiveIRQ();
            if (irq != irqInvalid) {
                handleInterrupt(irq);
            }
        }
        break;

    case SysCall:
        ret = handleInvocation(true, true);
        if (unlikely(ret != EXCEPTION_NONE)) {
            irq = getActiveIRQ();
            if (irq != irqInvalid) {
                handleInterrupt(irq);
            }
        }
        break;

    case SysWait:
        handleWait();
        break;

    case SysReply:
        handleReply();
        break;

    case SysReplyWait:
        handleReply();
        handleWait();
        break;

    case SysYield:
        handleYield();
        break;

    default:
        fail("Invalid syscall");
    }

    schedule();
    activateThread();

    return EXCEPTION_NONE;
}
コード例 #9
0
ファイル: syscall.c プロジェクト: SummerSnail2014/seL4
exception_t
handleSyscall(syscall_t syscall)
{
    exception_t ret;
    irq_t irq;

#ifdef DEBUG
    ksKernelEntry.path = Debug_Syscall;
    ksKernelEntry.syscall_no = syscall;
#endif /* DEBUG */

    switch (syscall) {
    case SysSend:
        ret = handleInvocation(false, true);
        if (unlikely(ret != EXCEPTION_NONE)) {
            irq = getActiveIRQ();
            if (irq != irqInvalid) {
                handleInterrupt(irq);
            }
        }
        break;

    case SysNBSend:
        ret = handleInvocation(false, false);
        if (unlikely(ret != EXCEPTION_NONE)) {
            irq = getActiveIRQ();
            if (irq != irqInvalid) {
                handleInterrupt(irq);
            }
        }
        break;

    case SysCall:
        ret = handleInvocation(true, true);
        if (unlikely(ret != EXCEPTION_NONE)) {
            irq = getActiveIRQ();
            if (irq != irqInvalid) {
                handleInterrupt(irq);
            }
        }
        break;

    case SysRecv:
        handleRecv(true);
        break;

    case SysReply:
        handleReply();
        break;

    case SysReplyRecv:
        handleReply();
        handleRecv(true);
        break;

    case SysNBRecv:
        handleRecv(false);
        break;

    case SysYield:
        handleYield();
        break;

    default:
        fail("Invalid syscall");
    }

    schedule();
    activateThread();

    return EXCEPTION_NONE;
}
コード例 #10
0
ファイル: Monitor.cpp プロジェクト: trapexit/Nebula
std::unique_ptr<MonitorState> Monitor::run() {
    setActive();

    LOG( MONITOR, info ) << "Simulation is active.";
    _screen = std::move( sdl::SCREEN );

    while ( isActive() )  {
        if ( ! _state.isConnected ) {
            LOG( MONITOR, info ) << "Disconnected. Waiting for interrupt.";

            _procInt->waitForTriggerOrDeath( *this );
        }

        if ( _procInt->isActive() ) {
            LOG( MONITOR, info ) << "Got interrupt.";

            auto proc = _procInt->state();
            auto a = proc->read( Register::A );

            switch ( a ) {
            case 0:
                handleInterrupt( MonitorOperation::MapVideoMemory, proc );
                break;
            case 1:
                handleInterrupt( MonitorOperation::MapFontMemory, proc );
                break;
            case 2:
                handleInterrupt( MonitorOperation::MapPaletteMemory, proc );
                break;
            case 3:
                handleInterrupt( MonitorOperation::SetBorderColor, proc );
                break;
            case 4:
                handleInterrupt( MonitorOperation::DumpFont, proc );
                break;
            case 5:
                handleInterrupt( MonitorOperation::DumpPalette, proc );
                break;
            }

            _procInt->respond();

            LOG( MONITOR, info ) << "Handled interrupt.";
        }

        clear();

        if ( _state.isConnected ) {
            // Show the start-up image if the monitor is still initializing.
            if ( _state.timeSinceConnected ) {
                *_state.timeSinceConnected += sim::MONITOR_FRAME_DURATION;
                drawStartUp();

                if ( *_state.timeSinceConnected >=
                     std::chrono::duration_cast<std::chrono::microseconds>( sim::MONITOR_START_UP_DURATION ) ) {

                    _state.timeSinceConnected.reset();
                }
            } else {
                drawBorder();
                drawFromMemory();
            }
        }

        update();
        std::this_thread::sleep_for( sim::MONITOR_FRAME_DURATION );

        _state.sinceLastBlink += sim::MONITOR_FRAME_DURATION;

        if ( _state.sinceLastBlink >=
             std::chrono::duration_cast<std::chrono::microseconds>( sim::MONITOR_BLINK_DURATION ) ) {

            _state.sinceLastBlink = std::chrono::microseconds { 0 };
            _state.blinkVisible = ! _state.blinkVisible;
        }
    }

    LOG( MONITOR, info ) << "Shutting down.";
    return {};
}
コード例 #11
0
ファイル: syscall.c プロジェクト: G-VAR/seL4
exception_t
handleSyscall(syscall_t syscall)
{
    exception_t ret;
    irq_t irq;

#if defined(DEBUG) || defined(CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES)
    ksKernelEntry.path = Entry_Syscall;
    ksKernelEntry.syscall_no = syscall;
#endif /* DEBUG */
#ifdef CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES
    benchmark_track_start();
#endif /* CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES */

    switch (syscall) {
    case SysSend:
        ret = handleInvocation(false, true);
        if (unlikely(ret != EXCEPTION_NONE)) {
            irq = getActiveIRQ();
            if (irq != irqInvalid) {
                handleInterrupt(irq);
            }
        }
        break;

    case SysNBSend:
        ret = handleInvocation(false, false);
        if (unlikely(ret != EXCEPTION_NONE)) {
            irq = getActiveIRQ();
            if (irq != irqInvalid) {
                handleInterrupt(irq);
            }
        }
        break;

    case SysCall:
        ret = handleInvocation(true, true);
        if (unlikely(ret != EXCEPTION_NONE)) {
            irq = getActiveIRQ();
            if (irq != irqInvalid) {
                handleInterrupt(irq);
            }
        }
        break;

    case SysRecv:
        handleRecv(true);
        break;

    case SysReply:
        handleReply();
        break;

    case SysReplyRecv:
        handleReply();
        handleRecv(true);
        break;

    case SysNBRecv:
        handleRecv(false);
        break;

    case SysYield:
        handleYield();
        break;

    default:
        fail("Invalid syscall");
    }

    schedule();
    activateThread();

#ifdef CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES
    benchmark_track_exit();
#endif /* CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES */
    return EXCEPTION_NONE;
}
コード例 #12
0
void PORTE_IRQHandler(void)
{
    handleInterrupt(PORT_E);
    Dash.wakeFromSleep();
}
コード例 #13
0
void StreamClient::onErrorOccured()
{
    handleInterrupt();
}
コード例 #14
0
ファイル: syscall.c プロジェクト: buaakq/RefOS
exception_t
handleSyscall(syscall_t syscall)
{
    exception_t ret;
    irq_t irq;

//printf("\n=====In handleSyscall funtion======\n");
//printf("syscall num is %d\n", syscall);
//printf("caller is %d of domain %d\n", ksCurThread->tcbPriority, ksCurThread->tcbDomain);

    switch (syscall) {
    case SysSend:
        ret = handleInvocation(false, true);
        if (unlikely(ret != EXCEPTION_NONE)) {
            irq = getActiveIRQ();
            if (irq != irqInvalid) {
                handleInterrupt(irq);
            }
        }
        break;

    case SysNBSend:
        ret = handleInvocation(false, false);
        if (unlikely(ret != EXCEPTION_NONE)) {
            irq = getActiveIRQ();
            if (irq != irqInvalid) {
                handleInterrupt(irq);
            }
        }
        break;

    case SysCall:
        ret = handleInvocation(true, true);
        if (unlikely(ret != EXCEPTION_NONE)) {
            irq = getActiveIRQ();
            if (irq != irqInvalid) {
                handleInterrupt(irq);
            }
        }
        break;

    case SysWait:
//printf("will call handleWait\n");
        handleWait(true);
        break;

    case SysReply:
        handleReply();
        break;

    case SysReplyWait:
        handleReply();
        handleWait(true);
        break;

    case SysPoll:
        handleWait(false);
        break;

    case SysYield:
        handleYield();
        break;

    default:
        fail("Invalid syscall");
    }

    schedule();
    activateThread();

    return EXCEPTION_NONE;
}