Ejemplo n.º 1
0
/*
 * @implemented
 */
void _tsearchenv(const _TCHAR* file,const _TCHAR* var,_TCHAR* path)
{
    _TCHAR* env = _tgetenv(var);
    _TCHAR* x;
    _TCHAR* y;
    _TCHAR* FilePart;

    TRACE(MK_STR(_tsearchenv)"()\n");

    x = _tcschr(env,'=');
    if ( x != NULL ) {
        *x = 0;
        x++;
    }
    y = _tcschr(env,';');
    while ( y != NULL ) {
        *y = 0;
        if ( SearchPath(x,file,NULL,MAX_PATH,path,&FilePart) > 0 ) {
            return;
        }
        x = y+1;
        y = _tcschr(env,';');
    }
    return;
}
Ejemplo n.º 2
0
static int display_banner(void)
{
	printf("\n\n%s\n\n", version_string);
	printf("CPU:   ADSP " MK_STR(CONFIG_BFIN_CPU) " "
		"(Detected Rev: 0.%d) "
		"(%s boot)\n",
		bfin_revid(),
		get_bfin_boot_mode(CONFIG_BFIN_BOOT_MODE));
	return 0;
}
Ejemplo n.º 3
0
/*
 * INTERNAL
 */
int access_dirT(const _TCHAR *_path)
{
    DWORD Attributes = GetFileAttributes(_path);
    TRACE(MK_STR(is_dirT)"('%"sT"')\n", _path);

    if (Attributes == (DWORD)-1) {
         _dosmaperr(GetLastError());
        return -1;
    }

    if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
    {
      _set_errno(EACCES);
      return -1;
    }

   return 0;
}
Ejemplo n.º 4
0
static void
init_scm(void)
{
    last_scm_cmd = SCHEME_INIT_TEXT;

    {
        SCM ini_res = ag_scm_c_eval_string_from_file_line(
            SCHEME_INIT_TEXT, AG_TEXT_STRTABLE_FILE, SCHEME_INIT_TEXT_LINENO);
        AGDUPSTR(libguile_ver, scm2display(ini_res), "ini res");
    }

    {
        unsigned int maj, min, mic;
        switch (sscanf(libguile_ver, "%u.%u.%u", &maj, &min, &mic)) {
        case 2:
        case 3: break;
        default:
            AG_ABEND(aprf(GUILE_VERSION_BAD, libguile_ver));
            /* NOT_REACHED */
        }
        maj = min + (100 * maj);
        if ((GUILE_VERSION / 1000) != maj)
            AG_ABEND(aprf(GUILE_VERSION_WRONG, libguile_ver,
                          MK_STR(GUILE_VERSION)));
    }

    {
#       if GUILE_VERSION >= 200000
#         define SCHEME_INIT_DEBUG SCHEME_INIT_DEBUG_2_0
#       else
#         define SCHEME_INIT_DEBUG SCHEME_INIT_DEBUG_1_6
#       endif
        char * p = aprf(INIT_SCM_ERRS_FMT, SCHEME_INIT_DEBUG);
#       undef  SCHEME_INIT_DEBUG

        last_scm_cmd = p;
        ag_scm_c_eval_string_from_file_line(p, __FILE__, __LINE__);
        AGFREE(p);
    }
}
Ejemplo n.º 5
0
// *******************************************************************************************
// main; read command line args and start stencil
int main(int argc, char *argv[])
{
#ifdef _DIST_
    CnC::dist_cnc_init< my_context > dc_init;
#endif
    int Nx = 100;
    int Ny = 100;
    int Nz = 20;
    int T = 40;
    dist_type dt = BLOCKED_3D;

    if (argc > 3) {
        Nx = atoi(argv[1]);
        Ny = atoi(argv[2]);
        Nz = atoi(argv[3]);
    }  
    if (argc > 4)
        T = atoi(argv[4]);
    if( argc > 5 )
        dt = static_cast< dist_type >( atoi( argv[5] ) );

    // create CnC context and init problem
    my_context _ctxt( Nx, Ny, Nz, T, dt );
    // run it
    _ctxt.run();

#ifdef OUTFILE
    std::ofstream of( MK_STR( OUTFILE ) );
    _ctxt.print_y( of );
    of.close();
#else
    _ctxt.print_y( std::cout );
#endif
#ifdef DUMP
    _ctxt.dump( "ptile.out" );
#endif

    return 0;
}
Ejemplo n.º 6
0
int _do_env_set (int flag, int argc, char * const argv[])
{
	bd_t  *bd = gd->bd;
	int   i, len;
	int   console = -1;
	char  *name, *value, *s;
	ENTRY e, *ep;

	name = argv[1];

	if (strchr(name, '=')) {
		printf("## Error: illegal character '=' in variable name \"%s\"\n", name);
		return 1;
	}

	env_id++;
	/*
	 * search if variable with this name already exists
	 */
	e.key = name;
	e.data = NULL;
	hsearch_r(e, FIND, &ep, &env_htab);

	/* Check for console redirection */
	if (strcmp(name, "stdin") == 0)
		console = stdin;
	else if (strcmp(name, "stdout") == 0)
		console = stdout;
	else if (strcmp(name, "stderr") == 0)
		console = stderr;

	if (console != -1) {
		if (argc < 3) {		/* Cannot delete it! */
			printf("Can't delete \"%s\"\n", name);
			return 1;
		}

#ifdef CONFIG_CONSOLE_MUX
		i = iomux_doenv(console, argv[2]);
		if (i)
			return i;
#else
		/* Try assigning specified device */
		if (console_assign(console, argv[2]) < 0)
			return 1;

#ifdef CONFIG_SERIAL_MULTI
		if (serial_assign(argv[2]) < 0)
			return 1;
#endif
#endif /* CONFIG_CONSOLE_MUX */
	}

	/*
	 * Some variables like "ethaddr" and "serial#" can be set only
	 * once and cannot be deleted; also, "ver" is readonly.
	 */
	if (ep) {		/* variable exists */
#ifndef CONFIG_ENV_OVERWRITE
		if ((strcmp(name, "serial#") == 0) ||
		    ((strcmp(name, "ethaddr") == 0)
#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
		     && (strcmp(ep->data, MK_STR(CONFIG_ETHADDR)) != 0)
#endif	/* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
		    ) ) {
			printf("Can't overwrite \"%s\"\n", name);
			return 1;
		}
#endif
		/*
		 * Switch to new baudrate if new baudrate is supported
		 */
		if (strcmp(name, "baudrate") == 0) {
			int baudrate = simple_strtoul(argv[2], NULL, 10);
			int i;
			for (i = 0; i < N_BAUDRATES; ++i) {
				if (baudrate == baudrate_table[i])
					break;
			}
			if (i == N_BAUDRATES) {
				printf("## Baudrate %d bps not supported\n",
					baudrate);
				return 1;
			}
			printf ("## Switch baudrate to %d bps and press ENTER ...\n",
				baudrate);
			udelay(50000);
			gd->baudrate = baudrate;
#if defined(CONFIG_PPC) || defined(CONFIG_MCF52x2)
			gd->bd->bi_baudrate = baudrate;
#endif

			serial_setbrg();
			udelay(50000);
			for (;;) {
				if (getc() == '\r')
					break;
			}
		}
	}

	/* Delete only ? */
	if ((argc < 3) || argv[2] == NULL) {
		int rc = hdelete_r(name, &env_htab);
		return !rc;
	}

	/*
	 * Insert / replace new value
	 */
	for (i = 2, len = 0; i < argc; ++i)
		len += strlen(argv[i]) + 1;

	value = malloc(len);
	if (value == NULL) {
		printf("## Can't malloc %d bytes\n", len);
		return 1;
	}
	for (i = 2, s = value; i < argc; ++i) {
		char *v = argv[i];

		while ((*s++ = *v++) != '\0')
			;
		*(s-1) = ' ';
	}
	if (s != value)
		*--s = '\0';

	e.key  = name;
	e.data = value;
	hsearch_r(e, ENTER, &ep, &env_htab);
	free(value);
	if (!ep) {
		printf("## Error inserting \"%s\" variable, errno=%d\n",
			name, errno);
		return 1;
	}

	/*
	 * Some variables should be updated when the corresponding
	 * entry in the environment is changed
	 */

	if (strcmp(name, "ipaddr") == 0) {
		char *s = argv[2];	/* always use only one arg */
		char *e;
		unsigned long addr;
		bd->bi_ip_addr = 0;
		for (addr = 0, i = 0; i < 4; ++i) {
			ulong val = s ? simple_strtoul(s, &e, 10) : 0;
			addr <<= 8;
			addr  |= (val & 0xFF);
			if (s) s = (*e) ? e+1 : e;
		}
		bd->bi_ip_addr = htonl(addr);
		return 0;
	} else if (strcmp(argv[1], "loadaddr") == 0) {
		load_addr = simple_strtoul(argv[2], NULL, 16);
		return 0;
	}
#if defined(CONFIG_CMD_NET)
	else if (strcmp(argv[1], "bootfile") == 0) {
		copy_filename(BootFile, argv[2], sizeof(BootFile));
		return 0;
	}
#endif
	return 0;
}
Ejemplo n.º 7
0
#endif
	{
#if defined(CONFIG_BOOTARGS)
	"bootargs="	CONFIG_BOOTARGS			"\0"
#endif
#if defined(CONFIG_BOOTCOMMAND)
	"bootcmd="	CONFIG_BOOTCOMMAND		"\0"
#endif
#if defined(CONFIG_RAMBOOTCOMMAND)
	"ramboot="	CONFIG_RAMBOOTCOMMAND		"\0"
#endif
#if defined(CONFIG_NFSBOOTCOMMAND)
	"nfsboot="	CONFIG_NFSBOOTCOMMAND		"\0"
#endif
#if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
	"bootdelay="	MK_STR(CONFIG_BOOTDELAY)	"\0"
#endif
#if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0)
	"baudrate="	MK_STR(CONFIG_BAUDRATE)		"\0"
#endif
#ifdef	CONFIG_LOADS_ECHO
	"loads_echo="	MK_STR(CONFIG_LOADS_ECHO)	"\0"
#endif
#ifdef	CONFIG_ETHADDR
	"ethaddr="	MK_STR(CONFIG_ETHADDR)		"\0"
#endif
#ifdef	CONFIG_ETH1ADDR
	"eth1addr="	MK_STR(CONFIG_ETH1ADDR)		"\0"
#endif
#ifdef	CONFIG_ETH2ADDR
	"eth2addr="	MK_STR(CONFIG_ETH2ADDR)		"\0"
Ejemplo n.º 8
0
int _do_setenv (int flag, int argc, char *argv[])
{
	int   i, len, oldval;
	int   console = -1;
	uchar *env, *nxt = NULL;
	char *name;
	bd_t *bd = gd->bd;

	uchar *env_data = env_get_addr(0);

	if (!env_data)	/* need copy in RAM */
		return 1;

	name = argv[1];

	if (strchr(name, '=')) {
		printf ("## Error: illegal character '=' in variable name \"%s\"\n", name);
		return 1;
	}

	/*
	 * search if variable with this name already exists
	 */
	oldval = -1;
	for (env=env_data; *env; env=nxt+1) {
		for (nxt=env; *nxt; ++nxt)
			;
		if ((oldval = envmatch((uchar *)name, env-env_data)) >= 0)
			break;
	}

	/*
	 * Delete any existing definition
	 */
	if (oldval >= 0) {
#ifndef CONFIG_ENV_OVERWRITE

		/*
		 * Ethernet Address and serial# can be set only once,
		 * ver is readonly.
		 */
		if (
#ifdef CONFIG_HAS_UID
		/* Allow serial# forced overwrite with 0xdeaf4add flag */
		    ((strcmp (name, "serial#") == 0) && (flag != 0xdeaf4add)) ||
#else
		    (strcmp (name, "serial#") == 0) ||
#endif
		    ((strcmp (name, "ethaddr") == 0)
#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
		     && (strcmp ((char *)env_get_addr(oldval),MK_STR(CONFIG_ETHADDR)) != 0)
#endif	/* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
		    ) ) {
			printf ("Can't overwrite \"%s\"\n", name);
			return 1;
		}
#endif

		/* Check for console redirection */
		if (strcmp(name,"stdin") == 0) {
			console = stdin;
		} else if (strcmp(name,"stdout") == 0) {
			console = stdout;
		} else if (strcmp(name,"stderr") == 0) {
			console = stderr;
		}

		if (console != -1) {
			if (argc < 3) {		/* Cannot delete it! */
				printf("Can't delete \"%s\"\n", name);
				return 1;
			}

#ifdef CONFIG_CONSOLE_MUX
			i = iomux_doenv(console, argv[2]);
			if (i)
				return i;
#else
			/* Try assigning specified device */
			if (console_assign (console, argv[2]) < 0)
				return 1;

#ifdef CONFIG_SERIAL_MULTI
			if (serial_assign (argv[2]) < 0)
				return 1;
#endif
#endif /* CONFIG_CONSOLE_MUX */
		}

		/*
		 * Switch to new baudrate if new baudrate is supported
		 */
		if (strcmp(argv[1],"baudrate") == 0) {
			int baudrate = simple_strtoul(argv[2], NULL, 10);
			int i;
			for (i=0; i<N_BAUDRATES; ++i) {
				if (baudrate == baudrate_table[i])
					break;
			}
			if (i == N_BAUDRATES) {
				printf ("## Baudrate %d bps not supported\n",
					baudrate);
				return 1;
			}
			printf ("## Switch baudrate to %d bps and press ENTER ...\n",
				baudrate);
			udelay(50000);
			gd->baudrate = baudrate;
#if defined(CONFIG_PPC) || defined(CONFIG_MCF52x2)
			gd->bd->bi_baudrate = baudrate;
#endif

			serial_setbrg ();
			udelay(50000);
			for (;;) {
				if (getc() == '\r')
				      break;
			}
		}

		if (*++nxt == '\0') {
			if (env > env_data) {
				env--;
			} else {
				*env = '\0';
			}
		} else {
			for (;;) {
				*env = *nxt++;
				if ((*env == '\0') && (*nxt == '\0'))
					break;
				++env;
			}
		}
		*++env = '\0';
	}

#ifdef CONFIG_NET_MULTI
	if (strncmp(name, "eth", 3) == 0) {
		char *end;
		int   num = simple_strtoul(name+3, &end, 10);

		if (strcmp(end, "addr") == 0) {
			eth_set_enetaddr(num, argv[2]);
		}
	}
#endif


	/* Delete only ? */
	if ((argc < 3) || argv[2] == NULL) {
		env_crc_update ();
		return 0;
	}

	/*
	 * Append new definition at the end
	 */
	for (env=env_data; *env || *(env+1); ++env)
		;
	if (env > env_data)
		++env;
	/*
	 * Overflow when:
	 * "name" + "=" + "val" +"\0\0"  > ENV_SIZE - (env-env_data)
	 */
	len = strlen(name) + 2;
	/* add '=' for first arg, ' ' for all others */
	for (i=2; i<argc; ++i) {
		len += strlen(argv[i]) + 1;
	}
	if (len > (&env_data[ENV_SIZE]-env)) {
		printf ("## Error: environment overflow, \"%s\" deleted\n", name);
		return 1;
	}
	while ((*env = *name++) != '\0')
		env++;
	for (i=2; i<argc; ++i) {
		char *val = argv[i];

		*env = (i==2) ? '=' : ' ';
		while ((*++env = *val++) != '\0')
			;
	}

	/* end is marked with double '\0' */
	*++env = '\0';

	/* Update CRC */
	env_crc_update ();

	/*
	 * Some variables should be updated when the corresponding
	 * entry in the enviornment is changed
	 */

	if (strcmp(argv[1],"ethaddr") == 0) {
		char *s = argv[2];	/* always use only one arg */
		char *e;
		for (i=0; i<6; ++i) {
			bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
			if (s) s = (*e) ? e+1 : e;
		}
#ifdef CONFIG_NET_MULTI
		eth_set_enetaddr(0, argv[2]);
#endif
		return 0;
	}

	if (strcmp(argv[1],"ipaddr") == 0) {
		char *s = argv[2];	/* always use only one arg */
		char *e;
		unsigned long addr;
		bd->bi_ip_addr = 0;
		for (addr=0, i=0; i<4; ++i) {
			ulong val = s ? simple_strtoul(s, &e, 10) : 0;
			addr <<= 8;
			addr  |= (val & 0xFF);
			if (s) s = (*e) ? e+1 : e;
		}
		bd->bi_ip_addr = htonl(addr);
		return 0;
	}
	if (strcmp(argv[1],"loadaddr") == 0) {
		load_addr = simple_strtoul(argv[2], NULL, 16);
		return 0;
	}
#if defined(CONFIG_CMD_NET)
	if (strcmp(argv[1],"bootfile") == 0) {
		copy_filename (BootFile, argv[2], sizeof(BootFile));
		return 0;
	}
#endif

#ifdef CONFIG_AMIGAONEG3SE
	if (strcmp(argv[1], "vga_fg_color") == 0 ||
	    strcmp(argv[1], "vga_bg_color") == 0 ) {
		extern void video_set_color(unsigned char attr);
		extern unsigned char video_get_attr(void);

		video_set_color(video_get_attr());
		return 0;
	}
#endif	/* CONFIG_AMIGAONEG3SE */

	return 0;
}
Ejemplo n.º 9
0
#else
static void env_init(void);
#endif	/* CFG_FLASH_ENV_ADDR */

#define XMK_STR(x)	#x
#define MK_STR(x)	XMK_STR(x)

static uchar default_environment[] = {
#ifdef	CONFIG_BOOTARGS
	"bootargs="	CONFIG_BOOTARGS			"\0"
#endif
#ifdef	CONFIG_BOOTCOMMAND
	"bootcmd="	CONFIG_BOOTCOMMAND		"\0"
#endif
#if (CONFIG_BOOTDELAY >= 0)
	"bootdelay="	MK_STR(CONFIG_BOOTDELAY)	"\0"
#endif
#if (CONFIG_BAUDRATE >= 0)
	"baudrate="	MK_STR(CONFIG_BAUDRATE)		"\0"
#endif
#ifdef	CONFIG_ETHADDR
	"ethaddr="	MK_STR(CONFIG_ETHADDR)		"\0"
#endif
#ifdef	CONFIG_IPADDR
	"ipaddr="	MK_STR(CONFIG_IPADDR)		"\0"
#endif
#ifdef	CONFIG_SERVERIP
	"serverip="	MK_STR(CONFIG_SERVERIP)		"\0"
#endif
	"\0"
};
Ejemplo n.º 10
0
int _do_setenv (bd_t *bd, int flag, int argc, char *argv[])
{
    int   i, len, oldval;
    uchar *env, *nxt = 0;
    uchar *name;
    
    /* need writable copy in RAM */
    if (!bd->bi_env_data)
      return 1;

    name = argv[1];
    
    /*
     * search if variable with this name already exists
     */
    oldval = -1;
    for (env = bd->bi_env_data; *env; env = nxt+1) {
	for (nxt = env; *nxt; ++nxt)
	  ;
	if ((oldval = envmatch(bd, name, (ulong)env - (ulong)bd->bi_env_data)) >= 0)
	  break;
    }
    
    /*
     * Delete any existing definition
     */
    if (oldval >= 0) {
#ifndef CONFIG_ENV_OVERWRITE
	
	/*
	 * Ethernet Address and serial# can be set only once
	 */
	if ( (strcmp (name, "serial#") == 0) ||
	    ((strcmp (name, "ethaddr") == 0)
# if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
	     && (strcmp (get_env_addr(bd, oldval),MK_STR(CONFIG_ETHADDR)) != 0)
# endif	/* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
	     ) ) {
	    printf ("Can't overwrite \"%s\"\n", name);
	    return 1;
	}
#endif
	
	/*
	 * Switch to new baudrate if new baudrate is supported
	 */
	if (strcmp(argv[1],"baudrate") == 0) {
	    int baudrate = simple_strtoul(argv[2], NULL, 10);
	    int i;
	    for (i=0; i<N_BAUDRATES; ++i) {
		if (baudrate == baudrate_table[i])
		  break;
	    }
	    if (i == N_BAUDRATES) {
		printf ("## Baudrate %d bps not supported\n",
			baudrate);
		return 1;
	    }
	    printf ("## Switch baudrate to %d bps and press ENTER ...\n",
		    baudrate);
	    udelay(50000);
	    serial_setbrg (bd, baudrate);
	    udelay(50000);
	    for (;;) {
		if (getc() == '\r')
		  break;
	    }
	    bd->bi_baudrate = baudrate;
	}
	
	if (*++nxt == '\0') {
	    if ((ulong)env > (ulong)bd->bi_env_data) {
		env--;
	    } else {
		*env = '\0';
	    }
	} else {
	    for (;;) {
		*env = *nxt++;
		if ((*env == '\0') && (*nxt == '\0'))
		  break;
		++env;
	    }
	}
	*++env = '\0';
    }
    /* Delete only ? */
    if ((argc < 3) || argv[2] == NULL) {    
	/* Update CRC */
	bd->bi_env_crc = crc32(0, bd->bi_env_data, sizeof(bd->bi_env_data));
	return 0;
    }

    /*
     * Append new definition at the end
     */
    for (env = bd->bi_env_data; *env || *(env+1); ++env)
      ;
    if ((ulong)env > (ulong)bd->bi_env_data)
      ++env;
    /*
     * Overflow when:
     * "name" + "=" + "val" +"\0\0"  > 
     *      sizeof(bd->bi_env_data) - (env-bd->bi_env_data)
     */
    len = strlen(name) + 2;
    /* add '=' for first arg, ' ' for all others */
    for (i=2; i<argc; ++i) {
	len += strlen(argv[i]) + 1;
    }
    if (len > sizeof(bd->bi_env_data)) {
	printf ("## Error: environment overflow, \"%s\" deleted\n", name);
	return 1;
    }
    while ((*env = *name++) != '\0')
      env++;
    for (i=2; i<argc; ++i) {
	char *val = argv[i];
	
	*env = (i==2) ? '=' : ' ';
	while ((*++env = *val++) != '\0')
	  ;
    }
    
    /* end is marked with double '\0' */
    *++env = '\0';
    
    /* Update CRC */
    bd->bi_env_crc = crc32(0, bd->bi_env_data, sizeof(bd->bi_env_data));

    /*
     * Some variables should be updated when the corresponding
     * entry in the enviornment is changed
     */
    
    if (strcmp(argv[1],"ethaddr") == 0) {
	char *s = argv[2];	/* always use only one arg */
	char *e;
	for (i=0; i<6; ++i) {
	    bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
	    if (s) s = (*e) ? e+1 : e;
	}
	return 0;
    }

#if (CONFIG_COMMANDS & CFG_CMD_NET)
    if (strcmp(argv[1],"ipaddr") == 0) {
	char *s = argv[2];	/* always use only one arg */
	bd->bi_ip_addr = string_to_ip(s);
	return 0;
    }
#endif

    if (strcmp(argv[1],"loadaddr") == 0) {
	load_addr = simple_strtoul(argv[2], NULL, 16);
	return 0;
    }

    if (strcmp(argv[1],"pagelength") == 0) {
	pagelength = simple_strtoul(argv[2], NULL, 10);
	return 0;
    }

#if (CONFIG_COMMANDS & CFG_CMD_NET)
    if (strcmp(argv[1],"bootfile") == 0) {
	copy_filename (BootFile, argv[2], sizeof(BootFile));
	return 0;
    }
#endif	/* CFG_CMD_NET */

#ifdef CONFIG_KEYBOARD
    if (strcmp(argv[1],"keymap") == 0) {
	kbd_mapping (argv[2]);
	return 0;
    }
#endif	/* CONFIG_KEYBOARD */

#ifdef CONFIG_ADJUST_LCD
    if (strcmp(argv[1],"contrast") == 0) {
	lcd_contrast(simple_strtoul(argv[2], NULL, 10));
	return 0;
	}
    if (strcmp(argv[1],"brightness") == 0) {
	lcd_brightness(simple_strtoul(argv[2], NULL, 10));
	return 0;
	}
#endif	/* CONFIG_ADJUST_LCD */

    return 0;
}
Ejemplo n.º 11
0
/*
 * Prints available information about the board
 */
void print_board_info(void)
{
	u32 ahb_clk, cpu_clk, ddr_clk, spi_clk, ref_clk;
#if defined(CONFIG_PCI)
	u32 did, vid;
#endif
	u32 bank;
	bd_t *bd = gd->bd;
	char buffer[24];

	/* Show warning if last reboot was caused by SOC watchdog */
	if (last_reset_wdt())
		printf_wrn("reset caused by watchdog!\n\n");

	/* Board name */
	printf("%" ALIGN_SIZE "s %s\n",
	       "BOARD:", MK_STR(CONFIG_BOARD_CUSTOM_STRING));

	/* SOC name, version and revision */
	qca_soc_name_rev(buffer);
	printf("%" ALIGN_SIZE "s %s\n", "SOC:", buffer);

	/* MIPS CPU type */
	cpu_name(buffer);
	printf("%" ALIGN_SIZE "s %s\n", "CPU:", buffer);

	/* RAM size and type */
	printf("%" ALIGN_SIZE "s ", "RAM:");
	print_size(bd->bi_memsize, "");

	switch (qca_dram_type()) {
	case RAM_MEMORY_TYPE_SDR:
		puts(" SDR ");
		break;
	case RAM_MEMORY_TYPE_DDR1:
		puts(" DDR1 ");
		break;
	case RAM_MEMORY_TYPE_DDR2:
		puts(" DDR2 ");
		break;
	default:
		break;
	}

	/* DDR interface width */
	printf("%d-bit ", qca_dram_ddr_width());

	/* tCL-tRCD-tRP-tRAS latency */
	printf("CL%d-%d-%d-%d\n", qca_dram_cas_lat(),
				  qca_dram_trcd_lat(),
				  qca_dram_trp_lat(),
				  qca_dram_tras_lat());

	/* SPI NOR FLASH sizes and types */
	printf("%" ALIGN_SIZE "s ", "FLASH:");

	for (bank = 0; bank < CFG_MAX_FLASH_BANKS; bank++) {
		if (flash_info[bank].size == 0)
			continue;

		if (bank > 0)
			printf("%" ALIGN_SIZE "s ", " ");

		print_size(flash_info[bank].size, "");

		if (flash_info[bank].manuf_name != NULL)
			printf(" %s", flash_info[bank].manuf_name);

		if (flash_info[bank].model_name != NULL)
			printf(" %s", flash_info[bank].model_name);

		puts("\n");
	}

	/* PCIE device/s info */
#if defined(CONFIG_PCI)
	printf("%" ALIGN_SIZE "s ", "PCIe:");

	#if (SOC_TYPE & QCA_AR934X_SOC) |\
		(SOC_TYPE & QCA_QCA955X_SOC)
	if (!qca_pcie0_in_ep_mode()) {
		if (qca_pcie_dev_info(0, &vid, &did))
			printf("%04X:%04X", vid, did);
		else
			puts("no device");
	} else {
		puts("EP mode");
	}
	#elif (SOC_TYPE & QCA_QCA953X_SOC)
	if (qca_pcie_dev_info(0, &vid, &did))
		printf("%04X:%04X", vid, did);
	else
		puts("no device");
	#endif

	#if (SOC_TYPE & QCA_QCA956X_SOC)
	if (qca_pcie_dev_info(1, &vid, &did))
		printf("%04X:%04X", vid, did);
	else
		puts("no device");
	#elif (SOC_TYPE & QCA_QCA955X_SOC)
	if (qca_pcie_dev_info(1, &vid, &did))
		printf(", %04X:%04X", vid, did);
	else
		puts(", no device");
	#endif

	puts("\n");
#endif

	/* MAC address */
	printf("%" ALIGN_SIZE "s %02X:%02X:%02X:%02X:%02X:%02X", "MAC:",
		bd->bi_enetaddr[0],bd->bi_enetaddr[1], bd->bi_enetaddr[2],
		bd->bi_enetaddr[3], bd->bi_enetaddr[4], bd->bi_enetaddr[5]);

	if (mac_is_not_valid)
		puts(" (fixed)\n");
	else
		puts("\n");

	/* System clocks */
	printf("%" ALIGN_SIZE "s CPU/RAM/AHB/SPI/REF\n", "CLOCKS:");

	qca_sys_clocks(&cpu_clk, &ddr_clk, &ahb_clk, &spi_clk, &ref_clk);
	cpu_clk = cpu_clk / 1000000;
	ddr_clk = ddr_clk / 1000000;
	ahb_clk = ahb_clk / 1000000;
	spi_clk = spi_clk / 1000000;
	ref_clk = ref_clk / 1000000;

	printf("%" ALIGN_SIZE "s %3d/%3d/%3d/%3d/%3d MHz\n",
		" ", cpu_clk, ddr_clk, ahb_clk, spi_clk, ref_clk);

	puts("\n");
}
Ejemplo n.º 12
0
/*
 * @implemented
 */
FILE *_tpopen (const _TCHAR *cm, const _TCHAR *md) /* program name, pipe mode */
{
    _TCHAR *szCmdLine=NULL;
    _TCHAR *szComSpec=NULL;
    _TCHAR *s;
    FILE *ret;
    HANDLE hReadPipe, hWritePipe;
    BOOL result;
    STARTUPINFO StartupInfo;
    PROCESS_INFORMATION ProcessInformation;
    SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
    struct popen_handle *container;
    DWORD i;

    TRACE(MK_STR(_tpopen)"('%"sT"', '%"sT"')\n", cm, md);

    if (cm == NULL)
        return NULL;

    szComSpec = _tgetenv(_T("COMSPEC"));
    if (szComSpec == NULL)
    {
        szComSpec = _T("cmd.exe");
    }

    s = max(_tcsrchr(szComSpec, '\\'), _tcsrchr(szComSpec, '/'));
    if (s == NULL)
        s = szComSpec;
    else
        s++;

    szCmdLine = malloc((_tcslen(s) + 4 + _tcslen(cm) + 1) * sizeof(_TCHAR));
    if (szCmdLine == NULL)
    {
        return NULL;
    }

    _tcscpy(szCmdLine, s);
    s = _tcsrchr(szCmdLine, '.');
    if (s)
        *s = 0;
    _tcscat(szCmdLine, _T(" /C "));
    _tcscat(szCmdLine, cm);

    if ( !CreatePipe(&hReadPipe,&hWritePipe,&sa,1024))
    {
        free (szCmdLine);
        return NULL;
    }

    memset(&ProcessInformation, 0, sizeof(ProcessInformation));
    memset(&StartupInfo, 0, sizeof(STARTUPINFO));
    StartupInfo.cb = sizeof(STARTUPINFO);

    if (*md == 'r' ) {
        StartupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
        StartupInfo.hStdOutput = hWritePipe;
        StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
    }
    else if ( *md == 'w' ) {
        StartupInfo.hStdInput = hReadPipe;
        StartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
        StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
    }

    if (StartupInfo.dwFlags & STARTF_USESTDHANDLES)
        StartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);

    result = CreateProcess(szComSpec,
        szCmdLine,
        NULL,
        NULL,
        TRUE,
        0,
        NULL,
        NULL,
        &StartupInfo,
        &ProcessInformation);
    free (szCmdLine);

    if (result == FALSE)
    {
        CloseHandle(hReadPipe);
        CloseHandle(hWritePipe);
        return NULL;
    }

    CloseHandle(ProcessInformation.hThread);

    _mlock(_POPEN_LOCK);
    for(i=0; i<popen_handles_size; i++)
    {
        if (!popen_handles[i].f)
            break;
    }
    if (i==popen_handles_size)
    {
        i = (popen_handles_size ? popen_handles_size*2 : 8);
        container = realloc(popen_handles, i*sizeof(*container));
        if (!container) goto error;

        popen_handles = container;
        container = popen_handles+popen_handles_size;
        memset(container, 0, (i-popen_handles_size)*sizeof(*container));
        popen_handles_size = i;
    }
    else container = popen_handles+i;

    if ( *md == 'r' )
    {
        ret = _tfdopen(msvcrt_alloc_fd(hReadPipe,  split_oflags(_fmode)) , _T("r"));
        CloseHandle(hWritePipe);
    }
    else
    {
        ret = _tfdopen( msvcrt_alloc_fd(hWritePipe, split_oflags(_fmode)) , _T("w"));
        CloseHandle(hReadPipe);
    }

    container->f = ret;
    container->proc = ProcessInformation.hProcess;
    _munlock(_POPEN_LOCK);

    return ret;

error:
    _munlock(_POPEN_LOCK);
    if (ProcessInformation.hProcess != 0)
        CloseHandle(ProcessInformation.hProcess);
    return NULL;
}
Ejemplo n.º 13
0
/*
 * @implemented
 */
FILE *_tpopen (const _TCHAR *cm, const _TCHAR *md) /* program name, pipe mode */
{
    _TCHAR *szCmdLine=NULL;
    _TCHAR *szComSpec=NULL;
    _TCHAR *s;
    FILE *pf;
    HANDLE hReadPipe, hWritePipe;
    BOOL result;
    STARTUPINFO StartupInfo;
    PROCESS_INFORMATION ProcessInformation;
    SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};

    TRACE(MK_STR(_tpopen)"('%"sT"', '%"sT"')\n", cm, md);

    if (cm == NULL)
        return( NULL );

    szComSpec = _tgetenv(_T("COMSPEC"));
    if (szComSpec == NULL)
    {
        szComSpec = _T("cmd.exe");
    }

    s = max(_tcsrchr(szComSpec, '\\'), _tcsrchr(szComSpec, '/'));
    if (s == NULL)
        s = szComSpec;
    else
        s++;

    szCmdLine = malloc((_tcslen(s) + 4 + _tcslen(cm) + 1) * sizeof(_TCHAR));
    if (szCmdLine == NULL)
    {
        return NULL;
    }

    _tcscpy(szCmdLine, s);
    s = _tcsrchr(szCmdLine, '.');
    if (s)
        *s = 0;
    _tcscat(szCmdLine, _T(" /C "));
    _tcscat(szCmdLine, cm);

    if ( !CreatePipe(&hReadPipe,&hWritePipe,&sa,1024))
    {
        free (szCmdLine);
        return NULL;
    }

    memset(&StartupInfo, 0, sizeof(STARTUPINFO));
    StartupInfo.cb = sizeof(STARTUPINFO);

    if (*md == 'r' ) {
        StartupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
        StartupInfo.hStdOutput = hWritePipe;
        StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
    }
    else if ( *md == 'w' ) {
        StartupInfo.hStdInput = hReadPipe;
        StartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
        StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
    }

    if (StartupInfo.dwFlags & STARTF_USESTDHANDLES)
        StartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);

    result = CreateProcess(szComSpec,
        szCmdLine,
        NULL,
        NULL,
        TRUE,
        0,
        NULL,
        NULL,
        &StartupInfo,
        &ProcessInformation);
    free (szCmdLine);

    if (result == FALSE)
    {
        CloseHandle(hReadPipe);
        CloseHandle(hWritePipe);
        return NULL;
    }

    CloseHandle(ProcessInformation.hThread);
    CloseHandle(ProcessInformation.hProcess);

    if ( *md == 'r' )
    {
        pf = _tfdopen(msvcrt_alloc_fd(hReadPipe,  split_oflags(_fmode)) , _T("r"));
        CloseHandle(hWritePipe);
    }
    else
    {
        pf = _tfdopen( msvcrt_alloc_fd(hWritePipe, split_oflags(_fmode)) , _T("w"));
        CloseHandle(hReadPipe);
    }

    return( pf );
}