Skip to content

Commit de72d57

Browse files
authored
Merge pull request #1372 from hioa-cs/dev
Merge dev
2 parents c186da5 + 9a944cc commit de72d57

28 files changed

Lines changed: 238 additions & 161 deletions

api/kernel/rng.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
// Licensed under the Apache License, Version 2.0 (the "License");
88
// you may not use this file except in compliance with the License.
99
// You may obtain a copy of the License at
10-
//
10+
//
1111
// http://www.apache.org/licenses/LICENSE-2.0
12-
//
12+
//
1313
// Unless required by applicable law or agreed to in writing, software
1414
// distributed under the License is distributed on an "AS IS" BASIS,
1515
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,5 +40,10 @@ inline uint32_t rng_extract_uint32()
4040
return x;
4141
}
4242

43+
struct RNG
44+
{
45+
static void init();
46+
};
47+
4348

4449
#endif

api/net/ip4/arp.hpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <rtc>
2323
#include <unordered_map>
2424
#include <util/timer.hpp>
25-
#include <delegate>
2625
#include "ip4.hpp"
2726

2827
using namespace std::chrono_literals;
@@ -92,23 +91,7 @@ namespace net {
9291
{ cache_.clear(); };
9392

9493
/** Flush expired cache entries. RFC-2.3.2.1 */
95-
void flush_expired () {
96-
INFO("ARP", "Flushing expired entries");
97-
std::vector<IP4::addr> expired;
98-
for (auto ent : cache_) {
99-
if (ent.second.expired()) {
100-
expired.push_back(ent.first);
101-
}
102-
}
103-
104-
for (auto ip : expired) {
105-
cache_.erase(ip);
106-
}
107-
108-
if (not cache_.empty()) {
109-
flush_timer_.start(flush_interval_);
110-
}
111-
}
94+
void flush_expired ();
11295

11396
void set_cache_flush_interval(std::chrono::minutes m) {
11497
flush_interval_ = m;

api/net/ws/websocket.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@
2323

2424
#include <net/http/server.hpp>
2525
#include <net/http/client.hpp>
26+
#include <stdexcept>
2627

2728
namespace net {
2829

30+
struct WS_error : public std::runtime_error {
31+
using base = std::runtime_error;
32+
using base::base;
33+
};
34+
2935
class WebSocket {
3036
public:
3137
class Message {
@@ -76,7 +82,7 @@ class WebSocket {
7682
data_.insert(data_.end(), data, data+len);
7783
}
7884
else {
79-
throw std::string{"Panncake"};
85+
throw WS_error{"Exceeding Message size"};
8086
}
8187
}
8288

api/smp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,13 @@ public:
114114
// execute @func on another CPU core
115115
// call @done back on main CPU when task returns
116116
// use signal() to broadcast work should begin
117-
static void add_task(task_func func, done_func done);
118-
static void add_task(task_func func);
117+
static void add_task(task_func func, done_func done, int cpu = 0);
118+
static void add_task(task_func func, int cpu = 0);
119+
// execute a function on the main cpu
120+
static void add_bsp_task(done_func func);
119121

120122
// call this to signal that tasks are queued up
121-
static void signal();
123+
static void signal(int cpu = -1);
122124

123125
// trigger interrupt on specified CPU
124126
static void unicast(int cpu, uint8_t intr);

api/util/crc64.hpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct crc64 {
4646
}
4747

4848

49-
static constexpr inline uint64_t checksum(uint64_t crc_accumulator, const char* data, size_t data_len) noexcept {
49+
static constexpr uint64_t checksum(uint64_t crc_accumulator, const char* data, size_t data_len) noexcept {
5050
auto crc64_table = get_table();
5151

5252
crc_accumulator = ~crc_accumulator;
@@ -84,10 +84,10 @@ struct crc64 {
8484

8585
using CRC64_table_t = std::array<std::array<uint64_t, 256>, 8>;
8686

87-
static constexpr inline const CRC64_table_t get_table() noexcept {
87+
static constexpr const CRC64_table_t get_table() noexcept {
8888
auto crc64_itable = get_init_table();
8989

90-
CRC64_table_t crc64_table;
90+
CRC64_table_t crc64_table {{}};
9191
crc64_table[0] = crc64_itable;
9292

9393
for (uint64_t i = 0; i < 256; ++i) {
@@ -102,18 +102,14 @@ struct crc64 {
102102
return crc64_table;
103103
}
104104

105-
static constexpr inline const std::array<uint64_t, 256> get_init_table() noexcept {
106-
std::array<uint64_t, 256> data;
105+
static constexpr const std::array<uint64_t, 256> get_init_table() noexcept {
106+
std::array<uint64_t, 256> data {{}};
107107

108108
for (uint64_t i {0}; i < 256; ++i) {
109109
uint64_t crc {i};
110110

111111
for (uint64_t j {0}; j < 8; ++j) {
112-
if (crc & 1) {
113-
crc = (crc >> 1) ^ POLY;
114-
} else {
115-
crc >>= 1;
116-
}
112+
crc = (crc & 1) ? ((crc >> 1) ^ POLY) : (crc >> 1);
117113
}
118114

119115
data[i] = crc;

cmake/botan.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
include(ExternalProject)
55

66
if(${ARCH} STREQUAL "x86_64")
7-
set(BOTAN_HASH 7432fa529d86070317f594dddb07944f)
7+
set(BOTAN_HASH fb698d0f5c9497b7029c9573888c22c8)
88
elseif(${ARCH} STREQUAL "i686")
9-
set(BOTAN_HASH 5ef7f26047f8fe17219f62755938621d)
9+
set(BOTAN_HASH c22686843461d58a5ac15da7fab18e21)
1010
endif()
1111

1212
ExternalProject_Add(botan
1313
PREFIX botan
14-
URL https://github.com/includeos/botan/releases/download/inc-2.0/botan-includeos-${ARCH}.tar.gz
14+
URL https://github.com/fwsgonzo/botan/releases/download/v0.11/botan-includeos-${ARCH}.tar.gz
1515
URL_HASH MD5=${BOTAN_HASH}
1616
CONFIGURE_COMMAND ""
1717
BUILD_COMMAND ""

cmake/post.service.cmake

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ add_library(libgcc STATIC IMPORTED)
248248
set_target_properties(libgcc PROPERTIES LINKER_LANGUAGE C)
249249
set_target_properties(libgcc PROPERTIES IMPORTED_LOCATION ${INSTALL_LOC}/${ARCH}/lib/libgcc.a)
250250

251+
# Depending on the output of this command will make it always run. Like magic.
252+
add_custom_command(OUTPUT fake_news
253+
COMMAND cmake -E touch_nocreate alternative_facts)
254+
251255
# add memdisk
252256
function(add_memdisk DISK)
253257
get_filename_component(DISK_RELPATH "${DISK}"
@@ -256,7 +260,7 @@ function(add_memdisk DISK)
256260
OUTPUT memdisk.o
257261
COMMAND python ${INSTALL_LOC}/memdisk/memdisk.py --file ${INSTALL_LOC}/memdisk/memdisk.asm ${DISK_RELPATH}
258262
COMMAND nasm -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} ${INSTALL_LOC}/memdisk/memdisk.asm -o memdisk.o
259-
DEPENDS ${DISK_RELPATH}
263+
DEPENDS ${DISK_RELPATH} fake_news
260264
)
261265
add_library(memdisk STATIC memdisk.o)
262266
set_target_properties(memdisk PROPERTIES LINKER_LANGUAGE CXX)
@@ -269,8 +273,9 @@ function(diskbuilder FOLD)
269273
add_custom_command(
270274
OUTPUT memdisk.fat
271275
COMMAND ${INSTALL_LOC}/bin/diskbuilder -o memdisk.fat ${REL_PATH}
272-
)
273-
add_custom_target(diskbuilder ALL DEPENDS memdisk.fat)
276+
DEPENDS fake_news
277+
)
278+
add_custom_target(diskbuilder ALL DEPENDS memdisk.fat)
274279
add_dependencies(service diskbuilder)
275280
add_memdisk("${CMAKE_BINARY_DIR}/memdisk.fat")
276281
endfunction()

etc/install_dependencies_linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ case $SYSTEM in
135135
;;
136136
"Linux")
137137
case $RELEASE in
138-
"debian"|"ubuntu"|"linuxmint")
138+
"debian"|"ubuntu"|"linuxmint"|"parrot")
139139
DEPENDENCIES="$DEPENDENCIES"
140140
sudo apt-get -qq update || exit 1
141141
sudo apt-get -qqy install $DEPENDENCIES > /dev/null || exit 1

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ check_os_support() {
7171
;;
7272
"Linux")
7373
case $RELEASE in
74-
"debian"|"ubuntu"|"linuxmint")
74+
"debian"|"ubuntu"|"linuxmint"|"parrot")
7575
return 0;
7676
;;
7777
"fedora")

src/arch/x86_64/arch_start.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extern __multiboot_addr
2222

2323
%define PAGE_SIZE 0x1000
2424
%define P4_TAB 0x1000
25-
%define P3_TAB 0x2000 ;; - 0x5000
25+
%define P3_TAB 0x2000 ;; - 0x5fff
2626
%define P2_TAB 0x100000
2727
%define STACK_LOCATION 0xA00000
2828

0 commit comments

Comments
 (0)