style: run style formatter on all files

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
This commit is contained in:
Gerwin Klein 2020-12-07 17:43:31 +11:00
parent 2c14cf80f6
commit 8976abc1c4
173 changed files with 1804 additions and 1404 deletions

View File

@ -28,9 +28,9 @@ endfunction()
enable_testing()
macro(add_simulate_test test_script)
set(TEST_SCRIPT ${test_script})
configure_file(${CMAKE_SOURCE_DIR}/tests/test_script.tcl.in ${CMAKE_BINARY_DIR}/test.tcl @ONLY)
add_test(${CMAKE_PROJECT_NAME} expect -f ${CMAKE_BINARY_DIR}/test.tcl)
set(TEST_SCRIPT ${test_script})
configure_file(${CMAKE_SOURCE_DIR}/tests/test_script.tcl.in ${CMAKE_BINARY_DIR}/test.tcl @ONLY)
add_test(${CMAKE_PROJECT_NAME} expect -f ${CMAKE_BINARY_DIR}/test.tcl)
endmacro()
# We only support one application being built at a time

View File

@ -8,7 +8,4 @@ cmake_minimum_required(VERSION 3.7.2)
project(ComponentAdder C)
DeclareCAmkESComponent(Adder
SOURCES src/adder.c
INCLUDES include
)
DeclareCAmkESComponent(Adder SOURCES src/adder.c INCLUDES include)

View File

@ -4,13 +4,10 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#ifndef _PAYLOAD_
#define _PAYLOAD_
#pragma once
struct payload {
int sz;
int operands[100];
int result;
};
#endif

View File

@ -9,15 +9,16 @@
#include <camkes/dataport.h>
#include "payload.h"
dataport_ptr_t a_calculate(dataport_ptr_t ptr) {
dataport_ptr_t a_calculate(dataport_ptr_t ptr)
{
struct payload *p1, *p2;
p1 = (struct payload*)dataport_unwrap_ptr(ptr);
p2 = (struct payload*)((void*)d + 2048);
p1 = (struct payload *)dataport_unwrap_ptr(ptr);
p2 = (struct payload *)((void *)d + 2048);
const char *name = get_instance_name();
p2->result = 0;
for (int i = 0; i < p1->sz; i++) {
printf("%s: Adding %d\n", name, p1->operands[i]);
p2->result += p1->operands[i];
}
return dataport_wrap_ptr((void*)p2);
return dataport_wrap_ptr((void *)p2);
}

View File

@ -9,7 +9,4 @@ cmake_minimum_required(VERSION 3.7.2)
project(ComponentClient C)
DeclareCAmkESComponent(Client
SOURCES src/client.c
INCLUDES include
)
DeclareCAmkESComponent(Client SOURCES src/client.c INCLUDES include)

View File

@ -4,13 +4,10 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#ifndef _PAYLOAD_
#define _PAYLOAD_
#pragma once
struct payload {
int sz;
int operands[100];
int result;
};
#endif

View File

@ -9,7 +9,8 @@
#include "payload.h"
#include <camkes/dataport.h>
int run(void) {
int run(void)
{
int operands[] = { 342, 74, 283, 37, 534 };
int sz = sizeof(operands) / sizeof(int);
const char *name = get_instance_name();
@ -23,13 +24,13 @@ int run(void) {
}
printf("?\n");
struct payload *p = (void*)d + 1024;
struct payload *p = (void *)d + 1024;
p->sz = sz;
for (int i = 0; i < sz; i++) {
p->operands[i] = operands[i];
}
dataport_ptr_t ptr = a_calculate(dataport_wrap_ptr((void*)p));
dataport_ptr_t ptr = a_calculate(dataport_wrap_ptr((void *)p));
p = dataport_unwrap_ptr(ptr);
printf("%s: result was %d\n", name, p->result);

View File

@ -14,13 +14,14 @@
#include <stdlib.h>
/* This function is invoked by the main CAmkES thread in this component. */
int run(void) {
ringbuffer_t *input = rb_new((void*)keyboard_input, sizeof(*keyboard_input));
int run(void)
{
ringbuffer_t *input = rb_new((void *)keyboard_input, sizeof(*keyboard_input));
if (input == NULL) {
abort();
}
ringbuffer_t *output = rb_new((void*)framebuffer, sizeof(*framebuffer));
ringbuffer_t *output = rb_new((void *)framebuffer, sizeof(*framebuffer));
if (output == NULL) {
abort();
}

View File

@ -23,18 +23,19 @@ static enum {
} selected = LOW;
/* This function is invoked by the main CAmkES thread in this component. */
int run(void) {
ringbuffer_t *low = rb_new((void*)low_output, sizeof(*low_output));
int run(void)
{
ringbuffer_t *low = rb_new((void *)low_output, sizeof(*low_output));
if (low == NULL) {
abort();
}
ringbuffer_t *high = rb_new((void*)high_output, sizeof(*high_output));
ringbuffer_t *high = rb_new((void *)high_output, sizeof(*high_output));
if (high == NULL) {
abort();
}
ringbuffer_t *input = rb_new((void*)char_in, sizeof(*char_in));
ringbuffer_t *input = rb_new((void *)char_in, sizeof(*char_in));
if (input == NULL) {
abort();
}

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,8 @@
#include "common.h"
int run() {
int run()
{
printf("Calling server...\n");
a_f();
printf("Back from server!\n");

View File

@ -19,7 +19,8 @@ typedef struct foo {
/* Hopefully the compiler will attempt to optimize this
* function with sse instructions on x86.
*/
static inline void memcpy_test(foo_t *a, foo_t *b) {
static inline void memcpy_test(foo_t *a, foo_t *b)
{
foo_t intermediate = *a;
intermediate.arr[1] += 0.5;
memcpy(b, &intermediate, sizeof(foo_t));
@ -32,7 +33,8 @@ void movaps_test(void);
* to unaligned operands of sse instructions with alignment
* requirements, unless the stack is correctly aligned.
*/
static inline void test_alignment(void) {
static inline void test_alignment(void)
{
foo_t a, b;
a.arr[0] = 0.1;
a.arr[1] = 0.2;

View File

@ -9,7 +9,8 @@
#include "common.h"
void b_f(void) {
void b_f(void)
{
printf("Server is testing alignment...\n");
test_alignment();
}

View File

@ -9,7 +9,8 @@
#define TO_ECHO 42
int run(void) {
int run(void)
{
printf("Echoing: %d == %d\n", TO_ECHO, echo_echo(TO_ECHO));

View File

@ -6,7 +6,8 @@
#include <camkes.h>
int run(void) {
int run(void)
{
while (1) {
ready_emit();

View File

@ -8,14 +8,16 @@
static int global;
static void callback(void *arg) {
static void callback(void *arg)
{
int *ret = arg;
*ret = global;
int error = binsem_post();
assert(!error);
}
int echo_echo(int i) {
int echo_echo(int i)
{
int ret;
global = i;
int error = ready_reg_callback(callback, &ret);

View File

@ -13,9 +13,7 @@ include(${CAKEML_META_PATH})
project(cakeml_hello C)
DeclareCAmkESComponent(Client
SOURCES client.c
)
DeclareCAmkESComponent(Client SOURCES client.c)
DeclareCakeMLMetaUtils(
${CAKEML_LIBS_DIR}/meta_utils
@ -25,12 +23,16 @@ DeclareCakeMLMetaUtils(
meta_utils_path
)
DeclareCAmkESComponent(Hello
CAKEML_SOURCES componentScript.sml
DeclareCAmkESComponent(
Hello CAKEML_SOURCES componentScript.sml
# Demonstrate that we can override the heap size
CAKEML_HEAP_SIZE 51
CAKEML_INCLUDES ${meta_utils_path}
CAKEML_DEPENDS meta_utils_target ${meta_utils_target_files}
CAKEML_HEAP_SIZE
51
CAKEML_INCLUDES
${meta_utils_path}
CAKEML_DEPENDS
meta_utils_target
${meta_utils_target_files}
)
DeclareCAmkESRootserver(cakeml_hello.camkes)

View File

@ -7,7 +7,8 @@
#include <camkes.h>
#include <stdio.h>
int run() {
int run()
{
uint32_t i, j;
uint8_t k;
@ -40,8 +41,8 @@ int run() {
h_input_strings("Foo!", "Bar!");
char * input_str = "Hello world";
char * reversed = h_reverse_string(input_str);
char *input_str = "Hello world";
char *reversed = h_reverse_string(input_str);
printf("Hello_reverse_string: \"%s\" -> \"%s\"\n", input_str, reversed);
g_bye();

View File

@ -21,20 +21,26 @@ DeclareCakeMLMetaUtils(
meta_utils_path
)
DeclareCAmkESComponent(CakeMLFilter
SOURCES components/CakeMLFilter/emit_string.c
CAKEML_SOURCES components/CakeMLFilter/filterProgScript.sml components/CakeMLFilter/componentScript.sml
CAKEML_HEAP_SIZE 100
CAKEML_INCLUDES ${meta_utils_path} "/$(HOLDIR)/examples/formal-languages/regular" "${CAKEMLDIR}/semantics/proofs"
CAKEML_DEPENDS meta_utils_target ${meta_utils_target_files}
DeclareCAmkESComponent(
CakeMLFilter
SOURCES
components/CakeMLFilter/emit_string.c
CAKEML_SOURCES
components/CakeMLFilter/filterProgScript.sml
components/CakeMLFilter/componentScript.sml
CAKEML_HEAP_SIZE
100
CAKEML_INCLUDES
${meta_utils_path}
"/$(HOLDIR)/examples/formal-languages/regular"
"${CAKEMLDIR}/semantics/proofs"
CAKEML_DEPENDS
meta_utils_target
${meta_utils_target_files}
)
DeclareCAmkESComponent(Producer
SOURCES components/Producer/producer.c
)
DeclareCAmkESComponent(Producer SOURCES components/Producer/producer.c)
DeclareCAmkESComponent(Consumer
SOURCES components/Consumer/consumer.c
)
DeclareCAmkESComponent(Consumer SOURCES components/Consumer/consumer.c)
DeclareCAmkESRootserver(cakeml_regex.camkes)

View File

@ -8,6 +8,7 @@
#include <camkes.h>
// FFI function called from CakeML to send output over IPC to the Consumer
void ffiemit_string(unsigned char * c, long clen, unsigned char * a, long alen) {
server_transfer_string(c);
void ffiemit_string(unsigned char *c, long clen, unsigned char *a, long alen)
{
server_transfer_string(c);
}

View File

@ -6,7 +6,8 @@
#include <camkes.h>
void client_transfer_string(const char * s) {
void client_transfer_string(const char *s)
{
printf("%s", s);
fflush(stdout);
}

View File

@ -6,7 +6,8 @@
#include <camkes.h>
int run() {
int run()
{
while (true) {
server_transfer_string("This will get through 1\n");
server_transfer_string("Won't get through 1\n");

View File

@ -24,23 +24,29 @@ DeclareCakeMLMetaUtils(
meta_utils_path
)
DeclareCAmkESComponent(Client
SOURCES components/client/client.c
LIBS virtqueue vswitch
DeclareCAmkESComponent(Client SOURCES components/client/client.c LIBS virtqueue vswitch)
CakeMLPP(
components/cakeml-filter ${CAKEML_LIBS_DIR}/cakeml_libraries/libvirtqueue/virtqueueScript.sml
)
CakeMLPP(components/cakeml-filter
${CAKEML_LIBS_DIR}/cakeml_libraries/libvirtqueue/virtqueueScript.sml
)
DeclareCAmkESComponent(CakeMLFilter
CAKEML_SOURCES components/cakeml-filter/componentScript.sml
${CMAKE_CURRENT_BINARY_DIR}/components/cakeml-filter/virtqueueScript.sml
CAKEML_INCLUDES ${CAKEML_INCLUDES} ${meta_utils_path}
SOURCES components/cakeml-filter/global_endpoint.c
LIBS vswitch
CAKEML_HEAP_SIZE 50
CAKEML_DEPENDS meta_utils_target ${meta_utils_target_files}
DeclareCAmkESComponent(
CakeMLFilter
CAKEML_SOURCES
components/cakeml-filter/componentScript.sml
${CMAKE_CURRENT_BINARY_DIR}/components/cakeml-filter/virtqueueScript.sml
CAKEML_INCLUDES
${CAKEML_INCLUDES}
${meta_utils_path}
SOURCES
components/cakeml-filter/global_endpoint.c
LIBS
vswitch
CAKEML_HEAP_SIZE
50
CAKEML_DEPENDS
meta_utils_target
${meta_utils_target_files}
)
DeclareCAmkESRootserver(cakeml_tipc.camkes)

View File

@ -14,7 +14,8 @@
seL4_CPtr virtqueue_wait_notification(void);
// Return the global endpoint for our CakeML filter component
void ffiget_global_endpoint(char * c, unsigned long clen, char * a, unsigned long alen) {
void ffiget_global_endpoint(char *c, unsigned long clen, char *a, unsigned long alen)
{
assert(alen >= 1 + sizeof(seL4_CPtr));
seL4_CPtr src = virtqueue_wait_notification();
memcpy(a + 1, &src, sizeof(seL4_CPtr));

View File

@ -8,7 +8,8 @@
#include <stdio.h>
#include <stdlib.h>
int run() {
int run()
{
char *shello = "hello world";
char *s;
int i = 42, j;
@ -20,16 +21,16 @@ int run() {
printf("-------------------\n");
j = i_echo_int(i);
printf("echo_int: %d -> %d\n",i, j);
printf("echo_int: %d -> %d\n", i, j);
g = i_echo_float(f);
printf("echo_float: %f -> %f\n",f, g);
printf("echo_float: %f -> %f\n", f, g);
e = i_echo_double(d);
printf("echo_double: %f -> %f\n",d, e);
printf("echo_double: %f -> %f\n", d, e);
j = i_echo_mix(d);
printf("echo_mix: %f -> %d\n",d, j);
printf("echo_mix: %f -> %d\n", d, j);
s = i_echo_string(shello);
printf("echo_string: \"%s\" -> \"%s\"\n", shello, s);

View File

@ -7,30 +7,37 @@
#include <camkes.h>
#include <string.h>
void r__init(void) {
void r__init(void)
{
}
char * r_echo_string(const char *s) {
char *r_echo_string(const char *s)
{
return i_echo_string(s);
}
int r_echo_int(int i) {
int r_echo_int(int i)
{
return i_echo_int(i);
}
float r_echo_float(float f) {
float r_echo_float(float f)
{
return i_echo_float(f);
}
double r_echo_double(double d) {
double r_echo_double(double d)
{
return i_echo_double(d);
}
int r_echo_mix(double d) {
int r_echo_mix(double d)
{
return i_echo_mix(d);
}
int r_echo_parameter(int pin, int *pout) {
int r_echo_parameter(int pin, int *pout)
{
return i_echo_parameter(pin, pout);
}

View File

@ -7,30 +7,37 @@
#include <camkes.h>
#include <string.h>
void i__init(void) {
void i__init(void)
{
}
char * i_echo_string(const char *s) {
char *i_echo_string(const char *s)
{
return strdup(s);
}
int i_echo_int(int i) {
int i_echo_int(int i)
{
return i;
}
float i_echo_float(float f) {
float i_echo_float(float f)
{
return f;
}
double i_echo_double(double d) {
double i_echo_double(double d)
{
return d;
}
int i_echo_mix(double d) {
int i_echo_mix(double d)
{
return d;
}
int i_echo_parameter(int pin, int *pout) {
int i_echo_parameter(int pin, int *pout)
{
*pout = pin;
return pin;
}

View File

@ -8,7 +8,8 @@
#include <stdio.h>
#include <stdlib.h>
int run() {
int run()
{
char *shello = "hello world";
char *s;
int i = 42, j;
@ -20,16 +21,16 @@ int run() {
printf("-------------------\n");
j = i_echo_int(i);
printf("echo_int: %d -> %d\n",i, j);
printf("echo_int: %d -> %d\n", i, j);
g = i_echo_float(f);
printf("echo_float: %f -> %f\n",f, g);
printf("echo_float: %f -> %f\n", f, g);
e = i_echo_double(d);
printf("echo_double: %f -> %f\n",d, e);
printf("echo_double: %f -> %f\n", d, e);
j = i_echo_mix(d);
printf("echo_mix: %f -> %d\n",d, j);
printf("echo_mix: %f -> %d\n", d, j);
s = i_echo_string(shello);
printf("echo_string: \"%s\" -> \"%s\"\n", shello, s);

View File

@ -7,30 +7,37 @@
#include <camkes.h>
#include <string.h>
void i__init(void) {
void i__init(void)
{
}
char * i_echo_string(const char *s) {
char *i_echo_string(const char *s)
{
return strdup(s);
}
int i_echo_int(int i) {
int i_echo_int(int i)
{
return i;
}
float i_echo_float(float f) {
float i_echo_float(float f)
{
return f;
}
double i_echo_double(double d) {
double i_echo_double(double d)
{
return d;
}
int i_echo_mix(double d) {
int i_echo_mix(double d)
{
return d;
}
int i_echo_parameter(int pin, int *pout) {
int i_echo_parameter(int pin, int *pout)
{
*pout = pin;
return pin;
}

View File

@ -8,7 +8,8 @@
#include <stdio.h>
#include <stdlib.h>
int run() {
int run()
{
char *shello = "hello world";
char *s;
int i = 42, j;
@ -20,16 +21,16 @@ int run() {
printf("-------------------\n");
j = i_echo_int(i);
printf("echo_int: %d -> %d\n",i, j);
printf("echo_int: %d -> %d\n", i, j);
g = i_echo_float(f);
printf("echo_float: %f -> %f\n",f, g);
printf("echo_float: %f -> %f\n", f, g);
e = i_echo_double(d);
printf("echo_double: %f -> %f\n",d, e);
printf("echo_double: %f -> %f\n", d, e);
j = i_echo_mix(d);
printf("echo_mix: %f -> %d\n",d, j);
printf("echo_mix: %f -> %d\n", d, j);
s = i_echo_string(shello);
printf("echo_string: \"%s\" -> \"%s\"\n", shello, s);

View File

@ -7,30 +7,37 @@
#include <camkes.h>
#include <string.h>
void i__init(void) {
void i__init(void)
{
}
char * i_echo_string(const char *s) {
char *i_echo_string(const char *s)
{
return strdup(s);
}
int i_echo_int(int i) {
int i_echo_int(int i)
{
return i;
}
float i_echo_float(float f) {
float i_echo_float(float f)
{
return f;
}
double i_echo_double(double d) {
double i_echo_double(double d)
{
return d;
}
int i_echo_mix(double d) {
int i_echo_mix(double d)
{
return d;
}
int i_echo_parameter(int pin, int *pout) {
int i_echo_parameter(int pin, int *pout)
{
*pout = pin;
return pin;
}

View File

@ -9,15 +9,17 @@
#include <string.h>
#include <sel4/sel4.h>
int run(void) {
int run(void)
{
const char *shello = "hello world";
printf("Starting...\n");
printf("-----------\n");
strcpy((void*)DataOut, shello);
while(!*((char*)DataIn))
strcpy((void *)DataOut, shello);
while (!*((char *)DataIn)) {
seL4_Yield();
printf("%s read %s\n", get_instance_name(), (char*)DataIn);
}
printf("%s read %s\n", get_instance_name(), (char *)DataIn);
return 0;
}

View File

@ -11,7 +11,8 @@
int global_number = 34;
int run() {
int run()
{
const char *shello = "hello world";
const char *smore = "a longer string that will overflow the message registers on ARM";
char *s;
@ -24,17 +25,17 @@ int run() {
printf("-------------------\n");
camkes_software_breakpoint();
j = a_echo_int(i);
printf("echo_int: %d -> %d\n",i, j);
printf("echo_int: %d -> %d\n", i, j);
g = a_echo_float(f);
printf("echo_float: %f -> %f\n",f, g);
printf("echo_float: %f -> %f\n", f, g);
e = a_echo_double(d);
printf("echo_double: %f -> %f\n",d, e);
printf("echo_double: %f -> %f\n", d, e);
camkes_software_breakpoint();
j = a_echo_mix(d);
printf("echo_mix: %f -> %d\n",d, j);
printf("echo_mix: %f -> %d\n", d, j);
s = a_echo_string(shello);
printf("echo_string: \"%s\" -> \"%s\"\n", shello, s);

View File

@ -8,31 +8,38 @@
#include <string.h>
char * b_echo_string(const char *s) {
char *b_echo_string(const char *s)
{
return strdup(s);
}
int b_echo_int(int i) {
int b_echo_int(int i)
{
return i;
}
float b_echo_float(float f) {
float b_echo_float(float f)
{
return f;
}
double b_echo_double(double d) {
double b_echo_double(double d)
{
return d;
}
int b_echo_mix(double d) {
int b_echo_mix(double d)
{
return d;
}
int b_echo_parameter(int pin, int *pout) {
int b_echo_parameter(int pin, int *pout)
{
*pout = pin;
return pin;
}
void b_increment_parameter(int *x) {
void b_increment_parameter(int *x)
{
*x = *x + 1;
}

View File

@ -8,7 +8,8 @@
#include <stdio.h>
#include "util.h"
int run(void) {
int run(void)
{
/* Our IP address, once we're assigned one from the server. */
uint32_t ip = 0;

View File

@ -28,7 +28,8 @@ static uint32_t routing_table[4] = { 0 };
#define routing_table_sz (sizeof(routing_table) / sizeof(routing_table[0]))
/* Handle a DHCPDISCOVER message. */
static uint32_t discover(uint64_t hwaddr, uint32_t *siaddr) {
static uint32_t discover(uint64_t hwaddr, uint32_t *siaddr)
{
lock_lock();
/* Figure out a suitable IP address to offer them */
@ -36,7 +37,7 @@ static uint32_t discover(uint64_t hwaddr, uint32_t *siaddr) {
do {
offer = (my_ip & ~0xff) | (uint32_t)next_offer_octet;
next_offer_octet++;
} while ((offer & 0xff) == 0 || offer == my_ip ||
} while ((offer & 0xff) == 0 || offer == my_ip ||
offer == routing_table[0] || offer == routing_table[1] ||
offer == routing_table[2] || offer == routing_table[3]);
@ -47,7 +48,7 @@ static uint32_t discover(uint64_t hwaddr, uint32_t *siaddr) {
* servers on the same network.
*/
*siaddr = my_ip;
char pretty_ip[STRLEN_IP];
ip_to_string(offer, pretty_ip);
dprintf("%s: Sending DHCPOFFER of IP %s\n", get_instance_name(), pretty_ip);
@ -56,7 +57,8 @@ static uint32_t discover(uint64_t hwaddr, uint32_t *siaddr) {
}
/* Handle a DHCPREQ message */
static uint32_t request(unsigned int client, uint32_t ip, uint32_t siaddr) {
static uint32_t request(unsigned int client, uint32_t ip, uint32_t siaddr)
{
if (siaddr != my_ip) {
/* This message was intended for a different DHCP server. In a real
@ -65,7 +67,7 @@ static uint32_t request(unsigned int client, uint32_t ip, uint32_t siaddr) {
* *must* send a reply, so we just NAK it.
*/
dprintf("%s: Sending DHCPNAK due to server IP mismatch\n",
get_instance_name());
get_instance_name());
return 0;
}
@ -81,19 +83,19 @@ static uint32_t request(unsigned int client, uint32_t ip, uint32_t siaddr) {
if (routing_table[client] == ip) {
/* They requested their existing IP. OK, whatever. */
dprintf("%s: Sending DHCPACK to client %u for its existing IP\n",
get_instance_name(), client);
get_instance_name(), client);
assigned = ip;
} else if (ip != my_ip && ip != 0 && ip != routing_table[0] &&
ip != routing_table[1] && ip != routing_table[2] &&
ip != routing_table[3]) {
ip != routing_table[1] && ip != routing_table[2] &&
ip != routing_table[3]) {
/* They requested an IP that was not ours, 0 or in the routing table
* already. XXX: we should probably block the broadcast IP here too.
*/
char pretty_ip[STRLEN_IP];
ip_to_string(ip, pretty_ip);
dprintf("%s: Sending DHCPACK to client %u of IP %s\n",
get_instance_name(), client, pretty_ip);
get_instance_name(), client, pretty_ip);
routing_table[client] = ip;
assigned = ip;
}
@ -102,34 +104,42 @@ static uint32_t request(unsigned int client, uint32_t ip, uint32_t siaddr) {
return assigned;
}
uint32_t client1_discover(uint64_t hwaddr, uint32_t *siaddr) {
uint32_t client1_discover(uint64_t hwaddr, uint32_t *siaddr)
{
return discover(hwaddr, siaddr);
}
uint32_t client2_discover(uint64_t hwaddr, uint32_t *siaddr) {
uint32_t client2_discover(uint64_t hwaddr, uint32_t *siaddr)
{
return discover(hwaddr, siaddr);
}
uint32_t client3_discover(uint64_t hwaddr, uint32_t *siaddr) {
uint32_t client3_discover(uint64_t hwaddr, uint32_t *siaddr)
{
return discover(hwaddr, siaddr);
}
uint32_t client4_discover(uint64_t hwaddr, uint32_t *siaddr) {
uint32_t client4_discover(uint64_t hwaddr, uint32_t *siaddr)
{
return discover(hwaddr, siaddr);
}
uint32_t client1_request(uint32_t ip, uint32_t siaddr) {
uint32_t client1_request(uint32_t ip, uint32_t siaddr)
{
return request(0, ip, siaddr);
}
uint32_t client2_request(uint32_t ip, uint32_t siaddr) {
uint32_t client2_request(uint32_t ip, uint32_t siaddr)
{
return request(1, ip, siaddr);
}
uint32_t client3_request(uint32_t ip, uint32_t siaddr) {
uint32_t client3_request(uint32_t ip, uint32_t siaddr)
{
return request(2, ip, siaddr);
}
uint32_t client4_request(uint32_t ip, uint32_t siaddr) {
uint32_t client4_request(uint32_t ip, uint32_t siaddr)
{
return request(3, ip, siaddr);
}

View File

@ -10,7 +10,8 @@
/* Number of bytes in a MAC address. */
#define SIZEOF_MAC (48 / 8)
uint64_t make_mac(const char *data) {
uint64_t make_mac(const char *data)
{
uint64_t x = 0;
/* Consume bytes from the input string until we've exhausted it and then
@ -31,16 +32,18 @@ uint64_t make_mac(const char *data) {
* little endian. Only chosen this way to make construction simpler.
*/
void mac_to_string(uint64_t input, char *output) {
void mac_to_string(uint64_t input, char *output)
{
sprintf(output, "%02x:%02x:%02x:%02x:%02x:%02x",
(unsigned int)(input & 0xff), (unsigned int)((input >> 8) & 0xff),
(unsigned int)((input >> 16) & 0xff),
(unsigned int)((input >> 24) & 0xff),
(unsigned int)((input >> 32) & 0xff),
(unsigned int)((input >> 40) & 0xff));
(unsigned int)(input & 0xff), (unsigned int)((input >> 8) & 0xff),
(unsigned int)((input >> 16) & 0xff),
(unsigned int)((input >> 24) & 0xff),
(unsigned int)((input >> 32) & 0xff),
(unsigned int)((input >> 40) & 0xff));
}
void ip_to_string(uint32_t input, char *output) {
void ip_to_string(uint32_t input, char *output)
{
sprintf(output, "%u.%u.%u.%u", input >> 24, (input >> 16) & 0xff,
(input >> 8) & 0xff, input & 0xff);
(input >> 8) & 0xff, input & 0xff);
}

View File

@ -9,7 +9,8 @@
#include <camkes.h>
#include <camkes/dma.h>
int run(void) {
int run(void)
{
printf("Starting client...\n");
/* Test the legacy allocation functions. */
@ -17,7 +18,7 @@ int run(void) {
printf("Allocating some DMA pages...\n");
void *buffers[100];
int i;
for (i = 0; i < sizeof(buffers) / sizeof(void*); i++) {
for (i = 0; i < sizeof(buffers) / sizeof(void *); i++) {
buffers[i] = camkes_dma_alloc(4096, 4096, true);
if (buffers[i] == NULL) {
printf("Ran out of memory after %d of them\n", i);
@ -27,7 +28,7 @@ int run(void) {
printf("Reversing some offsets into them...\n");
for (int j = 0; j < i; j++) {
printf(" vaddr %p reversed to %p\n", buffers[j] + j * 13, (void*)camkes_dma_get_paddr(buffers[j] + j * 13));
printf(" vaddr %p reversed to %p\n", buffers[j] + j * 13, (void *)camkes_dma_get_paddr(buffers[j] + j * 13));
}
printf("Freeing them...\n");
@ -48,7 +49,7 @@ int run(void) {
printf("%p\nReversing some offsets...\n", p);
for (int j = 0; j < 7; j++) {
printf(" vaddr %p reversed to %p\n", p + j * 0x513,
(void*)camkes_dma_get_paddr(p + j * 0x513));
(void *)camkes_dma_get_paddr(p + j * 0x513));
}
camkes_dma_free(p, 0x2000);
}
@ -58,8 +59,8 @@ int run(void) {
printf("Allocating with different alignment requirements...\n");
for (int j = 0; j < 14; j++) {
printf(" Allocating 0x1000 with alignment %d...", 1<<j);
void *p = camkes_dma_alloc(0x1000, 1<<j, true);
printf(" Allocating 0x1000 with alignment %d...", 1 << j);
void *p = camkes_dma_alloc(0x1000, 1 << j, true);
if (p == NULL) {
printf("Failed\n");
} else {

View File

@ -7,6 +7,7 @@
#include <assert.h>
/* This function is never expected to be called. */
void dummy_dummy(void) {
void dummy_dummy(void)
{
assert(0);
}

View File

@ -34,55 +34,55 @@
void epit_init()
{
printf("EPIT init\n");
REG_VAL(KZM_EPIT_CTRL_ADDR) = 0;
printf("EPIT init\n");
/* Disable EPIT and reset. */
REG_VAL(KZM_EPIT_CTRL_ADDR) = CTRL_SWR;
REG_VAL(KZM_EPIT_CTRL_ADDR) = 0;
/* Select Clock source */
REG_VAL(KZM_EPIT_CTRL_ADDR) = (CLKSRC_IPG << CTRL_CLKSRC_SHIFT);
/* Disable EPIT and reset. */
REG_VAL(KZM_EPIT_CTRL_ADDR) = CTRL_SWR;
/* Reload from load register */
REG_VAL(KZM_EPIT_CTRL_ADDR) |= (CTRL_RLD | CTRL_ENMOD);
/* Select Clock source */
REG_VAL(KZM_EPIT_CTRL_ADDR) = (CLKSRC_IPG << CTRL_CLKSRC_SHIFT);
/* Enable interrupt */
REG_VAL(KZM_EPIT_CTRL_ADDR) |= CTRL_OCIEN;
/* Reload from load register */
REG_VAL(KZM_EPIT_CTRL_ADDR) |= (CTRL_RLD | CTRL_ENMOD);
/* Enable interrupt */
REG_VAL(KZM_EPIT_CTRL_ADDR) |= CTRL_OCIEN;
}
/* Set interrupt interval, in milliseconds. */
void epit_set_interval(int interval)
{
REG_VAL(KZM_EPIT_LOAD_ADDR) = (IPG_CLK_KHZ * interval) ;
REG_VAL(KZM_EPIT_COMP_ADDR) = 0;
REG_VAL(KZM_EPIT_LOAD_ADDR) = (IPG_CLK_KHZ * interval) ;
REG_VAL(KZM_EPIT_COMP_ADDR) = 0;
}
void epit_start_timer(void)
{
REG_VAL(KZM_EPIT_STAT_ADDR) = 0x1;
REG_VAL(KZM_EPIT_STAT_ADDR) = 0x1;
/* Enable timer */
REG_VAL(KZM_EPIT_CTRL_ADDR) |= CTRL_EN;
/* Enable timer */
REG_VAL(KZM_EPIT_CTRL_ADDR) |= CTRL_EN;
}
static int count = 0;
void irq_handle(void)
{
/* Clear status bit. */
REG_VAL(KZM_EPIT_STAT_ADDR) = 0x1;
irq_acknowledge();
/* Clear status bit. */
REG_VAL(KZM_EPIT_STAT_ADDR) = 0x1;
irq_acknowledge();
printf("EPIT time out...%d\n", count++);
printf("EPIT time out...%d\n", count++);
}
int run(void)
{
epit_init();
epit_set_interval(1000);
epit_init();
epit_set_interval(1000);
epit_start_timer();
epit_start_timer();
return 0;
return 0;
}

View File

@ -10,7 +10,8 @@
#define MAX_COUNT 100
static int count = 0;
static void event_callback(void *_ UNUSED) {
static void event_callback(void *_ UNUSED)
{
count++;
@ -21,7 +22,8 @@ static void event_callback(void *_ UNUSED) {
}
}
int run(void) {
int run(void)
{
ev_reg_callback(event_callback, NULL);
return 0;
}

View File

@ -8,7 +8,8 @@
#include <stdio.h>
#include <sel4/sel4.h>
int run(void) {
int run(void)
{
while (1) {
ev_emit();

View File

@ -7,16 +7,18 @@
#include <camkes.h>
#include <stdio.h>
static void event_callback(void *_ UNUSED) {
printf("%s: Got an event\n", __func__);
static void event_callback(void *_ UNUSED)
{
printf("%s: Got an event\n", __func__);
printf("%s: Register for another event\n", __func__);
ev_reg_callback(&event_callback, NULL);
printf("%s: Register for another event\n", __func__);
ev_reg_callback(&event_callback, NULL);
}
int run(void) {
printf("Waiting for an event\n");
int run(void)
{
printf("Waiting for an event\n");
ev_reg_callback(event_callback, NULL);
ev_reg_callback(event_callback, NULL);
return 0;
}

View File

@ -8,26 +8,27 @@
#include <stdio.h>
#include <sel4/sel4.h>
int run(void) {
int run(void)
{
int i;
unsigned long int ii;
/* Give the collector a chance to register. */
for (i = 0; i < 25; i++) {
seL4_Yield();
}
ev_emit();
for (i = 0; i < 25; i++) {
seL4_Yield();
}
ev_emit();
printf("starting to emit a lot...\n");
ii = 0;
while (1) {
ii++;
ev_emit();
printf("starting to emit a lot...\n");
ii = 0;
while (1) {
ii++;
ev_emit();
if (ii % 10000 == 0) {
printf("still emitting\n");
}
}
if (ii % 10000 == 0) {
printf("still emitting\n");
}
}
return 0;
}

View File

@ -13,21 +13,21 @@
int run(void)
{
char *ret;
const char *input = "This is a client string.";
char *output = NULL;
char *joint = malloc(25);
strncpy(joint, input, 25);
joint[24] = '\0';
ret = a_exchange(input, &output, &joint);
char *ret;
const char *input = "This is a client string.";
char *output = NULL;
char *joint = malloc(25);
strncpy(joint, input, 25);
joint[24] = '\0';
printf("Client output: %s\n", output);
printf("Client joint: %s\n", joint);
printf("Client ret: %s\n", ret);
ret = a_exchange(input, &output, &joint);
free(output);
free(joint);
free(ret);
return 0;
printf("Client output: %s\n", output);
printf("Client joint: %s\n", joint);
printf("Client ret: %s\n", ret);
free(output);
free(joint);
free(ret);
return 0;
}

View File

@ -13,20 +13,20 @@
char *a_exchange(const char *input, char **output, char **joint)
{
char *reply = strdup("This is a string from server.");
*output = malloc(30);
strncpy(*output, reply, 30);
(*output)[29] = '\0';
char *reply = strdup("This is a string from server.");
*output = malloc(30);
strncpy(*output, reply, 30);
(*output)[29] = '\0';
printf("Server input: %s\n", input);
printf("Server joint: %s\n", *joint);
printf("Server input: %s\n", input);
printf("Server joint: %s\n", *joint);
free(*joint);
free(*joint);
*joint = malloc(50);
strcpy(*joint, input);
strcpy(*joint + strlen(input), reply);
*joint = malloc(50);
strcpy(*joint, input);
strcpy(*joint + strlen(input), reply);
return reply;
return reply;
}

View File

@ -8,7 +8,8 @@
#include <stdio.h>
#include <stdlib.h>
int run(void) {
int run(void)
{
printf("Looking up key \"foo\"...");
char *value = l_get_value("foo");
printf("received value \"%s\"\n", value);

View File

@ -9,7 +9,8 @@
void external__init(void) {}
char *external_get_value(const char *key) {
char *external_get_value(const char *key)
{
if (!strcmp(key, "secret")) {
/* Block reading the value of "secret" */
return strdup("");

View File

@ -7,7 +7,8 @@
#include <camkes.h>
#include <string.h>
void l__init(void) {
void l__init(void)
{
}
static struct {
@ -25,7 +26,8 @@ static struct {
};
/* Lookup and return the value associated with 'key' */
char *l_get_value(const char *key) {
char *l_get_value(const char *key)
{
for (unsigned int i = 0; i < sizeof(dict) / sizeof(dict[0]); ++i) {
if (!strcmp(key, dict[i].key)) {
return strdup(dict[i].value);

View File

@ -12,7 +12,15 @@ project(global-imports C)
# and only this import needs to be updated
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/global)
DeclareCAmkESComponent(Client SOURCES components/Client/src/main.c LIBS GetterIface PrinterIface ServerInterface)
DeclareCAmkESComponent(
Client
SOURCES
components/Client/src/main.c
LIBS
GetterIface
PrinterIface
ServerInterface
)
DeclareCAmkESRootserver(global-imports.camkes)
add_simulate_test([=[

View File

@ -9,7 +9,8 @@
#include <vec.h>
#include <shared_int.h>
int run(void) {
int run(void)
{
char *str = g_get_string();
p_print_string(str);
vec_t vec = g_get_vec();

View File

@ -8,9 +8,11 @@
#include <stdio.h>
#include <vec.h>
void printer_print_string(const char *str) {
void printer_print_string(const char *str)
{
printf("%s", str);
}
void printer_print_vec(vec_t v) {
void printer_print_vec(vec_t v)
{
printf("(%2f, %2f)\n", v.x, v.y);
}

View File

@ -10,6 +10,9 @@ project(Server C)
# Interface library for our dataport
add_library(ServerInterface INTERFACE)
target_include_directories(ServerInterface INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/../common_port_types")
target_include_directories(
ServerInterface
INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/../common_port_types"
)
DeclareCAmkESComponent(Server SOURCES src/main.c LIBS GetterIface ServerInterface)

View File

@ -8,16 +8,21 @@
#include <string.h>
#include <vec.h>
void getter__init(void) {
void getter__init(void)
{
counter->value = 0;
}
char * getter_get_string(void) {
char *getter_get_string(void)
{
counter->value++;
return strdup("Hello, World!\n");
}
vec_t getter_get_vec(void) {
vec_t getter_get_vec(void)
{
counter->value++;
return (vec_t) {.x = 4.0, .y = 2.0};
return (vec_t) {
.x = 4.0, .y = 2.0
};
}

View File

@ -4,9 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#ifndef _SHARED_INT_H_
#define _SHARED_INT_H_
#pragma once
typedef struct {
int value;
} shared_int_t;
#endif

View File

@ -8,4 +8,7 @@ cmake_minimum_required(VERSION 3.7.2)
# Declare interface library for our headers
add_library(GetterIface INTERFACE)
target_include_directories(GetterIface INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/../common_procedure_types")
target_include_directories(
GetterIface
INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/../common_procedure_types"
)

View File

@ -8,4 +8,7 @@ cmake_minimum_required(VERSION 3.7.2)
# Declare interface library for our headers
add_library(PrinterIface INTERFACE)
target_include_directories(PrinterIface INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/../common_procedure_types")
target_include_directories(
PrinterIface
INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/../common_procedure_types"
)

View File

@ -4,10 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#ifndef _VECTOR_H_
#define _VECTOR_H_
#pragma once
typedef struct {
double x;
double y;
} vec_t;
#endif

View File

@ -10,7 +10,7 @@ project(hellorust C)
include(rust)
if ("${KernelSel4Arch}" STREQUAL "x86_64")
if("${KernelSel4Arch}" STREQUAL "x86_64")
set(RUST_ARCH "x86_64-sel4-none")
elseif("${KernelSel4Arch}" STREQUAL "aarch64")
set(RUST_ARCH "aarch64-sel4-none")

View File

@ -7,6 +7,7 @@
#include <camkes.h>
#include <stdio.h>
void self_pa_print_attributes(void) {
void self_pa_print_attributes(void)
{
printf("str: %s\n", str);
}

View File

@ -7,6 +7,7 @@
#include <camkes.h>
#include <stdio.h>
void pa_print_attributes(void) {
void pa_print_attributes(void)
{
printf("str: %s\n", str);
}

View File

@ -7,7 +7,8 @@
#include <camkes.h>
#include <stdio.h>
int run(void) {
int run(void)
{
printf("Foo\n");
foo_pa_print_attributes();
@ -17,7 +18,7 @@ int run(void) {
printf("Foo Bar Baz\n");
foo_nested_pa1_print_attributes();
printf("Foo Baz\n");
foo_nested_pa2_print_attributes();

View File

@ -7,7 +7,8 @@
#include <camkes.h>
#include <stdio.h>
void self_pa_print_attributes(void) {
void self_pa_print_attributes(void)
{
printf("str0: %s\n", str0);
printf("str1: %s\n", str1);
}

View File

@ -10,7 +10,8 @@
#define BUF_SIZE 128
void i_process(const char *str) {
void i_process(const char *str)
{
char buf[BUF_SIZE];
snprintf(buf, BUF_SIZE, "%s%s", str, string_to_append);

View File

@ -6,7 +6,8 @@
#include <camkes.h>
int run(void) {
int run(void)
{
o1_process("hello ");
o2_process("hello ");

View File

@ -6,7 +6,8 @@
#include <camkes.h>
void extra_process(const char *str) {
void extra_process(const char *str)
{
printf("%sworld!\n", str);
}

View File

@ -8,13 +8,14 @@
#include <stdlib.h>
#include <string.h>
void i_process(const char *arg) {
void i_process(const char *arg)
{
char *str = strdup(arg);
int last_idx = strlen(str)-1;
for (int i = 0;i<last_idx/2;i++) {
int last_idx = strlen(str) - 1;
for (int i = 0; i < last_idx / 2; i++) {
char tmp = str[i];
str[i] = str[last_idx-i];
str[last_idx-i] = tmp;
str[i] = str[last_idx - i];
str[last_idx - i] = tmp;
}
o_process(str);

View File

@ -7,6 +7,7 @@
#include <camkes.h>
#include <stdio.h>
void i_process(const char *str) {
void i_process(const char *str)
{
printf("%s\n", str);
}

View File

@ -10,9 +10,10 @@
#define TO_UPPER_DIST ('A' - 'a')
void i_process(const char *arg) {
void i_process(const char *arg)
{
char *str = strdup(arg);
for (char *cptr = str;*cptr != '\0';cptr++) {
for (char *cptr = str; *cptr != '\0'; cptr++) {
if (*cptr >= 'a' && *cptr <= 'z') {
*cptr += TO_UPPER_DIST;
}

View File

@ -9,17 +9,17 @@
static void keyboard_event_callback(void *arg)
{
int key = kbd_get_scancode();
printf("Key Pressed: %d\n", key);
int key = kbd_get_scancode();
printf("Key Pressed: %d\n", key);
keypress_reg_callback(&keyboard_event_callback, NULL);
keypress_reg_callback(&keyboard_event_callback, NULL);
}
int run(void)
{
printf("Register keyboard driver event.\n");
printf("Register keyboard driver event.\n");
keypress_reg_callback(&keyboard_event_callback, NULL);
return 0;
keypress_reg_callback(&keyboard_event_callback, NULL);
return 0;
}

View File

@ -7,7 +7,8 @@
#include <camkes.h>
#include <stdio.h>
int run(void) {
int run(void)
{
printf("%s: starting...\n", get_instance_name());
l_lock();
printf("%s: got lock!\n", get_instance_name());

View File

@ -6,26 +6,32 @@
#include <camkes.h>
void a_lock(void) {
void a_lock(void)
{
(void)m_lock();
}
void a_unlock(void) {
void a_unlock(void)
{
(void)m_unlock();
}
void b_lock(void) {
void b_lock(void)
{
(void)m_lock();
}
void b_unlock(void) {
void b_unlock(void)
{
(void)m_unlock();
}
void c_lock(void) {
void c_lock(void)
{
(void)m_lock();
}
void c_unlock(void) {
void c_unlock(void)
{
(void)m_unlock();
}

View File

@ -8,7 +8,8 @@
#include <stdio.h>
#include <stdlib.h>
int run() {
int run()
{
char *shello = "hello world";
char *s;
int i = 42, j;
@ -20,16 +21,16 @@ int run() {
printf("-------------------\n");
j = i_echo_int(i);
printf("echo_int: %d -> %d\n",i, j);
printf("echo_int: %d -> %d\n", i, j);
g = i_echo_float(f);
printf("echo_float: %f -> %f\n",f, g);
printf("echo_float: %f -> %f\n", f, g);
e = i_echo_double(d);
printf("echo_double: %f -> %f\n",d, e);
printf("echo_double: %f -> %f\n", d, e);
j = i_echo_mix(d);
printf("echo_mix: %f -> %d\n",d, j);
printf("echo_mix: %f -> %d\n", d, j);
s = i_echo_string(shello);
printf("echo_string: \"%s\" -> \"%s\"\n", shello, s);

View File

@ -7,30 +7,37 @@
#include <camkes.h>
#include <string.h>
void i__init(void) {
void i__init(void)
{
}
char * i_echo_string(const char *s) {
char *i_echo_string(const char *s)
{
return strdup(s);
}
int i_echo_int(int i) {
int i_echo_int(int i)
{
return i;
}
float i_echo_float(float f) {
float i_echo_float(float f)
{
return f;
}
double i_echo_double(double d) {
double i_echo_double(double d)
{
return d;
}
int i_echo_mix(double d) {
int i_echo_mix(double d)
{
return d;
}
int i_echo_parameter(int pin, int *pout) {
int i_echo_parameter(int pin, int *pout)
{
*pout = pin;
return pin;
}

View File

@ -8,7 +8,8 @@
#include <stdio.h>
#include <stdlib.h>
int run() {
int run()
{
char *shello = "hello world";
char *s;
int i = 42, j;
@ -20,16 +21,16 @@ int run() {
printf("-------------------\n");
j = i_echo_int(i);
printf("echo_int: %d -> %d\n",i, j);
printf("echo_int: %d -> %d\n", i, j);
g = i_echo_float(f);
printf("echo_float: %f -> %f\n",f, g);
printf("echo_float: %f -> %f\n", f, g);
e = i_echo_double(d);
printf("echo_double: %f -> %f\n",d, e);
printf("echo_double: %f -> %f\n", d, e);
j = i_echo_mix(d);
printf("echo_mix: %f -> %d\n",d, j);
printf("echo_mix: %f -> %d\n", d, j);
s = i_echo_string(shello);
printf("echo_string: \"%s\" -> \"%s\"\n", shello, s);

View File

@ -7,30 +7,37 @@
#include <camkes.h>
#include <string.h>
void i__init(void) {
void i__init(void)
{
}
char * i_echo_string(const char *s) {
char *i_echo_string(const char *s)
{
return strdup(s);
}
int i_echo_int(int i) {
int i_echo_int(int i)
{
return i;
}
float i_echo_float(float f) {
float i_echo_float(float f)
{
return f;
}
double i_echo_double(double d) {
double i_echo_double(double d)
{
return d;
}
int i_echo_mix(double d) {
int i_echo_mix(double d)
{
return d;
}
int i_echo_parameter(int pin, int *pout) {
int i_echo_parameter(int pin, int *pout)
{
*pout = pin;
return pin;
}

View File

@ -10,7 +10,8 @@
#define BUF_SIZE 128
void i_process(const char *str) {
void i_process(const char *str)
{
char buf[BUF_SIZE];
snprintf(buf, BUF_SIZE, "%s%s", str, string_to_append);

View File

@ -6,7 +6,8 @@
#include <camkes.h>
int run(void) {
int run(void)
{
o_process("hello ");

View File

@ -8,13 +8,14 @@
#include <stdlib.h>
#include <string.h>
void i_process(const char *arg) {
void i_process(const char *arg)
{
char *str = strdup(arg);
int last_idx = strlen(str)-1;
for (int i = 0;i<last_idx/2;i++) {
int last_idx = strlen(str) - 1;
for (int i = 0; i < last_idx / 2; i++) {
char tmp = str[i];
str[i] = str[last_idx-i];
str[last_idx-i] = tmp;
str[i] = str[last_idx - i];
str[last_idx - i] = tmp;
}
o_process(str);

View File

@ -7,6 +7,7 @@
#include <camkes.h>
#include <stdio.h>
void i_process(const char *str) {
void i_process(const char *str)
{
printf("%s\n", str);
}

View File

@ -10,9 +10,10 @@
#define TO_UPPER_DIST ('A' - 'a')
void i_process(const char *arg) {
void i_process(const char *arg)
{
char *str = strdup(arg);
for (char *cptr = str;*cptr != '\0';cptr++) {
for (char *cptr = str; *cptr != '\0'; cptr++) {
if (*cptr >= 'a' && *cptr <= 'z') {
*cptr += TO_UPPER_DIST;
}

View File

@ -13,7 +13,8 @@ void event_reg_callback(void *_ UNUSED)
e_reg_callback(&event_reg_callback, NULL);
}
int run() {
int run()
{
int j;
printf("Starting the client\n");
@ -24,7 +25,7 @@ int run() {
j = s_echo_int();
printf("echo_int: %d\n", j);
printf("%s\n", (char*)d);
printf("%s\n", (char *)d);
printf("After the client\n");
return 0;

View File

@ -8,20 +8,23 @@
#include <string.h>
int count = 0;
static inline void udelay(uint32_t us){
volatile int i;
for(; us > 0; us--)
for(i = 0; i < 100; i++);
static inline void udelay(uint32_t us)
{
volatile int i;
for (; us > 0; us--)
for (i = 0; i < 100; i++);
}
void s__init(void) {
void s__init(void)
{
}
int s_echo_int(void) {
int s_echo_int(void)
{
const char *str = "This string is in the dataport.";
udelay(100000);
strcpy((char*)d, str);
strcpy((char *)d, str);
e_emit();
return count++;
}

View File

@ -13,7 +13,8 @@ void event_reg_callback(void *_ UNUSED)
e_reg_callback(&event_reg_callback, NULL);
}
int run() {
int run()
{
int j;
printf("Starting the client\n");
@ -24,7 +25,7 @@ int run() {
j = s_echo_int();
printf("echo_int: %d\n", j);
printf("%s\n", (char*)d);
printf("%s\n", (char *)d);
printf("After the client\n");
return 0;

View File

@ -10,7 +10,8 @@
#include <stddef.h>
#include <stdlib.h>
int run(void) {
int run(void)
{
int operands[] = { 342, 74, 283, };
int *inplace;
int *other;
@ -19,7 +20,7 @@ int run(void) {
size_t inplace_sz = 2;
const char *name = get_instance_name();
inplace = (int*)malloc(sizeof(int) * inplace_sz);
inplace = (int *)malloc(sizeof(int) * inplace_sz);
assert(inplace != NULL);
inplace[0] = 7;
inplace[1] = 8;

View File

@ -10,7 +10,9 @@
#include <stdio.h>
#include <stdlib.h>
int a_calculate(size_t operands_sz, const int *operands, size_t *other_sz, int **other, size_t *inplace_sz, int **inplace) {
int a_calculate(size_t operands_sz, const int *operands, size_t *other_sz, int **other, size_t *inplace_sz,
int **inplace)
{
const char *name = get_instance_name();
int total = 1;
for (int i = 0; i < operands_sz; i++) {
@ -18,7 +20,7 @@ int a_calculate(size_t operands_sz, const int *operands, size_t *other_sz, int *
total *= operands[i];
}
int i;
*other = (int*)malloc(sizeof(int) * *inplace_sz);
*other = (int *)malloc(sizeof(int) * *inplace_sz);
assert(*other != NULL);
for (i = 0; i < *inplace_sz; i++) {
printf("%s: stashing %d\n", name, (*inplace)[i]);

View File

@ -8,7 +8,8 @@
#include <sel4/sel4.h>
#include <stdio.h>
int run(void) {
int run(void)
{
const char *name = get_instance_name();
printf("%s: Started\n", name);
@ -17,8 +18,9 @@ int run(void) {
printf("%s: Got it!\n", name);
printf("%s: Let's do some long running calculation (or more accurately, waste time)...\n", name);
for (int i = 0; i < 10000; i++)
asm volatile ("");
for (int i = 0; i < 10000; i++) {
asm volatile("");
}
printf("%s: Releasing the lock...\n", name);
lock_unlock();

View File

@ -11,7 +11,8 @@ int lock_lock(void);
int lock_unlock(void);
static unsigned long long factorial(unsigned long long n) {
static unsigned long long factorial(unsigned long long n)
{
if (n == 0) {
return 1;
} else {
@ -19,7 +20,8 @@ static unsigned long long factorial(unsigned long long n) {
}
}
int run() {
int run()
{
const char *name = get_instance_name();
printf("%s: started.\n", name);
@ -33,8 +35,9 @@ int run() {
unsigned long long result = factorial(n);
printf("%s: So, it turns out factorial %llu is %llu\n", name, n, result);
printf("%s: Let's take a breather...\n", name);
for (int i = 0; i < 100000; i++)
asm volatile ("");
for (int i = 0; i < 100000; i++) {
asm volatile("");
}
printf("%s: Unlocking...\n", name);
lock_unlock();

View File

@ -10,12 +10,14 @@
/*- set ep = alloc('ep', seL4_EndpointObject, read=True, write=True) -*/
int /*? me.interface.name ?*/__run(void) {
int /*? me.interface.name ?*/__run(void)
{
/* No setup required */
return 0;
}
int /*? me.interface.name ?*/_lock(void) {
int /*? me.interface.name ?*/_lock(void)
{
seL4_SetMR(0, 0);
seL4_MessageInfo_t info = seL4_MessageInfo_new(0, 0, 0, 1);
seL4_Send(/*? ep ?*/, info);
@ -23,7 +25,8 @@ int /*? me.interface.name ?*/_lock(void) {
return 0;
}
int /*? me.interface.name ?*/_unlock(void) {
int /*? me.interface.name ?*/_unlock(void)
{
seL4_SetMR(0, 1);
seL4_MessageInfo_t info = seL4_MessageInfo_new(0, 0, 0, 1);
seL4_Send(/*? ep ?*/, info);

View File

@ -18,20 +18,24 @@ static sync_mutex_t mutex;
/* We implement the 'to' side of this interface, removing the need for the user
* to implement it.
*/
int /*? me.interface.name ?*/_lock(void) {
int /*? me.interface.name ?*/_lock(void)
{
return sync_mutex_lock(&mutex);
}
int /*? me.interface.name ?*/_unlock(void) {
int /*? me.interface.name ?*/_unlock(void)
{
return sync_mutex_unlock(&mutex);
}
void /*? me.interface.name ?*/__init(void) {
void /*? me.interface.name ?*/__init(void)
{
int result = sync_mutex_init(&mutex, /*? notification ?*/);
assert(result == 0);
}
int /*? me.interface.name ?*/__run(void) {
int /*? me.interface.name ?*/__run(void)
{
while (1) {
/*- if options.realtime -*/
seL4_MessageInfo_t info = seL4_Wait(/*? ep ?*/, NULL);

View File

@ -16,7 +16,8 @@
uint64_t acc = 0;
int run() {
int run()
{
IPRINT("--- Starting ---\n");

View File

@ -9,9 +9,10 @@
#include <string.h>
#include <stdio.h>
int run(void) {
int run(void)
{
char *buffer_str = (char*)buffer;
char *buffer_str = (char *)buffer;
snprintf(buffer_str, REVERSE_STRING_MAX_LEN, "Hello, World!");

View File

@ -9,9 +9,10 @@
#include <string.h>
#include <stdio.h>
int run(void) {
int run(void)
{
char *buffer_str = (char*)buffer;
char *buffer_str = (char *)buffer;
while (buffer_str[REVERSE_STRING_END_IDX] == 0) {
/* Poll the last byte of the buffer until the client is

View File

@ -4,11 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#ifndef _MYTYPE_
#define _MYTYPE_
#pragma once
typedef struct {
int i;
} MyType_t;
#endif

View File

@ -7,7 +7,8 @@
#include <camkes.h>
#include <stdio.h>
int run(void) {
int run(void)
{
MyType_t a, b, c, d;
a.i = 1;

View File

@ -6,7 +6,8 @@
#include <camkes.h>
MyType_t s_rotate(MyType_t a, MyType_t *b, MyType_t *c) {
MyType_t s_rotate(MyType_t a, MyType_t *b, MyType_t *c)
{
b->i = c->i;
c->i = a.i;
return a;

View File

@ -15,14 +15,19 @@ includeGlobalComponents()
include(${CMAKE_CURRENT_LIST_DIR}/../rumprun_common.cmake)
DeclareExternalRumprunProject(
rump_ether_external
${CMAKE_CURRENT_LIST_DIR}/components/rump_ether
bin/reverse)
rump_ether_external ${CMAKE_CURRENT_LIST_DIR}/components/rump_ether bin/reverse
)
DeclareRumprunCAmkESComponent(rumprun_ether
POSIX_BIN ${CMAKE_CURRENT_BINARY_DIR}/bin/reverse
BAKE_CONFIG sel4_ethernet
PUBLIC_SYMBOLS camkes_buffer* camkes_ev* camkes_ev1*
DeclareRumprunCAmkESComponent(
rumprun_ether
POSIX_BIN
${CMAKE_CURRENT_BINARY_DIR}/bin/reverse
BAKE_CONFIG
sel4_ethernet
PUBLIC_SYMBOLS
camkes_buffer*
camkes_ev*
camkes_ev1*
)
DeclareCAmkESRootserver(rumprun_ethernet.camkes CPP_INCLUDES ${CAMKES_RUMPRUN_PATH} include)

View File

@ -9,10 +9,11 @@
#include <string.h>
#include <stdio.h>
int run(void) {
int run(void)
{
char *buffer_str = (char*)buffer;
while(true) {
char *buffer_str = (char *)buffer;
while (true) {
/* Wait for event */
ev_wait();
printf("Got string: %s\n", buffer_str);

View File

@ -47,10 +47,13 @@ void camkes_ev1_wait(void);
#pragma weak camkes_ev1_wait
int main (int argc, char *argv[]) {
if (argc < 2) on_error("Usage: %s [port]\n", argv[0]);
int main(int argc, char *argv[])
{
if (argc < 2) {
on_error("Usage: %s [port]\n", argv[0]);
}
char *buffer_str = (char*)camkes_buffer;
char *buffer_str = (char *)camkes_buffer;
snprintf(buffer_str, REVERSE_STRING_MAX_LEN, "Hello, World!");
@ -63,52 +66,66 @@ int main (int argc, char *argv[]) {
printf("%s\n", buffer_str);
int port = atoi(argv[1]);
int port = atoi(argv[1]);
int server_fd, client_fd, err;
struct sockaddr_in server, client;
char buf[REVERSE_STRING_BUFSIZE];
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");
server_fd = socket(AF_INET, SOCK_STREAM, 0);
if (server_fd < 0) {
on_error("Could not create socket\n");
}
}
return 0;
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;
}

View File

@ -12,14 +12,14 @@ includeGlobalComponents()
include(${CMAKE_CURRENT_LIST_DIR}/../rumprun_common.cmake)
DeclareExternalRumprunProject(
hello_external
${CMAKE_CURRENT_LIST_DIR}/components/hello
bin/hello)
DeclareExternalRumprunProject(hello_external ${CMAKE_CURRENT_LIST_DIR}/components/hello bin/hello)
DeclareRumprunCAmkESComponent(rumprun
POSIX_BIN ${CMAKE_CURRENT_BINARY_DIR}/bin/hello
BAKE_CONFIG sel4_generic
DeclareRumprunCAmkESComponent(
rumprun
POSIX_BIN
${CMAKE_CURRENT_BINARY_DIR}/bin/hello
BAKE_CONFIG
sel4_generic
)
DeclareCAmkESRootserver(rumprun_hello.camkes CPP_INCLUDES ${CAMKES_RUMPRUN_PATH})

Some files were not shown because too many files have changed in this diff Show More