Changeset View
Changeset View
Standalone View
Standalone View
sys/powerpc/powernv/opal_console.c
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | uart_opal_real_unmap_outbuffer(uint64_t *len) | ||||
if (!pmap_bootstrapped) | if (!pmap_bootstrapped) | ||||
return; | return; | ||||
mtx_assert(&opalcons_buffer.mtx, MA_OWNED); | mtx_assert(&opalcons_buffer.mtx, MA_OWNED); | ||||
*len = opalcons_buffer.size; | *len = opalcons_buffer.size; | ||||
mtx_unlock_spin(&opalcons_buffer.mtx); | mtx_unlock_spin(&opalcons_buffer.mtx); | ||||
} | } | ||||
static int64_t | |||||
uart_opal_console_write_buffer_space(int vtermid) | |||||
{ | |||||
int64_t buffer_space_val = 0; | |||||
vm_paddr_t buffer_space_ptr; | |||||
if (pmap_bootstrapped) | |||||
buffer_space_ptr = vtophys(&buffer_space_val); | |||||
else | |||||
buffer_space_ptr = (vm_paddr_t)&buffer_space_val; | |||||
luporl: It's better to cast the address to the same type of variable you're using: vm_paddr_t | |||||
if (opal_call(OPAL_CONSOLE_WRITE_BUFFER_SPACE, vtermid, | |||||
buffer_space_ptr) != OPAL_SUCCESS) | |||||
Done Inline Actionsstyle: this line should be indented with 4 extra spaces from where the above 'if' column begins. luporl: style: this line should be indented with 4 extra spaces from where the above 'if' column begins. | |||||
return (-1); | |||||
return (be64toh(buffer_space_val)); | |||||
} | |||||
static int | static int | ||||
uart_opal_probe_node(struct uart_opal_softc *sc) | uart_opal_probe_node(struct uart_opal_softc *sc) | ||||
{ | { | ||||
phandle_t node = sc->node; | phandle_t node = sc->node; | ||||
uint32_t reg; | uint32_t reg; | ||||
char buf[64]; | char buf[64]; | ||||
sc->inbuflen = 0; | sc->inbuflen = 0; | ||||
▲ Show 20 Lines • Show All 233 Lines • ▼ Show 20 Lines | if (sc->protocol == OPAL_RAW) { | ||||
*(uint64_t*)olen = be64toh(*(uint64_t*)olen); | *(uint64_t*)olen = be64toh(*(uint64_t*)olen); | ||||
uart_opal_real_unmap_outbuffer(&len); | uart_opal_real_unmap_outbuffer(&len); | ||||
uart_unlock(&sc->sc_mtx); | uart_unlock(&sc->sc_mtx); | ||||
len -= 4; | len -= 4; | ||||
} | } | ||||
#if 0 | if (err == OPAL_SUCCESS) | ||||
if (err != OPAL_SUCCESS) | |||||
len = 0; | |||||
#endif | |||||
return (len); | return (len); | ||||
else if (err == OPAL_BUSY_EVENT) | |||||
return(0); | |||||
return (-1); | |||||
} | } | ||||
static int | static int | ||||
uart_opal_cngetc(struct consdev *cp) | uart_opal_cngetc(struct consdev *cp) | ||||
{ | { | ||||
return (uart_opal_getc(cp->cn_arg)); | return (uart_opal_getc(cp->cn_arg)); | ||||
} | } | ||||
Show All 39 Lines | |||||
} | } | ||||
static void | static void | ||||
uart_opal_ttyoutwakeup(struct tty *tp) | uart_opal_ttyoutwakeup(struct tty *tp) | ||||
{ | { | ||||
struct uart_opal_softc *sc; | struct uart_opal_softc *sc; | ||||
char buffer[8]; | char buffer[8]; | ||||
int len; | int len; | ||||
int64_t buffer_space; | |||||
sc = tty_softc(tp); | sc = tty_softc(tp); | ||||
while ((len = ttydisc_getc(tp, buffer, sizeof(buffer))) != 0) | while ((len = ttydisc_getc(tp, buffer, sizeof(buffer))) != 0) { | ||||
uart_opal_put(sc, buffer, len); | int bytes_written = 0; | ||||
while (bytes_written == 0) { | |||||
buffer_space = uart_opal_console_write_buffer_space(sc->vtermid); | |||||
if (buffer_space == -1) | |||||
/* OPAL failure or invalid terminal */ | |||||
break; | |||||
Done Inline ActionsWouldn't it be better to break instead of returning, to keep the handling of everything available in ttydisc? luporl: Wouldn't it be better to break instead of returning, to keep the handling of everything… | |||||
Done Inline ActionsCurrently it should return an error only if terminal is invalid, and in this case doesn't make sense to process pending data. But since I made uart_opal_console_write_buffer_space() generic in terms of error handling and to keep consistent with previous code, I agree with your suggestion, thanks! alfredo: Currently it should return an error only if terminal is invalid, and in this case doesn't make… | |||||
else if (buffer_space >= len) | |||||
bytes_written = uart_opal_put(sc, buffer, len); | |||||
if (bytes_written == 0) | |||||
/* OPAL must be busy, poll and retry */ | |||||
opal_call(OPAL_POLL_EVENTS, NULL); | |||||
else if (bytes_written == -1) | |||||
/* OPAL failure or invalid terminal */ | |||||
break; | |||||
Done Inline ActionsFor the same reasons above and for consistency, it would be better to change this return to a break too. luporl: For the same reasons above and for consistency, it would be better to change this return to a… | |||||
} | |||||
} | |||||
} | } | ||||
static void | static void | ||||
uart_opal_intr(void *v) | uart_opal_intr(void *v) | ||||
{ | { | ||||
struct uart_opal_softc *sc = v; | struct uart_opal_softc *sc = v; | ||||
struct tty *tp = sc->tp; | struct tty *tp = sc->tp; | ||||
int c; | int c; | ||||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |
It's better to cast the address to the same type of variable you're using: vm_paddr_t