Exemple #1
0
int
print_str(char *s, unsigned int len)
{
//	if (!COS_IN_ARGREG(s) || !COS_IN_ARGREG(s + len)) {
	if (1) {
		static char foo[MAX_LEN];
		snprintf(foo, MAX_LEN, "print argument out of bounds: %x", (unsigned int)s);
		cos_print(foo, 0);
		return -1;
	}
	s[len+1] = '\0';

#ifdef COS_PRINT_SHELL
	assert(!print_init()); 

	if (sharedbuf.b) {
		int amnt;

		amnt = cringbuf_produce(&sharedbuf, s, len);
		assert(amnt >= 0);
		cos_trans_cntl(COS_TRANS_TRIGGER, COS_TRANS_SERVICE_PRINT, 0, 0);
	}
#endif

#ifdef COS_PRINT_DMESG
	cos_print(buf_ptr, len);
#endif

	return 0;
}
Exemple #2
0
static inline int send_str(char *s, unsigned int len)
{
	int param[PARAMS_PER_INV], pending;
	unsigned int i = 0, j;
	char *p; 

	p = (char *)param; 

	for (i = 0; i <= len; i += CHAR_PER_INV) {
		for (j = 0; j < CHAR_PER_INV; j++) {
			if (s[i + j] == '\0') { 
				p[j] = '\0'; 
                                /* if we reach the end of the string,
				 * then pedding the rest of the
				 * parameters with \0 */
				while (++j < CHAR_PER_INV) { p[j] = '\0'; }
				break; 
			} else {
				p[j] = s[i + j];
			}
		}
		pending = print_str(param[0], param[1], param[2], param[3]);
		if(p[j-1] =='\0' && pending) {cos_print("BUG1", 4); while (1);}
		if(p[j-1] != '\0' && !pending) {cos_print("BUG2", 4); while (1);}
	}
	return 0;
}
Exemple #3
0
int __attribute__((format(printf,1,2))) printc(char *fmt, ...)
{
	char s[MAX_LEN];
	va_list arg_ptr;
	unsigned int ret;
	int len = MAX_LEN;

	/* Stable approach below. */

#if (NUM_CPU > 1)
	va_start(arg_ptr, fmt);
	ret = vsnprintf(s, len, fmt, arg_ptr);
	va_end(arg_ptr);
	cos_print(s, ret);
	
	return 0;
#endif

	va_start(arg_ptr, fmt);
	ret = vsnprintf(s, len, fmt, arg_ptr);
	va_end(arg_ptr);

	if (unlikely(ret == 0)) goto done;

	send_str(s, ret);
	
done:
	return ret;
}
int print_str(char *s, unsigned int len)
{
//	char *ptr;
//	int l = len;

    if (!COS_IN_ARGREG(s) || !COS_IN_ARGREG(s + len)) {
        snprintf(foo, MAX_LEN, "print argument out of bounds: %x", (unsigned int)s);
        cos_print(foo, 0);
        return -1;
    }
    s[len+1] = '\0';

    cos_print(s, len);

    return 0;
}
Exemple #5
0
printc(char *fmt, ...)
{
	char s[ARG_STRLEN];
	va_list arg_ptr;
	int ret;

	va_start(arg_ptr, fmt);
	ret = vsnprintf(s, ARG_STRLEN-1, fmt, arg_ptr);
	va_end(arg_ptr);
	s[ARG_STRLEN-1] = '\0';
#if (NUM_CPU > 1)
	cos_print(s, ret);
#else
	prints(s);
#endif

	return ret;
}