console: Cleanup console API
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Thu, 18 Jun 2020 01:06:33 +0000 (11:06 +1000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 23 Jun 2020 23:53:46 +0000 (09:53 +1000)
Use a more generic console_init() instead of potato_uart_init(),
and do the same for interrupt control. There should be no
change in behaviour.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
16 files changed:
hello_world/hello_world.bin
hello_world/hello_world.c
hello_world/hello_world.elf
hello_world/hello_world.hex
include/console.h
include/microwatt_soc.h
lib/console.c
litedram/gen-src/sdram_init/main.c
rust_lib_demo/hello_world.c
tests/decrementer/decrementer.c
tests/illegal/illegal.c
tests/misc/misc.c
tests/mmu/mmu.c
tests/privileged/privileged.c
tests/sc/sc.c
tests/xics/xics.c

index ae4c4a8311b39e5cdef455ff1672da7b2cac9c4b..dda2b66b7468d5072bdb2f304390b821f4622ccb 100755 (executable)
Binary files a/hello_world/hello_world.bin and b/hello_world/hello_world.bin differ
index 6575667bcf92fb1d1edee7f9dc35eeb31d4714f1..b5d1ef27ecb6f64f675c607b65b2f61789ede124 100644 (file)
@@ -7,7 +7,7 @@
 
 int main(void)
 {
-       potato_uart_init();
+       console_init();
 
        puts(HELLO_WORLD);
 
index e65843824b7b7ff33f700d011187a7108c0d84e7..d89e408e44fa6b4c7300a77983901c9dfa4e5ce5 100755 (executable)
Binary files a/hello_world/hello_world.elf and b/hello_world/hello_world.elf differ
index 609824771198dc139c8dd1501986228bad54bd5e..f799a45ba4831ebc3eefddeefdb520d97784e5ba 100644 (file)
@@ -514,67 +514,68 @@ e8010010ebc1fff0
 7c0803a6ebe1fff8
 3c4000014e800020
 7c0802a63842a000
-3fe2fffffbe1fff8
-f80100103bff7240
-48000051f821ffd1
-7fe3fb7860000000
-60000000480001d5
-7fe3fb787c641b78
-600000004800017d
-60000000480000ed
-480001295463063e
+f821ffe1f8010010
+6000000048000229
+386372783c62ffff
+600000004800018d
+60000000480000f9
+480001355463063e
 4bffffec60000000
 0100000000000000
-3c40000100000180
+3c40000100000080
 3d20c0003842a000
 6129200060000000
 f922800079290020
 612900203d20c000
 7c0004ac79290020
 3d40001c7d204eea
-7d295392614a2000
-394a0018e9428000
-7c0004ac3929ffff
+614a200079290600
+e94280007d295392
+3929ffff394a0018
+7d2057ea7c0004ac
+000000004e800020
+0000000000000000
+3842a0003c400001
+419e00082fa40000
+6000000060630002
+39290020e9228000
+7c604fea7c0004ac
+000000004e800020
+0000000000000000
+3842a0003c400001
+e922800060000000
+3929002039400000
+7d404fea7c0004ac
+000000004e800020
+0000000000000000
+3842a0003c400001
+e922800060000000
+7c0004ac39290010
+712900017d204eea
+e86280004082ffe8
+7c0004ac38630008
+5463063e7c601eea
+000000004e800020
+0000000000000000
+3842a0003c400001
+e922800060000000
+7c0004ac39290010
+712900087d204eea
+5469063e4082ffe8
+7c0004ace9428000
 4e8000207d2057ea
 0000000000000000
 3c40000100000000
-600000003842a000
-394000ffe9228000
-7c0004ac39290020
-4e8000207d404fea
-0000000000000000
-3c40000100000000
-600000003842a000
-39400000e9228000
-7c0004ac39290020
-4e8000207d404fea
-0000000000000000
-3c40000100000000
-600000003842a000
-39290010e9228000
-7d204eea7c0004ac
-4082ffe871290001
-38630008e8628000
-7c601eea7c0004ac
-4e8000205463063e
-0000000000000000
-3c40000100000000
-600000003842a000
-39290010e9228000
-7d204eea7c0004ac
-4082ffe871290008
-7c0004ace9228000
-4e8000207c604fea
-0000000000000000
-3c40000100000000
 7c0802a63842a000
 fbe1fff8fbc1fff0
-7c7f1b787fc32214
-f821ffd1f8010010
-409e000c7fbff040
-4bfffe0c38210030
-3bff0001887f0000
-4bffffe44bffff8d
+f80100103bc3ffff
+8ffe0001f821ffd1
+409e00102fbf0000
+3860000038210030
+2b9f000a4bfffe10
+3860000d409e000c
+7fe3fb784bffff81
+4bffffd04bffff79
 0100000000000000
 3920000000000280
 2f8a00007d4348ae
@@ -582,5 +583,11 @@ f821ffd1f8010010
 392900014e800020
 000000004bffffe8
 0000000000000000
+3842a0003c400001
+000000004bfffe1c
+0000000000000000
+3842a0003c400001
+000000004bfffe68
+0000000000000000
 6f57206f6c6c6548
-0000000a0d646c72
+000000000a646c72
index e871c67eea4e06dd4f0cdb0943fd1692b5703b77..78d0a866cb35417d21e3bf553858e61107bea6e8 100644 (file)
@@ -1,8 +1,7 @@
 #include <stddef.h>
 
-void potato_uart_init(void);
-void potato_uart_irq_en(void);
-void potato_uart_irq_dis(void);
+void console_init(void);
+void console_set_irq_en(bool rx_irq, bool tx_irq);
 int getchar(void);
 int putchar(int c);
 int puts(const char *str);
index 77d5a58bc13717bc972a876b2bce5cd565ed8c27..8b69889aea9f932fe567a493c9be688ac6895ae0 100644 (file)
@@ -69,6 +69,8 @@
 #define   POTATO_CONSOLE_STATUS_TX_FULL                        0x08
 #define POTATO_CONSOLE_CLOCK_DIV       0x18
 #define POTATO_CONSOLE_IRQ_EN          0x20
+#define   POTATO_CONSOLE_IRQ_RX                                0x01
+#define   POTATO_CONSOLE_IRQ_TX                                0x02
 
 /*
  * Register definitionss for our standard (16550 style) UART
index bce220e9f9eb1bceaf5667fecf9af3b3a6541ec7..892c76f491e667bea436f7efa43a0ee6a3863895 100644 (file)
@@ -80,9 +80,15 @@ void potato_uart_init(void)
        potato_uart_reg_write(POTATO_CONSOLE_CLOCK_DIV, potato_uart_divisor(proc_freq, UART_FREQ));
 }
 
-void potato_uart_irq_en(void)
+void potato_uart_set_irq_en(bool rx_irq, bool tx_irq)
 {
-       potato_uart_reg_write(POTATO_CONSOLE_IRQ_EN, 0xff);
+       uint64_t en = 0;
+
+       if (rx_irq)
+               en |= POTATO_CONSOLE_IRQ_RX;
+       if (tx_irq)
+               en |= POTATO_CONSOLE_IRQ_TX;
+       potato_uart_reg_write(POTATO_CONSOLE_IRQ_EN, en);
 }
 
 void potato_uart_irq_dis(void)
@@ -131,3 +137,13 @@ size_t strlen(const char *s)
        return len;
 }
 #endif
+
+void console_init(void)
+{
+       potato_uart_init();
+}
+
+void console_set_irq_en(bool rx_irq, bool tx_irq)
+{
+       potato_uart_set_irq_en(rx_irq, tx_irq);
+}
index dd3b507b3cfb60e0768648bcc05be913eb75c912..19cc2ad4ce2954f7c824e1763cf3c1b40c1aa64c 100644 (file)
@@ -241,7 +241,7 @@ uint64_t main(void)
        bool try_flash = false;
 
        /* Init the UART */
-       potato_uart_init();
+       console_init();
 
        printf("\n\nWelcome to Microwatt !\n\n");
 
index c8797fd71d1a872e77556ddb78761fe1074d45f2..6c44be9ca1b81576002180fa5ffc11ac609f16a2 100644 (file)
@@ -25,7 +25,7 @@ void init_bss()
 int main(void)
 {
        init_bss();
-       potato_uart_init();
+       console_init();
 
        puts(HELLO_WORLD);
 
index e6cff2cc0342ccfc3e04fbf948391b18a792ccd5..7b1c345d92ec1ac5cc4fe080cf41f7e393b470f2 100644 (file)
@@ -25,7 +25,7 @@ int main(void)
 {
        int fail = 0;
 
-       potato_uart_init();
+       console_init();
 
        print_test_number(1);
        if (dec_test_1() != 0) {
index af0c04bcd7abff311ee8c59108b10d65001cbde3..fbd9634e08fbb25689ea5d7118fce8e979e41af3 100644 (file)
@@ -23,7 +23,7 @@ int main(void)
 {
        int fail = 0;
 
-       potato_uart_init();
+       console_init();
 
        print_test_number(1);
        if (ill_test_1() != 0) {
index 0b9079c2d4be42a99cdc3b909196ac0ad3e31f2d..f96203e034e8bbecd42b69f5b244bfec3510b468 100644 (file)
@@ -24,7 +24,7 @@ int main(void)
 {
        int fail = 0;
 
-       potato_uart_init();
+       console_init();
 
        print_test_number(1);
        if (test_addpcis_1() != 0) {
index a5d086b9afcd65da58161b6e71e564f4f1bf992b..b91a85238f1619b2d47b598c70a3f43a045bd486 100644 (file)
@@ -661,7 +661,7 @@ void do_test(int num, int (*test)(void))
 
 int main(void)
 {
-       potato_uart_init();
+       console_init();
        init_mmu();
 
        do_test(1, mmu_test_1);
index 98c037c50b8eed30493e0b5df50c1f5bd8bf8163..154e9b4dc87498a595b1c616a42556587e0799a2 100644 (file)
@@ -228,7 +228,7 @@ void do_test(int num, int (*fn)(unsigned long))
 
 int main(void)
 {
-       potato_uart_init();
+       console_init();
        init_mmu();
        map(0x2000, 0x2000, REF | CHG | PERM_RD | PERM_EX);     /* map code page */
        map(0x7000, 0x7000, REF | CHG | PERM_RD | PERM_WR);     /* map stack page */
index a705d19550deecec94d59d600f2a258af70e4fc9..94e17fa65d82b6bdb9fe1eab8acdb8f6ce7cb679 100644 (file)
@@ -23,7 +23,7 @@ int main(void)
 {
        int fail = 0;
 
-       potato_uart_init();
+       console_init();
 
        print_test_number(1);
        if (sc_test_1() != 0) {
index a86774460b624d28ce41b788d64056b0e630432b..97b6539a18f629f09016f9edb69753b03d80506a 100644 (file)
@@ -83,7 +83,7 @@ void ipi_isr(void) {
 void uart_isr(void) {
        debug_puts(UART);
 
-       potato_uart_irq_dis(); // disable interrupt to ack it
+       console_set_irq_en(false, false);
 
        isrs_run |= ISR_UART;
 }
@@ -202,7 +202,7 @@ int xics_test_1(void)
        icp_write8(XICS_XIRR, 0x00); // mask all interrupts
 
        // trigger two interrupts
-       potato_uart_irq_en();        // cause serial interrupt
+       console_set_irq_en(true,true);// cause serial interrupt
        ics_write_xive(0x6, 0);      // set source to prio 6
        icp_write8(XICS_MFRR, 0x04); // cause ipi interrupt at prio 5
 
@@ -222,7 +222,7 @@ int xics_test_1(void)
 
        // cleanup
        icp_write8(XICS_XIRR, 0x00); // mask all interrupts
-       potato_uart_irq_dis();
+       console_set_irq_en(false, false);
        ics_write_xive(0, 0xff);
        isrs_run = 0;
 
@@ -242,7 +242,7 @@ int xics_test_2(void)
        assert(isrs_run == 0);
 
        // trigger both
-       potato_uart_irq_en(); // cause 0x500 interrupt
+       console_set_irq_en(true, true);
        icp_write8(XICS_MFRR, 0x05); // cause 0x500 interrupt
 
        delay();
@@ -250,7 +250,7 @@ int xics_test_2(void)
 
        // cleanup
        icp_write8(XICS_XIRR, 0x00); // mask all interrupts
-       potato_uart_irq_dis();
+       console_set_irq_en(false, false);
        isrs_run = 0;
 
        return 0;
@@ -307,7 +307,7 @@ int main(void)
        int i = 0;
        int (*t)(void);
 
-       potato_uart_init();
+       console_init();
        ipi_running = false;
 
        /* run the tests */