Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87fa72d
commit cd17c31
Showing
35 changed files
with
1,950 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# | ||
# Copyright 2017, Data61 | ||
# Commonwealth Scientific and Industrial Research Organisation (CSIRO) | ||
# ABN 41 687 119 230. | ||
# | ||
# This software may be distributed and modified according to the terms of | ||
# the BSD 2-Clause license. Note that NO WARRANTY is provided. | ||
# See "LICENSE_BSD2.txt" for details. | ||
# | ||
# @TAG(DATA61_BSD) | ||
# | ||
|
||
|
||
|
||
apps-$(CONFIG_APP_RUMPRUN_ETHERNET) += rumprun_ethernet | ||
rumprun_ethernet: rumprun libsel4muslccamkes libsel4camkes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# | ||
# Copyright 2017, Data61 | ||
# Commonwealth Scientific and Industrial Research Organisation (CSIRO) | ||
# ABN 41 687 119 230. | ||
# | ||
# This software may be distributed and modified according to the terms of | ||
# the BSD 2-Clause license. Note that NO WARRANTY is provided. | ||
# See "LICENSE_BSD2.txt" for details. | ||
# | ||
# @TAG(DATA61_BSD) | ||
# | ||
|
||
|
||
|
||
config APP_RUMPRUN_ETHERNET | ||
bool "rumprun ethernet CAmkES application" | ||
default n | ||
help | ||
A simple rumprun app that reverses strings over a TCP connection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# | ||
# Copyright 2017, Data61 | ||
# Commonwealth Scientific and Industrial Research Organisation (CSIRO) | ||
# ABN 41 687 119 230. | ||
# | ||
# This software may be distributed and modified according to the terms of | ||
# the BSD 2-Clause license. Note that NO WARRANTY is provided. | ||
# See "LICENSE_BSD2.txt" for details. | ||
# | ||
# @TAG(DATA61_BSD) | ||
# | ||
|
||
TARGETS := $(notdir ${SOURCE_DIR}).cdl | ||
ADL := rumprun_ethernet.camkes | ||
TEMPLATES += ../../projects/global-components/templates | ||
|
||
PROJECT_BASE := $(PWD) | ||
RUMPRUN_BASE_DIR := $(PWD)/libs/rumprun | ||
|
||
|
||
all: default | ||
|
||
include TimeServer/TimeServer.mk | ||
include SerialServer/SerialServer.mk | ||
include PCIConfigIO/PCIConfigIO.mk | ||
|
||
include ${SOURCE_DIR}/components/rump_ether/rump_ether.mk | ||
include ${SOURCE_DIR}/components/reverse_string/server.mk | ||
|
||
|
||
|
||
include ${PWD}/tools/camkes/camkes.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!-- | ||
Copyright 2017, Data61 | ||
Commonwealth Scientific and Industrial Research Organisation (CSIRO) | ||
ABN 41 687 119 230. | ||
|
||
This software may be distributed and modified according to the terms of | ||
the BSD 2-Clause license. Note that NO WARRANTY is provided. | ||
See "LICENSE_BSD2.txt" for details. | ||
|
||
@TAG(DATA61_BSD) | ||
--> | ||
|
||
This application demonstrates a simple TCP echo program that runs in a | ||
rumprun unikernel instance on CAmkES on seL4. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2017, Data61 | ||
* Commonwealth Scientific and Industrial Research Organisation (CSIRO) | ||
* ABN 41 687 119 230. | ||
* | ||
* This software may be distributed and modified according to the terms of | ||
* the BSD 2-Clause license. Note that NO WARRANTY is provided. | ||
* See "LICENSE_BSD2.txt" for details. | ||
* | ||
* @TAG(DATA61_BSD) | ||
*/ | ||
|
||
#include <camkes.h> | ||
#include <buffer.h> | ||
#include <string.h> | ||
#include <stdio.h> | ||
|
||
int run(void) { | ||
|
||
char *buffer_str = (char*)buffer; | ||
while(true) { | ||
/* Wait for event */ | ||
ev_wait(); | ||
printf("Got string: %s\n", buffer_str); | ||
|
||
int len = strnlen(buffer_str, REVERSE_STRING_MAX_LEN); | ||
for (int i = 0; i < len / 2; ++i) { | ||
int swap_idx = len - i - 1; | ||
char tmp = buffer_str[i]; | ||
buffer_str[i] = buffer_str[swap_idx]; | ||
buffer_str[swap_idx] = tmp; | ||
} | ||
|
||
/* Signal to client that we are finished */ | ||
ev1_emit(); | ||
} | ||
|
||
return 0; | ||
} |
22 changes: 22 additions & 0 deletions
22
apps/rumprun_ethernet/components/reverse_string/server.camkes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
/* | ||
* Copyright 2017, Data61 | ||
* Commonwealth Scientific and Industrial Research Organisation (CSIRO) | ||
* ABN 41 687 119 230. | ||
* | ||
* This software may be distributed and modified according to the terms of | ||
* the BSD 2-Clause license. Note that NO WARRANTY is provided. | ||
* See "LICENSE_BSD2.txt" for details. | ||
* | ||
* @TAG(DATA61_BSD) | ||
*/ | ||
|
||
#include <buffer.h> | ||
|
||
component Server { | ||
control; | ||
dataport Buf(REVERSE_STRING_BUFSIZE) buffer; | ||
consumes SomethingHappenedEvent ev; | ||
emits SomethingHappenedEvent ev1; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# | ||
# Copyright 2017, Data61 | ||
# Commonwealth Scientific and Industrial Research Organisation (CSIRO) | ||
# ABN 41 687 119 230. | ||
# | ||
# This software may be distributed and modified according to the terms of | ||
# the BSD 2-Clause license. Note that NO WARRANTY is provided. | ||
# See "LICENSE_BSD2.txt" for details. | ||
# | ||
# @TAG(DATA61_BSD) | ||
# | ||
|
||
CURRENT_DIR := $(dir $(abspath $(lastword ${MAKEFILE_LIST}))) | ||
|
||
|
||
Server_CFILES := ${CURRENT_DIR}/server.c | ||
Server_HFILES := $(patsubst ${SOURCE_DIR}/%,%,$(wildcard ${SOURCE_DIR}/include/*.h)) | ||
|
||
CAMKES_FLAGS += --cpp-flag=-I${SOURCE_DIR}/include |
26 changes: 26 additions & 0 deletions
26
apps/rumprun_ethernet/components/rump_ether/rump_ether.camkes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2017, Data61 | ||
* Commonwealth Scientific and Industrial Research Organisation (CSIRO) | ||
* ABN 41 687 119 230. | ||
* | ||
* This software may be distributed and modified according to the terms of | ||
* the BSD 2-Clause license. Note that NO WARRANTY is provided. | ||
* See "LICENSE_BSD2.txt" for details. | ||
* | ||
* @TAG(DATA61_BSD) | ||
*/ | ||
|
||
#include <rumprun_camkes.h> | ||
#include <buffer.h> | ||
|
||
import <rumprun.camkes>; | ||
|
||
component rumprun_ether { | ||
RUMPRUN_COMPONENT_DEFINITION() | ||
uses PCIConfig pci_config; | ||
consumes IRQ eth_irq; | ||
dataport Buf(REVERSE_STRING_BUFSIZE) camkes_buffer; | ||
emits SomethingHappenedEvent camkes_ev; | ||
consumes SomethingHappenedEvent camkes_ev1; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Copyright 2017, Data61 | ||
# Commonwealth Scientific and Industrial Research Organisation (CSIRO) | ||
# ABN 41 687 119 230. | ||
# | ||
# This software may be distributed and modified according to the terms of | ||
# the BSD 2-Clause license. Note that NO WARRANTY is provided. | ||
# See "LICENSE_BSD2.txt" for details. | ||
# | ||
# @TAG(DATA61_BSD) | ||
# | ||
|
||
CURRENT_DIR := $(dir $(abspath $(lastword ${MAKEFILE_LIST}))) | ||
|
||
include ${RUMPRUN_BASE_DIR}/platform/sel4/rumprunlibs.mk | ||
|
||
cfiles := $(wildcard ${CURRENT_DIR}/tcp_server.c) | ||
CAMKES_FLAGS += --cpp-flag=-I${RUMPRUN_BASE_DIR}/platform/sel4/camkes/ | ||
|
||
|
||
rumprun_ether_rumpbin := hello | ||
|
||
hello: $(cfiles) | ||
echo ${CURRENT_DIR} | ||
$(RUMPRUN_CC) -I${CURRENT_DIR}/../../include $^ -o $@ -lpthread | ||
|
112 changes: 112 additions & 0 deletions
112
apps/rumprun_ethernet/components/rump_ether/tcp_server.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/** | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2014 Mathias Buus | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
/* Modifications made by Data61 */ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <sys/types.h> | ||
#include <sys/socket.h> | ||
#include <netinet/in.h> | ||
#include <unistd.h> | ||
#include <buffer.h> | ||
|
||
#define on_error(...) { fprintf(stderr, __VA_ARGS__); fflush(stderr); exit(1); } | ||
|
||
|
||
/* XXX: CAmkES symbols that are linked in after this file is compiled. | ||
They need to be marked as weak and this is the current hacky way it is done */ | ||
extern void *camkes_buffer; | ||
void camkes_ev_emit(void); | ||
void camkes_ev1_wait(void); | ||
#pragma weak camkes_buffer | ||
#pragma weak camkes_ev_emit | ||
#pragma weak camkes_ev1_wait | ||
|
||
|
||
int main (int argc, char *argv[]) { | ||
if (argc < 2) on_error("Usage: %s [port]\n", argv[0]); | ||
|
||
char *buffer_str = (char*)camkes_buffer; | ||
|
||
snprintf(buffer_str, REVERSE_STRING_MAX_LEN, "Hello, World!"); | ||
|
||
printf("Sending string: %s\n", buffer_str); | ||
|
||
/* Signal the string reverse server and wait for response */ | ||
camkes_ev_emit(); | ||
camkes_ev1_wait(); | ||
|
||
printf("%s\n", buffer_str); | ||
|
||
|
||
int port = atoi(argv[1]); | ||
|
||
int server_fd, client_fd, err; | ||
struct sockaddr_in server, client; | ||
char buf[REVERSE_STRING_BUFSIZE]; | ||
|
||
server_fd = socket(AF_INET, SOCK_STREAM, 0); | ||
if (server_fd < 0) on_error("Could not create socket\n"); | ||
|
||
server.sin_family = AF_INET; | ||
server.sin_port = htons(port); | ||
server.sin_addr.s_addr = htonl(INADDR_ANY); | ||
|
||
int opt_val = 1; | ||
setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &opt_val, sizeof opt_val); | ||
|
||
err = bind(server_fd, (struct sockaddr *) &server, sizeof(server)); | ||
if (err < 0) on_error("Could not bind socket\n"); | ||
|
||
err = listen(server_fd, 128); | ||
if (err < 0) on_error("Could not listen on socket\n"); | ||
|
||
printf("Server is listening on %d\n", port); | ||
|
||
/* In a loop we wait for connections from clients */ | ||
while (1) { | ||
socklen_t client_len = sizeof(client); | ||
client_fd = accept(server_fd, (struct sockaddr *) &client, &client_len); | ||
|
||
if (client_fd < 0) on_error("Could not establish new connection\n"); | ||
|
||
/* In a loop we wait for messages from the client, reverse the string | ||
and then respond to the client */ | ||
while (1) { | ||
int read = recv(client_fd, buf, REVERSE_STRING_BUFSIZE, 0); | ||
if (!read) break; // done reading | ||
if (read < 0) on_error("Client read failed\n"); | ||
buf[read] = 0; | ||
snprintf(buffer_str, read +1, buf); | ||
camkes_ev_emit(); | ||
camkes_ev1_wait(); | ||
|
||
err = send(client_fd, buffer_str, read, 0); | ||
if (err < 0) on_error("Client write failed\n"); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright 2017, Data61 | ||
* Commonwealth Scientific and Industrial Research Organisation (CSIRO) | ||
* ABN 41 687 119 230. | ||
* | ||
* This software may be distributed and modified according to the terms of | ||
* the BSD 2-Clause license. Note that NO WARRANTY is provided. | ||
* See "LICENSE_BSD2.txt" for details. | ||
* | ||
* @TAG(DATA61_BSD) | ||
*/ | ||
|
||
#pragma once | ||
|
||
#define REVERSE_STRING_BUFSIZE 4096 | ||
#define REVERSE_STRING_END_IDX (REVERSE_STRING_BUFSIZE - 1) | ||
#define REVERSE_STRING_MAX_LEN (REVERSE_STRING_END_IDX - 1) |
Oops, something went wrong.