Пример #1
0
void s_printf(char *format,...)
{
 va_list	opt;

 char out[2]=" ";

 int val;

 char *s;

 va_start(opt, format);

 while(format[0])
	{
	if(format[0]!='%') {out[0]=*format++;os_puts(out);}
	else
		{
		format++;
		switch(format[0])
			{
			case 'd':
			case 'i':
				val=va_arg(opt,int);
				int_char(val);
				
				os_puts(mem_cad);
				
				break;

			case 'u':
				val=va_arg(opt, unsigned);
				uint_char(val);
				
				os_puts(mem_cad);
				
				break;

			case 'x':
				val=va_arg(opt,int);
				hex_char((u32) val);
				os_puts(mem_cad);
				
				break;

			case 's':
				s=va_arg(opt,char *);
				os_puts(s);
				break;

			}
		 format++;
		}
	
	}
   
	va_end(opt);

	
}
Пример #2
0
void puts(const char *s)
{
#ifdef CONFIG_SANDBOX
	if (!gd) {
		os_puts(s);
		return;
	}
#endif

#ifdef CONFIG_SILENT_CONSOLE
	if (gd->flags & GD_FLG_SILENT)
		return;
#endif

#ifdef CONFIG_DISABLE_CONSOLE
	if (gd->flags & GD_FLG_DISABLE_CONSOLE)
		return;
#endif

#ifdef CONFIG_MV_LOG_BASE
	/* save the bootloader log to mmplog buffer which shared with kernel */
	mmp_log_buf_write(s);
#endif
	if (!gd->have_console)
		return pre_console_puts(s);

	if (gd->flags & GD_FLG_DEVINIT) {
		/* Send to the standard output */
		fputs(stdout, s);
	} else {
		/* Send directly to the handler */
		serial_puts(s);
	}
}
Пример #3
0
/*
 * 这个函数很重要
 */
void puts(const char *s)
{
#ifdef CONFIG_SANDBOX
	if (!gd) {
		os_puts(s);
		return;
	}
#endif

#ifdef CONFIG_SILENT_CONSOLE
	if (gd->flags & GD_FLG_SILENT)
		return;
#endif

#ifdef CONFIG_DISABLE_CONSOLE
	if (gd->flags & GD_FLG_DISABLE_CONSOLE)
		return;
#endif

    /* 如果终端初始化不ok的话,调用pre_console_puts */
	if (!gd->have_console)
		return pre_console_puts(s);

    /* 如果标准输入输出初始化ok,则调用fputs,否则使用serial_puts, 一般情况下, fputs也是使用的串口*/
	if (gd->flags & GD_FLG_DEVINIT) {
		/* Send to the standard output */
		fputs(stdout, s);
	} else {
		/* Send directly to the handler */
		serial_puts(s);
	}
}
Пример #4
0
void puts(const char *s)
{
#ifdef CONFIG_SANDBOX
	if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
		os_puts(s);
		return;
	}
#endif

#ifdef CONFIG_SILENT_CONSOLE
	if (gd->flags & GD_FLG_SILENT)
		return;
#endif

#ifdef CONFIG_DISABLE_CONSOLE
	if (gd->flags & GD_FLG_DISABLE_CONSOLE)
		return;
#endif

	if (!gd->have_console)
		return pre_console_puts(s);

	if (gd->flags & GD_FLG_DEVINIT) {
		/* Send to the standard output */
		fputs(stdout, s);
	} else {
		/* Send directly to the handler */
		serial_puts(s);
	}
}
Пример #5
0
void *USB_Alloc(int size)
{
  void * ret = 0;
  ret= os_heap_alloc_aligned(heap, size, 32);
 // ret= os_heap_alloc(heap, size);
  if(ret==0)
	{
    os_puts("USB Alloc: not enough memory!\n");
     while(1) {swi_mload_led_on();ehci_msleep(200);swi_mload_led_off();ehci_msleep(200);}
	}
  return ret;
}