void rtl8139_getmac(struct rtl8139 *rtl, char *mac) { for(int i = 0; i < 6; i++) { mac[i] = rtl_inb(rtl, i); } }
char serial_inc() { int i; #ifndef CONFIG_SERIAL_SC16IS7X0_CONSOLE while (1) { if (rtl_inb(UART_LSR) & 0x1) break; } i=rtl_inb(UART_RBR); return (i & 0xff); #endif // ---------------------------------------------------- // above is UART0, and below is SC16IS7x0 // ---------------------------------------------------- #ifdef CONFIG_SERIAL_SC16IS7X0_CONSOLE unsigned long flags; unsigned int in; if( sc16is7x0_err ) while( 1 ); // never return while (1) { save_and_cli(flags); in = sc16is7x0_serial_in_i2c( UART_MEM2REG( UART_LSR ) ); restore_flags(flags); if( in & 0x1) break; // add delay to be interrupted by eth-driver for( i = 0; i < 10; i ++ ) // 10ms delay udelay( 1000 ); } i = sc16is7x0_serial_in_i2c( UART_MEM2REG( UART_RBR ) ); return (i & 0xff); #endif }
void rtl8139_start(struct rtl8139 *rtl) { rtl->tx_cur = 0; rtl_outb(rtl, 0x37, 0x10); while((rtl_inb(rtl, 0x37) & 0x10) != 0); kmemset(rtl->rx_buffer, 0, (8192*8)+16+1500); rtl_outl(rtl, 0x30,(uintptr_t)V2P(rtl->rx_buffer)); rtl_outb(rtl, 0x37, 0xc); for(int i=0; i < 4; i++) { rtl_outl(rtl, 0x20 + i*4, (uintptr_t)V2P(rtl->tx_buffers) + i*(8192 +16+1500)); } //TODO: need to register pci IRQs instead of doing it directly //interrupt_register(32 + rtl->pci_hdr->int_line, &rtl_handler); pci_register_irq(rtl->pci, &rtl_handler, rtl); rtl_outl(rtl, 0x44, (1 << 7) | 8| (1 << 1)); rtl_outw(rtl, 0x3c, 0x5 ); for(int i = 0; i < 6; i ++) rtl->mac[i] = rtl_inb(rtl, i); for(int i = 0; i < 100; i++) { /* uint16_t isr = rtl_inw(rtl, ISR); if(isr & 0x20) { rtl_outw(rtl, ISR, 0x20); printf("isr %x\n",isr); break; }*/ } }
void serial_outc(char c) { int i=0; while (1) { i++; if (i >=0x6000) break; if (rtl_inb(UART_LSR) & 0x20) break; } rtl_outb(UART_THR, c); }
void serial_outc(char c) { int i; i=0; #ifndef CONFIG_SERIAL_SC16IS7X0_CONSOLE #if 1 while (1) { i++; if (i >=3210) break; if (rtl_inb(UART_LSR) & 0x60) break; } #endif //for(i=0; i<0xff00;i++); rtl_outb(UART_THR, c); if (c == 0x0a) rtl_outb(UART_THR, 0x0d); #endif // ---------------------------------------------------- // above is UART0, and below is SC16IS7x0 // ---------------------------------------------------- #ifdef CONFIG_SERIAL_SC16IS7X0_CONSOLE if( sc16is7x0_err ) return; while (1) { i++; if (i >=3210) break; if (sc16is7x0_serial_in_i2c( UART_MEM2REG( UART_LSR ) ) & 0x60) break; } sc16is7x0_serial_out_i2c( UART_MEM2REG( UART_THR ), c ); if (c == 0x0a) sc16is7x0_serial_out_i2c( UART_MEM2REG( UART_THR ), 0x0d); #endif }