?? temp
字號:
/* tab:4 * * * "Copyright (c) 2000-2002 The Regents of the University of California. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose, without fee, and without written * agreement is hereby granted, provided that the above copyright * notice, the following two paragraphs and the author appear in all * copies of this software. * * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS * DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, * UPDATES, ENHANCEMENTS, OR MODIFICATIONS." * *//* tab:4 * * IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. * By downloading, copying, installing or using the software you * agree to this license. If you do not agree to this license, do * not download, install, copy or use the software. * * Intel Open Source License * * Copyright (c) 2002 Intel Corporation * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * *//* * Authors: Philip Levis <pal@cs.berkeley.edu> * Neil Patel * History: Apr 11, 2003 Inception. * */includes AM;includes Bombilla;module BombillaEngine { provides { interface StdControl; interface BombillaError; command result_t computeInstruction(BombillaContext* context); command result_t executeContext(BombillaContext* context); command result_t alertSendContext(BombillaContext* caller, BombillaStackVariable* var); command result_t alertReceiveContext(TOS_MsgPtr msg); } uses { interface StdControl as SubControlTimer; interface StdControl as SubControlNetwork; interface StdControl as SubControl; interface Timer as ClockTimer; interface Leds; interface Random; interface SendMsg as SendError; interface ReceiveMsg as ReceivePacket; interface BombillaStacks as Stacks; interface BombillaBuffer as Buffer; interface BombillaLocks as Locks; interface BombillaContextSynch as Synch; interface BombillaInstruction as Instruction; interface BombillaQueue as Queue; interface BombillaVirus as Virus; interface BombillaAnalysis as Analysis; interface BombillaBytecode as Bytecode[uint8_t bytecode] ; }}implementation { BombillaContext clockContext; BombillaContext sendContext; BombillaContext recvContext; //BombillaContext onceContext; BombillaState state; command result_t StdControl.init() { uint16_t i; dbg(DBG_BOOT, "VM: Bombilla initializing.\n"); call Leds.init(); call Random.init(); call SubControlTimer.init(); call SubControlNetwork.init(); call SubControl.init(); state.inErrorState = FALSE; clockContext.rootCapsule = &state.capsules[BOMB_CAPSULE_CLOCK_INDEX]; clockContext.state = BOMB_STATE_HALT; sendContext.rootCapsule = &state.capsules[BOMB_CAPSULE_SEND_INDEX]; sendContext.state = BOMB_STATE_HALT; recvContext.rootCapsule = &state.capsules[BOMB_CAPSULE_RECV_INDEX]; recvContext.state = BOMB_STATE_HALT; /* onceContext.rootCapsule = &state.capsules[BOMB_CAPSULE_ONCE_INDEX]; onceContext.state = BOMB_STATE_HALT; */ call Queue.init(&state.readyQueue); for (i = 0; i < BOMB_BUF_NUM; i++) { state.buffers[i].type = BOMB_DATA_NONE; state.buffers[i].size = 0; } clockContext.which = BOMB_CAPSULE_CLOCK; sendContext.which = BOMB_CAPSULE_SEND; recvContext.which = BOMB_CAPSULE_RECV; /* onceContext.which = BOMB_CAPSULE_ONCE; */ for (i = 0; i < BOMB_HEAPSIZE; i++) { state.heap[(int)i].type = BOMB_TYPE_VALUE; state.heap[(int)i].value.var = 0; } state.capsules[BOMB_CAPSULE_SUB0].capsule.type = BOMB_CAPSULE_SUB0; state.capsules[BOMB_CAPSULE_SUB1].capsule.type = BOMB_CAPSULE_SUB1; state.capsules[BOMB_CAPSULE_SUB2].capsule.type = BOMB_CAPSULE_SUB2; state.capsules[BOMB_CAPSULE_SUB3].capsule.type = BOMB_CAPSULE_SUB3; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.type = BOMB_CAPSULE_CLOCK; state.capsules[BOMB_CAPSULE_RECV_INDEX].capsule.type = BOMB_CAPSULE_RECV; state.capsules[BOMB_CAPSULE_SEND_INDEX].capsule.type = BOMB_CAPSULE_SEND; state.capsules[BOMB_CAPSULE_ONCE_INDEX].capsule.type = BOMB_CAPSULE_ONCE; for (i = 0; i < BOMB_CAPSULE_NUM; i++) { state.capsules[i].capsule.type |= BOMB_OPTION_FORWARD; if (TOS_LOCAL_ADDRESS == 25 && i == BOMB_CAPSULE_CLOCK_INDEX) { state.capsules[i].capsule.version = 1; state.capsules[i].capsule.type |= BOMB_OPTION_FORWARD; } else { state.capsules[i].capsule.version = 0; } call Virus.registerCapsule(state.capsules[i].capsule.type, &(state.capsules[i].capsule)); } { int pc = 0; /* state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPpushc|1; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPsense; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPgetvar|1; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPadd; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPcopy; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPcopy; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPpushc|7; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPland; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPputled; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPsetvar|1; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPpushc|2; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPbpush0; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPadd; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPadd; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPbsize; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPbpush0; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPbtail; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPbpush0; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPbclear; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPhalt; */ state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPpushc | 1; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPgetvar | 0; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPadd; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPcopy; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPcopy; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPsetvar | 0; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPpushc | 7; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPland; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPputled; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPbpush0; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPbclear; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPadd; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPsendr; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.code[pc++] = OPhalt; state.capsules[BOMB_CAPSULE_CLOCK_INDEX].capsule.version = 0; pc = 0; state.capsules[BOMB_CAPSULE_SEND_INDEX].capsule.code[pc++] = OPpushc; state.capsules[BOMB_CAPSULE_SEND_INDEX].capsule.code[pc++] = OPlnot; state.capsules[BOMB_CAPSULE_SEND_INDEX].capsule.code[pc++] = OPsendr; state.capsules[BOMB_CAPSULE_SEND_INDEX].capsule.code[pc++] = OPhalt; state.capsules[BOMB_CAPSULE_SEND_INDEX].capsule.options = 0; state.capsules[BOMB_CAPSULE_SEND_INDEX].capsule.version = 0; pc = 0; //state.capsules[BOMB_CAPSULE_RECV_INDEX].capsule.code[pc++] = OPpushc; //state.capsules[BOMB_CAPSULE_RECV_INDEX].capsule.code[pc++] = OPbyank; state.capsules[BOMB_CAPSULE_RECV_INDEX].capsule.code[pc++] = OPbhead; state.capsules[BOMB_CAPSULE_RECV_INDEX].capsule.code[pc++] = OPpushc | 7; state.capsules[BOMB_CAPSULE_RECV_INDEX].capsule.code[pc++] = OPland; state.capsules[BOMB_CAPSULE_RECV_INDEX].capsule.code[pc++] = OPputled; state.capsules[BOMB_CAPSULE_RECV_INDEX].capsule.code[pc++] = OPhalt; state.capsules[BOMB_CAPSULE_RECV_INDEX].capsule.options = 0; state.capsules[BOMB_CAPSULE_RECV_INDEX].capsule.version = 0; } call Analysis.analyzeCapsuleVars(&state, BOMB_CAPSULE_CLOCK_INDEX); call Analysis.analyzeCapsuleVars(&state, BOMB_CAPSULE_SEND_INDEX); call Analysis.analyzeCapsuleVars(&state, BOMB_CAPSULE_RECV_INDEX); return SUCCESS; } task void ClockTask() { call computeInstruction(&clockContext); if (clockContext.state == BOMB_STATE_RUN) { dbg(DBG_USR1, "VM: Posting ClockTask in task.\n"); post ClockTask();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -