Skip to content
This repository
  • 2 commits
  • 4 files changed
  • 0 comments
  • 1 contributor
26  software/bios/main.c
@@ -648,7 +648,7 @@ static void readstr(char *s, int size)
648 648
 				}
649 649
 				break;
650 650
 			case '\e':
651  
-				vga_set_console(!vga_get_console());
  651
+//				vga_set_console(!vga_get_console());
652 652
 				break;
653 653
 			case 0x07:
654 654
 				break;
@@ -685,7 +685,6 @@ static void ethreset()
685 685
 int main(int i, char **c)
686 686
 {
687 687
 	char buffer[64];
688  
-	unsigned short int k;
689 688
 
690 689
 	/* lock gdbstub ROM */
691 690
 	CSR_DBG_CTRL = DBG_CTRL_GDB_ROM_LOCK;
@@ -696,9 +695,11 @@ int main(int i, char **c)
696 695
 	CSR_GPIO_OUT = GPIO_LED1;
697 696
 	rescue = !((unsigned int)main > FLASH_OFFSET_REGULAR_BIOS);
698 697
 
699  
-	irq_setmask(0);
700  
-	irq_enable(1);
701 698
 	uart_init();
  699
+	uart_force_sync(1);
  700
+	irq_setmask(0);
  701
+	irq_enable(0);
  702
+
702 703
 	putsnonl(banner);
703 704
 	crcbios();
704 705
 	brd_init();
@@ -706,20 +707,11 @@ int main(int i, char **c)
706 707
 	if(rescue)
707 708
 		printf("I: Booting in rescue mode\n");
708 709
 
709  
-	boot_sequence();
710  
-
711  
-	uart_force_sync(1);
712  
-	irq_enable(0);
713  
-
714  
-	for (k = 0 ; k < 65000 ; ++k)
715  
-		asm volatile("nop");
716  
-
717  
-	dtlb_load_test();
718  
-
  710
+	uart_set_polling_mode(1);
719 711
 	while(1) {
720  
-		if (++k == 0)
721  
-			printf(".");
722  
-		asm volatile("nop");
  712
+		putsnonl("\e[1mBIOS>\e[0m ");
  713
+		readstr(buffer, 64);
  714
+		do_command(buffer);
723 715
 	}
724 716
 
725 717
 	return 0;
6  software/bios/mmu_test_gen.c
@@ -47,6 +47,8 @@ int main(void) {
47 47
 		"unsigned int count;\n"
48 48
 		"asm volatile(\"mv %0, sp\" : \"=r\"(stack) :: );\n"
49 49
 		"mmu_dtlb_map(0x44002000, 0x44001000);\n"
  50
+		"mmu_dtlb_map(stack, stack);\n"
  51
+		"mmu_dtlb_map(stack-0x1000, stack-0x1000);\n"
50 52
 		"printf(\"stack == 0x%08X\\n\", stack);"
51 53
 		"a = 0;\n"
52 54
 		"b = 1;\n"
@@ -75,12 +77,12 @@ int main(void) {
75 77
 
76 78
 			puts("disable_dtlb();");
77 79
 			puts("printf(\"addr == 0x%08X\\n\", addr);");
78  
-			puts("printf(\"[MMU OFF] *(0x%08X) == 0x%08X\\n\", addr, *(unsigned int *)addr);");
  80
+			puts("printf(\"[MMU OFF] *(0x%08X) == 0x%08X\\n\", addr, *(volatile unsigned int *)addr);");
79 81
 			puts("enable_dtlb();");
80 82
 			puts("asm volatile(\"lw %0, (%1+0)\" : \"=&r\"(data) : \"r\"(addr) : );");
81 83
 			puts("disable_dtlb();");
82 84
 			puts("printf(\"[MMU ON] *(0x%08X) == 0x%08X\\n\", addr, data);");
83  
-			puts("printf(\"[MMU OFF] *(0x%08X) == 0x%08X\\n\", addr-0x1000, *(unsigned int *)(addr - 0x1000));");
  85
+			puts("printf(\"[MMU OFF] *(0x%08X) == 0x%08X\\n\", addr-0x1000, *(volatile unsigned int *)(addr - 0x1000));");
84 86
 			printf("printf(\"Test n° %02d : \");\n", test_num);
85 87
 			puts(	"if (value == value_verif) {\n"
86 88
 					"\tputs(\"PASS\");\n"
29  software/libbase/console.c
@@ -25,6 +25,7 @@
25 25
 static console_write_hook write_hook;
26 26
 static console_read_hook read_hook;
27 27
 static console_read_nonblock_hook read_nonblock_hook;
  28
+static char uart_polling_mode = 0;
28 29
 
29 30
 void console_set_write_hook(console_write_hook h)
30 31
 {
@@ -40,20 +41,34 @@ void console_set_read_hook(console_read_hook r, console_read_nonblock_hook rn)
40 41
 static void writechar(char c)
41 42
 {
42 43
 	uart_write(c);
43  
-	if(write_hook != NULL)
44  
-		write_hook(c);
45 44
 }
46 45
 
47 46
 char readchar(void)
48 47
 {
49  
-	while(1) {
50  
-		if(uart_read_nonblock())
51  
-			return uart_read();
52  
-		if((read_nonblock_hook != NULL) && read_nonblock_hook())
53  
-			return read_hook();
  48
+	if ( uart_polling_mode )
  49
+	{
  50
+		while (!uart_rx_event());
  51
+		uart_rx_event_ack();
  52
+		return uart_getchar();
  53
+	} else {
  54
+		uart_write('-');
  55
+		while(1) {
  56
+			if(uart_read_nonblock())
  57
+				return uart_read();
  58
+			if((read_nonblock_hook != NULL) && read_nonblock_hook())
  59
+				return read_hook();
  60
+		}
54 61
 	}
55 62
 }
56 63
 
  64
+void uart_set_polling_mode(char m) {
  65
+	uart_polling_mode = m;
  66
+	if (m)
  67
+		uart_activate_irq(1);
  68
+	else
  69
+		uart_activate_irq(0);
  70
+}
  71
+
57 72
 int readchar_nonblock(void)
58 73
 {
59 74
 	return (uart_read_nonblock()
41  software/libbase/uart.c
@@ -44,20 +44,26 @@ static volatile int tx_cts;
44 44
 
45 45
 static int force_sync;
46 46
 
  47
+char uart_rx_event(void)
  48
+{
  49
+	unsigned int stat = CSR_UART_STAT;
  50
+	return stat & UART_STAT_RX_EVT;
  51
+}
  52
+
  53
+void uart_rx_event_ack(void)
  54
+{
  55
+	CSR_UART_STAT = UART_STAT_RX_EVT;
  56
+}
  57
+
  58
+char uart_getchar(void)
  59
+{
  60
+	return CSR_UART_RXTX;
  61
+}
47 62
 
48 63
 void uart_isr(void)
49 64
 {
50 65
 	unsigned int stat = CSR_UART_STAT;
51 66
 
52  
-	mmu_dtlb_map(uart_isr, uart_isr);
53  
-	mmu_dtlb_map(rx_buf, rx_buf);
54  
-	mmu_dtlb_map(tx_buf, tx_buf);
55  
-	mmu_dtlb_map(&tx_produce, &tx_produce);
56  
-	mmu_dtlb_map(&tx_consume, &tx_consume);
57  
-	mmu_dtlb_map(&rx_produce, &rx_produce);
58  
-	mmu_dtlb_map(&tx_cts, &tx_cts);
59  
-	mmu_dtlb_map(irq_ack, irq_ack);
60  
-
61 67
 	if(stat & UART_STAT_RX_EVT) {
62 68
 		rx_buf[rx_produce] = CSR_UART_RXTX;
63 69
 		rx_produce = (rx_produce + 1) & UART_RINGBUFFER_MASK_RX;
@@ -113,6 +119,23 @@ void uart_write(char c)
113 119
 	irq_setmask(oldmask);
114 120
 }
115 121
 
  122
+void uart_activate_irq(char a)
  123
+{
  124
+	unsigned int mask;
  125
+	if (a)
  126
+	{
  127
+		CSR_UART_CTRL &= ~(UART_CTRL_TX_INT) & ~(UART_CTRL_RX_INT);
  128
+		mask = irq_getmask();
  129
+		mask |= IRQ_UART;
  130
+		irq_setmask(mask);
  131
+	} else {
  132
+		CSR_UART_CTRL = UART_CTRL_TX_INT | UART_CTRL_RX_INT;
  133
+		mask = irq_getmask();
  134
+		mask &= ~IRQ_UART;
  135
+		irq_setmask(mask);
  136
+	}
  137
+}
  138
+
116 139
 void uart_init(void)
117 140
 {
118 141
 	unsigned int mask;

No commit comments for this range

Something went wrong with that request. Please try again.