Пример #1
0
void rtl_console_init(void)
{

	int i;
	unsigned long dl;
	unsigned long dll;     
	unsigned long dlm;       
           
  	rtl_outl( UART_LCR,0x03000000);		//Line Control Register  8,n,1
  		
  	rtl_outl( UART_FCR,0xc7000000);		//FIFO Ccontrol Register
  	rtl_outl( UART_IER,0x00000000);
  	dl = (SYS_CLK_RATE /16)/BAUD_RATE-1;
  	*(volatile unsigned long *)(0xa1000000) = dl ; 
  	dll = dl & 0xff;
  	dlm = dl / 0x100;
  	rtl_outl( UART_LCR,0x83000000);		//Divisor latch access bit=1
  	rtl_outl( UART_DLL,dll*0x1000000);
   	rtl_outl( UART_DLM,dlm*0x1000000); 
   	rtl_outl( UART_LCR,0x83000000& 0x7fffffff);	//Divisor latch access bit=0
   	//rtl_outl( UART_THR,0x41000000);	
  	
//	dprintf("\nUART1 output test ok\n");
 	//prom_printf("\ntest value = %x \n", dl);
}
Пример #2
0
size_t rtl8139_send(struct network_dev *dev, uint8_t *_buf, size_t length)
{
	struct rtl8139 *rtl = dev->device;
	
	void* tx_buffer = (void *)(rtl->tx_buffers + 8192*rtl->tx_cur);
	kmemset(tx_buffer, 0, (length <60) ? 60 : length);
	kmemcpy(tx_buffer, _buf, length);
		
	if(length < 60)
		length = 60;
	
	rtl_outl(rtl, 0x20 + rtl->tx_cur*4, V2P(tx_buffer));
	rtl_outl(rtl, 0x10 + rtl->tx_cur*4, length | (48 << 16)); 
	rtl->tx_cur++;
	rtl->tx_cur %= 4;

	return length;
}
Пример #3
0
void timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{             
	//unsigned int i,j;	
	unsigned char status;
	static int light=0;

//	prom_printf("in timer interrupt\n");
	
	prom_printf("IRQ=%x\n",irq);
	if (irq != 8)
	{
		prom_printf("in timer irq, irq!=0\n");
		for(;;);
	}	
	status = rtl_inl(TCIR);
	if (status & 0x40000000)
	{
		((volatile timer_t *)(dev_id))->timer0tick= ((volatile timer_t *)(dev_id))->timer0tick + 1;
		#if (WATCHDOG_TEST == 1) 
			    /*Cyrus Tsai*/
                /*this should be longer */		
		if (Jiffies <=0x19)
		   {
		    rtl_outl(WDTCNR,0x100);	
		   } 
		#endif
	}
	if (status & 0x20)
	{
		((volatile timer_t *)(dev_id))->timer1tick= ((volatile timer_t *)(dev_id))->timer1tick + 1;
		//serial_outc('T');
		
		//wlan_tx_list_generate(0xFF);
		flush_cache();


		//twiddle(); 
		Jiffies++;	

		if(Jiffies>1000)
		{
		prom_printf("----\n");
		Jiffies=0;
		}



	}	
	if (status & 0x40)
		((volatile timer_t *)(dev_id))->timer2tick= ((volatile timer_t *)(dev_id))->timer2tick + 1;	

}
Пример #4
0
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;
		}*/
	}
	
	



}
Пример #5
0
void rtl8139_enable_timer(struct rtl8139 *rtl)
{
	rtl_outl(rtl, 0x54, 32768);//set rate ~1ms
	rtl_outl(rtl, 0x48, 0); //set timer count to 0
}