Skip to content

Commit 8a734b8

Browse files
author
Ricardo Koller
committed
Point to solo5 v0.3.0
This is mainly for includeos#1515 as solo5 version (0.3.0) has a fix for it. The solo5 interface changed slightly for 0.3.0: function names, and args to `solo5_app_main` and `solo5_block_read`.
1 parent 847dd5b commit 8a734b8

5 files changed

Lines changed: 49 additions & 35 deletions

File tree

cmake/cross_compiled_libraries.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ExternalProject_Add(solo5_repo
3333
PREFIX precompiled
3434
BUILD_IN_SOURCE 1
3535
GIT_REPOSITORY https://github.com/solo5/solo5.git
36-
GIT_TAG 2765e0f5f090c0b27a8d62a48285842236e7d20f
36+
GIT_TAG v0.3.0
3737
CONFIGURE_COMMAND CC=gcc ./configure.sh
3838
UPDATE_COMMAND ""
3939
BUILD_COMMAND make

src/drivers/solo5blk.cpp

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,45 @@ extern "C" {
1616
Solo5Blk::Solo5Blk()
1717
: hw::Block_device()
1818
{
19-
INFO("Solo5Blk", "Block device with %zu sectors", solo5_blk_sectors());
19+
struct solo5_block_info bi;
20+
solo5_block_info(&bi);
21+
assert(bi.block_size == SECTOR_SIZE);
22+
INFO("Solo5Blk", "Block device with %zu sectors",
23+
bi.capacity / SECTOR_SIZE);
2024
}
2125

2226
Solo5Blk::block_t Solo5Blk::size() const noexcept {
23-
return solo5_blk_sectors();
27+
struct solo5_block_info bi;
28+
solo5_block_info(&bi);
29+
return bi.capacity / SECTOR_SIZE;
2430
}
2531

26-
Solo5Blk::buffer_t Solo5Blk::read_sync(block_t blk)
27-
{
28-
auto buffer = fs::construct_buffer(block_size());
29-
int rlen = SECTOR_SIZE;
32+
Solo5Blk::buffer_t Solo5Blk::read_sync(block_t blk) {
33+
auto buffer = fs::construct_buffer(SECTOR_SIZE);
34+
solo5_result_t res;
3035

31-
solo5_blk_read_sync((uint64_t) blk, buffer->data(), &rlen);
36+
res = solo5_block_read((solo5_off_t) blk * SECTOR_SIZE,
37+
buffer->data(), SECTOR_SIZE);
38+
if (res != SOLO5_R_OK) {
39+
buffer.reset();
40+
return nullptr;
41+
}
3242
return buffer;
3343
}
3444

3545
Solo5Blk::buffer_t Solo5Blk::read_sync(block_t blk, size_t count) {
36-
auto buffer = fs::construct_buffer(block_size() * count);
37-
int rlen = SECTOR_SIZE * count;
46+
auto buffer = fs::construct_buffer(SECTOR_SIZE * count);
47+
solo5_result_t res;
3848

39-
solo5_blk_read_sync((uint64_t) blk, buffer->data(), &rlen);
49+
auto* data = (uint8_t*) buffer->data();
50+
for (size_t i = 0; i < count; i++) {
51+
res = solo5_block_read((solo5_off_t) (blk + i) * SECTOR_SIZE,
52+
data + (i * SECTOR_SIZE), SECTOR_SIZE);
53+
if (res != SOLO5_R_OK) {
54+
buffer.reset();
55+
return nullptr;
56+
}
57+
}
4058
return buffer;
4159
}
4260

src/drivers/solo5net.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ Solo5Net::Solo5Net()
3636
bufstore_{NUM_BUFFERS, 2048u} // don't change this
3737
{
3838
INFO("Solo5Net", "Driver initializing");
39-
mac_addr = MAC::Addr(solo5_net_mac_str());
39+
struct solo5_net_info ni;
40+
solo5_net_info(&ni);
41+
mac_addr = MAC::Addr(ni.mac_address[0], ni.mac_address[1], ni.mac_address[2],
42+
ni.mac_address[3], ni.mac_address[4], ni.mac_address[5]);
4043
}
4144

4245
void Solo5Net::transmit(net::Packet_ptr pckt)
@@ -48,7 +51,7 @@ void Solo5Net::transmit(net::Packet_ptr pckt)
4851
// next in line
4952
auto next = tail->detach_tail();
5053
// write data to network
51-
solo5_net_write_sync(tail->buf(), tail->size());
54+
solo5_net_write(tail->buf(), tail->size());
5255
// set tail to next, releasing tail
5356
tail = std::move(next);
5457
// Stat increase packets transmitted
@@ -75,8 +78,8 @@ net::Packet_ptr Solo5Net::recv_packet()
7578
auto* pckt = (net::Packet*) buffer.addr;
7679
new (pckt) net::Packet(0, MTU(), packet_len(), buffer.bufstore);
7780
// Populate the packet buffer with new packet, if any
78-
int size = packet_len();
79-
if (solo5_net_read_sync(pckt->buf(), &size) == 0) {
81+
size_t size = packet_len();
82+
if (solo5_net_read(pckt->buf(), size, &size) == 0) {
8083
// Adjust packet size to match received data
8184
if (size) {
8285
pckt->set_data_end(size);

src/platform/x86_solo5/kernel_start.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,21 @@ extern "C" {
2626

2727
static char temp_cmdline[1024];
2828
static uintptr_t mem_size = 0;
29+
static uintptr_t free_mem_begin;
2930

3031
extern "C"
3132
void kernel_start()
3233
{
3334
// generate checksums of read-only areas etc.
3435
__init_sanity_checks();
3536

36-
// Determine where free memory starts
37-
uintptr_t free_mem_begin = reinterpret_cast<uintptr_t>(&_end);
38-
3937
// Preserve symbols from the ELF binary
4038
free_mem_begin += _move_symbols(free_mem_begin);
4139

4240
// Do not zero out all solo5 global variables!! == don't touch the BSS
4341
//_init_bss();
4442

4543
// Initialize heap
46-
// XXX: this is dangerous as solo5 might be doing malloc()'s using it's own
47-
// idea of a heap. Luckily there is no malloc instance at solo5/kernel/[ukvm|virtio|muen],
48-
// so might be OK (for now).
4944
OS::init_heap(free_mem_begin, mem_size);
5045

5146
_init_elf_parser();
@@ -62,17 +57,15 @@ void kernel_start()
6257
}
6358

6459
extern "C"
65-
int solo5_app_main(char* cmdline)
60+
int solo5_app_main(const struct solo5_start_info *si)
6661
{
67-
// cmdline is stored at 0x6000 by ukvm which is used by includeos. Move it fast.
68-
strncpy(temp_cmdline, cmdline, sizeof(temp_cmdline)-1);
69-
temp_cmdline[sizeof(temp_cmdline)-1] = 0;
70-
71-
// solo5 sets the stack to be at the end of memory, so let's use that as
72-
// our memory size (before we change).
73-
mem_size = (uintptr_t) get_cpu_ebp();
74-
75-
// set the stack location to its new includeos location, and call kernel_start
76-
set_stack();
77-
return 0;
62+
// si is stored at 0x6000 by ukvm which is used by includeos. Move it fast.
63+
strncpy(temp_cmdline, si->cmdline, sizeof(temp_cmdline)-1);
64+
temp_cmdline[sizeof(temp_cmdline)-1] = 0;
65+
free_mem_begin = si->heap_start;
66+
mem_size = si->heap_size;
67+
68+
// set the stack location to its new includeos location, and call kernel_start
69+
set_stack();
70+
return 0;
7871
}

src/platform/x86_solo5/os.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void OS::event_loop()
154154
// XXX: temporarily ALWAYS sleep for 0.5 ms. We should ideally ask Timers
155155
// for the next immediate timer to fire (the first from the "scheduled" list
156156
// of timers?)
157-
rc = solo5_poll(solo5_clock_monotonic() + 500000ULL); // now + 0.5 ms
157+
rc = solo5_yield(solo5_clock_monotonic() + 500000ULL); // now + 0.5 ms
158158
Timers::timers_handler();
159159
if (rc) {
160160
for(auto& nic : hw::Devices::devices<hw::Nic>()) {
@@ -198,7 +198,7 @@ void OS::block()
198198
highest_blocking_level = blocking_level;
199199

200200
int rc;
201-
rc = solo5_poll(solo5_clock_monotonic() + 50000ULL); // now + 0.05 ms
201+
rc = solo5_yield(solo5_clock_monotonic() + 50000ULL); // now + 0.05 ms
202202
if (rc == 0) {
203203
Timers::timers_handler();
204204
} else {

0 commit comments

Comments
 (0)