Example #1
0
void
vm_init(void *d)
{
	vmid = (int)d;
	cos_meminfo_init(&booter_info.mi, BOOT_MEM_KM_BASE, VM_UNTYPED_SIZE, BOOT_CAPTBL_SELF_UNTYPED_PT);
	cos_compinfo_init(&booter_info, BOOT_CAPTBL_SELF_PT, BOOT_CAPTBL_SELF_CT, BOOT_CAPTBL_SELF_COMP,
			  (vaddr_t)cos_get_heap_ptr(), VM_CAPTBL_FREE, &booter_info);

	PRINTC("Micro Booter started.\n");
	test_run_vk();
	PRINTC("Micro Booter done.\n");

	EXIT();
	return;
}
Example #2
0
int cdfs_read_raw_frame2(struct super_block * sb, int lba, unsigned char *buf,unsigned int data_size)
{
	/*     
	struct cdrom_msf *msf;
	msf = (struct cdrom_msf*) buf;
	msf->cdmsf_min0   = (lba + CD_MSF_OFFSET) / CD_FRAMES / CD_SECS;
	msf->cdmsf_sec0   = (lba + CD_MSF_OFFSET) / CD_FRAMES % CD_SECS;
	msf->cdmsf_frame0 = (lba + CD_MSF_OFFSET) % CD_FRAMES;

	if(data_size==2048)
	{
		PRINTC("david0213: data_size==2048, using CDROMREADMODE2\n");
		return cdfs_ioctl(sb, CDROMREADMODE2, (unsigned long)msf);
	}
	else
	{
		PRINTC("david0213: data_size!=2048, using CDROMREADRAW\n");
		return cdfs_ioctl(sb, CDROMREADRAW, (unsigned long)msf);	//david 1014
	}
	*/
	static struct cdrom_generic_command cgc;
	static struct request_sense buffer2;
	unsigned char *frame;
	int ret;
	
	memset(&cgc, 0, sizeof(cgc));	

	if(data_size==2048)
	{
		PRINTC("david0213: data_size==2048, using CDROMREADMODE2\n");
		frame = kmalloc(CD_FRAMESIZE_RAW, GFP_KERNEL);	
		if (!frame)
		{
			printk("memory allocation failed in cdfs_read_raw_frame2\n");
			return 0;
		}
		cgc.sense = &buffer2;
		cgc.buffer = frame;
		cgc.buflen=CD_FRAMESIZE_RAW;
		cgc.data_direction=CGC_DATA_READ;
		cgc.quiet = 1;
		cgc.stat = 1;
		cgc.cmd[0]=GPCMD_READ_CD;
		cgc.cmd[1]= 0<<2;
		cgc.cmd[2]=(lba>>24)&0xff;      // MSB
		cgc.cmd[3]=(lba>>16)&0xff;      
		cgc.cmd[4]=(lba>>8 )&0xff;      
		cgc.cmd[5]=(lba    )&0xff;      // LSB
		cgc.cmd[8]=1;			//Transfer length in blocks LSB
		cgc.cmd[9]=0xf8;
		ret=cdfs_ioctl( sb, CDROM_SEND_PACKET, (unsigned int)&cgc );
		if (!ret) memcpy(buf, frame+16, CD_FRAMESIZE_RAW0);
		kfree(frame);
		return(ret);
	}
Example #3
0
static void
QuoteText(
    char *string,		/* The line of text. */
    int count)			/* Number of characters to write from
				 * string. */
{
    if (count == 0) {
	PRINT(("{}"));
	return;
    }
    for ( ; count > 0; string++, count--) {
	switch (*string) {
	case '\\':
	    if (*(string+1) == 'N' && *(string+2) == '\'') {
		int ch;

		string += 3;
		count -= 3;
		sscanf(string,"%d",&ch);
		PRINT(("\\u%04x", ch));
		while(count>0&&*string!='\'') {string++;count--;}
		continue;
	    } else if (*(string+1) == '0') {
		PRINT(("\\ "));
		string++;
		count--;
		continue;
	    }
	case '$': case '[': case '{': case ' ': case ';':
	case '"': case '\t':
	    PRINTC('\\');
	default:
	    PRINTC(*string);
	}
    }
}
Example #4
0
static void
DoText(
    char *line)			/* The line of text. */
{
    char *p, *end;

    /*
     * Divide the line up into pieces consisting of backslash sequences, tabs,
     * and other text.
     */

    p = line;
    while (*p != 0) {
	if (*p == '\t') {
	    PRINT(("tab\n"));
	    p++;
	} else if (*p != '\\') {
	    /*
	     * Ordinary text.
	     */

	    for (end = p+1; (*end != '\\') && (*end != 0); end++) {
		/* Empty loop body. */
	    }
	    PRINT(("text "));
	    QuoteText(p, end-p);
	    PRINTC('\n');
	    p = end;
	} else {
	    /*
	     * A backslash sequence. There are particular ones that we
	     * understand; output an error message for anything else and just
	     * ignore the backslash.
	     */

	    p++;
	    if (*p == 'f') {
		/*
		 * Font change.
		 */

		PRINT(("font %c\n", p[1]));
		p += 2;
	    } else if (*p == '-') {
		PRINT(("dash\n"));
		p++;
	    } else if (*p == 'e') {
		PRINT(("text \\\\\n"));
		p++;
	    } else if (*p == '.') {
		PRINT(("text .\n"));
		p++;
	    } else if (*p == '&') {
		p++;
	    } else if (*p == '0') {
		PRINT(("text { }\n"));
		p++;
	    } else if (*p == '(') {
		if ((p[1] == 0) || (p[2] == 0)) {
		    fprintf(stderr, "Bad \\( sequence on line %d.\n",
			    lineNumber);
		    status = 1;
		} else {
		    PRINT(("char {\\(%c%c}\n", p[1], p[2]));
		    p += 3;
		}
	    } else if (*p == 'N' && *(p+1) == '\'') {
		int ch;

		p += 2;
		sscanf(p,"%d",&ch);
		PRINT(("text \\u%04x\n", ch));
		while(*p&&*p!='\'') p++;
		p++;  
	    } else if (*p != 0) {
		PRINT(("char {\\%c}\n", *p));
		p++;
	    }
	}
    }
    PRINT(("newline\n"));
}
Example #5
0
static void
DoMacro(
    char *line)			/* The line of text that contains the macro
				 * invocation. */
{
    char *p, *end;
    int quote;

    /*
     * If there is no macro name, then just skip the whole line.
     */

    if ((line[1] == 0) || (isspace(line[1]))) {
	return;
    }

    PRINT(("macro"));
    if (*line != '.') {
	PRINT(("2"));
    }

    /*
     * Parse the arguments to the macro (including the name), in order.
     */

    p = line+1;
    while (1) {
	PRINTC(' ');
	if (*p == '"') {
	    /*
	     * The argument is delimited by quotes.
	     */

	    for (end = p+1; *end != '"'; end++) {
		if (*end == 0) {
		    fprintf(stderr,
			    "Unclosed quote in macro call on line %d.\n",
			    lineNumber);
		    status = 1;
		    break;
		}
	    }
	    QuoteText(p+1, (end-(p+1)));
	} else {
	    quote = 0;
	    for (end = p+1; (*end != 0) && (quote || !isspace(*end)); end++) {
		if (*end == '\'') {
		    quote = !quote;
		}
	    }
	    QuoteText(p, end-p);
	}
	if (*end == 0) {
	    break;
	}
	p = end+1;
	while (isspace(*p)) {
	    /*
	     * Skip empty space before next argument.
	     */

	    p++;
	}
	if (*p == 0) {
	    break;
	}
    }
    PRINTC('\n');
}
Example #6
0
void IntegrateRationalFunction(node_type *root, char var, char newvar,
                               int trace)
{
     RatFun A, h, content;
     Coefficient R = {special}, rat_part = {rational}, solution = {special};
     Coefficient *Qit = NULL, *Sit = NULL;
     Coefficient Qit2 = {special}, Sit2 = {special};
     Integral integral;
     unsigned i;

     init_ratfun(&A);
     init_ratfun(&h);
     init_ratfun(&content);

     init_bigrat(&rat_part.u.rat);

     init_integral(&integral);

     if (root->type != ratfun_type) {
          printf("Error! IntegrateRationalFunction"
                 "requires a rational function.\n");
          return;
     }

     copy_ratfun(&integral.integrand, root->u.ratfun);
     integral.var = var;
     integral.newvar = newvar;

     if (ratfun_zero(integral.integrand)) {
          goto print;
     }

     /* make numerator and denominator primitive */
     coef_content(&content.num, root->u.ratfun.num, var);
     exact_div_coefficients(&root->u.ratfun.num,
                            root->u.ratfun.num,
                            content.num);
     coef_content(&content.den, root->u.ratfun.den, var);
     exact_div_coefficients(&root->u.ratfun.den,
                            root->u.ratfun.den,
                            content.den);

     if (trace) {
          printf("Computing rational part of integral using "
                 "Hermite reduction...\n");
          WAIT;
     }

     HermiteReduce(&integral.rational_part,
                   &h,
                   root->u.ratfun,
                   var,
                   trace);

     /* put contents back on */
     /* PRINTR(content); */
     mul_ratfuns(&integral.rational_part, integral.rational_part, content);
     mul_ratfuns(&h, h, content);
     /* PRINTR(h); */

     if (trace) {
          printf("Found rational part:\t\t");
          print_ratfun(integral.rational_part);
          printf("\n");

          printf("\nHermite reduction leaves:\t");
          print_ratfun(h);
          printf("\n");
          WAIT;

          printf("Remove polynomial part...\n");
          WAIT;
     }

     polydiv_coefficients(&integral.poly_part, &R, h.num, h.den);

     if (trace) {
          printf("Polynomial part:\t\t");
          print_coefficient(integral.poly_part);
          printf("\n");
     }

     coef_integrate(&integral.poly_part, integral.poly_part, var);

     if (trace) {
          printf("Integrate it:\t\t\t");
          print_coefficient(integral.poly_part);
          printf("\n");
          WAIT;

          printf("Left over:\t\t\t");
          print_coefficient(R);
          printf("/");
          print_coefficient(h.den);
          printf("\n");
     }

     if (!coef_zero(R) && coef_deg(h.den, var) > coef_deg(R, var)) {

          if (trace) {
               printf("\nComputing logarithmic part using "
                      "Lazard-Rioboo-Trager algorithm...\n");
               WAIT;
          }

          IntRationalLogPart(&integral.Qi, &integral.Si, R, h.den, var, newvar,
                             trace);
          
          /* make Qi and Si primitive */
          for (i = 0; i < integral.Qi.size; ++i) {
               Qit = ca_get2(&integral.Qi, i);
               Sit = ca_get2(&integral.Si, i);
               
               rat_part.u.rat = coef_rat_part(*Qit);
               mul_coefficients(Qit, *Qit, rat_part);
               free_bigrat(&rat_part.u.rat);
               
               /* rat_part.u.rat = coef_rat_part(*Sit); */
               /* mul_coefficients(Sit, *Sit, rat_part); */
               /* free_bigrat(&rat_part.u.rat); */

               coef_pp(Qit, *Qit, newvar);
               /* coef_pp(Sit, *Sit, var); */
          }

          if (trace) {
               printf("Found logarithmic part.\n");
               printf("%d sum(s) over roots:\t\t", integral.Qi.size);
               if (integral.Qi.size > 0) {
                    for (i = 0; i < integral.Qi.size; ++i) {
                         printf("sum(%c | ", integral.newvar);
                         print_coefficient(ca_get(&integral.Qi, i));
                         printf(" = 0) %c*ln(", integral.newvar);
                         print_coefficient(ca_get(&integral.Si, i));
                         printf(")");
                         if (i < integral.Qi.size-1) {
                              printf(" + ");
                         }
                    }
               }
               printf("\n");
               WAIT;

               printf("Solve the linear univariate Qis to get explicit sums...\n");
          }

          /* solve linear univariate Qis */
          for (i = 0; i < integral.Qi.size; ++i) {
               if (coef_deg(ca_get(&integral.Qi, i), newvar) != 1
                   || !poly_univar(ca_get(&integral.Qi, i).u.poly)) {
                    continue;
               }
               solve_linear_poly(&solution, ca_get(&integral.Qi, i).u.poly);
               subst_var_coef(ca_get2(&integral.Si, i), solution, newvar);

               /* move to solved arrays */
               ca_push_back(&integral.QiS, solution);
               ca_push_back(&integral.SiS, ca_get(&integral.Si, i));

               /* remove from normal arrays */
               Qit2 = ca_remove(&integral.Qi, i);
               Sit2 = ca_remove(&integral.Si, i);
               free_coefficient(&Qit2);
               free_coefficient(&Sit2);
               --i;
          }

          /* make SiS primitive */
          for (i = 0; i < integral.SiS.size; ++i) {
               Sit = ca_get2(&integral.SiS, i);
               
               rat_part.u.rat = coef_rat_part(*Sit);
               mul_coefficients(Sit, *Sit, rat_part);
               free_bigrat(&rat_part.u.rat);

               coef_pp(Sit, *Sit, var);
          }

          if (trace) {
               printf("Found %d explicit sum(s):\t", integral.QiS.size);
               if (integral.QiS.size > 0) {
                    for (i = 0; i < integral.QiS.size; ++i) {
                         if (!coef_one(ca_get(&integral.QiS, i))) {
                              print_coefficient(ca_get(&integral.QiS, i));
                              printf("*ln(");
                         }
                         else {
                              printf("ln(");
                         }
                         print_coefficient(ca_get(&integral.SiS, i));
                         printf(")");
                         if (i < integral.QiS.size-1) {
                              printf(" + ");
                         }
                    }
               }
               printf("\n");
               WAIT;
          }
     }
     else if (coef_deg(h.den, var) == 0) {
          /* this is actually just a poly over a constant,
           * so integrate it trivially */
          coef_integrate(&R, R, var);
          /* move this to the numerator of h */
          free_coefficient(&h.num);
          h.num = R;
          R.type = special;
          /* add h to the rational part of integral */
          add_ratfuns(&integral.rational_part, integral.rational_part, h);
     }
     else {
          /* this shouldn't happen */
          printf("Error!  Invalid ratfun following Hermite reduction!\n");
          PRINTR(h);
          printf("\n");
          PRINTC(R);
          printf("\n");
     }

print:
     if (trace) {
          printf("\nFinal answer:\n");
     }
     print_integral(integral);
     printf("\nLaTeX format:\n");
     print_integral_LaTeX(integral);

     free_ratfun(&A);
     free_ratfun(&h);
     free_ratfun(&content);
     free_coefficient(&R);
     free_integral(&integral);
}
Example #7
0
File: env.c Project: lemahdi/mglib
void
gsl_ieee_env_setup (void)
{
  const char * p = getenv("GSL_IEEE_MODE") ;

  int precision = 0, rounding = 0, exception_mask = 0 ;

  int comma = 0 ;

  if (p == 0)  /* GSL_IEEE_MODE environment variable is not set */
    return ;

  if (*p == '\0') /* GSL_IEEE_MODE environment variable is empty */
    return ;

  gsl_ieee_read_mode_string (p, &precision, &rounding, &exception_mask) ;

  gsl_ieee_set_mode (precision, rounding, exception_mask) ;
  
  fprintf(stderr, "GSL_IEEE_MODE=\"") ;

  /* Print string with a preceeding comma if the list has already begun */

#define PRINTC(x) do {if(comma) fprintf(stderr,","); fprintf(stderr,x); comma++ ;} while(0)
  
  switch (precision) 
    {
    case GSL_IEEE_SINGLE_PRECISION:
      PRINTC("single-precision") ;
      break ;
    case GSL_IEEE_DOUBLE_PRECISION:
      PRINTC("double-precision") ;
      break ;
    case GSL_IEEE_EXTENDED_PRECISION:
      PRINTC("extended-precision") ;
      break ;
    }

  switch (rounding) 
    {
    case GSL_IEEE_ROUND_TO_NEAREST:
      PRINTC("round-to-nearest") ;
      break ;
    case GSL_IEEE_ROUND_DOWN:
      PRINTC("round-down") ;
      break ;
    case GSL_IEEE_ROUND_UP:
      PRINTC("round-up") ;
      break ;
    case GSL_IEEE_ROUND_TO_ZERO:
      PRINTC("round-to-zero") ;
      break ;
    }

  if ((exception_mask & GSL_IEEE_MASK_ALL) == GSL_IEEE_MASK_ALL)
    {
      PRINTC("mask-all") ;
    }
  else if ((exception_mask & GSL_IEEE_MASK_ALL) == 0)
    {
      PRINTC("trap-common") ;
    }
  else 
    {
      if (exception_mask & GSL_IEEE_MASK_INVALID)
        PRINTC("mask-invalid") ;
      
      if (exception_mask & GSL_IEEE_MASK_DENORMALIZED)
        PRINTC("mask-denormalized") ;
      
      if (exception_mask & GSL_IEEE_MASK_DIVISION_BY_ZERO)
        PRINTC("mask-division-by-zero") ;
      
      if (exception_mask & GSL_IEEE_MASK_OVERFLOW)
        PRINTC("mask-overflow") ;
      
      if (exception_mask & GSL_IEEE_MASK_UNDERFLOW)
        PRINTC("mask-underflow") ;
    }

  if (exception_mask & GSL_IEEE_TRAP_INEXACT)
    PRINTC("trap-inexact") ;
  
  fprintf(stderr,"\"\n") ;
}