summaryrefslogtreecommitdiff
path: root/src/kernel/console.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2018-01-05 20:52:57 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2018-01-05 20:52:57 +0100
commit8f3c73740a30ad02a594e21a52d47aa4ae9efe91 (patch)
tree3507da836c7a346371a1af8bbcfd56fb1dd707bf /src/kernel/console.c
parent24de320bb1d63beefd5bc89c97b4ad727d8e05e7 (diff)
downloadabaos-8f3c73740a30ad02a594e21a52d47aa4ae9efe91.tar.gz
abaos-8f3c73740a30ad02a594e21a52d47aa4ae9efe91.tar.bz2
some preliminary work on an UDP netconsole
Diffstat (limited to 'src/kernel/console.c')
-rw-r--r--src/kernel/console.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/kernel/console.c b/src/kernel/console.c
index 04fb44f..bf83fec 100644
--- a/src/kernel/console.c
+++ b/src/kernel/console.c
@@ -9,6 +9,7 @@ void console_init( console_t *console )
console->vga_text = NULL;
console->serial = NULL;
+ console->network = NULL;
}
void console_add_vga_text_output( console_t *console, vga_text_t *vga_text )
@@ -21,6 +22,37 @@ void console_add_serial_output( console_t *console, serial_t *serial )
console->serial = serial;
}
+void console_add_network_output( console_t *console, network_t *network )
+{
+ console->network = network;
+}
+
+static void send_via_udp( network_t *network, const char *s, size_t n )
+{
+ //~ network_ethernet_packet_t *packet = (network_ethernet_packet_t *)event->buf.data;
+
+ //~ network_mac_address_t dst_addr;
+ //~ network_mac_address_t src_addr;
+ //~ network_ether_type_t type;
+//~ } __attribute__( ( packed ) ) network_ethernet_packet_header_t;
+//~ typedef struct {
+ //~ network_ethernet_packet_header_t header;
+ //~ uint8_t *data;
+//~ } __attribute__( ( packed ) ) network_ethernet_packet_t;
+
+ //~ packet->header.dst_addr = arp->source_hardware_address;
+ //~ packet->header.src_addr = global_context.network->mac_address;
+ //~ arp->operation = ARP_OPERATION_ANSWER;
+ //~ arp->destination_hardware_address = arp->source_hardware_address;
+ //~ arp->source_hardware_address = global_context.network->mac_address;
+ //~ network_ipv4_address_t tmp = arp->destination_protocol_address;
+ //~ arp->destination_protocol_address = arp->source_protocol_address;
+ //~ arp->source_protocol_address = tmp;
+ //~ event->buf.length = sizeof( network_ethernet_packet_header_t ) + sizeof( network_arp_packet_t );
+
+ //~ ((network_vtable_t *)( global_context.network->base.vtable ))->send( global_context.network, event->buf );
+}
+
void console_put_char( console_t *console, const char c )
{
if( console->vga_text != NULL ) {
@@ -30,6 +62,10 @@ void console_put_char( console_t *console, const char c )
if( console->serial != NULL ) {
serial_put_char( console->serial, c );
}
+
+ if( console->network != NULL ) {
+ send_via_udp( console->network, &c, 1 );
+ }
}
void console_put_string( console_t *console, const char *s )
@@ -41,6 +77,10 @@ void console_put_string( console_t *console, const char *s )
if( console->serial != NULL ) {
serial_put_string( console->serial, s );
}
+
+ if( console->network != NULL ) {
+ send_via_udp( console->network, s, strlen( s ) );
+ }
}
void console_put_newline( console_t *console )
@@ -58,4 +98,9 @@ void console_put_newline( console_t *console )
if( console->serial != NULL ) {
serial_put_newline( console->serial );
}
+
+ if( console->network != NULL ) {
+ char c = '\n';
+ send_via_udp( console->network, &c, 1 );
+ }
}