console: Cleanup console API

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>
pull/213/head
Benjamin Herrenschmidt 5 years ago
parent 7575b1e0c2
commit e3941109af

Binary file not shown.

@ -7,7 +7,7 @@

int main(void)
{
potato_uart_init();
console_init();

puts(HELLO_WORLD);


Binary file not shown.

@ -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

@ -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);

@ -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

@ -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);
}

@ -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");


@ -25,7 +25,7 @@ void init_bss()
int main(void)
{
init_bss();
potato_uart_init();
console_init();

puts(HELLO_WORLD);


@ -25,7 +25,7 @@ int main(void)
{
int fail = 0;

potato_uart_init();
console_init();

print_test_number(1);
if (dec_test_1() != 0) {

@ -23,7 +23,7 @@ int main(void)
{
int fail = 0;

potato_uart_init();
console_init();

print_test_number(1);
if (ill_test_1() != 0) {

@ -24,7 +24,7 @@ int main(void)
{
int fail = 0;

potato_uart_init();
console_init();

print_test_number(1);
if (test_addpcis_1() != 0) {

@ -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);

@ -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 */

@ -23,7 +23,7 @@ int main(void)
{
int fail = 0;

potato_uart_init();
console_init();

print_test_number(1);
if (sc_test_1() != 0) {

@ -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 */

Loading…
Cancel
Save