init.hh revision 9554
15522Snate@binkert.org/* 25522Snate@binkert.org * Copyright (c) 2008 The Hewlett-Packard Development Company 35522Snate@binkert.org * All rights reserved. 45522Snate@binkert.org * 55522Snate@binkert.org * Redistribution and use in source and binary forms, with or without 65522Snate@binkert.org * modification, are permitted provided that the following conditions are 75522Snate@binkert.org * met: redistributions of source code must retain the above copyright 85522Snate@binkert.org * notice, this list of conditions and the following disclaimer; 95522Snate@binkert.org * redistributions in binary form must reproduce the above copyright 105522Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 115522Snate@binkert.org * documentation and/or other materials provided with the distribution; 125522Snate@binkert.org * neither the name of the copyright holders nor the names of its 135522Snate@binkert.org * contributors may be used to endorse or promote products derived from 145522Snate@binkert.org * this software without specific prior written permission. 155522Snate@binkert.org * 165522Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175522Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185522Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195522Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205522Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215522Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225522Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235522Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245522Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255522Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265522Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275522Snate@binkert.org * 285522Snate@binkert.org * Authors: Nathan Binkert 295522Snate@binkert.org */ 305522Snate@binkert.org 315522Snate@binkert.org#ifndef __SIM_INIT_HH__ 325522Snate@binkert.org#define __SIM_INIT_HH__ 335522Snate@binkert.org 349554Sandreas.hansson@arm.com#include <Python.h> 359554Sandreas.hansson@arm.com 365522Snate@binkert.org/* 375522Snate@binkert.org * Data structure describing an embedded python file. 385522Snate@binkert.org */ 397674Snate@binkert.org#include <list> 407674Snate@binkert.org 418946Sandreas.hansson@arm.com#include <inttypes.h> 428946Sandreas.hansson@arm.com 437674Snate@binkert.org#ifndef PyObject_HEAD 447674Snate@binkert.orgstruct _object; 457674Snate@binkert.orgtypedef _object PyObject; 467674Snate@binkert.org#endif 477674Snate@binkert.org 487674Snate@binkert.orgstruct EmbeddedPython 495522Snate@binkert.org{ 505522Snate@binkert.org const char *filename; 517502Snate@binkert.org const char *abspath; 525522Snate@binkert.org const char *modpath; 538946Sandreas.hansson@arm.com const uint8_t *code; 545522Snate@binkert.org int zlen; 557674Snate@binkert.org int len; 567674Snate@binkert.org 577674Snate@binkert.org EmbeddedPython(const char *filename, const char *abspath, 588946Sandreas.hansson@arm.com const char *modpath, const uint8_t *code, int zlen, int len); 597674Snate@binkert.org 607674Snate@binkert.org PyObject *getCode() const; 617674Snate@binkert.org bool addModule() const; 627674Snate@binkert.org 637674Snate@binkert.org static EmbeddedPython *importer; 647674Snate@binkert.org static PyObject *importerModule; 657674Snate@binkert.org static std::list<EmbeddedPython *> &getList(); 667674Snate@binkert.org static int initAll(); 675522Snate@binkert.org}; 685522Snate@binkert.org 697674Snate@binkert.orgstruct EmbeddedSwig 707674Snate@binkert.org{ 717674Snate@binkert.org void (*initFunc)(); 727674Snate@binkert.org 737674Snate@binkert.org EmbeddedSwig(void (*init_func)()); 747674Snate@binkert.org 757674Snate@binkert.org static std::list<EmbeddedSwig *> &getList(); 767674Snate@binkert.org static void initAll(); 777674Snate@binkert.org}; 785522Snate@binkert.org 799554Sandreas.hansson@arm.comvoid dumpStatsHandler(int sigtype); 809554Sandreas.hansson@arm.comvoid dumprstStatsHandler(int sigtype); 819554Sandreas.hansson@arm.comvoid exitNowHandler(int sigtype); 829554Sandreas.hansson@arm.comvoid abortHandler(int sigtype); 835522Snate@binkert.orgvoid initSignals(); 845522Snate@binkert.orgint initM5Python(); 855522Snate@binkert.orgint m5Main(int argc, char **argv); 869554Sandreas.hansson@arm.comPyMODINIT_FUNC initm5(void); 875522Snate@binkert.org 885522Snate@binkert.org#endif // __SIM_INIT_HH__ 89