Commit 0d33ac29 authored by Adam Wujek's avatar Adam Wujek

lib/netconsole: make netconsole to use console API not simple_uart

Signed-off-by: 's avatarAdam Wujek <dev_public@wujek.eu>
parent 9d5ed1ee
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
* *
* Released according to the GNU GPL, version 2 or any later version. * Released according to the GNU GPL, version 2 or any later version.
*/ */
#include <netconsole.h>
#ifndef __BOARD_WRC_H #ifndef __BOARD_WRC_H
#define __BOARD_WRC_H #define __BOARD_WRC_H
/* /*
...@@ -61,7 +64,7 @@ ...@@ -61,7 +64,7 @@
#undef CONFIG_DISALLOW_LONG_DIVISION #undef CONFIG_DISALLOW_LONG_DIVISION
#define BOARD_MAX_CONSOLE_DEVICES 1 #define BOARD_MAX_CONSOLE_DEVICES (1 + HAS_NETCONSOLE)
#define CONSOLE_UART_BAUDRATE 115200 #define CONSOLE_UART_BAUDRATE 115200
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "board.h" #include "board.h"
#include "dev/simple_uart.h" #include "dev/simple_uart.h"
#include "dev/console.h" #include "dev/console.h"
#include <netconsole.h>
static int puts_direct = 0; static int puts_direct = 0;
...@@ -30,6 +31,7 @@ struct console_uart_priv_data ...@@ -30,6 +31,7 @@ struct console_uart_priv_data
static struct console_uart_priv_data console_uart_priv; static struct console_uart_priv_data console_uart_priv;
struct console_device console_uart_dev; struct console_device console_uart_dev;
struct console_device* console_devs[BOARD_MAX_CONSOLE_DEVICES]; struct console_device* console_devs[BOARD_MAX_CONSOLE_DEVICES];
static struct console_device console_netconsole_dev;
#define CON_ESCAPE_CODE 0x1b #define CON_ESCAPE_CODE 0x1b
#define CON_SWITCH_BINARY_CODE 'B' #define CON_SWITCH_BINARY_CODE 'B'
...@@ -271,6 +273,23 @@ void console_ipmi_init( ) ...@@ -271,6 +273,23 @@ void console_ipmi_init( )
#endif #endif
static int con_netconsole_getc(struct console_device* dev)
{
return netconsole_read_byte();
}
static int con_netconsole_put_string(struct console_device* dev, const char *s)
{
return netconsole_write_string(s);
}
static void console_netconsole_init(void)
{
console_netconsole_dev.get_char = con_netconsole_getc;
console_netconsole_dev.put_string = con_netconsole_put_string;
console_register_device( &console_netconsole_dev );
}
int puts(const char *s) int puts(const char *s)
{ {
if( puts_direct) if( puts_direct)
...@@ -334,6 +353,9 @@ void console_init() ...@@ -334,6 +353,9 @@ void console_init()
console_ipmi_init(); console_ipmi_init();
#endif #endif
if (HAS_NETCONSOLE)
console_netconsole_init();
pp_printf("Console UART FIFO:: %d\n", suart_is_fifo_supported( &console_uart_priv.uart_dev ) ); pp_printf("Console UART FIFO:: %d\n", suart_is_fifo_supported( &console_uart_priv.uart_dev ) );
} }
......
...@@ -18,16 +18,6 @@ ...@@ -18,16 +18,6 @@
( ((( (unsigned long long)baudrate * 8ULL) << (16 - 7)) + \ ( ((( (unsigned long long)baudrate * 8ULL) << (16 - 7)) + \
(CPU_CLOCK >> 8)) / (CPU_CLOCK >> 7) ) (CPU_CLOCK >> 8)) / (CPU_CLOCK >> 7) )
#ifdef CONFIG_NETCONSOLE
#define HAS_NETCONSOLE 1
int netconsole_read_byte(void);
int netconsole_write_string(const char *);
#else
#define HAS_NETCONSOLE 0
static int netconsole_read_byte(void) {return -1;}
static int netconsole_write_string(const char *s) {return -1;}
#endif
static inline uint32_t suart_calc_baud( int baudrate ) static inline uint32_t suart_calc_baud( int baudrate )
{ {
uint64_t n = (((uint64_t) (baudrate)) << 12 ) + (CPU_CLOCK >> 8); uint64_t n = (((uint64_t) (baudrate)) << 12 ) + (CPU_CLOCK >> 8);
...@@ -59,8 +49,6 @@ int suart_write_string(struct simple_uart_device *dev, const char *s) ...@@ -59,8 +49,6 @@ int suart_write_string(struct simple_uart_device *dev, const char *s)
{ {
const char *t = s; const char *t = s;
if (HAS_NETCONSOLE)
netconsole_write_string(s);
while (*s) while (*s)
suart_write_byte(dev, *(s++)); suart_write_byte(dev, *(s++));
return s - t; return s - t;
...@@ -85,12 +73,6 @@ int suart_poll(struct simple_uart_device *dev) ...@@ -85,12 +73,6 @@ int suart_poll(struct simple_uart_device *dev)
int suart_read_byte(struct simple_uart_device *dev) int suart_read_byte(struct simple_uart_device *dev)
{ {
int ret;
/* check if there is anything from netconsole first */
if (HAS_NETCONSOLE && (ret = netconsole_read_byte()) >= 0)
return ret;
if (!suart_poll(dev)) if (!suart_poll(dev))
return -1; return -1;
......
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
#ifndef __NETCONSOLE_H__ #ifndef __NETCONSOLE_H__
#define __NETCONSOLE_H__ #define __NETCONSOLE_H__
#ifdef CONFIG_NETCONSOLE
#define HAS_NETCONSOLE 1
#else
#define HAS_NETCONSOLE 0
#endif
#define NETCONSOLE_ENABLED 1 #define NETCONSOLE_ENABLED 1
#define NETCONSOLE_DISABLED 2 #define NETCONSOLE_DISABLED 2
#define NETCONSOLE_WAIT 3 #define NETCONSOLE_WAIT 3
......
...@@ -36,7 +36,7 @@ struct wr_sockaddr netconsole_sock_addr; ...@@ -36,7 +36,7 @@ struct wr_sockaddr netconsole_sock_addr;
int netconsole_status = NETCONSOLE_DEF_VAL; int netconsole_status = NETCONSOLE_DEF_VAL;
struct wr_udp_addr netconsole_udp_addr; struct wr_udp_addr netconsole_udp_addr;
/* init for netconsole task */
void netconsole_init(void) void netconsole_init(void)
{ {
netconsole_socket = ptpd_netif_create_socket( netconsole_socket = ptpd_netif_create_socket(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment