示例#1
0
VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc)
{
  struct dpb *dpbp;
  struct cds FAR *cdsp;
  static char rg[8];

  /* next - "log" in the drive            */
  drive = (drive == 0 ? default_drive : drive - 1);

  cdsp = &CDSp->cds_table[drive];
  if (cdsp->cdsFlags & 0x8000)
  {
    int2f_Remote_call(REM_GETSPACE, 0, 0, 0, cdsp, 0, &rg);

    *spc = (COUNT) rg[0];
    *navc = (COUNT) rg[2];
    *bps = (COUNT) rg[4];
    *nc = (COUNT) rg[6];
    return;
  }

  /* first check for valid drive          */
  if (drive < 0 || drive > lastdrive)
  {
    *spc = -1;
    return;
  }

  dpbp = (struct dpb *)CDSp->cds_table[drive].cdsDpb;
  if (dpbp == 0)
  {
    *spc = -1;
    return;
  }

  if ((media_check(dpbp) < 0))
  {
    *spc = -1;
    return;
  }

  /* get the data vailable from dpb       */
  *nc = dpbp->dpb_size;
  *spc = dpbp->dpb_clsmask + 1;
  *bps = dpbp->dpb_secsize;

  /* now tell fs to give us free cluster  */
  /* count                                */
  *navc = dos_free(dpbp);
}
示例#2
0
void gem_main(void)
{
    WORD    i;

    sh_rdinf();                 /* get start of emudesk.inf */
    if (!gl_changerez)          /* can't be here because of rez change,       */
        process_inf1();         /*  so see if .inf says we need to change rez */

    if (gl_changerez) {
        switch(gl_changerez) {
#if CONF_WITH_ATARI_VIDEO
        case 1:                     /* ST(e) or TT display */
            Setscreen(-1L,-1L,gl_nextrez-2,0);
            initialise_palette_registers(gl_nextrez-2,0);
            break;
#endif
#if CONF_WITH_VIDEL
        case 2:                     /* Falcon display */
            Setscreen(-1L, -1L, FALCON_REZ, gl_nextrez);
            initialise_palette_registers(FALCON_REZ,gl_nextrez);
            break;
#endif
        }
        gsx_wsclear();              /* avoid artefacts that may show briefly */
        /*
         * resolution change always resets the default drive to the
         * boot device.  TOS3 issues a Dsetdrv() when this happens,
         * which Hatari's GEMDOS drive emulation uses to keep track
         * of the current drive.  we do the same.
         */
        dos_sdrv(bootdev);
    }

    ml_ocnt = 0;

    gl_changerez = FALSE;

    mn_init();                      /* initialise variables for menu_register() */

    num_accs = count_accs();        /* puts ACC names in acc_name[] */

    D.g_acc = NULL;
    if (num_accs)
        D.g_acc = dos_alloc(num_accs*sizeof(AESPROCESS));
    if (D.g_acc)
        memset(D.g_acc,0x00,num_accs*sizeof(AESPROCESS));
    else num_accs = 0;

    totpds = num_accs + 2;

    disable_interrupts();
    set_aestrap();                  /* set trap#2 -> aestrap */

    /* init event recorder  */
    gl_recd = FALSE;
    gl_rlen = 0;
    gl_rbuf = NULL;

    /* link up all the evb's to the event unused list */
    eul = NULL;
    for (i = 0; i < 2; i++)
        ev_init(D.g_int[i].a_evb,EVBS_PER_PD);
    for (i = 0; i < num_accs; i++)
        ev_init(D.g_acc[i].a_evb,EVBS_PER_PD);

    /* initialize sync blocks */
    wind_spb.sy_tas = 0;
    wind_spb.sy_owner = NULL;
    wind_spb.sy_wait = 0;

    /*
     * init processes - TODO: should go in gempd or gemdisp.
     */

    /* initialize list and unused lists   */
    nrl = drl = NULL;
    dlr = zlr = NULL;
    fph = fpt = fpcnt = 0;

    /* init initial process */
    for(i=totpds-1; i>=0; i--)
    {
        rlr = pd_index(i);
        if (i < 2)
        {
            rlr->p_uda = &D.g_int[i].a_uda;
            rlr->p_cda = &D.g_int[i].a_cda;
        }
        else
        {
            rlr->p_uda = &D.g_acc[i-2].a_uda;
            rlr->p_cda = &D.g_acc[i-2].a_cda;
        }
        rlr->p_qaddr = rlr->p_queue;
        rlr->p_qindex = 0;
        memset(rlr->p_name, ' ', AP_NAMELEN);
        rlr->p_appdir[0] = '\0'; /* by default, no application directory */
        /* if not rlr then initialize his stack pointer */
        if (i != 0)
            rlr->p_uda->u_spsuper = &rlr->p_uda->u_supstk;
        rlr->p_pid = i;
        rlr->p_stat = 0;
    }
    curpid = 0;
    rlr->p_pid = curpid++;
    rlr->p_link = NULL;

    /* end of process init */

    /* restart the tick     */
    enable_interrupts();

    /*
     * screen manager process init. this process starts out owning the mouse
     * and the keyboard. it has a pid == 1
     */
    gl_mowner = ctl_pd = iprocess("SCRENMGR", ctlmgr);

    /*
     * run the accessories and the desktop until termination
     * (for shutdown or resolution change)
     */
    aes_run_rom_program(accdesk_start);

    /* restore previous trap#2 address */
    disable_interrupts();
    unset_aestrap();
    enable_interrupts();

    if (D.g_acc)
        dos_free((LONG)D.g_acc);
}
示例#3
0
/*
*       File Selector input routine that takes control of the mouse
*       and keyboard, searchs and sort the directory, draws the file 
*       selector, interacts with the user to determine a selection
*       or change of path, and returns to the application with
*       the selected path, filename, and exit button.
*/
WORD fs_input(BYTE *pipath, BYTE *pisel, WORD *pbutton, BYTE *pilabel)
{
        register WORD   touchob, value, fnum;
        WORD            curr, count, sel;
        WORD            mx, my;
        LONG            tree;
        ULONG           bitmask;
        BYTE            *ad_fpath, *ad_fname, *ad_ftitle;
        WORD            drive; 
        WORD            dclkret, cont, newlist, newsel, newdrive;
        register BYTE   *pstr;
        GRECT           pt;
        BYTE            locstr[LEN_ZPATH+1], mask[LEN_ZFNAME+1], selname[LEN_FSNAME];
        OBJECT          *obj;
        TEDINFO         *tedinfo;

        curr = 0;
        count = 0;
                                        /* get out quick if path is     */
                                        /*   nullptr or if pts to null. */
        if (pipath == NULL)
          return(FALSE);
                                        /* if path string is empty, */
                                        /*   set reasonable default */
        if (*pipath == '\0') {
          strcpy(pipath,"A:\\*.*");
          *pipath += dos_gdrv();
        }
                                        /* get memory for the filename buffer */
                                        /*  & the array that points to it     */
        for (nm_files = MAX_NM_FILES; nm_files >= MIN_NM_FILES; nm_files /= 2)
        {
          ad_fsnames = (BYTE *)dos_alloc(nm_files*(LEN_FSNAME+sizeof(BYTE *)));
          if (ad_fsnames)
            break;
        }
        if (!ad_fsnames)
          return(FALSE);
        g_fslist = (LONG *)(ad_fsnames+nm_files*LEN_FSNAME);

        strcpy(locstr, pipath);

        tree = ad_fstree;
                                                /* init strings in form */
        obj = ((OBJECT *)tree) + FTITLE;
        tedinfo = (TEDINFO *)obj->ob_spec;
        ad_ftitle = (BYTE *)tedinfo->te_ptext;
        set_mask(mask, locstr);                 /* save caller's mask */
        strcpy(ad_ftitle, mask);                /*  & copy to title line */

        obj = ((OBJECT *)tree) + FSDIRECT;
        tedinfo = (TEDINFO *)obj->ob_spec;
        ad_fpath = (BYTE *)tedinfo->te_ptext;
        inf_sset(tree, FSDIRECT, locstr);

        obj = ((OBJECT *)tree) + FSSELECT;
        tedinfo = (TEDINFO *)obj->ob_spec;
        ad_fname = (BYTE *)tedinfo->te_ptext;
        fmt_str(pisel, selname);                /* selname[] is without dot */
        inf_sset(tree, FSSELECT, selname);

        obj = ((OBJECT *)tree) + FSTITLE;
        obj->ob_spec = pilabel ? (LONG)pilabel : (LONG)rs_str(ITEMSLCT);

                                                /* set drive buttons */
        obj = ((OBJECT *)tree) + DRIVE_OFFSET;
        for (drive = 0, bitmask = 1; drive < NM_DRIVES; drive++, bitmask <<= 1, obj++)
        {
          if (drvbits & bitmask)
            obj->ob_state &= ~DISABLED;
          else
            obj->ob_state |= DISABLED;
        }
        select_drive(tree,locstr[0]-'A',0);
                                                /* set clip and start   */
                                                /*   form fill-in by    */
                                                /*   drawing the form   */
        gsx_sclip(&gl_rfs);     
        fm_dial(FMD_START, &gl_rfs);
        ob_draw(tree, ROOT, 2);
                                                /* init for while loop  */
                                                /*   by forcing initial */
                                                /*   fs_newdir call     */
        sel = 0;
        newsel = FALSE;
        cont = newlist = TRUE;
        while( cont )
        {
          touchob = (newlist) ? 0x0 : fm_do(tree, FSSELECT);
          gsx_mxmy(&mx, &my);
        
          if ( newlist )
          {
            fs_sel(sel, NORMAL);
            if ( (touchob == FSOK) ||
                 (touchob == FSCANCEL) )
              ob_change(tree, touchob, NORMAL, TRUE);
            inf_sset(tree, FSDIRECT, locstr);
            pstr = fs_pspec(locstr, NULL);        
            strcpy(pstr, mask);
            fs_newdir(locstr, mask, tree, &count);
            curr = 0;
            sel = touchob = 0;
            newlist = FALSE;
          }

          value = 0;
          dclkret = ((touchob & 0x8000) != 0);
          switch( (touchob &= 0x7fff) )
          {
            case FSOK:
            case FSCANCEL:
                cont = FALSE;
                break;
            case FUPAROW:
            case FDNAROW:
                value = 1;
                break;
            case FSVSLID:
                ob_actxywh(tree, FSVELEV, &pt);
                /* anemic slidebars
                  pt.g_x -= 3;
                  pt.g_w += 6;
                */
                if ( !inside(mx, my, &pt) )
                  {
                  touchob = (my <= pt.g_y) ? FUPAROW : FDNAROW;
                  value = NM_NAMES;
                  break;
                  }
                /* drop through */
            case FSVELEV:
                fm_own(TRUE);
                value = gr_slidebox(tree, FSVSLID, FSVELEV, TRUE);
                fm_own(FALSE);
                value = curr - mul_div(value, count-NM_NAMES, 1000);
                if (value >= 0)
                  touchob = FUPAROW;
                else
                {
                  touchob = FDNAROW;
                  value = -value;
                }
                break;
            case F1NAME:
            case F2NAME:
            case F3NAME:
            case F4NAME:
            case F5NAME:
            case F6NAME:
            case F7NAME:
            case F8NAME:
            case F9NAME:
                fnum = touchob - F1NAME + 1;
                if ( fnum > count )
                  break;
                if ( (sel) && (sel != fnum) )
                  fs_sel(sel, NORMAL);
                if ( sel != fnum)
                {
                  sel = fnum;
                  fs_sel(sel, SELECTED);
                }
                                                /* get string and see   */
                                                /*   if file or folder  */
                inf_sget(tree, touchob, selname);
                if (selname[0] == ' ')          /* a file was selected  */
                {                               /* copy to selection    */
                  newsel = TRUE;
                  if (dclkret)
                    cont = FALSE;
                }
                else                            /* a folder was selected:  */
                {                               /* insert name before mask */
                  pstr = fs_pspec(locstr, NULL);
                  unfmt_str(selname+1, pstr);
                  pstr += strlen(pstr);
                  *pstr++ = '\\';
                  strcpy(pstr, mask);
                  newlist = TRUE;
                }
                break;
            case FCLSBOX:
                pstr = fs_back(locstr, NULL);
                if (*pstr-- != '\\')    /* ignore strange path string */
                  break;
                if (*pstr != ':')       /* not at root of drive, so back up */
                {
                  pstr = fs_back(locstr, pstr);
                  if (*pstr == '\\')    /* we must have at least X:\ */
                    strcpy(pstr+1, mask);
                }
                newlist = TRUE;
                break;
            default:
                drive = touchob - DRIVE_OFFSET;
                if ((drive < 0) || (drive >= NM_DRIVES))/* not for us */
                  break;
                if (drive == locstr[0] - 'A')           /* no change */
                  break;
                obj = ((OBJECT *)tree) + touchob;
                if (obj->ob_state & DISABLED)           /* non-existent drive */
                  break;
                strcpy(locstr, "A:\\*.*");
                locstr[0] += drive;
                newdrive = TRUE;
                break;
          }
          if (!newlist && !newdrive
           && path_changed(locstr))                     /* path changed manually */
          {
            if (ad_fpath[0] != locstr[0])               /* drive has changed */
              newdrive = TRUE;
            else
              newlist = TRUE;
            strcpy(locstr, ad_fpath);
          }
          if (newdrive)
          {
            select_drive(tree, touchob-DRIVE_OFFSET,1);
            newdrive = FALSE;
            newlist = TRUE;
          }
          if (newlist)
          {
            inf_sset(tree, FSDIRECT, locstr);
            set_mask(mask, locstr);                 /* set mask         */
            selname[1] = '\0';                      /* selected is empty */
            newsel = TRUE;
          }
          if (newsel)
          {
            strcpy(ad_fname, selname + 1);
            ob_draw(tree, FSSELECT, MAX_DEPTH);
            if (!cont)
              ob_change(tree, FSOK, SELECTED, TRUE);
            newsel = FALSE;
          }
          if (value)
            curr = fs_nscroll(tree, &sel, curr, count, touchob, value);
        }
                                                /* return path and      */
                                                /*   file name to app   */
        strcpy(pipath, locstr);
        unfmt_str(ad_fname, selname);
        strcpy(pisel, selname);
                                                /* start the redraw     */
        fm_dial(FMD_FINISH, &gl_rfs);
                                                /* return exit button   */
        *pbutton = inf_what(tree, FSOK, FSCANCEL);
        dos_free((LONG)ad_fsnames);

        return( TRUE );
}
示例#4
0
int run_simulation(struct simulation *sim)
{
struct device cell;
log_clear(sim);

printf_log(sim,_("Run_simulation\n"));

device_init(&cell);
cell.onlypos=FALSE;

dump_init(sim,&cell);

set_dump_status(sim,dump_stop_plot, FALSE);
set_dump_status(sim,dump_print_text, TRUE);


char temp[1000];

cell.kl_in_newton=FALSE;

//if (strcmp(outputpath,"")!=0) strcpy(get_output_path(sim),outputpath);

//if (strcmp(inputpath,"")!=0) strcpy(get_input_path(sim),inputpath);

dump_load_config(sim,&cell);

int i;
int z;
int x;
int y;


join_path(2,temp,get_output_path(sim),"error.dat");
remove(temp);

join_path(2,temp,get_output_path(sim),"equilibrium");
remove_dir(sim,temp);

join_path(2,temp,get_output_path(sim),"snapshots");
remove_dir(sim,temp);

join_path(2,temp,get_output_path(sim),"light_dump");
remove_dir(sim,temp);

join_path(2,temp,get_output_path(sim),"dynamic");
remove_dir(sim,temp);

join_path(2,temp,get_output_path(sim),"frequency");
remove_dir(sim,temp);



load_config(sim,&cell);

if (strcmp(sim->force_sim_mode,"")!=0)
{
	strcpy(cell.simmode,sim->force_sim_mode);
}

if (strcmp(cell.simmode,"opticalmodel@optics")!=0)
{
	solver_init(sim,cell.solver_name);
	newton_init(sim,cell.newton_name);

	printf_log(sim,_("Loading DoS for %d layers\n"),cell.my_epitaxy.electrical_layers);
	char tempn[100];
	char tempp[100];
	i=0;

	for (i=0;i<cell.my_epitaxy.electrical_layers;i++)
	{
		dos_init(&cell,i);
		printf_log(sim,"Load DoS %d/%d\n",i,cell.my_epitaxy.electrical_layers);
		sprintf(tempn,"%s_dosn.dat",cell.my_epitaxy.dos_file[i]);
		sprintf(tempp,"%s_dosp.dat",cell.my_epitaxy.dos_file[i]);
		load_dos(sim,&cell,tempn,tempp,i);
	}

	device_alloc_traps(&cell);

	if (get_dump_status(sim,dump_write_converge)==TRUE)
	{
	sim->converge = fopena(get_output_path(sim),"converge.dat","w");
	fclose(sim->converge);

	sim->tconverge=fopena(get_output_path(sim),"tconverge.dat","w");
	fclose(sim->tconverge);
	}

	mesh_cal_layer_widths(&cell);

	long double depth=0.0;
	long double percent=0.0;
	long double value=0.0;
	for (z=0;z<cell.zmeshpoints;z++)
	{
		for (x=0;x<cell.xmeshpoints;x++)
		{
			for (y=0;y<cell.ymeshpoints;y++)
			{

				depth=cell.ymesh[y]-cell.layer_start[cell.imat[z][x][y]];
				percent=depth/cell.layer_width[cell.imat[z][x][y]];
				cell.Nad[z][x][y]=get_dos_doping_start(&cell,cell.imat[z][x][y])+(get_dos_doping_stop(&cell,cell.imat[z][x][y])-get_dos_doping_start(&cell,cell.imat[z][x][y]))*percent;
			}
		}		
		
	}

	init_mat_arrays(&cell);




	for (z=0;z<cell.zmeshpoints;z++)
	{
		for (x=0;x<cell.xmeshpoints;x++)
		{
			for (y=0;y<cell.ymeshpoints;y++)
			{
				cell.phi[z][x][y]=0.0;
				cell.R[z][x][y]=0.0;
				cell.n[z][x][y]=0.0;
			}
		}
	}

	contacts_load(sim,&cell);

	cell.C=cell.xlen*cell.zlen*epsilon0*cell.epsilonr[0][0][0]/(cell.ylen+cell.other_layers);
	if (get_dump_status(sim,dump_print_text)==TRUE) printf_log(sim,"C=%Le\n",cell.C);
	cell.A=cell.xlen*cell.zlen;
	cell.Vol=cell.xlen*cell.zlen*cell.ylen;

	///////////////////////light model
	char old_model[100];
	gdouble old_Psun=0.0;
	old_Psun=light_get_sun(&cell.mylight);
	light_init(&cell.mylight);
	light_set_dx(&cell.mylight,cell.ymesh[1]-cell.ymesh[0]);
	light_load_config(sim,&cell.mylight);

	if (cell.led_on==TRUE)
	{
		strcpy(old_model,cell.mylight.mode);
		strcpy(cell.mylight.mode,"ray");
	}
	
	light_load_dlls(sim,&cell.mylight);
	light_setup_ray(sim,&cell,&cell.mylight);

	if (cell.led_on==TRUE)
	{
		cell.mylight.force_update=TRUE;

		light_set_sun(&(cell.mylight),1.0);
		light_set_sun_delta_at_wavelength(&(cell.mylight),cell.led_wavelength);
		light_solve_all(sim,&(cell.mylight));
		
		cell.mylight.force_update=FALSE;
		strcpy(cell.mylight.mode,old_model);
		light_set_sun(&(cell.mylight),old_Psun);
		light_free_dlls(sim,&cell.mylight);
		light_load_dlls(sim,&cell.mylight);
	}
	///////////////////////

	//update_arrays(&cell);

	contact_set_all_voltages(sim,&cell,0.0);
	get_initial(sim,&cell);

	remesh_shrink(&cell);

	if (cell.math_enable_pos_solver==TRUE)
	{
		for (z=0;z<cell.zmeshpoints;z++)
		{
			for (x=0;x<cell.xmeshpoints;x++)
			{
				solve_pos(sim,&cell,z,x);
			}
		}
	}


	time_init(sim,&cell);

	cell.N=0;
	cell.M=0;

	solver_realloc(sim,&cell);



	plot_open(sim);


	cell.go_time=FALSE;

	plot_now(sim,"plot");
	//set_solver_dump_every_matrix(1);

	find_n0(sim,&cell);
	//set_solver_dump_every_matrix(0);
	draw_gaus(&cell);


	if (cell.onlypos==TRUE)
	{
		join_path(2,temp,get_output_path(sim),"equilibrium");
		dump_1d_slice(sim,&cell,temp);
		device_free(sim,&cell);
		device_free_traps(&cell);
		mesh_free(sim,&cell);
		return 0;
	}
}


//Load the dll
if (is_domain(cell.simmode)!=0)
{
	char gussed_full_mode[200];
	if (guess_whole_sim_name(sim,gussed_full_mode,get_input_path(sim),cell.simmode)==0)
	{
		printf_log(sim,"I guess we are using running %s\n",gussed_full_mode);
		strcpy(cell.simmode,gussed_full_mode);
	}else
	{
		ewe(sim,"I could not guess which simulation to run from the mode %s\n",cell.simmode);
	}


}

run_electrical_dll(sim,&cell,strextract_domain(cell.simmode));


if (strcmp(cell.simmode,"opticalmodel@optics")!=0)
{
	device_free(sim,&cell);
	device_free_traps(&cell);
	mesh_free(sim,&cell);
	plot_close(sim);

	for (i=0;i<cell.my_epitaxy.electrical_layers;i++)
	{
		dos_free(&cell,i);
	}
	solver_free_memory(sim,&cell);

	newton_interface_free(sim);
	light_free(sim,&cell.mylight);
}



return cell.odes;
}
示例#5
0
void disk_demo(void)
{
    X_REGS16 ir,or;
    X_SREGS16 sr;
    char*dosptr;

    /* reset */
    ir.h.ah = 0x00;
    ir.h.al = 0;
    ir.h.dl = 0;
    ir.x.di = 0;
    sr.es = 0;
    vm86_callBIOS(0x13, &ir, &or, &sr);
    message("reset finished.\n");

    ir.h.ah = 0x08;
    ir.h.al = 0;
    ir.h.dl = 0;
    ir.x.di = 0;
    sr.es = 0;
    vm86_callBIOS(0x13, &ir, &or, &sr);
    if (or.x.cflag &0x01) {
        message("Failed to get the floppy drive parameters...\n");
	
	return;
    }

    message("Drives: %d\n", or.h.dl);
    message("Drive Type: 0x%x\n", or.h.bl);
    message("Cylinders: %d\n", or.h.ch + ((WORD) (or.h.cl& 0xC0) << 2) + 1);
    message("Sectors: %d\n", or.h.cl & 0x3F);
    message("...");

#if 0
    ir.h.ah = 0x04;
    ir.h.al = 8;       /* Let's verify 8 sectors... */
    ir.h.dl = 0;
    ir.h.ch = 0;       /* Cylonder 0 */
    ir.h.cl = 1;       /* Sector 0 */
    ir.h.dh = 0;       /* Head 0 */
#else

    dosptr = dos_alloc(512);
    ir.h.ah = 2;
    ir.h.al = 1;
    ir.h.ch = 0; /* C */
    ir.h.cl = 1; /* S */
    ir.h.dh = 0; /* H */
    ir.h.dl = 0;
    sr.es = DOS_SEG(dosptr);
    ir.x.bx = DOS_OFF(dosptr);
#endif

    message("Read a sector:");
    vm86_callBIOS(0x13, &ir, &or, &sr);

    message("Bytes: %s\n",&dosptr[0x36]);

    dos_free(dosptr,512);

    if (or.x.cflag &0x01) {
        message("failed...\n");

        return;
    }
    message("Ok!!!\n");
}