- fix wxWindows on win32, which was broken when we added plugin support.
- add a new global struct bx_startup_flags which stores argc,argv and when necessary, the WinMain arguments hInstance, hPrevInstance, etc. The new struct is defined in gui/siminterface.h because it is needed in both the main.cc code and in wxmain.cc and textconfig.cc (which don't include bochs.h). - rename main() to bxmain() and create new main() and WinMain(). main() and WinMain() just fill in the bx_startup_flags and then call bxmain(). Only one is defined at a time, of course. - so far, WinMain is ONLY used when compiling with wxWindows on win32. It may be useful in other contexts as well, but I don't want to enable it in any other situation without some serious testing of different configurations. - modified: main.cc gui/siminterface.cc gui/siminterface.h gui/textconfig.cc gui/wxmain.cc
This commit is contained in:
parent
692ee03065
commit
c6d6b17c9a
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: siminterface.cc,v 1.80 2002-10-27 21:25:33 cbothamy Exp $
|
||||
// $Id: siminterface.cc,v 1.81 2002-11-01 15:19:40 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// See siminterface.h for description of the siminterface concept.
|
||||
@ -693,9 +693,6 @@ bx_real_sim_c::configuration_interface(const char *ignore, ci_command_t command)
|
||||
int
|
||||
bx_real_sim_c::begin_simulation (int argc, char *argv[])
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
#warning does the config interface actually need to pass these args into bx_begin_simulation?? None of them is actually doing it.
|
||||
#endif
|
||||
return bx_begin_simulation (argc, argv);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: siminterface.h,v 1.82 2002-10-29 22:26:31 yakovlev Exp $
|
||||
// $Id: siminterface.h,v 1.83 2002-11-01 15:19:43 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Before I can describe what this file is for, I have to make the
|
||||
@ -1247,3 +1247,26 @@ BOCHSAPI extern bx_simulator_interface_c *SIM;
|
||||
|
||||
BOCHSAPI extern void bx_init_siminterface ();
|
||||
BOCHSAPI extern int bx_init_main (int argc, char *argv[]);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// Just to provide HINSTANCE, etc. in files that have not included bochs.h.
|
||||
// I don't like this at all, but I don't see a way around it.
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
// define structure to hold data that is passed into our main function.
|
||||
typedef struct BOCHSAPI {
|
||||
// standard argc,argv
|
||||
int argc;
|
||||
char **argv;
|
||||
#ifdef __WXMSW__
|
||||
// these are only used when compiling with wxWindows. This gives us a
|
||||
// place to store the data that was passed to WinMain.
|
||||
HINSTANCE hInstance;
|
||||
HINSTANCE hPrevInstance;
|
||||
LPSTR m_lpCmdLine;
|
||||
int nCmdShow;
|
||||
#endif
|
||||
} bx_startup_flags_t;
|
||||
|
||||
extern bx_startup_flags_t BOCHSAPI bx_startup_flags;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: textconfig.cc,v 1.1 2002-10-29 20:17:05 bdenney Exp $
|
||||
// $Id: textconfig.cc,v 1.2 2002-11-01 15:19:47 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This is code for a text-mode configuration interfac. Note that this file
|
||||
@ -406,8 +406,7 @@ int bx_config_interface (int menu)
|
||||
bx_config_interface_init ();
|
||||
return 0;
|
||||
case BX_CI_START_SIMULATION: {
|
||||
char *myargv[] = {"manufactured-argv"};
|
||||
SIM->begin_simulation (1, myargv);
|
||||
SIM->begin_simulation (bx_startup_flags.argc, bx_startup_flags.argv);
|
||||
// we don't expect it to return, but if it does, quit
|
||||
SIM->quit_sim(1);
|
||||
break;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// $Id: wxmain.cc,v 1.73 2002-10-26 13:22:47 bdenney Exp $
|
||||
// $Id: wxmain.cc,v 1.74 2002-11-01 15:19:48 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// wxmain.cc implements the wxWindows frame, toolbar, menus, and dialogs.
|
||||
@ -158,12 +158,22 @@ static int ci_callback (void *userdata, ci_command_t command)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case CI_START: {
|
||||
case CI_START:
|
||||
//fprintf (stderr, "wxmain.cc: start\n");
|
||||
char *argv[] = {"manufactured-argv"};
|
||||
wxEntry (1, argv);
|
||||
#ifdef __WXMSW__
|
||||
// on Windows only, wxEntry needs some data that is passed into WinMain.
|
||||
// So, in main.cc we define WinMain and fill in the bx_startup_flags
|
||||
// structure with the data, so that when we're ready to call wxEntry
|
||||
// it has access to the data.
|
||||
wxEntry (
|
||||
bx_startup_flags.hInstance,
|
||||
bx_startup_flags.hPrevInstance,
|
||||
bx_startup_flags.m_lpCmdLine,
|
||||
bx_startup_flags.nCmdShow);
|
||||
#else
|
||||
wxEntry (bx_startup_flags.argc, bx_startup_flags.argv);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case CI_RUNTIME_CONFIG:
|
||||
fprintf (stderr, "wxmain.cc: runtime config not implemented\n");
|
||||
break;
|
||||
@ -1477,9 +1487,7 @@ SimThread::Entry (void)
|
||||
static jmp_buf context; // this must not go out of scope. maybe static not needed
|
||||
if (setjmp (context) == 0) {
|
||||
SIM->set_quit_context (&context);
|
||||
int argc=1;
|
||||
char *argv[] = {"bochs"};
|
||||
SIM->begin_simulation (argc, argv);
|
||||
SIM->begin_simulation (bx_startup_flags.argc, bx_startup_flags.argv);
|
||||
wxLogDebug ("in SimThread, SIM->begin_simulation() exited normally");
|
||||
} else {
|
||||
wxLogDebug ("in SimThread, SIM->begin_simulation() exited by longjmp");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: main.cc,v 1.171 2002-10-30 18:30:29 yakovlev Exp $
|
||||
// $Id: main.cc,v 1.172 2002-11-01 15:19:34 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -70,6 +70,7 @@ static char *divider = "========================================================
|
||||
static logfunctions thePluginLog;
|
||||
logfunctions *pluginlog = &thePluginLog;
|
||||
|
||||
bx_startup_flags_t bx_startup_flags;
|
||||
|
||||
/* typedefs */
|
||||
|
||||
@ -1402,12 +1403,13 @@ static void setupWorkingDirectory (char *path)
|
||||
}
|
||||
#endif
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
int bxmain () {
|
||||
bx_init_siminterface (); // create the SIM object
|
||||
static jmp_buf context;
|
||||
if (setjmp (context) == 0) {
|
||||
SIM->set_quit_context (&context);
|
||||
if (bx_init_main (argc, argv) < 0) return 0;
|
||||
if (bx_init_main (bx_startup_flags.argc, bx_startup_flags.argv) < 0)
|
||||
return 0;
|
||||
// read a param to decide which config interface to start.
|
||||
// If one exists, start it. If not, just begin.
|
||||
bx_param_enum_c *ci_param = SIM->get_param_enum (BXP_SEL_CONFIG_INTERFACE);
|
||||
@ -1432,6 +1434,34 @@ int main (int argc, char *argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
extern "C" int WinMain(
|
||||
HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR m_lpCmdLine, int nCmdShow)
|
||||
{
|
||||
bx_startup_flags.hInstance = hInstance;
|
||||
bx_startup_flags.hPrevInstance = hPrevInstance;
|
||||
bx_startup_flags.m_lpCmdLine = m_lpCmdLine;
|
||||
bx_startup_flags.nCmdShow = nCmdShow;
|
||||
#ifdef __GNUC__
|
||||
#warning should split m_lpCmdLine and fill argc,argv for real.
|
||||
#endif
|
||||
// make fake argc,argv.
|
||||
bx_startup_flags.argc=1;
|
||||
static char *my_argv[] = {"bochs"};
|
||||
bx_startup_flags.argv=my_argv;
|
||||
return bxmain ();
|
||||
}
|
||||
#else
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
bx_startup_flags.argc = argc;
|
||||
bx_startup_flags.argv = argv;
|
||||
return bxmain ();
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
print_usage ()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user