Ejemplo n.º 1
0
/* Type 0 -- BIOS Information */
static void *
smbios_type_0_init(void *start)
{
	struct smbios_type_0 *p = (struct smbios_type_0 *)start;
	int flashsize = 0;
	char update[11];
	char release_date_string[11];
	char pmon_version[40];
	char temp[20];
	int i;

	memset(p, 0, sizeof(*p));

  	get_update(update);
	strncpy(temp, update, 4);
	strncpy(temp + 4, update + 5, 2);
	strncpy(temp + 6, update + 8, 2);
	for(i = 0; i < 8; i++){
		if(temp[i] == ' ')
			temp[i] = '0';
	}
	temp[8] = '\0';
    	sprintf(pmon_version, "Loongson-PMON-V3.2-%s", temp);
	p->header.type = 0;
	p->header.length = sizeof(struct smbios_type_0);
	p->header.handle = smbios_table_handle++;
    
	p->vendor_str = 1;
	p->version_str = 2;
	p->starting_address_segment =0xe000;
	p->release_date_str = 3;

	tgt_flashinfo((void *)0xbfc00000, &flashsize);
	p->rom_size = (flashsize>>16) - 1;
    
	memset(p->characteristics, 0, 8);
	//p->characteristics[7] = 0x08; /* BIOS characteristics not supported */
	//p->characteristics[0] = 0x80;
	p->characteristics[1] = 0x18;
	p->characteristics[2] = 0x05;
	
	
	p->characteristics_extension_bytes[0] = 0x80;
	p->characteristics_extension_bytes[1] = 0x02;
    
	p->major_release = 3;
	p->minor_release = 0;
	p->embedded_controller_major = 0xff;
	p->embedded_controller_minor = 0xff;

	start += sizeof(struct smbios_type_0);
	strcpy((char *)start, "Loongson");
	start += strlen("Loongson") + 1;
	strcpy((char *)start, pmon_version);
	start += strlen(pmon_version) + 1;
	
	strncpy(release_date_string, update + 5, 5);
	strncpy(release_date_string + 6, update, 4);
	release_date_string[2] = '/';
	release_date_string[5] = '/';
	release_date_string[10] = '\0';
	strcpy((char *)start, release_date_string);
	start += strlen(release_date_string) + 1;

	*((uint8_t *)start) = 0;
	return start + 1;
}
Ejemplo n.º 2
0
int main (int argc, char *argv[])
{
    bool verb, up2, up3;
    unsigned char update;
    int n1,n2,n3, i1,i2,i3, ns2, ns3, ip, np2, np3, n23;
    int order, np, i4, n4, k2, k3, j2, j3, i, jp, j;
    float eps, ***u, **p1, **p2, **cost, *trace, *q2=NULL, *q3=NULL;
    sf_file inp, out, dip;

    sf_init(argc,argv);
    inp = sf_input("in");
    dip = sf_input("dip");
    out = sf_output("out");

    if (!sf_histint(inp,"n1",&n1)) sf_error("No n1= in input");
    if (!sf_histint(inp,"n2",&n2)) sf_error("No n2= in input");
    if (!sf_histint(inp,"n3",&n3)) sf_error("No n3= in input");
    n23 = n2*n3;
    n4 = sf_leftsize(inp,3);

    if (!sf_getbool("verb",&verb)) verb=false;
    /* verbosity */
    if (!sf_getfloat("eps",&eps)) eps=0.01;
    /* regularization */
    
    if (!sf_getint("order",&order)) order=1;
    /* accuracy order */

    if (!sf_getint("ns2",&ns2)) sf_error("Need ns1=");
    if (!sf_getint("ns3",&ns3)) sf_error("Need ns2=");
    /* spray radius */
    np2 = 2*ns2+1;
    np3 = 2*ns3+1;
    np = np2*np3;

    sf_putint(out,"n2",np);
    sf_shiftdim(inp, out, 2);

    cost = sf_floatalloc2(np2,np3);
    for (i3=0; i3 < np3; i3++) {
	for (i2=0; i2 < np2; i2++) {
	    cost[i3][i2] = hypotf(i2-ns2,i3-ns3);
	}
    }

    predict_init (n1, n2, eps*eps, order, 1, true);
    update_init(np2,np3,*cost);

    u = sf_floatalloc3(n1,np,n23);
    for (i3=0; i3 < n23; i3++) {
	for (ip=0; ip < np; ip++) {
	    for (i1=0; i1 < n1; i1++) {
		u[i3][ip][i1] = 0.;
	    }
	}
    }

    p1 = sf_floatalloc2(n1,n23);
    p2 = sf_floatalloc2(n1,n23);

    for (i=0; i < n23; i++) { 
	sf_floatread(p1[i],n1,dip);
    }

    for (i=0; i < n23; i++) { 
	sf_floatread(p2[i],n1,dip);
    }

    for (i4=0; i4 < n4; i4++) {
	for (i=0; i < n23; i++) { 
	    sf_floatread(u[i][ns3*np2+ns2],n1,inp);
	    
	    i2 = i%n2;
	    i3 = i/n2;

	    for (ip=0; ip < np; ip++) {
		update = get_update(ip,&up2,&up3,&jp);
		
		/* from jp to j */
		k2 = jp%np2;
		k3 = jp/np2;
		
		j2 = i2+k2-ns2;
		j3 = i3+k3-ns3;

		if (j2 < 0 || j2 >= n2 || 
		    j3 < 0 || j3 >= n3) continue;

		j = j2+j3*n2;
		trace = u[j][jp];

		if (update & 1) {		
		    if (up2) {
			if (j2==0) continue;
			j2 = j-1;
			q2 = p1[j2];
			k2 = jp-1;
		    } else {
			if (j2==n2-1) continue;
			j2 = j+1;
			q2 = p1[j];
			k2 = jp+1;
		    }
		}
		if (update & 2) {
		    if (up3) {
			if (j3==0) continue;
			j3 = j-n2;
			q3 = p2[j3];
			k3 = jp-np2;
		    } else {
			if (j3==n3-1) continue;
			j3 = j+n2;
			q3 = p2[j];
			k3 = jp+np2;
		    }
		}

		switch(update) {
		    case 0:			
			break;
		    case 1:
			predict1_step(up2,u[j2][k2],q2,trace);
			break;
		    case 2:
			predict1_step(up3,u[j3][k3],q3,trace);
			break;
		    case 3:
			predict2_step(up2,up3,u[j2][k2],u[j3][k3],
				      q2,q3,trace);
			break;
		}
	    }
	}

	for (i=0; i < n23; i++) {
	    for (ip=0; ip < np; ip++) {
		sf_floatwrite(u[i][ip],n1,out);
	    }
	}
    }

    exit (0);
}