Hello HelenOS developers,
My name is Jakub Klama and I'm 24 years old developer studying
on Jagiellonian University, Poland who loves working on embedded.
I'm official FreeBSD committer, working mainly on FreeBSD ARM and
MIPS ports. I'm author of two FreeBSD ports: for TI DaVinci SoC
family (ARM9) and LPC EA32x0 SoC family (ARM9 too).
I was taking part in Google Summer of Code in 2010, 2011
and 2012[1]. This year I've found exciting project at HelenOS
project ideas for SOCIS 2013 - that is, porting HelenOS
to SPARC LEON.
I have minimal experience with SPARC architecture and only
a little with FPGA and VHDL (at least, I can read VHDL code),
but I think that this project will be ideal opportunity to learn
something new in that areas - and of course in microkernel
design.
At this moment, I'm doing research and writing SOCIS proposal
which will be ready in few days (so I wish I could get
some feedback on this proposal before submission deadline).
My current research focuses on:
* Preparing development environment:
There's only one free emulator for LEON - qemu-sparc, both
"official" emulators - TSIM and GRSIM from Gaisler are on
paid licenses. TSIM evaluation version works only for 2^32
clock cycles, making it virtually useless. There's also EGOS
but I'm unsure about licensing.
FPGA boards capable of running LEON - I'm looking for board
which will met LEON2 with at least PIC, Timers nad UART requirements
and will not be too expensive.
* reading SPARC V8 and V9 specifications from
http://www.sparc.org/standards/V8.pdf and
http://www.sparc.org/standards/SPARCV9.pdf respectively.
* digging in to HelenOS sparc64 implementatin and MMU code.
* giving LEON on qemu test drive with u-boot.
* scope of the work. Am I right that support for Timer, UART
and interrupt controller IP Cores is sufficent to run
HelenOS?
I've attached my qualifying patch - it's addressed to issue #457.
It fixes -r switch for ping and adds -n <count> switch, which means
number
of ICMP requests to be sent. It also brings getopt to parse
command-line
parameters.
My bzr identity: "Jakub Klama <[email protected]>"
Please let me know if patch is OK, or I done something wrong. :)
Any hints or information about this project idea (previous work in
this area, if exists, etc) is of course greatly appreciated too!
Best Regards,
Jakub
--
[1] - http://czlug.icis.pcz.pl/~jceel/cv.pdf
=== modified file 'uspace/app/ping/ping.c'
--- uspace/app/ping/ping.c 2013-07-19 13:23:00 +0000
+++ uspace/app/ping/ping.c 2013-07-25 00:53:13 +0000
@@ -41,8 +41,10 @@
#include <inet/addr.h>
#include <inet/inetping.h>
#include <io/console.h>
+#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
+#include <str.h>
#include <sys/types.h>
#define NAME "ping"
@@ -59,6 +61,10 @@
static FIBRIL_CONDVAR_INITIALIZE(done_cv);
static FIBRIL_MUTEX_INITIALIZE(done_lock);
+static bool quit = false;
+static FIBRIL_CONDVAR_INITIALIZE(quit_cv);
+static FIBRIL_MUTEX_INITIALIZE(quit_lock);
+
static inetping_ev_ops_t ev_ops = {
.recv = ping_ev_recv
};
@@ -66,11 +72,13 @@
static addr32_t src;
static addr32_t dest;
-static bool ping_repeat = false;
+static int ping_repeat_count = 1;
+
+static const char *short_options = "rn:";
static void print_syntax(void)
{
- printf("syntax: " NAME " [-r] <host>\n");
+ printf("syntax: " NAME " [-n <count>|-r] <host>\n");
}
static void ping_signal_done(void)
@@ -81,6 +89,14 @@
fibril_condvar_broadcast(&done_cv);
}
+static void ping_quit(void)
+{
+ fibril_mutex_lock(&quit_lock);
+ quit = true;
+ fibril_mutex_unlock(&quit_lock);
+ fibril_condvar_broadcast(&quit_cv);
+}
+
static int ping_ev_recv(inetping_sdu_t *sdu)
{
inet_addr_t src_addr;
@@ -104,8 +120,7 @@
printf("Received ICMP echo reply: from %s to %s, seq. no %u, "
"payload size %zu\n", asrc, adest, sdu->seq_no, sdu->size);
- if (!ping_repeat)
- ping_signal_done();
+ ping_signal_done();
free(asrc);
free(adest);
@@ -134,20 +149,32 @@
static int transmit_fibril(void *arg)
{
+ int rc;
uint16_t seq_no = 0;
- while (true) {
+ while (ping_repeat_count--) {
+ fibril_mutex_lock(&quit_lock);
+ if (quit) {
+ fibril_mutex_unlock(&quit_lock);
+ return 0;
+ }
+ fibril_mutex_unlock(&quit_lock);
+
+ (void) ping_send(++seq_no);
+
fibril_mutex_lock(&done_lock);
- if (done) {
- fibril_mutex_unlock(&done_lock);
- return 0;
- }
+ rc = fibril_condvar_wait_timeout(&done_cv, &done_lock,
+ PING_TIMEOUT);
fibril_mutex_unlock(&done_lock);
- (void) ping_send(++seq_no);
- async_usleep(PING_DELAY);
+ if (rc == ETIMEOUT)
+ printf(NAME ": Echo request timed out.\n");
+
+ if (ping_repeat_count != 0)
+ async_usleep(PING_DELAY);
}
+ ping_quit();
return 0;
}
@@ -168,7 +195,7 @@
0 && (ev.ev.key.mods & KM_CTRL) != 0) {
/* Ctrl+key */
if (ev.ev.key.key == KC_Q) {
- ping_signal_done();
+ ping_quit();
return 0;
}
}
@@ -183,8 +210,8 @@
char *asrc = NULL;
char *adest = NULL;
char *sdest = NULL;
+ char c;
int rc;
- int argi;
rc = inetping_init(&ev_ops);
if (rc != EOK) {
@@ -193,27 +220,35 @@
goto error;
}
- argi = 1;
- if (argi < argc && str_cmp(argv[argi], "-r") == 0) {
- ping_repeat = true;
- ++argi;
- } else {
- ping_repeat = false;
+ while ((c = getopt(argc, argv, short_options)) != -1) {
+ switch (c) {
+ case 'r':
+ ping_repeat_count = -1;
+ break;
+ case 'n':
+ ping_repeat_count = strtoul(optarg, NULL, 10);
+ break;
+ default:
+ printf(NAME ": Unknown option passed.\n");
+ print_syntax();
+ goto error;
+ }
}
- if (argc - argi != 1) {
+ if (optind >= argc) {
+ printf(NAME ": IP address or host name not supplied.\n");
print_syntax();
goto error;
}
/* Parse destination address */
inet_addr_t dest_addr;
- rc = inet_addr_parse(argv[argi], &dest_addr);
+ rc = inet_addr_parse(argv[optind], &dest_addr);
if (rc != EOK) {
/* Try interpreting as a host name */
- rc = dnsr_name2host(argv[argi], &hinfo, AF_INET);
+ rc = dnsr_name2host(argv[optind], &hinfo, AF_INET);
if (rc != EOK) {
- printf(NAME ": Error resolving host '%s'.\n", argv[argi]);
+ printf(NAME ": Error resolving host '%s'.\n", argv[optind]);
goto error;
}
@@ -223,7 +258,7 @@
uint16_t af = inet_addr_get(&dest_addr, &dest, NULL);
if (af != AF_INET) {
printf(NAME ": Destination '%s' is not an IPv4 address.\n",
- argv[argi]);
+ argv[optind]);
goto error;
}
@@ -265,38 +300,28 @@
fid_t fid;
- if (ping_repeat) {
- fid = fibril_create(transmit_fibril, NULL);
- if (fid == 0) {
- printf(NAME ": Failed creating transmit fibril.\n");
- goto error;
- }
-
- fibril_add_ready(fid);
-
- fid = fibril_create(input_fibril, NULL);
- if (fid == 0) {
- printf(NAME ": Failed creating input fibril.\n");
- goto error;
- }
-
- fibril_add_ready(fid);
- } else {
- ping_send(1);
- }
-
- fibril_mutex_lock(&done_lock);
+ fid = fibril_create(transmit_fibril, NULL);
+ if (fid == 0) {
+ printf(NAME ": Failed creating transmit fibril.\n");
+ goto error;
+ }
+
+ fibril_add_ready(fid);
+
+ fid = fibril_create(input_fibril, NULL);
+ if (fid == 0) {
+ printf(NAME ": Failed creating input fibril.\n");
+ goto error;
+ }
+
+ fibril_add_ready(fid);
+
+ fibril_mutex_lock(&quit_lock);
rc = EOK;
- while (!done && rc != ETIMEOUT) {
- rc = fibril_condvar_wait_timeout(&done_cv, &done_lock,
- ping_repeat ? 0 : PING_TIMEOUT);
- }
- fibril_mutex_unlock(&done_lock);
+ while (!quit && rc != ETIMEOUT)
+ rc = fibril_condvar_wait_timeout(&quit_cv, &quit_lock, 0);
- if (rc == ETIMEOUT) {
- printf(NAME ": Echo request timed out.\n");
- goto error;
- }
+ fibril_mutex_unlock(&quit_lock);
free(asrc);
free(adest);
_______________________________________________
HelenOS-devel mailing list
[email protected]
http://lists.modry.cz/listinfo/helenos-devel