Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: fallen/milkymist-mmu
base: 5cf6408
...
head fork: fallen/milkymist-mmu
compare: 8e87083
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
26 software/bios/main.c
@@ -648,7 +648,7 @@ static void readstr(char *s, int size)
}
break;
case '\e':
- vga_set_console(!vga_get_console());
+// vga_set_console(!vga_get_console());
break;
case 0x07:
break;
@@ -685,7 +685,6 @@ static void ethreset()
int main(int i, char **c)
{
char buffer[64];
- unsigned short int k;
/* lock gdbstub ROM */
CSR_DBG_CTRL = DBG_CTRL_GDB_ROM_LOCK;
@@ -696,9 +695,11 @@ int main(int i, char **c)
CSR_GPIO_OUT = GPIO_LED1;
rescue = !((unsigned int)main > FLASH_OFFSET_REGULAR_BIOS);
- irq_setmask(0);
- irq_enable(1);
uart_init();
+ uart_force_sync(1);
+ irq_setmask(0);
+ irq_enable(0);
+
putsnonl(banner);
crcbios();
brd_init();
@@ -706,20 +707,11 @@ int main(int i, char **c)
if(rescue)
printf("I: Booting in rescue mode\n");
- boot_sequence();
-
- uart_force_sync(1);
- irq_enable(0);
-
- for (k = 0 ; k < 65000 ; ++k)
- asm volatile("nop");
-
- dtlb_load_test();
-
+ uart_set_polling_mode(1);
while(1) {
- if (++k == 0)
- printf(".");
- asm volatile("nop");
+ putsnonl("\e[1mBIOS>\e[0m ");
+ readstr(buffer, 64);
+ do_command(buffer);
}
return 0;
View
6 software/bios/mmu_test_gen.c
@@ -47,6 +47,8 @@ int main(void) {
"unsigned int count;\n"
"asm volatile(\"mv %0, sp\" : \"=r\"(stack) :: );\n"
"mmu_dtlb_map(0x44002000, 0x44001000);\n"
+ "mmu_dtlb_map(stack, stack);\n"
+ "mmu_dtlb_map(stack-0x1000, stack-0x1000);\n"
"printf(\"stack == 0x%08X\\n\", stack);"
"a = 0;\n"
"b = 1;\n"
@@ -75,12 +77,12 @@ int main(void) {
puts("disable_dtlb();");
puts("printf(\"addr == 0x%08X\\n\", addr);");
- puts("printf(\"[MMU OFF] *(0x%08X) == 0x%08X\\n\", addr, *(unsigned int *)addr);");
+ puts("printf(\"[MMU OFF] *(0x%08X) == 0x%08X\\n\", addr, *(volatile unsigned int *)addr);");
puts("enable_dtlb();");
puts("asm volatile(\"lw %0, (%1+0)\" : \"=&r\"(data) : \"r\"(addr) : );");
puts("disable_dtlb();");
puts("printf(\"[MMU ON] *(0x%08X) == 0x%08X\\n\", addr, data);");
- puts("printf(\"[MMU OFF] *(0x%08X) == 0x%08X\\n\", addr-0x1000, *(unsigned int *)(addr - 0x1000));");
+ puts("printf(\"[MMU OFF] *(0x%08X) == 0x%08X\\n\", addr-0x1000, *(volatile unsigned int *)(addr - 0x1000));");
printf("printf(\"Test n° %02d : \");\n", test_num);
puts( "if (value == value_verif) {\n"
"\tputs(\"PASS\");\n"
View
29 software/libbase/console.c
@@ -25,6 +25,7 @@
static console_write_hook write_hook;
static console_read_hook read_hook;
static console_read_nonblock_hook read_nonblock_hook;
+static char uart_polling_mode = 0;
void console_set_write_hook(console_write_hook h)
{
@@ -40,20 +41,34 @@ void console_set_read_hook(console_read_hook r, console_read_nonblock_hook rn)
static void writechar(char c)
{
uart_write(c);
- if(write_hook != NULL)
- write_hook(c);
}
char readchar(void)
{
- while(1) {
- if(uart_read_nonblock())
- return uart_read();
- if((read_nonblock_hook != NULL) && read_nonblock_hook())
- return read_hook();
+ if ( uart_polling_mode )
+ {
+ while (!uart_rx_event());
+ uart_rx_event_ack();
+ return uart_getchar();
+ } else {
+ uart_write('-');
+ while(1) {
+ if(uart_read_nonblock())
+ return uart_read();
+ if((read_nonblock_hook != NULL) && read_nonblock_hook())
+ return read_hook();
+ }
}
}
+void uart_set_polling_mode(char m) {
+ uart_polling_mode = m;
+ if (m)
+ uart_activate_irq(1);
+ else
+ uart_activate_irq(0);
+}
+
int readchar_nonblock(void)
{
return (uart_read_nonblock()
View
41 software/libbase/uart.c
@@ -44,20 +44,26 @@ static volatile int tx_cts;
static int force_sync;
+char uart_rx_event(void)
+{
+ unsigned int stat = CSR_UART_STAT;
+ return stat & UART_STAT_RX_EVT;
+}
+
+void uart_rx_event_ack(void)
+{
+ CSR_UART_STAT = UART_STAT_RX_EVT;
+}
+
+char uart_getchar(void)
+{
+ return CSR_UART_RXTX;
+}
void uart_isr(void)
{
unsigned int stat = CSR_UART_STAT;
- mmu_dtlb_map(uart_isr, uart_isr);
- mmu_dtlb_map(rx_buf, rx_buf);
- mmu_dtlb_map(tx_buf, tx_buf);
- mmu_dtlb_map(&tx_produce, &tx_produce);
- mmu_dtlb_map(&tx_consume, &tx_consume);
- mmu_dtlb_map(&rx_produce, &rx_produce);
- mmu_dtlb_map(&tx_cts, &tx_cts);
- mmu_dtlb_map(irq_ack, irq_ack);
-
if(stat & UART_STAT_RX_EVT) {
rx_buf[rx_produce] = CSR_UART_RXTX;
rx_produce = (rx_produce + 1) & UART_RINGBUFFER_MASK_RX;
@@ -113,6 +119,23 @@ void uart_write(char c)
irq_setmask(oldmask);
}
+void uart_activate_irq(char a)
+{
+ unsigned int mask;
+ if (a)
+ {
+ CSR_UART_CTRL &= ~(UART_CTRL_TX_INT) & ~(UART_CTRL_RX_INT);
+ mask = irq_getmask();
+ mask |= IRQ_UART;
+ irq_setmask(mask);
+ } else {
+ CSR_UART_CTRL = UART_CTRL_TX_INT | UART_CTRL_RX_INT;
+ mask = irq_getmask();
+ mask &= ~IRQ_UART;
+ irq_setmask(mask);
+ }
+}
+
void uart_init(void)
{
unsigned int mask;

No commit comments for this range

Something went wrong with that request. Please try again.