4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
30 * Copyright 2000, 2001 Bernardo Innocenti <bernie@codewiz.org>
36 * \author Bernardo Innocenti <bernie@develer.com>
38 * \brief Qt-based emulator framework for embedded applications (implementation)
44 #include "cfg/cfg_kern.h"
46 #include <cfg/module.h>
50 #include <cstdlib> // std::exit()
52 #include <QtGui/qapplication.h>
55 /// The global emulator instance.
59 #include <mware/list.h>
61 /// List of process stacks
64 // HACK: Reserve 64KB of stack space for kernel processes
66 int stacks[NPROC][(64 * 1024) / sizeof(int)];
69 Emulator::Emulator(int &argc, char **argv) :
70 emulApp(new QApplication(argc, argv)),
71 emulWin(new EmulWin(this))
79 // we don't delete emulWin because it automatically
80 // deletes itself when closed
85 NORETURN void Emulator::quit()
91 // do we have a better way to shut down the emulation?
97 /// Main emulator entry point.
98 extern "C" void emul_init(int *argc, char *argv[])
100 // setup global emulator pointer
101 emul = new Emulator(*argc, argv);
104 LIST_INIT(&StackFreeList);
105 for (int i = 0; i < NPROC; i++)
106 ADDTAIL(&StackFreeList, (Node *)stacks[i]);
112 extern "C" void emul_cleanup()
120 extern "C" void emul_idle()
122 // We process GUI events when the application is idle.
123 emul->emulApp->processEvents();