Esempio n. 1
0
/*********************************************************************
*
*       _ShowStamp
*
*  Function description
*
*/
static void _ShowStamp(void) {
#if SHOW_TIME
  {
    I32 Time;
    char ac[20];
    char * sBuffer = &ac[0];
    Time = OS_GetTime32();
    sBuffer = _WriteUnsigned(sBuffer, Time / 1000, 0);
    *sBuffer++ = ':';
    sBuffer = _WriteUnsigned(sBuffer, Time % 1000, 3);
    *sBuffer++ = ' ';
    *sBuffer++ = 0;
    _puts(ac);
  }
#endif

#if SHOW_TASK
  {
    const char * s;
    s = OS_GetTaskName(NULL);
    if (s) {
      _puts(s);
      _puts(" - ");
    }
  }
#endif
}
Esempio n. 2
0
main() {

	reg char	*sp;
	char		*getenv();
	int		_putchar(), die();

	srand(getpid());		/* initialize random sequence */

	if (isatty(0)) {
	       gettmode();
	       if (sp=getenv("TERM"))
		       setterm(sp);
		signal(SIGINT, die);
	}
	else {
		printf("Need a terminal on %d\n", _tty_ch);
		exit(1);
	}
	_puts(TI);
	_puts(VS);

	noecho();
	nonl();
	tputs(CL, NLINES, _putchar);
	for (;;) {
		makeboard();		/* make the board setup */
		puton('*');		/* put on '*'s */
		puton(' ');		/* cover up with ' 's */
	}
}
Esempio n. 3
0
/*
 * tstp:
 *      Handle stop and start signals
 */
static void
tstp(int dummy)
{
	int     y, x;

	y = cur_row;
	x = cur_col;
	mvcur(cur_row, cur_col, HEIGHT, 0);
	cur_row = HEIGHT;
	cur_col = 0;
	_puts(VE);
	_puts(TE);
	fflush(stdout);
	tcsetattr(0, TCSADRAIN, &__orig_termios);
	kill(getpid(), SIGSTOP);
	signal(SIGTSTP, tstp);
	tcsetattr(0, TCSADRAIN, &saved_tty);
	_puts(TI);
	_puts(VS);
	cur_row = y;
	cur_col = x;
	_puts(tgoto(CM, cur_row, cur_col));
	display_redraw_screen();
	fflush(stdout);
}
Esempio n. 4
0
/*
 * display_end:
 *	close the display
 */
void
display_end(void)
{
	tcsetattr(0, TCSADRAIN, &__orig_termios);
	_puts(VE);
	_puts(TE);
}
Esempio n. 5
0
int hl(char *str) {
    _puts("Hello : ");
    _puts(str);
    _puts("\n");
    
    return (0);
}
Esempio n. 6
0
/*********************************************************************
*
*       IP_Log
*
*  Function description
*    This function is called by the stack in debug builds with log output.
*    In a release build, this function may not be linked in.
*
*  Notes
*    (1)  Interrupts and task switches
*         printf() has a reentrance problem on  alot of systems if interrupts are not disabled.
*                  which would scramble strings if printf() called from an ISR interrupts an other printf.
*         In order to avoid this problem, interrupts are disabled.
*
*/
void IP_Log(const char * s) {

  IP_OS_DisableInterrupt();
  _ShowStamp();
  _puts(s);
  _puts("\n");
  IP_OS_EnableInterrupt();
}
Esempio n. 7
0
/*********************************************************************
*
*       IP_Warn
*
*  Function description
*    This function is called by the stack in debug builds with log output.
*    In a release build, this function may not be linked in.
*
*  Notes
*    (1)  Interrupts and task switches
*         See IP_Log()
*/
void IP_Warn(const char * s) {
  IP_OS_DisableInterrupt();
  _ShowStamp();
  _puts("*** Warning *** ");
  _puts(s);
  _puts("\n");
  IP_OS_EnableInterrupt();
}
Esempio n. 8
0
/*********************************************************************
*
*       IP_Panic
*
*  Function description
*    This function is called if the stack encounters a critical situation.
*    In a release build, this function may not be linked in.
*
*/
void IP_Panic(const char * s) {
  (void)s;
  IP_OS_DisableInterrupt();
#if IP_DEBUG > 1
  _puts("*** Fatal error, System halted: ");
  _puts(s);
  _puts("\n");
#endif
  while (1);
}
Esempio n. 9
0
/*
 * This routine initializes the current and standard screen.
 */
WINDOW *
initscr()
{
	char	*sp;
	int 	nfd;

# ifdef DEBUG
	fprintf(outf, "INITSCR()\n");
# endif
	if (My_term)
		setterm(Def_term);
	else {
	        nfd = getdtablesize();
		for (_tty_ch = 0; _tty_ch < nfd; _tty_ch++)
			if (isatty(_tty_ch))
				break;
		gettmode();
		sp = getenv("TERM");
		if (! sp)
			sp = Def_term;
		setterm(sp);
# ifdef DEBUG
		fprintf(outf, "INITSCR: term = %s\n", sp);
# endif
	}
	_puts(TI);
	_puts(VS);
# ifdef SIGTSTP
	signal(SIGTSTP, (sig_t)tstp);
# endif
	if (curscr != NULL) {
# ifdef DEBUG
		fprintf(outf, "INITSCR: curscr = 0%o\n", curscr);
# endif
		delwin(curscr);
	}
# ifdef DEBUG
	fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS);
# endif
	if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR)
		return ERR;
	clearok(curscr, TRUE);
	curscr->_flags &= ~_FULLLINE;
	if (stdscr != NULL) {
# ifdef DEBUG
		fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr);
# endif
		delwin(stdscr);
	}
	stdscr = newwin(LINES, COLS, 0, 0);
	return stdscr;
}
Esempio n. 10
0
endwin()
{
	resetty();
	_puts(VE);
	_puts(TE);
	if (curscr) {
		if (curscr->_flags & _STANDOUT) {
			_puts(SE);
			curscr->_flags &= ~_STANDOUT;
		}
		_endwin = TRUE;
	}
}
Esempio n. 11
0
void qputsln(uart_handle uart, char *s){
	/* put string */
	uart_TXLED_on(uart);
	_puts(uart, s);
	uart__putchar(uart, '\n');
	uart_TXLED_off(uart);
}
Esempio n. 12
0
void fun_4010a8(int32_t ecx) {
    int32_t ecx2;
    int1_t zf3;
    unsigned char* eax4;
    signed char* eax5;
    signed char al6;
    uint1_t cf7;
    struct s3* eax8;
    signed char al9;
    unsigned char* eax10;
    signed char tmp8_11;
    unsigned char tmp8_12;
    uint1_t cf13;
    struct s4* ebp14;
    unsigned char* eax15;
    struct s5* eax16;
    unsigned char tmp8_17;
    uint1_t cf18;

    ecx2 = ecx - 1;
    if (reinterpret_cast<uint1_t>(!!ecx2) & reinterpret_cast<uint1_t>(!zf3)) {
        __asm__("sti ");
        *eax4 = reinterpret_cast<unsigned char>(reinterpret_cast<signed char>(*eax5 + al6) + cf7);
        *reinterpret_cast<signed char*>(&eax8) = reinterpret_cast<signed char>(al9 + 17);
        eax10 = &eax8->f1;
        tmp8_11 = reinterpret_cast<signed char>(gc7004011 + *reinterpret_cast<signed char*>(&ecx2));
        gc7004011 = tmp8_11;
        tmp8_12 = reinterpret_cast<unsigned char>(*reinterpret_cast<unsigned char*>(&eax10) + 36);
        cf13 = reinterpret_cast<uint1_t>(tmp8_12 < *reinterpret_cast<unsigned char*>(&eax10));
        *reinterpret_cast<unsigned char*>(&eax10) = tmp8_12;
        *eax10 = reinterpret_cast<unsigned char>(reinterpret_cast<unsigned char>(*eax10 + *reinterpret_cast<unsigned char*>(&eax10)) + cf13);
        _puts(eax10, __return_address());
        goto ebp14->f4;
    } else {
Esempio n. 13
0
/*
 *	This routine initializes the current and standard screen.
 *
 * 3/5/81 (Berkeley) @(#)initscr.c	1.2
 */
WINDOW *
initscr() {

	reg char	*sp;
	int		tstp();

# ifdef DEBUG
	fprintf(outf, "INITSCR()\n");
# endif
	if (!My_term && isatty(2)) {
		_tty_ch = 2;
		gettmode();
		if ((sp = getenv("TERM")) == NULL)
			sp = Def_term;
		setterm(sp);
# ifdef DEBUG
		fprintf(outf, "INITSCR: term = %s\n", sp);
# endif
	}
	else
		setterm(Def_term);
	_puts(TI);
	_puts(VS);
# ifdef SIGTSTP
	signal(SIGTSTP, tstp);
# endif
	if (curscr != NULL) {
# ifdef DEBUG
		fprintf(outf, "INITSCR: curscr = 0%o\n", curscr);
# endif
		delwin(curscr);
	}
# ifdef DEBUG
	fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS);
# endif
	if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR)
		return ERR;
	curscr->_clear = TRUE;
	if (stdscr != NULL) {
# ifdef DEBUG
		fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr);
# endif
		delwin(stdscr);
	}
	stdscr = newwin(LINES, COLS, 0, 0);
	return stdscr;
}
Esempio n. 14
0
int main() {
    uint16_t c;

    clrscr();

    _puts("bcc bios keyboard test\r\n");

    for(;;) {
        c = _kbhit();
        if(c != 0) {
            _puts("keystroke! _kbhit() returned 0x");
            put_hex16(c);
            _puts("\r\n");
        }
    }
    
}
Esempio n. 15
0
static void float_print(long double f1,long double f2,int multi,int *cntr_val)
{
	int i=1,temp,cntr=0,i1,neg_flag=0;
	char s1[10];

	 if(f1<0)
	 {
		 f1=f1*-1;
		 neg_flag=1;
		 f2=f1;
	 }
	 temp=(int)f1;

	 f1=f1-temp;
     f1=f1*multi;

     temp=f1;

     if(temp==0)
    	s1[cntr++]='0';
     while(temp>0)
     {
         i1=temp%10;
         temp=temp/10;
         s1[cntr]=i1+0x30;
         cntr++;
     }

     while(right_val<9&&(right_val -cntr)>0)
	   s1[cntr++]='0';
	   s1[cntr]='.';
	   cntr++;

	   temp=(int)f2;
	 if(temp==0)
		s1[cntr++]='0';
	 while(temp>0)
	 {
	      i1=temp%10;
	      temp=temp/10;
	      s1[cntr]=i1+0x30;
	      cntr++;
	 }

	 while(left_val-- -cntr>0)
		{
			_putchar(' ');
			(*cntr_val)++;
		}
			if(neg_flag==1)
	    s1[cntr++]='-';
	    s1[cntr]='\0';
	    cntr--;
	 	strrev(s1);
    	_puts(s1);
		(*cntr_val)+=strlen(s1);
   		neg_flag=0;
}
Esempio n. 16
0
static enum result def_reduce(struct printer *p, struct status *stat)
{
	const char *sym = _ul_reduce(stat->unit);
	if (!sym)
		return RES_FAIL;

	if (p->prefix)
		CHECK_R(_puts(stat, p->prefix));

	bool first = true;
	CHECK_R(p->fac(stat, stat->unit->factor, &first));
	CHECK_R(p->sym(stat, sym, 1, &first));

	if (p->postfix)
		CHECK_R(_puts(stat, p->postfix));

	return RES_OK;
}
Esempio n. 17
0
int puts(const char *s)
{
    void *lib = dlopen("/lib/x86_64-linux-gnu/libc.so.6", RTLD_LAZY);
    int (*_puts)(const char*);

    _puts = (int(*)()) dlsym(lib, "puts");
    dlclose(lib);
    return _puts(s);
}
Esempio n. 18
0
static void fiq_ack(struct platform_device *pdev, unsigned int fiq)
{
	char buffer[64];
	sprintf(buffer, "current cpu: %d (online: %d%d%d%d)",
		    smp_processor_id(),
		    cpu_online(0), cpu_online(1), cpu_online(2), cpu_online(3));
	_puts(buffer);
	*dump_buffer_head = DUMP_BUFFER_MAGIC;
	while (1); /* no return */
}
Esempio n. 19
0
/*
 * display_open:
 *	open the display
 */
void
display_open(void)
{
	char *term;

	if (!isatty(0) || (term = getenv("TERM")) == NULL)
		errx(1, "no terminal type");

	gettmode();
	setterm(term);
	noecho();
	cbreak();
	tcgetattr(0, &saved_tty);
	_puts(TI);
	_puts(VS);
#ifdef SIGTSTP
	signal(SIGTSTP, tstp);
#endif
}
Esempio n. 20
0
static enum result def_normal(struct printer *p, struct status *stat)
{
	if (p->prefix)
		CHECK_R(_puts(stat, p->prefix));

	bool first = true;

	CHECK_R(p->fac(stat, stat->unit->factor, &first));

	for (int i=0; i < NUM_BASE_UNITS; ++i) {
		if (stat->unit->exps[i] != 0)
			CHECK_R(p->sym(stat, _ul_symbols[i], stat->unit->exps[i], &first));
	}

	if (p->postfix)
		CHECK_R(_puts(stat, p->postfix));

	return RES_OK;
}
Esempio n. 21
0
File: uio.c Progetto: bajdcc/MiniOS
void fprintf(int fd, char *fmt, ...){
    char buf[256];
    va_list args;

    memset(buf, 0, sizeof(buf));
    va_start(args, fmt);
    vsprint(buf, fmt, args);
    va_end(args);
    
    _puts(fd, buf);
}
Esempio n. 22
0
File: uart.c Progetto: kcoewoys/work
int _printf(const char *fmt, ...)
{
	va_list ap;

	int n;
	char buf[64];
	char *s;
	
	va_start(ap, fmt);

	while(*fmt)
	{
		if(*fmt == '%')
		{
			fmt++;
			switch(*fmt)
			{
				case 'd':
					n = va_arg(ap, int);
					itoa(n, buf);
					_puts(buf);
					break;
				case 'x':
					n = va_arg(ap, int);
					xtoa(n, buf);
					_puts(buf);
					break;
				case 'c':
					n = va_arg(ap, int);
					_putc(n);
					break;
				case 's':
					s = va_arg(ap, char *);
					_puts(s);
					break;
				default:
					break;
			}	
		}
		else
		{
Esempio n. 23
0
int _timer_stop( unsigned int channel ) 
{
#if NB_TIM_CHANNELS

    if ( channel >= NB_TIM_CHANNELS )
    {
        _puts("[GIET ERROR] in _timer_stop()\n");
        return -1;
    }

    _timer_set_register( channel, TIMER_MODE  , 0 );

    return 0;

#else

    _puts("[GIET ERROR] _timer_stop() should not be called when NB_TIM_CHANNELS is 0\n");
    return -1;

#endif
}
Esempio n. 24
0
static bool p_latex_sym(struct status *stat, const char *sym, int exp, bool *first)
{
	if (!*first)
		CHECK(_putc(stat, ' '));

	CHECK(_puts(stat, "\\text{"));
	if (!*first)
		CHECK(_putc(stat, ' '));

	CHECK(_puts(stat, sym));
	CHECK(_puts(stat, "}"));
	if (exp != 1) {
		CHECK(_putc(stat, '^'));
		CHECK(_putc(stat, '{'));
		CHECK(_putd(stat, exp));
		CHECK(_putc(stat, '}'));
	}
	if (first)
		*first = false;
	return true;
}
Esempio n. 25
0
int _timer_reset_cpt( unsigned int channel ) 
{
#if NB_TIM_CHANNELS

    if ( channel >= NB_TIM_CHANNELS )
    {
        _puts("[GIET ERROR in _timer_reset_cpt()\n");
        return -1;
    }

    unsigned int period = _timer_get_register( channel, TIMER_PERIOD );
    _timer_set_register( channel, TIMER_PERIOD, period );

    return 0;

#else

    _puts("[GIET ERROR] _timer_reset_cpt should not be called when NB_TIM_CHANNELS is 0\n");
    return -1;

#endif
}
Esempio n. 26
0
void msg_init(void)
{
    // init the message list
    for (uint32_t i = 0; i < NUMB_PROC; i++) {
        msg_list[i].nbr_in_que = 0;
        msg_list[i].next_msg = NULL;
        msg_list[i].last_msg = NULL;
    }

    // init the semaphore protecting the message list
    semaphore_init(&g_mutex_msg_list, MUTEX_INIT_VALUE);
    _puts("IPC by messages configured...\n\n", 100);
    return;
}
Esempio n. 27
0
void _timer_isr( unsigned int irq_type,   // HWI / PTI
                 unsigned int irq_id,     // index returned by XCU
                 unsigned int channel )   // user timer index
{
#if NB_TIM_CHANNELS

    // acknowledge IRQ
    _timer_set_register( channel, TIMER_RESETIRQ, 0 ); 

    // register the event
    _user_timer_event[channel] = 1;

    // display a message on TTY 0 
    _puts("\n[GIET WARNING] User Timer IRQ at cycle %d for channel = %d\n",
            _get_proctime(), channel );

#else

    _puts("[GIET ERROR] _timer_isr() should not be called when NB_TIM_CHANNELS == 0\n");
    _exit();

#endif
}
Esempio n. 28
0
int _timer_start( unsigned int channel, 
                  unsigned int period ) 
{
#if NB_TIM_CHANNELS

    if ( channel >= NB_TIM_CHANNELS )
    {
        _puts("[GIET ERROR] in _timer_start()\n");
        return -1;
    }

    _timer_set_register( channel, TIMER_PERIOD, period );
    _timer_set_register( channel, TIMER_MODE  , 0x3 );
    
    return 0;

#else

    _puts("[GIET ERROR] _timer_start() should not be called when NB_TIM_CHANNELS is 0\n");
    return -1;

#endif
}
Esempio n. 29
0
File: hax.c Progetto: mkoval/hax
void loop_1(void)
{
	Getdata(&rxdata);

#ifdef DEBUG
	{
		uint8_t i;
		printf((char*)
			   "rxdata:\n"
			   "  packet_num rcmode rcstatusflag: %i %i %i\n"
			   , rxdata.packet_num
			   , rxdata.rcmode.allbits
			   , rxdata.rcstatusflag.allbits);

		_puts( "  reserved_1[0..2] : ");
		for(i = 0; i < 3; i++) {
			printf((char*)"%i, ",rxdata.reserved_1[i]);
		}

		_puts( "; reserved_2[0..8] : ");
		for(i = 0; i < 8; i++) {
			printf((char*)"%i, ",rxdata.reserved_2[i]);
		}

		printf((char*) "\n"
			   "  master_version : %i\n", rxdata.master_version);

		printf((char*)
			    "statusflag: 0x%02x\n"
				"  ",statusflag.a);
		for(i = 0; i < 8; i++) {
			printf((char*)"%i, ", (statusflag.a & (1<<i) ) >> i);
		}
		_putc('\n');
	}
#endif
}
Esempio n. 30
0
static enum result p_lfrac(struct printer *p, struct status *stat)
{
	if (p->prefix)
		CHECK_R(_puts(stat, p->prefix));

	bool first = true;

	CHECK_R(_puts(stat, "\\frac{"));
	if (_fabsn(stat->unit->factor) >= 1)
		CHECK_R(p->fac(stat, stat->unit->factor, &first));

	for (int i=0; i < NUM_BASE_UNITS; ++i) {
		if (stat->unit->exps[i] > 0)
			CHECK_R(p->sym(stat, _ul_symbols[i], stat->unit->exps[i], &first));
	}
	if (first)
		CHECK_R(p->fac(stat, 1.0, &first));

	CHECK_R(_puts(stat, "}{"));
	first = true;
	if (_fabsn(stat->unit->factor) < 1)
		CHECK_R(p->fac(stat, stat->unit->factor, &first));
	for (int i=0; i < NUM_BASE_UNITS; ++i) {
		if (stat->unit->exps[i] < 0)
			CHECK_R(p->sym(stat, _ul_symbols[i], -stat->unit->exps[i], &first));
	}
	if (first)
		CHECK_R(p->fac(stat, 1.0, &first));

	CHECK_R(_putc(stat, '}'));

	if (p->postfix)
		CHECK_R(_puts(stat, p->postfix));

	return RES_OK;
}