コード例 #1
0
ファイル: main.c プロジェクト: RajasekharBhumi/L4Re
/******************************************************************************
 * main                                                                       *
 *                                                                            *
 * Main function                                                              *
 ******************************************************************************/
int main(int argc, char *argv[])
{
  int error = 0, i=1;
  l4_threadid_t dummy_l4id = L4_NIL_ID, loader_id;
//  l4events_event_t event;
//  l4events_nr_t eventnr;

  CORBA_Environment _env = dice_default_environment;

  /* init */
  do_args(argc, argv);
  my_l4id = l4thread_l4_id( l4thread_myself() );

  LOG("Hello, I'm running as "l4util_idfmt, l4util_idstr(my_l4id));

  /* ask for 'con' (timeout = 5000 ms) */
  if (names_waitfor_name(CON_NAMES_STR, &con_l4id, 50000) == 0) 
    {
      LOG("PANIC: %s not registered at names", CON_NAMES_STR);
      enter_kdebug("panic");
    }

  if (names_waitfor_name("LOADER", &loader_id, 50000) == 0)
    {
      LOG("PANIC: LOADER not registered at names");
      enter_kdebug("panic");
    }
  
  if (con_if_openqry_call(&con_l4id, MY_SBUF_SIZE, 0, 0,
		     L4THREAD_DEFAULT_PRIO,
		     &vc_l4id, 
	  	     CON_VFB, &_env))
    enter_kdebug("Ouch, open vc failed");
  
  if (con_vc_smode_call(&vc_l4id, CON_OUT, &dummy_l4id, &_env))
    enter_kdebug("Ouch, setup vc failed");

  if (con_vc_graph_gmode_call(&vc_l4id, &gmode, &xres, &yres,
			 &bits_per_pixel, &bytes_per_pixel,
			 &bytes_per_line, &accel_flags, 
			 &fn_x, &fn_y, &_env))
    enter_kdebug("Ouch, graph_gmode failed");

  if (bytes_per_pixel != 2)
    {
      printf("Graphics mode not 2 bytes/pixel, exiting\n");
      con_vc_close_call(&vc_l4id, &_env);
      exit(0);
    }

  if (create_logo())
    enter_kdebug("Ouch, logo creation failed");

  while (!error && (i>0)) 
    {
      if ((error = clear_screen()))
	enter_kdebug("Ouch, clear_screen failed");
      if ((error = logo()))
	enter_kdebug("Ouch, logo failed");
      l4_sleep(500);
      i--;
    }

  if (con_vc_close_call(&vc_l4id, &_env))
    enter_kdebug("Ouch, close vc failed?!");
  
  LOG("Finally closed vc");

  LOG("Going to bed ...");

  names_register("CON_DEMO1");
/*
  my_id = l4_myself();
  event.len=sizeof(l4_umword_t);
  *(l4_umword_t*)event.str=my_id.id.task;
  
  l4events_send(1, &event, &eventnr, L4EVENTS_SEND_ACK);
  l4events_get_ack(eventnr, L4_IPC_NEVER);
*/  
  return 0;
}
コード例 #2
0
ファイル: main.c プロジェクト: ErisBlastar/osfree
void main (int argc, char *argv[])
{
  CORBA_Server_Environment env = dice_default_server_environment;
  l4dm_dataspace_t ds;
  l4_threadid_t pager;
  l4_addr_t addr;
  l4_size_t size;
  int  rc, t;
  int  is_int = 0;
  int  value_int = 0;
  char buf[0x1000];
  char *p = buf;
  int optionid;
  int opt = 0;
  const struct option long_options[] =
                {
                { "events",      no_argument, NULL, 'e'},
		{ 0, 0, 0, 0}
                };

  //init_globals();

  if (!names_register("os2exec"))
    {
      LOG("Error registering on the name server!");
      return;
    }

  if (!names_waitfor_name("os2srv", &os2srv, 30000))
    {
      LOG("os2srv not found on name server!");
      return;
    }

  if (!names_waitfor_name("os2fs", &fs, 30000))
    {
      LOG("os2fs not found on name server!");
      return;
    }
  LOG("os2fs tid:%x.%x", fs.id.task, fs.id.lthread);

  if (!names_waitfor_name("LOADER", &loader, 30000))
    {
      LOG("LOADER not found on name server!");
      return;
    }

  execsrv = l4_myself();

  // Parse command line arguments
  for (;;)
  {
    opt = getopt_long(argc, argv, "e", long_options, &optionid);
    if (opt == -1) break;
    switch (opt)
    {
      case 'e':
        LOG("using events server");
	use_events = 1;
	break;
      
      default:
        LOG("Error: Unknown option %c", opt);
        usage();
        return;
    }
  }

  // start events thread
  if (use_events)
  {
    // start events thread
    l4thread_create(event_thread, 0, L4THREAD_CREATE_ASYNC);
    LOG("event thread started");
  }

  /* reserve the area below 64 Mb for application private code
     (not for use by libraries, loaded by execsrv) */
  addr = 0x2f000; size = 0x04000000 - addr;
  if ((rc  = l4rm_direct_area_setup_region(addr,
					   size,
					   L4RM_DEFAULT_REGION_AREA,
					   L4RM_REGION_BLOCKED, 0,
					   L4_INVALID_ID)) < 0)
    {
      LOG_printf("main(): setup region %x-%x failed (%d)!\n",
	  addr, addr + size, rc);
      l4rm_show_region_list();
      enter_kdebug("PANIC");
    }
  memset (&options, 0, sizeof(options));

#if 0
  if (!CfgGetopt("debugmodmgr", &is_int, &value_int, (char **)&p))
    if (is_int)
      options.debugmodmgr = value_int;

  if (!CfgGetopt("debugixfmgr", &is_int, &value_int, (char **)&p))
    if (is_int)
      options.debugixfmgr = value_int;

  if (!CfgGetopt("libpath", &is_int, &value_int, (char **)&p))
    if (!is_int)
    {
      options.libpath = (char *)malloc(strlen(p) + 1);
      strcpy(options.libpath, p);
    }

  LOG("debugmodmgr=%d", options.debugmodmgr);
  LOG("debugixfmgr=%d", options.debugixfmgr);
  LOG("libpath=%s", options.libpath);
#endif
  options.libpath = (char *)malloc(4);
  strcpy(options.libpath, "c:\\");

  /* get our l4env infopage as a dataspace */
  rc = l4loader_app_info_call(&loader, l4_myself().id.task,
                              0, &p, &ds, &env);
  /* attach it */  
  attach_ds(&ds, L4DM_RO, &infopage);

#if 0
  /* load shared libs */
  rc = loadso();
  if (rc)
  {
    LOG("Error loading shared libraries");
    return;
  }
#endif

  init_memmgr(&root_area);

  /* load IXF's */
  rc = load_ixfs();
  if (rc)
  {
    LOG("Error loading IXF driver");
    return;
  }
			      
  /* Initializes the module list. Keeps info about which dlls an process have loaded and
     has linked to it (Only support for LX dlls so far). The head of the linked list is
     declared as a global inside dynlink.c */
  rc = ModInitialize();
  if (rc)
  {
    LOG("Can't initialize module manager");
    return;
  }

  // server loop
  LOG("execsrv started.");
  env.malloc = (dice_malloc_func)malloc;
  env.free = (dice_free_func)free;
  os2exec_server_loop(&env);
}
コード例 #3
0
ファイル: sysinit.c プロジェクト: ErisBlastar/osfree
int sysinit (cfg_opts *options)
{
    struct t_os2process *proc; // sysinit's PTDA/proc
    //l4events_ch_t event_ch = L4EVENTS_EXIT_CHANNEL;
    //l4events_nr_t event_nr = L4EVENTS_NO_NR;
    //l4events_event_t event;
    char   *env;
    APIRET rc;

    // create global environment
    create_env(&env);

    // Create the sysinit process PTDA structure (pid == ppid == 0)
    proc = PrcCreate(0,         // ppid
                     "sysinit", // pPrg
                     NULL,      // pArg
                     env);      // pEnv

    /* set task number */
    sysinit_id = l4_myself();
    proc->task = sysinit_id;

    if (!names_register("os2srv.sysinit"))
        io_log("error registering on the name server\n");

    /* Start servers */
    exec_runserver(proc->pid);

    /* Start run=/call= */
    exec_run_call(proc->pid);

    // Check PROTSHELL statement value
    if (!options->protshell || !*(options->protshell))
    {
        io_log("No PROTSHELL statement in CONFIG.SYS\n");
        rc = ERROR_INVALID_PARAMETER; /*ERROR_INVALID_PARAMETER 87; Not defined for Windows*/
    } else {
        exec_protshell(options);
        rc = 0; /* NO_ERROR */
    }

    io_log("sem wait\n");

    if (!rc) // wait until child process (protshell) terminates (this will unblock us)
        l4semaphore_down(&proc->term_sem);

    io_log("done waiting\n");

    /* if (use_events) // use events server
    {
      // terminate by sending an exit event
      event.len = sizeof(l4_threadid_t);
      *(l4_threadid_t*)event.str = l4_myself();
      // send exit event
      l4events_send(event_ch, &event, &event_nr, L4EVENTS_SEND_ACK);
      // get acknowledge
      l4events_get_ack(&event_nr, L4_IPC_NEVER);
    } */

    io_log("event notification sent\n");

    // unregister at names
    if (!names_unregister_task(sysinit_id))
        io_log("Cannot unregister at name server!\n");

    // destroy proc/PTDA
    PrcDestroy(proc);

    // destroy global environment
    destroy_env(env);

    io_log("OS/2 Server ended\n");
    // terminate OS/2 Server
    exit(rc);

    return rc;
}
コード例 #4
0
ファイル: main.c プロジェクト: ErisBlastar/osfree
int main(int argc, char **argv)
{
  CORBA_Environment env = dice_default_environment;
  int optionid;
  int opt = 0;
  const struct option long_options[] =
                {
                { "events",      no_argument, NULL, 'e'},
		{ 0, 0, 0, 0}
                };
  //int  rc;

  init_globals();
  //FSR_INIT();

  if (!names_register("os2fs"))
  {
    LOG("Can't register on the name server!");
    return 1;
  }
  LOG("registered at the name server");

  if (!names_waitfor_name("os2srv", &os2srv, 30000))
  {
    LOG("Can't find os2srv on names, exiting...");
    return 1;
  }
  LOG("got os2srv tid from the name server");

  LOG("argc=%d", argc);
  // Parse command line arguments
  for (;;)
  {
    opt = getopt_long(argc, argv, "e", long_options, &optionid);
    LOG("opt=%d", opt);
    if (opt == -1) break;
    switch (opt)
    {
      case 'e':
        LOG("using events server");
	use_events = 1;
	break;
      
      default:
        LOG("Error: Unknown option %c", opt);
        usage();
        break;
    }
  }

  // start events thread
  if (use_events)
  {
    // start events thread
    l4thread_create((void *)event_thread, 0, L4THREAD_CREATE_ASYNC);
    LOG("event thread started");
  }

  // my id
  fs = l4_myself();

  // server loop
  LOG("going to the server loop");
  env.malloc = (dice_malloc_func)malloc;
  env.free = (dice_free_func)free;
  os2fs_server_loop(&env);

  return 0;
}