コード例 #1
0
ファイル: msu1.cpp プロジェクト: quequotion/higan-qq
void MSU1::mmio_write(unsigned addr, uint8 data) {
  cpu.synchronize_coprocessors();
  addr = 0x2000 | (addr & 7);

  switch(addr) {
  case 0x2000: mmio.data_seek_offset = (mmio.data_seek_offset & 0xffffff00) | (data <<  0); break;
  case 0x2001: mmio.data_seek_offset = (mmio.data_seek_offset & 0xffff00ff) | (data <<  8); break;
  case 0x2002: mmio.data_seek_offset = (mmio.data_seek_offset & 0xff00ffff) | (data << 16); break;
  case 0x2003: mmio.data_seek_offset = (mmio.data_seek_offset & 0x00ffffff) | (data << 24);
    mmio.data_read_offset = mmio.data_seek_offset;
    data_open();
    break;
  case 0x2004: mmio.audio_track = (mmio.audio_track & 0xff00) | (data << 0); break;
  case 0x2005: mmio.audio_track = (mmio.audio_track & 0x00ff) | (data << 8);
    mmio.audio_play_offset = 8;
    audio_open();
    break;
  case 0x2006: mmio.audio_volume = data; break;
  case 0x2007:
    if(mmio.audio_busy) break;
    if(mmio.audio_error) break;
    mmio.audio_repeat = data & 2;
    mmio.audio_play   = data & 1;
    break;
  }
}
コード例 #2
0
ファイル: nterm.c プロジェクト: rforge/muste
static int init_regressors() {
  int i,j;
  double dlapu;
  double *dlapu2;

  strcpy(nimi,survo_path);
  strcat(nimi,"SYS/NTERMLIB");

  if (data_open(nimi,&data)<0) {
    sur_print("\nError in opening file NTERMLIB!");
    WAIT; return(-1);
  }
  if (data.m_act>=MAX) {
    sur_print("\nToo many active regressors!");
    WAIT; return(-1);
  }
  for (i=0 ;i<data.m_act; ++i) {
    regressor[i]=(double *)muste_malloc((seq_n+1)*sizeof(double));
    if (regressor[i] == NULL) {
      sur_print("\nOut of memory!");
      WAIT; return(-1);
    }
    for (j=0;j<=seq_n;++j) {
      if (data_load(&data,data.l1+j,data.v[i],&dlapu)!=1) {
        sur_print("\nInvalid value in regressors!");
        WAIT; return(-1);
      }
      dlapu2=regressor[i];
      *(dlapu2+j)=dlapu;
    }
  }
  return(1);
}
コード例 #3
0
ファイル: stdio.c プロジェクト: gapry/RefOS-1
void
refos_setup_dataspace_stdio(char *dspacePath)
{
#if defined(SEL4_DEBUG_KERNEL) && defined(CONFIG_REFOS_SYS_FORCE_DEBUGPUTCHAR)
    return;
#else
    /* Find the path and connect to it. */
    refosIOState.stdioSession = serv_connect_no_pbuffer(dspacePath);
    if (!refosIOState.stdioSession.error == ESUCCESS || !refosIOState.stdioSession.serverSession) {
        seL4_DebugPrintf("Failed to connect to [%s]. Error: %d %s.\n", dspacePath,
                         refosIOState.stdioSession.error, refos_error_str(refosIOState.stdioSession.error));
#if defined(SEL4_DEBUG_KERNEL)
        seL4_DebugHalt();
#endif
        while (1);
    }

    /* Open the dataspace at the Resolved mount point. */
    int error;
    refosIOState.stdioDataspace = data_open(refosIOState.stdioSession.serverSession,
                                            refosIOState.stdioSession.serverMountPoint.dspaceName, 0, 0, 0, &error);
    if (error || !refosIOState.stdioDataspace) {
        seL4_DebugPrintf("Failed to open dataspace [%s].\n",
                         refosIOState.stdioSession.serverMountPoint.dspaceName);
#if defined(SEL4_DEBUG_KERNEL)
        seL4_DebugHalt();
#endif
        while (1);
    }
#endif
}
コード例 #4
0
ファイル: statmsf.c プロジェクト: rforge/muste
static int pvalues(int ii)
        {
        int i;
        char x[LLENGTH];
        double *freq;
        long l;
        double a;

        strcpy(x,spb[ii]);
        i=load_X(x); if (i<0) return(-1);
/* Rprintf("\ndim=%d,%d",mX,nX); getch(); */
        i=data_open(word[1],&d); if (i<0) return(-1);
        v=(int *)muste_malloc(mX*sizeof(int));
        if (v==NULL) { ei_tilaa(); return(-1); }
        i=nrot();
        mT=mX; nT=2; rlabT=rlabX ;
        i=mat_alloc_lab(&T,mT,nT,NULL,&clabT);
        freq=T+mT;
        for (i=0; i<mX; ++i) freq[i]=0.0;

        i=conditions(&d); if (i<0) return(-1);

        n=0L; sur_print("\n");
        for (l=d.l1; l<=d.l2; ++l)
            {
            if (unsuitable(&d)) continue;
            sprintf(sbuf,"%ld ",l); sur_print(sbuf);
            ++n;
            for (i=0; i<mX; ++i)
                {
                data_load(&d,l,v[i],&a);
                if (a==MISSING8) continue;
                if (a>X[i]) ++freq[i];
                }
            }
        if (n==0L)
            {
            sur_print("\nNo active observations!"); WAIT; return(-1);
            }

        a=1.0/(double)n;
        for (i=0; i<mX; ++i)
            {
            T[i]=X[i];
            freq[i]*=a;
            }
        strncpy(clabT,"Value   P       ",16);
        sprintf(exprT,"Tail_frequencies_in_data_%s_N=%d",word[1],n);
        save_T("TAILFREQ.M");

        return(1);
        }
コード例 #5
0
ファイル: xall.c プロジェクト: rforge/muste
static int xall(void)
{
    int i,j,k;
    double x,y;

    int var1;
    int vartotal;
    int howmany;

    i=data_open(word[1],&d); if (i<0) return -1;
    i=mask(&d); if (i<0) return -1;
    i=conditions(&d); if (i<0) return -1;
    var1=varfind(&d,word[2]); if (var1<0) return -1;
    vartotal=atoi(word[3]);
    if (g>4) howmany=atoi(word[4]); else howmany=1;
    if (howmany<1) return -1;

    muste_kv_s_disp("\nConverting \"X ALL\" responses in %d variables...", vartotal);
    muste_kv_s_disp("\nMoving values of %d variables at a time...", howmany);

    if ((var1+howmany*vartotal) > d.m) {
        muste_kv_s_err("Not enough variables after %s!", word[2]);
        return -1;
    }

    for (j=d.l1; j<=d.l2; j++) {
        if (unsuitable(&d,j)) continue;
        muste_kv_s_disp(" %d",j);
        for (i=(var1+howmany*vartotal-howmany); i>=var1; i-=howmany) {
            data_load(&d,j,i,&x);
            if (x==MISSING8) {
                data_save(&d,j,i,MISSING8); /* (data in edit field) */
                for (k=1; k<howmany; k++) { /* 31.5.97 */
                    data_save(&d,j,i+k,MISSING8);
                }
                continue;
            }
            if (howmany==1 && ((int)x == i)) continue;
            if (((int)x < 1) || ((int)x > vartotal)) continue; /* 20.5.97 */
            data_save(&d,j,i,MISSING8);
            data_save(&d,j,var1+howmany*(int)x-howmany,x);
            for (k=1; k<howmany; k++) { /* 20.5.97 */
                data_load(&d,j,i+k,&y);
                data_save(&d,j,i+k,MISSING8);
                data_save(&d,j,var1+howmany*(int)x-howmany+k,y);
            }
        }
    }
    data_close(&d);
    return 1;
}
コード例 #6
0
ファイル: vsearch.c プロジェクト: knusbaum/Wily
/* If 'label' is the label of some existing file, return View for it. */
View*
openlabel(char*label, Bool create) {
	View*v;
	Path	contracted;
	
	pathcontract(contracted,label);
	
	if ( (v=data_find(contracted)) ) {
		tile_show(v->tile);
		return v;
	} else if ( (v=data_open(contracted,create)) )
		return v;
	else
		return 0;
}
コード例 #7
0
ファイル: serialization.cpp プロジェクト: zeromus/dasShiny
void MSU1::serialize(serializer &s) {
  Thread::serialize(s);

  s.integer(boot);

  s.integer(mmio.data_offset);
  s.integer(mmio.audio_offset);
  s.integer(mmio.audio_loop_offset);

  s.integer(mmio.audio_track);
  s.integer(mmio.audio_volume);

  s.integer(mmio.data_busy);
  s.integer(mmio.audio_busy);
  s.integer(mmio.audio_repeat);
  s.integer(mmio.audio_play);
  s.integer(mmio.audio_error);

  data_open();
  audio_open();
}
コード例 #8
0
ファイル: msu1.cpp プロジェクト: quequotion/higan-qq
void MSU1::reset() {
  create(MSU1::Enter, 44100);

  mmio.data_seek_offset = 0;
  mmio.data_read_offset = 0;

  mmio.audio_play_offset = 0;
  mmio.audio_loop_offset = 0;

  mmio.audio_track = 0;
  mmio.audio_volume = 0;

  mmio.data_busy = false;
  mmio.audio_busy = false;
  mmio.audio_repeat = false;
  mmio.audio_play = false;
  mmio.audio_error = false;

  data_open();
  audio_open();
}
コード例 #9
0
ファイル: cluster.c プロジェクト: rforge/muste
void muste_cluster(char *argv)
        {
        int i,k;
        double a;
        char ch;

//      if (argc==1) return;
        s_init(argv);

        if (g<2)
            {
            sur_print("\nUsage: CLUSTER <SURVO_data>,<output_line>");
            WAIT; return;
            }
        tulosrivi=0;
        if (g>2)
            {
            tulosrivi=edline2(word[2],1,1);
            if (tulosrivi==0) return;
            }

        strcpy(aineisto,word[1]);
        i=data_open(aineisto,&d); if (i<0) return;
        i=sp_init(r1+r-1); if (i<0) return;
        i=mask(&d); if (i<0) return;
        scales(&d);
        i=conditions(&d); if (i<0) return;

        gvar=activated(&d,'G');
        if (gvar<0)
            {
            sur_print("\nNo grouping variable (activated by 'G') given!");
            WAIT; return;
            }

        ivar=-1; ivar=activated(&d,'I');

        i=spfind("TRIALS");
        if (i>=0) maxiter=atoi(spb[i]);

        i=rand_init(); if (i<0) return;   /* 30.4.1994 */

        i=spfind("TEMPFILE");
        if (i>=0) strcpy(tempfile,spb[i]);
        else { strcpy(tempfile,etmpd); strcat(tempfile,"SURVO.CLU"); }

        i=spfind("PRIND");
        if (i>=0 && atoi(spb[i])>0) prind=1;

        data_load(&d,1L,gvar,&a);
        i=data_save(&d,1L,gvar,a);
        if (i<0) return;

        gvar2=(int *)muste_malloc(d.m_act*sizeof(int));
        if (gvar2==NULL) { not_enough_memory(); return; }

        k=0; n_saved=0; m=0;
        for (i=0; i<d.m_act; ++i)
            {
            ch=d.vartype[d.v[i]][1];
            if (ch=='G')
                {
                ++k;
                gvar2[n_saved]=d.v[i];    /* gvar=gvar2[0] */
                ++n_saved; continue;
                }
            if (ch=='I') { ++k; continue; }
            d.v[m++]=d.v[i];
            }
/*
printf("\nivar=%d gvar=%d m=%d\n",ivar,gvar,m); getch();
for (i=0; i<m; ++i) Rprintf(" %d",d.v[i]); getch();
printf("\n"); for (i=0; i<n_saved; ++i) Rprintf(" %d",gvar2[i]); getch();
*/

        i=spfind("GROUPS");
        if (i<0) ng=2; else ng=atoi(spb[i]);
        if (ng<2) ng=2;
        ng2=ng+2;
        mn=m; if (mn<ng) mn=ng;

        first_line=r+1; if (r+n_saved>r3) first_line=1;
        n_show=n_saved; if (n_show>r3) n_show=r3;

        i=varaa_tilat(); if (i<0) return;

        i=lue_havainnot(); if (i<0) return;
        hav_muistissa=havainnot_muistiin();
        ortogonalisoi();
        if (ivar_init) alustava_luokittelu();
        LOCATE(first_line,1);
        SCROLL_UP(first_line,r3+1,r3);
        sur_print("\nCluster analysis: Iteration 1:");
        while (sur_kbhit()) sur_getch();
        it=0;
        while (1)
            {
            while (1)
                {
                if (it) init_gr();
                i=init_tilat();
                if (i>=0) break;
                if (maxiter==1) return;
                }
            iteroi();
            ++it;
            if (maxiter>1) vertaa_muihin();
            if (it==maxiter) break;
            LOCATE(first_line,1);
            sprintf(sbuf,"\nIteration %d (Cluster analysis)",it);
            sur_print(sbuf);
            for (i=0; i<n_show; ++i)
               {
               if (freq[i]==0) break;
               sprintf(sbuf,"\n%d %g %d        ",i+1,lambda2[i],freq[i]); sur_print(sbuf);
               }
            if (sur_kbhit())
                {
                i=sur_getch(); if (i=='.') break;
                }
            }
        tulosta();

        data_close(&d);
        sur_delete(tempfile);
        s_end(argv);
        }
コード例 #10
0
ファイル: sys_morecore.c プロジェクト: gapry/RefOS-1
long sys_mmap2(va_list ap)
{
    void *start = va_arg(ap, char*);
    unsigned int len = va_arg(ap, unsigned int);
    int prot = va_arg(ap, int);
    int flags = va_arg(ap, int);
    int fd = va_arg(ap, int);
    off_t offset = va_arg(ap, int);
    
    seL4_Word tempWindow;
    seL4_CPtr window;
    int error;
    int npages;
    npages = len / REFOS_PAGE_SIZE;
    int size;
    seL4_CPtr dspace;
    bool new_dspace = 0;

    /*user don't supply a dspace, create one*/
    if(fd == -1 || fd == 0)
    {
        //size = data_get_size(REFOS_PROCSERV_EP, fd);
        seL4_CPtr fd3 = data_open(REFOS_PROCSERV_EP, "anon", 0, 0, (uint32_t)len, &error);
        printf("dspace = %d\n error = %d\n", (int)fd3, (int)error);
        assert(fd3 != 0);
        assert(error == 0);
        new_dspace = 1;
        dspace = fd3;
    }

    /*can only do anon mmapings*/
    if(!(flags & MAP_ANONYMOUS))   
    {
        seL4_DebugPrintf("File mapping not implemented!\n");
        assert(!"File mapping not implemented!\n");
        return -_ENOMEM;
    }

    if (!new_dspace){
        /*private : open a new dspace and copy*/
        if(flags & MAP_PRIVATE){
            size = data_get_size(REFOS_PROCSERV_EP, fd);
            seL4_CPtr fd2 = data_open(REFOS_PROCSERV_EP,"anon", 0, 0, size, &error);
            printf("dspace = %d\n error = %d\n", (int)fd2, (int)error);
            assert(fd2 != 0);
            assert(error == 0);
            error = data_init_data(REFOS_PROCSERV_EP, fd2, fd, 0);
            dspace = fd2;
        }
        /*shared : map to fd directly*/
        else if(flags & MAP_SHARED){
	    /*TODO:should setup a shared window*/
            dspace = fd;
            seL4_DebugPrintf("shared mmap2 caught!\n");
        }
    }

    if(start==NULL){
        tempWindow = walloc(npages, &window);
        assert(tempWindow && window);
        error = data_datamap2(REFOS_PROCSERV_EP, dspace, window, 0, flags);
        assert(error == ESUCCESS);
        return (void *)tempWindow;
    }
    else{
        window = proc_create_mem_window(start, npages);
        assert(window);
        error = data_datamap2(REFOS_PROCSERV_EP, dspace, window, 0, flags);
        assert(error == ESUCCESS);
        return start;
    }
}
コード例 #11
0
ファイル: msu1.cpp プロジェクト: PGGB/Higan-Core
void MSU1::load() {
  data_open();
}
コード例 #12
0
ファイル: test_fileserv.c プロジェクト: Zolok/refos
static int
test_file_server_dataspace()
{
    /* ---------- datamap test ------------ */
    test_start("fs cpio dspace datamap");
    int error;

    /* Find the file server. */
    nsv_mountpoint_t mp = nsv_resolve("fileserv/*");
    test_assert(mp.success == true);
    test_assert(mp.serverAnon != 0);
    seL4_CPtr fileservAnon = mp.serverAnon;

    seL4_CPtr fileservSession = serv_connect_direct(fileservAnon, REFOS_LIVENESS, &error);
    test_assert(fileservSession && error == ESUCCESS);

    /* Allocate a temporary window. */
    seL4_CPtr tempWindow = 0;
    seL4_Word tempWindowVaddr = walloc(2, &tempWindow);
    test_assert(tempWindowVaddr && tempWindow);

    /* Open a new dataspace on the fileserver to test with. */
    seL4_CPtr dspace = data_open(fileservSession, "hello.txt", 0, O_RDWR, 0, &error);
    test_assert(dspace && error == ESUCCESS);

    /* Test datamap. */
    error = data_datamap(fileservSession, dspace, tempWindow, 3);
    test_assert(error == ESUCCESS);
    int scmp = strncmp((char*) tempWindowVaddr, "lo world!", 9);
    test_assert(scmp == 0);

    test_success();

    /* ---------- init_data test ------------ */
    test_start("fs cpio dspace init_data");

    /* Open a new anon dataspace to init data on */
    seL4_CPtr anonDS = data_open(REFOS_PROCSERV_EP, "anon", 0, O_RDWR, 0x1000, &error);
    test_assert(anonDS && error == ESUCCESS);

    /* Inititialise content of this anon dataspace with our fileserv CPIO dataspace. */
    error = data_init_data(fileservSession, anonDS, dspace , 3);
    test_assert(error == ESUCCESS);

    /* Allocate another temporary window. */
    seL4_CPtr tempWindowAnon = 0;
    seL4_Word tempWindowVaddrAnon = walloc(2, &tempWindowAnon);
    test_assert(tempWindowVaddrAnon && tempWindowAnon);

    /* Datamap initialised anon dataspace. */
    error = data_datamap(REFOS_PROCSERV_EP, anonDS, tempWindowAnon, 0);
    test_assert(error == ESUCCESS);
    scmp = strncmp((char*) tempWindowVaddrAnon, "lo world!", 9);
    test_assert(scmp == 0);

    /* Clean up. */
    data_dataunmap(fileservSession, tempWindow);
    data_dataunmap(REFOS_PROCSERV_EP, tempWindowAnon);
    if (tempWindow) {
        walloc_free(tempWindowVaddr, 2);
    }
    if (tempWindowAnon) {
        walloc_free(tempWindowVaddrAnon, 2);
    }
    if (fileservSession) {
        serv_disconnect_direct(fileservSession);
        seL4_CNode_Delete(REFOS_CSPACE, fileservSession, REFOS_CDEPTH);
        csfree(fileservSession);
    }

    /* Release the resources stored in the valid mountpoint. */
    nsv_mountpoint_release(&mp);
    test_assert(mp.success == false);
    test_assert(mp.serverAnon == 0);

    return test_success();
}