summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/LINKS.TODO8
-rw-r--r--doc/README.CrossCompiling4
-rw-r--r--src/kernel/console.c45
-rw-r--r--src/kernel/console.h3
-rw-r--r--src/kernel/kernel.c15
-rw-r--r--src/net/ipv4.h2
6 files changed, 69 insertions, 8 deletions
diff --git a/doc/LINKS.TODO b/doc/LINKS.TODO
index 5686ec6..9659164 100644
--- a/doc/LINKS.TODO
+++ b/doc/LINKS.TODO
@@ -1,3 +1,5 @@
+other projects
+
https://github.com/cs107e/cs107e.github.io
http://wiki.osdev.org/Calling_Conventions
http://wiki.osdev.org/Linker_Scripts
@@ -12,6 +14,10 @@ http://x86.renejeschke.de/html/file_module_x86_id_139.html
http://retired.beyondlogic.org/serial/serial1.htm
https://pdos.csail.mit.edu/6.828/2014/reference.html
+other projects
+
+https://bitbucket.org/adamholisky/versionone
+
tutorials:
https://littleosbook.github.io
@@ -130,3 +136,5 @@ http://wiki.osdev.org/Address_Resolution_Protocol
Syscalls:
AX, BX software interrupt 0x80, classic Linux/DOS/Windows syscalls
+UTP/Netconsole:
+https://www.cyberciti.biz/tips/linux-netconsole-log-management-tutorial.html
diff --git a/doc/README.CrossCompiling b/doc/README.CrossCompiling
index 74f31ce..a0d381a 100644
--- a/doc/README.CrossCompiling
+++ b/doc/README.CrossCompiling
@@ -2,11 +2,11 @@ Intro
-----
You can compile AbaOS from a 32-bit host or chroot (e.g. Arch32 chroot).
-But you have to be extremly careful that nothing ceeps into the kernel
+But you have to be extremly careful that nothing creeps into the kernel
from the host system.
You can also create a cross-compilation environment. Now, we don't need
-a full fledged chain, linker and C compiler is enough. AbaOs has a small
+a full-fledged chain, linker and C compiler is enough. AbaOs has a small
integrated C library which is sufficient to build the kernel.
gcc
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 );
+ }
}
diff --git a/src/kernel/console.h b/src/kernel/console.h
index a1c55ac..2c08b78 100644
--- a/src/kernel/console.h
+++ b/src/kernel/console.h
@@ -3,15 +3,18 @@
#include "vgatext.h"
#include "serial.h"
+#include "network.h"
typedef struct {
vga_text_t *vga_text;
serial_t *serial;
+ network_t *network;
} console_t;
void console_init( console_t *console );
void console_add_vga_text_output( console_t *console, vga_text_t *vga_text );
void console_add_serial_output( console_t *console, serial_t *serial );
+void console_add_network_output( console_t *console, network_t *network );
void console_put_char( console_t *console, const char c );
void console_put_string( console_t *console, const char *s );
void console_put_newline( console_t *console );
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
index e431327..11d35ce 100644
--- a/src/kernel/kernel.c
+++ b/src/kernel/kernel.c
@@ -49,6 +49,7 @@ typedef enum {
typedef struct {
vga_text_t vga_text;
+ console_t console;
driver_manager_t driver_manager;
task_manager_t task_manager;
memory_manager_t memory_manager;
@@ -85,13 +86,12 @@ void kernel_main( void )
vga_text_set_color( &global_context.vga_text, VGA_TEXT_COLOR_LIGHT_GREY );
vga_text_set_background_color( &global_context.vga_text, VGA_TEXT_COLOR_BLACK );
- console_t console;
- console_init( &console );
- console_add_vga_text_output( &console, &global_context.vga_text );
- console_add_serial_output( &console, &serial );
+ console_init( &global_context.console );
+ console_add_vga_text_output( &global_context.console, &global_context.vga_text );
+ console_add_serial_output( &global_context.console, &serial );
// initialize the early console of the kernel
- __stdio_set_console( &console );
+ __stdio_set_console( &global_context.console );
puts( "Started early kernel console" );
// TODO: get those values somehow from the boot loader
printf( "Kernel code and data is at 0x%X, kernel stack at 0x%X\n", 0x8800, 0x90000 );
@@ -482,6 +482,11 @@ void handle_network_event( network_event_t *event, void *context )
src_mac_addr, dst_mac_addr, src_ip, dst_ip, arp->operation >> 8 );
// TODO: remember the address mapping
+
+ // enable network logging
+ // TODO: for now we sent back to the machine sending us the first ARP request,
+ // whether or not that one is listing to funny UDP console packets or not.. :-)
+ console_add_network_output( &global_context.console, global_context.network );
// send answer
packet->header.dst_addr = arp->source_hardware_address;
diff --git a/src/net/ipv4.h b/src/net/ipv4.h
index 95dec18..58b1136 100644
--- a/src/net/ipv4.h
+++ b/src/net/ipv4.h
@@ -22,7 +22,7 @@ typedef struct {
typedef uint8_t network_ipv4_protocol_t;
-// TODO: network order not host oder, so for now swap it
+// TODO: network order not host order, so for now swap it
#define NETWORK_IPV4_PROTOCOL_ICMP (network_ipv4_protocol_t)0x01
#define NETWORK_IPV4_PROTOCOL_UDP (network_ipv4_protocol_t)0x11