Esempio n. 1
0
void init_sched (void)
{
	unsigned long eflags;

	eflags = read_flags ();

	if ((idle_task = kmalloc (sizeof (Task), 0)) == NULL) {
		printk ("init_sched: not enough memory\n");
		write_flags (eflags);
		return;
	}

	idle_task->pid		= next_pid++;
	idle_task->next		= idle_task;
#if 0
	idle_task->kernel_stack	= kstack;
#endif
	idle_task->tss.link	= 0;
	idle_task->tss.esp0	= (unsigned long) &kstack[PAGE_SIZE >> 2];
	idle_task->tss.ss0	= KERNEL_DS;
	idle_task->tss.cr3	= (unsigned long) &pg_dir[0];
	idle_task->tss.es	= KERNEL_DS;
	idle_task->tss.cs	= KERNEL_CS;
	idle_task->tss.ss	= KERNEL_DS;
	idle_task->tss.ds	= KERNEL_DS;
	idle_task->tss.fs	= KERNEL_DS;
	idle_task->tss.gs	= KERNEL_DS;

	current = idle_task;
	set_tss (idle_task);

	write_tr (idle_task->tss.tr);

	cli ();
	register_interrupt (0x08, do_timer);
	register_interrupt (0x80, do_fork);

	outb(0x36,0x43);
	outb(0xa9,0x40);
	outb(0x04,0x40);

	write_flags (eflags);
}
Esempio n. 2
0
void UmlActivityParameter::write(FileOut & out) {
  // write parameter def

  out.indent();
  out << "<ownedParameter name=\"";
  out.quote(name());
  out << '"';
  out.id(this);
  write_dir(out);
  write_effect(out);
  write_flags(out);
  out << ">\n";
  
  out.indent(+1);
  
  write_description_properties(out);
  write_multiplicity(out, multiplicity(), this);
  write_default_value(out, defaultValue(), this);
  UmlItem::write_type(out, type());
  
  out.indent(-1);

  out.indent();
  out << "</ownedParameter>\n";

  //write parameter node
  out.indent();
  out << "<node xmi:type=\"uml:ActivityParameterNode\" name =\"";
  out.quote(name());
  out << '"';
  out.id_prefix(this, "PARAMETER_NODE_");
  if (isControlType())
    out << " isControlType=\"true\"";
  write_ordering(out);
  write_selection(out);
  write_in_state(out);
  out << ">\n";
  out.indent(+1);

  UmlItem::write_type(out, type());

  const Q3PtrVector<UmlItem> ch = children();
  unsigned n = ch.size();
  
  for (unsigned i = 0; i != n; i += 1)
    ch[i]->write(out);

  out.indent(-1);
  out.indent();
  out << "</node>\n";

  unload();
}
Esempio n. 3
0
void printk (const char *fmt, ...)
{
	unsigned long eflags;
	static char buffer[1024];
	va_list args;

	eflags = read_flags ();
	cli ();

	args = va_start (args, fmt);
	vsprintf (buffer, fmt, args);
	va_end (args);

	tty_write (0, buffer, strlen (buffer));

	write_flags (eflags);
}
Esempio n. 4
0
File: mmv_poke.c Progetto: ubccr/pcp
int
main(int argc, char **argv)
{
    struct stat sbuf;
    char *file, *flags = NULL;
    int c, err = 0, pid = 0;

    __pmSetProgname(argv[0]);
    while ((c = getopt(argc, argv, "f:p:")) != EOF) {
        switch (c) {
        case 'f':
            flags = optarg;
            break;
        case 'p':
            pid = atoi(optarg);
            break;
        default:
            err++;
        }
    }

    if (err || argc != optind + 1)
        usage();

    file = argv[optind];

    c = open(file, O_RDWR, 0644);
    if (c < 0) {
        fprintf(stderr, "Cannot open %s for writing: %s\n",
                file, strerror(errno));
        exit(1);
    }
    fstat(c, &sbuf);
    addr = __pmMemoryMap(c, sbuf.st_size, 1);
    close(c);

    if (flags)
        write_flags(flags);

    if (pid)
        write_pid(pid);

    __pmMemoryUnmap(addr, sbuf.st_size);
    exit(0);
}
Esempio n. 5
0
File: vm8086.cpp Progetto: iver6/BA
void BX_CPU_C::iret16_stack_return_from_v86(bxInstruction_c *i)
{
  if ((BX_CPU_THIS_PTR get_IOPL() < 3) && (BX_CR4_VME_ENABLED == 0)) {
    // trap to virtual 8086 monitor
    BX_DEBUG(("IRET in vm86 with IOPL != 3, VME = 0"));
    exception(BX_GP_EXCEPTION, 0);
  }

  Bit16u ip, cs_raw, flags16;

  ip      = pop_16();
  cs_raw  = pop_16();
  flags16 = pop_16();

#if BX_CPU_LEVEL >= 5
  if (BX_CPU_THIS_PTR cr4.get_VME() && BX_CPU_THIS_PTR get_IOPL() < 3)
  {
    if (((flags16 & EFlagsIFMask) && BX_CPU_THIS_PTR get_VIP()) ||
         (flags16 & EFlagsTFMask))
    {
      BX_DEBUG(("iret16_stack_return_from_v86(): #GP(0) in VME mode"));
      exception(BX_GP_EXCEPTION, 0);
    }

    load_seg_reg(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS], cs_raw);
    EIP = (Bit32u) ip;

    // IF, IOPL unchanged, EFLAGS.VIF = TMP_FLAGS.IF
    Bit32u changeMask = EFlagsOSZAPCMask | EFlagsTFMask |
                            EFlagsDFMask | EFlagsNTMask | EFlagsVIFMask;
    Bit32u flags32 = (Bit32u) flags16;
    if (flags16 & EFlagsIFMask) flags32 |= EFlagsVIFMask;
    writeEFlags(flags32, changeMask);

    return;
  }
#endif

  load_seg_reg(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS], cs_raw);
  EIP = (Bit32u) ip;
  write_flags(flags16, /*IOPL*/ 0, /*IF*/ 1);
}
Esempio n. 6
0
	void create_landtiles_cfg()
	{
	  FILE* fp = fopen( "landtiles.cfg", "wt" );
	  unsigned count = 0;

	  for ( u16 i = 0; i <= 0x3FFF; ++i )
	  {
		USTRUCT_LAND_TILE landtile;
		if ( cfg_use_new_hsa_format )
		{
		  USTRUCT_LAND_TILE_HSA newlandtile;
		  readlandtile( i, &newlandtile );
		  landtile.flags = newlandtile.flags;
		  landtile.unk = newlandtile.unk;
		  memcpy( landtile.name, newlandtile.name, sizeof landtile.name );
		}
		else
		  readlandtile( i, &landtile );

		if ( landtile.name[0] || landtile.flags )
		{
		  fprintf( fp, "landtile 0x%x\n", i );
		  fprintf( fp, "{\n" );
		  fprintf( fp, "    Name %s\n", landtile.name );
		  fprintf( fp, "    UoFlags 0x%08lx\n", static_cast<unsigned long>( landtile.flags ) );

		  unsigned int flags = polflags_from_landtileflags( i, landtile.flags );
		  flags &= ~FLAG::MOVABLE; // movable makes no sense for landtiles
		  write_flags( fp, flags );
		  fprintf( fp, "}\n" );
		  fprintf( fp, "\n" );
		  ++count;
		}
	  }
	  fclose( fp );

      INFO_PRINT << count << " landtile definitions written to landtiles.cfg\n";
	}
Esempio n. 7
0
void make_makefile(int platform)
{
  char tmp[100],*s,de[5]; 
  FILE *fp;
  if (platform==DOS)
    strcpy(de,".exe");
  else de[0]=0;
  
  if (!get_var("MAKEFILE_NAME",tmp))
  {
    if (platform==DOS)
      strcpy(tmp,"makefile.wat");
    else
      strcpy(tmp,"Makefile");
  }

  fp=fopen(tmp,"w");

  if (!fp)
  {
    printf("Unable to open %s for writing\n",tmp);
    exit(0);
  }
  
  fprintf(fp,"CC=%s\n",compiler(platform));

  write_flags(fp,platform,0);
  write_flags(fp,platform,1);



  list_o_files("IMLIB_OBJS",fp,imlib_objs,imlib_dir,object_extension(platform),platform,0);
  list_o_files("IMLIB_OBJS",fp,imlib_objs,imlib_dir,object_extension(platform),platform,1);
  list_o_files("PROG_OBJS",fp,ofiles,NULL,object_extension(platform),platform,0);
  list_o_files("PROG_OBJS",fp,ofiles,NULL,object_extension(platform),platform,1);
  

  if (platform==LINUX)        /* for linux make two versions of program,  X11 & SVGA */
  {
    sprintf(tmp,"%sx",basename);
    fprintf(fp,"all : %s %s\n\n",basename,tmp);
    
    make_program(fp,basename,"LINUX_SVGA",platform,0);
    make_program(fp,tmp,"LINUX_X",platform,0); 

    fprintf(fp,"opt : %so %so\n\n",basename,tmp);
    
    make_program(fp,basename,"LINUX_SVGA",platform,1);
    make_program(fp,tmp,"LINUX_X",platform,1); 
  }
  else 
  {
    fprintf(fp,"all : %s%s\n\n",basename,de);    
    make_program(fp,basename,plat_name[platform],platform,0);    

    fprintf(fp,"opt : %so%s\n\n",basename,de);
    make_program(fp,basename,plat_name[platform],platform,1);    
  }
  sprintf(tmp,"%s_FILES",plat_name[platform]);

  list_o_depends(fp,tmp,imlib_dir,platform,0);
  list_o_depends(fp,tmp,imlib_dir,platform,1);
  list_o_depends(fp,"IMLIB_OBJS",imlib_dir,platform,0);
  list_o_depends(fp,"IMLIB_OBJS",imlib_dir,platform,1);
  list_o_depends(fp,"O_FILES",NULL,platform,0);
  list_o_depends(fp,"O_FILES",NULL,platform,1);
  if (platform!=DOS)
  {
    fprintf(fp,"clean :\n\t"
	    "rm -f $(%s_FILES) $(IMLIB_OBJS) $(O_FILES)\n",
	    plat_name[platform]);
    fprintf(fp,"cleano :\n\t"
	    "rm -f $(%s_FILES_O) $(IMLIB_OBJS_O) $(O_FILES_O)\n",
	    plat_name[platform]);
  }
  if (plat_stuff)
    fprintf(fp,"%s",plat_stuff);   /* add any platform specific additions  */

  fclose(fp);
}
Esempio n. 8
0
	void create_tiles_cfg()
	{
	  FILE* fp = fopen( "tiles.cfg", "wt" );
	  int mountCount;
	  char name[21];

	  unsigned count = 0;
	  for ( unsigned int graphic_i = 0; graphic_i <= Plib::systemstate.config.max_tile_id; ++graphic_i )
	  {
		u16 graphic = static_cast<u16>( graphic_i );
		USTRUCT_TILE tile;
		if ( cfg_use_new_hsa_format )
		{
		  USTRUCT_TILE_HSA newtile;
		  read_objinfo( graphic, newtile );
		  tile.anim = newtile.anim;
		  tile.flags = newtile.flags;
		  tile.height = newtile.height;
		  tile.layer = newtile.layer;
		  memcpy( tile.name, newtile.name, sizeof tile.name );
		  tile.unk14 = newtile.unk14;
		  tile.unk15 = newtile.unk15;
		  tile.unk6 = newtile.unk6;
		  tile.unk7 = newtile.unk7;
		  tile.unk8 = newtile.unk8;
		  tile.unk9 = newtile.unk9;
		  tile.weight = newtile.weight;
		}
		else
		  read_objinfo( graphic, tile );
		mountCount = static_cast<int>( MountTypes.count( graphic ) );

		if ( tile.name[0] == '\0' &&
			 tile.flags == 0 &&
			 tile.layer == 0 &&
			 tile.height == 0 &&
			 mountCount == 0
			 )
		{
		  continue;
		}
		unsigned int flags = polflags_from_tileflags( graphic, tile.flags, cfg_use_no_shoot, cfg_LOS_through_windows );
		if ( mountCount != 0 )
		{
		  tile.layer = 25;
		  flags |= FLAG::EQUIPPABLE;
		}

		memset( name, 0, sizeof name );
		memcpy( name, tile.name, sizeof tile.name );

		fprintf( fp, "tile 0x%x\n", graphic );
		fprintf( fp, "{\n" );
		fprintf( fp, "    Desc %s\n", name );
		fprintf( fp, "    UoFlags 0x%08lx\n", static_cast<unsigned long>( tile.flags ) );
		if ( tile.layer )
		  fprintf( fp, "    Layer %u\n", tile.layer );
		fprintf( fp, "    Height %u\n", tile.height );
		fprintf( fp, "    Weight %u\n", tile.weight );
		write_flags( fp, flags );
		fprintf( fp, "}\n" );
		fprintf( fp, "\n" );
		++count;
	  }
	  fclose( fp );

      INFO_PRINT << count << " tile definitions written to tiles.cfg\n";
	}