static void telnet_send_naws(struct session *ses) { unsigned char nego[128], *np; #define PUTBYTE(b) if ((b)==255) *np++=255; *np++=(b); np=nego; *np++=IAC; *np++=SB; *np++=NAWS; PUTBYTE(COLS/256); PUTBYTE(COLS%256); PUTBYTE((LINES-1-!!isstatus)/256); PUTBYTE((LINES-1-!!isstatus)%256); *np++=IAC; *np++=SE; write_socket(ses, (char*)nego, np-nego); #ifdef TELNET_DEBUG { char buf[BUFFER_SIZE], *b=buf; int neb=np-nego-2; np=nego+3; b=buf+sprintf(buf, "IAC SB NAWS "); while (np-nego<neb) b+=sprintf(b, "<%u> ", *np++); b+=sprintf(b, "IAC SE"); tintin_printf(ses, "~8~[telnet] sent: %s~-1~", buf); } #endif }
/* * NB: this function runs with MMU disabled! */ static void netwinder_reset(void) { register u_int base = DC21285_PCI_IO_BASE; #define PUTBYTE(reg, val) \ *((volatile u_int8_t *)(base + (reg))) = (val) PUTBYTE(0x338, 0x84); /* Red led(GP17), fan on(GP12) */ PUTBYTE(0x370, 0x87); /* Enter the extended function mode */ PUTBYTE(0x370, 0x87); /* (need to write the magic twice) */ PUTBYTE(0x370, 0x07); /* Select Logical Device Number reg */ PUTBYTE(0x371, 0x07); /* Select Logical Device 7 (GPIO) */ PUTBYTE(0x370, 0xe6); /* Select GP16 Control Reg */ PUTBYTE(0x371, 0x00); /* Make GP16 an output */ PUTBYTE(0x338, 0xc4); /* RESET(GP16), red led, fan on */ }
static void write_1_byte (int c) { PUTBYTE(c); }