rtems_device_driver console_write( rtems_device_major_number major, rtems_device_minor_number minor, void * arg ) { int count; int maximum; rtems_libio_rw_args_t *rw_args; char *buffer; rw_args = (rtems_libio_rw_args_t *) arg; buffer = rw_args->buffer; maximum = rw_args->count; for (count = 0; count < maximum; count++) { if ( buffer[ count ] == '\n') { outbyte('\r'); } outbyte( buffer[ count ] ); } rw_args->bytes_moved = maximum; return 0; }
/* * dump switch table */ void dumpsw (INTPTR_T *ws) /*int ws[];*/ { INTPTR_T i,j; // gdata (); gnlabel (ws[WSTAB]); if (ws[WSCASEP] != swstp) { j = ws[WSCASEP]; while (j < swstp) { defword (); i = 4; while (i--) { outdec (swstcase[j]); outbyte (','); outlabel (swstlab[j++]); if ((i == 0) | (j >= swstp)) { newl (); break; } outbyte (','); } } } defword (); outlabel (ws[WSDEF]); outstr (",0"); newl(); // gtext (); }
/* * Send the packet in buffer. */ void putpacket(unsigned char *buffer) { unsigned char checksum; int count; unsigned char ch; /* $<packet info>#<checksum>. */ do { outbyte('$'); checksum = 0; count = 0; while (ch = buffer[count]) { if (! outbyte(ch)) return; checksum += ch; count += 1; } outbyte('#'); outbyte(digit2hex(checksum >> 4)); outbyte(digit2hex(checksum & 0xf)); } while ((inbyte() & 0x7f) != '+'); }
/* Exit back to monitor, with the given status code. */ void hardware_exit_hook (int status) { outbyte ('\r'); outbyte ('\n'); cfe_exit (CFE_FLG_WARMSTART, status); }
/********************************************************************* * * main() * *********************************************************************/ void main() { char rxdata; /****************************************************************** * * Place your code here. ******************************************************************/ int cnt; cnt = 0; InitUSART(); printf("this is example for printf from library\r\n"); do { #ifndef USE_UART_INTR if (UART_GetChar(USART2, &rxdata) == 0) { } else { outbyte(rxdata); if(rxdata==0x0d) outbyte(0x0a); } #endif cnt++; } while (1); }
__attribute__((weak)) s32 _write (s32 fd, char8* buf, s32 nbytes) { #ifdef STDOUT_BASEADDRESS s32 i; char8* LocalBuf = buf; (void)fd; for (i = 0; i < nbytes; i++) { if(LocalBuf != NULL) { LocalBuf += i; } if(LocalBuf != NULL) { if (*LocalBuf == '\n') { outbyte ('\r'); } outbyte (*LocalBuf); } if(LocalBuf != NULL) { LocalBuf -= i; } } return (nbytes); #else (void)fd; (void)buf; (void)nbytes; return 0; #endif }
/* Print a string - no formatting characters will be interpreted here */ int prints(char** dst, const char *string, int width, int pad) { register int pc = 0, padchar = ' '; if (width > 0) { register int len = 0; register const char *ptr; for (ptr = string; *ptr; ++ptr) ++len; if (len >= width) width = 0; else width -= len; if (pad & PAD_ZERO) padchar = '0'; } if (!(pad & PAD_RIGHT)) { for ( ; width > 0; --width) { outbyte(dst, padchar); ++pc; } } for ( ; *string ; ++string) { outbyte(dst, *string); ++pc; } for ( ; width > 0; --width) { outbyte(dst, padchar); ++pc; } return pc; }
/* * Scan for the sequence $<data>#<checksum> */ void getpacket(unsigned char *buffer) { unsigned char checksum; unsigned char xmitcsum; int i; int count; unsigned char ch; do { /* wait around for the start character, ignore all other characters */ while ((ch = (inbyte() & 0x7f)) != '$') ; checksum = 0; xmitcsum = -1; count = 0; /* now, read until a # or end of buffer is found */ while (count < BUFMAX) { ch = inbyte() & 0x7f; if (ch == '#') break; checksum = checksum + ch; buffer[count] = ch; count = count + 1; } if (count >= BUFMAX) continue; buffer[count] = 0; if (ch == '#') { xmitcsum = hex2digit(inbyte() & 0x7f) << 4; xmitcsum |= hex2digit(inbyte() & 0x7f); #if 1 /* Humans shouldn't have to figure out checksums to type to it. */ outbyte ('+'); return; #endif if (checksum != xmitcsum) outbyte('-'); /* failed checksum */ else { outbyte('+'); /* successful transfer */ /* if a sequence char is present, reply the sequence ID */ if (buffer[2] == ':') { outbyte(buffer[0]); outbyte(buffer[1]); /* remove sequence chars from buffer */ count = strlen(buffer); for (i=3; i <= count; i++) buffer[i-3] = buffer[i]; } } } } while (checksum != xmitcsum); }
extern "C" void printnibble(unsigned int c) { c&=0xf; if (c>9) outbyte(c+'a'-10); else outbyte(c+'0'); }
void SimpleConsole::MoveCursorTo( int x, int y ) { int offset = y * width + x; outbyte( 0x3D4, 14 ); outbyte( 0x3D5, offset >> 8 ); outbyte( 0x3D4, 15 ); outbyte( 0x3D5, offset&0xFF ); }
// source: NUL/NRE void x86Machine::rebootPCI() { if(reqport(0xcf9) < 0) { printe("Unable to request port 0xcf9"); return; } outbyte(0xcf9,(inbyte(0xcf9) & ~4) | 0x02); outbyte(0xcf9,0x06); outbyte(0xcf9,0x01); }
void dumplits( int size, int pr_label , int queueptr,int queuelab, unsigned char *queue) { int j, k,lit ; if ( queueptr ) { if ( pr_label ) { output_section("rodata_compiler"); // output_section("text"); prefix(); queuelabel(queuelab) ; col() ; nl(); } k = 0 ; while ( k < queueptr ) { /* pseudo-op to define byte */ if (infunc) j=1; else j=10; if (size == 1) defbyte(); else if (size == 4) deflong(); else if (size == 0 ) { defmesg(); j=30; } else defword(); while ( j-- ) { if (size==0) { lit=getint(queue+k,1); if (lit >= 32 && lit <= 126 && lit != '"' && lit != '\\' ) outbyte(lit); else { outstr("\"\n"); defbyte(); outdec(lit); nl(); lit=0; } k++; if ( j == 0 || k >=queueptr || lit == 0 ) { if (lit) outbyte('"'); nl(); break; } } else { outdec(getint(queue+k, size)); k += size ; if ( j == 0 || k >= queueptr ) { nl(); /* need <cr> */ break; } outbyte(','); /* separate bytes */ } } } output_section("code_compiler"); // output_section("code"); } nl(); }
main () { outbyte ('&'); outbyte ('@'); outbyte ('$'); outbyte ('%'); print ("FooBar\r\n"); /* whew, we made it */ print ("\r\nDone...\r\n"); /* fflush(stdout); */ }
int write (int fd, char *buf, int nbytes) { int i, j; for (i = 0; i < nbytes; i++) { if (*(buf + i) == '\n') { outbyte ('\r'); /* LF -> CRLF */ } outbyte (*(buf + i)); for (j = 0; j < 300; j++); } return (nbytes); }
int main() { unsigned int value=0; int i; u32 input; unsigned int my_array[] = { 1841,1371,1356,1435,1364,1474,1741,1790,1720,1770,6770,7460,3660,5045,1111,9481 ,99,100,99,92,159,163,114,177,101,44,55,192,58,81,129,193,124,76,38,181,147,182,77,71, 17,164,149,193,62,45,81,176,184,165,28,199,1,199,1,199,1,199,1,199,1,199,1,199,15,12,9,98,9,134,14,15, 16,7,2,6,1,4,7,18,1,5,20,21,22,23,24,25,15,15,15,101,199,102,198,103,197,104,196,105,195,111,189,122, 184,137,136,135,134,144,141,190,120,170,60,70,30,50,111,981,141,171 }; GPIO_0_conf.BaseAddress = XPAR_AXI_GPIO_0_BASEADDR; GPIO_0_conf.DeviceId = XPAR_GPIO_0_DEVICE_ID; GPIO_0_conf.InterruptPresent = XPAR_GPIO_0_INTERRUPT_PRESENT; GPIO_0_conf.IsDual = XPAR_GPIO_0_IS_DUAL; //Initialize the XGpio instance XGpio_CfgInitialize(&GPIO_0, &GPIO_0_conf, GPIO_0_conf.BaseAddress); init_platform(); print("*Init*\n\r"); for(i=0;i<size;i++){ value = 0xe0000000 | (i<<16) | my_array[i]; XGpio_DiscreteWrite(&GPIO_0, 1, value); print("Preencheu RAM! \n\r"); } print("Fim do preenchimento\n\r"); print("Pressionar btnC\n\r"); input = XGpio_DiscreteRead(&GPIO_0, 2); // Separar valor para mostrar outbyte((char)((input/100)+0x30)); outbyte((char)((input/10)%10+0x30)); outbyte((char)(input%10+0x30)); print("\n"); cleanup_platform(); return 0; }
/* Newer version, shorter and certainly faster */ void outhex (INTPTR_T number) { int i = 0; char s[10]; outbyte('$'); sprintf(s,"%0X",(int)number); while (s[i]) outbyte(s[i++]); }
// Writes to uart an unsigned int value as an hex // number. nibble is the number of hex digits. void writeint(uint8_t nibbles, uint32_t val) { uint32_t i, digit; for (i=0; i<8; i++) { if (i >= 8-nibbles) { digit = (val & 0xf0000000) >> 28; if (digit >= 0xA) outbyte('A'+digit-10); else outbyte('0'+digit); } val <<= 4; }
extern "C" void printstring(const char *str) { while (*str) { outbyte(*str); str++; } }
/* * dump the literal pool */ void dumplits (void) { long j, k; if ((litptr == 0) && (const_nb == 0)) return; outstr("\t.data\n"); outstr("\t.bank CONST_BANK\n"); if (litptr) { outlabel(litlab); col(); k = 0; while (k < litptr) { defbyte(); j = 8; while (j--) { outdec(litq[k++] & 0xFF); if ((j == 0) | (k >= litptr)) { nl(); break; } outbyte(','); } } } if (const_nb) dump_const(); }
void doset_sprpalstatement(void) { /* syntax is number of the first palette to alter : integer name of the data for loading palettes : identifier [ number of palette to load : integer ] if last argument is missing, 1 is assumed */ flush_ins(); /* David, optimize.c related */ ot("_set_sprpal\t"); outconst(); if (outcomma()) return; if (outnameunderline()) return; if (!match(",")) { outstr(",#"); outdec(1); } else { outbyte(','); outconst(); } newl(); needbrack(")"); }
void doload_spritesstatement(void) { /* syntax is offset in vram to load data at : integer name of the data to transfert : identifier number of sprites (of size 32x64) to load : integer */ flush_ins(); /* David, optimize.c related */ ot("load_sprites\t"); outconst(); if (outcomma()) return; if (outnameunderline()) return; if (!match(",")) { outstr(",#"); outdec(1); } else { outbyte(','); outconst(); } newl(); needbrack(")"); }
static void outnum( const long long n, const long long base, params_t *par) { charptr cp; int negative; char outbuf[32]; const char digits[] = "0123456789ABCDEF"; unsigned long long num; /* Check if number is negative */ if (base == 10 && n < 0L) { negative = 1; num = -(n); } else{ num = (n); negative = 0; } /* Build number (backwards) in outbuf */ cp = outbuf; do { *cp++ = digits[(int)(num % base)]; } while ((num /= base) > 0); if (negative) *cp++ = '-'; *cp-- = 0; /* Move the converted number to the buffer and */ /* add in the padding where needed. */ par->len = strlen(outbuf); padding( !(par->left_flag), par); while (cp >= outbuf) outbyte( *cp--); padding( par->left_flag, par); }
void printString(char *s){ int i = 0; while(s[i]) { outbyte(s[i]); i++; } }
void console_outbyte_polled( int port, char ch ) { outbyte( ch ); }
// source: NUL/NRE void x86Machine::rebootSysCtrlPort() { if(reqport(0x92) < 0) { printe("Unable to request port 0x92"); return; } outbyte(0x92,0x01); }
void outbyte( char ch ) { #define TXS (m302.scc2.bd.tx[0].status) #define TXD (* ((volatile char *) m302.scc2.bd.tx[0].buffer)) #define RXS (m302.scc2.bd.rx[0].status) #define RXD (* ((volatile char *) m302.scc2.bd.rx[0].buffer)) while (TXS & RBIT_HDLC_READY_BIT) /* Wait until okay to transmit */ ; /* * Check for flow control requests and process. */ while ( ! (RXS & RBIT_HDLC_EMPTY_BIT)) { if (RXD == XOFF) do { RXS = RBIT_HDLC_EMPTY_BIT | RBIT_HDLC_WRAP_BIT; while (RXS & RBIT_HDLC_EMPTY_BIT) /* Wait until character received */ ; } while (RXD != XON); RXS = RBIT_HDLC_EMPTY_BIT | RBIT_HDLC_WRAP_BIT; } TXD = ch; TXS = RBIT_HDLC_READY_BIT | RBIT_HDLC_WRAP_BIT; if (ch == '\n') outbyte('\r'); }
void SimpleConsole::OutputChar( int ch ) { outbyte(0xE9,ch); //for bochs if(ch=='\t') { do{ OutputChar(' '); }while( (cursorX-1)%4 ); return; } if(ch=='\n') { NextLine(); } else if( ch == 8 ) { OutputChar( charStyle, cursorY, --cursorX ); } else if ( isprint((unsigned char)ch) ) { OutputChar( charStyle | ch, cursorY, cursorX++ ); } if(cursorX >= width ) { NextLine(); } MoveCursor(); }
int write (int fd, char *buf, int nbytes) { int i, j, ch; ch = ch_set(fd); if(ch == EBADF){ return ch; } for (i = 0; i < nbytes; i++) { if (*(buf + i) == '\n') { outbyte(ch,'\r'); /* LF -> CRLF */ } outbyte(ch,*(buf + i)); for (j = 0; j < 300; j++); } return (nbytes); }
/* * Output an hexadecimal number with a certain number of digits */ void outhexfix (INTPTR_T number, int length) { int i = 0; char s[10]; char format[10]; outbyte('$'); sprintf(format,"%%0%dX", length); sprintf(s,format,number); while (s[i]) outbyte(s[i++]); }
static void outmeta(const byte c) { /* Running status may not be used by file meta-events, and meta-events cancel any running status. */ lastStatus = -1; outevent(FileMetaEvent); outbyte(c); }