Skip to content

Commit e10f1aa

Browse files
authored
Merge pull request #1277 from fwsGonzo/dev
More fixes and g++ compatibility
2 parents 07aa647 + 720031b commit e10f1aa

10 files changed

Lines changed: 40 additions & 86 deletions

File tree

api/net/ethernet/header.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
// See the License for the specific language governing permissions and
1616
// limitations under the License.
17-
#pragma once
1817

18+
#pragma once
1919
#ifndef NET_ETHERNET_HEADER_HPP
2020
#define NET_ETHERNET_HEADER_HPP
2121

@@ -40,7 +40,7 @@ class Header {
4040
const MAC::Addr& src() const noexcept
4141
{ return src_; }
4242

43-
const Ethertype& type() const noexcept
43+
Ethertype type() const noexcept
4444
{ return type_; }
4545

4646
void set_dest(const MAC::Addr& dest)

api/net/ip4/icmp4_common.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ namespace net {
9595
return "TIMESTAMP REPLY (14)";
9696
case Type::NO_REPLY:
9797
return "NO REPLY";
98+
default:
99+
return "UNKNOWN";
98100
};
99101
}();
100102
}

etc/service.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,6 @@ set_target_properties(crti PROPERTIES IMPORTED_LOCATION $ENV{INCLUDEOS_PREFIX}/i
190190

191191
target_link_libraries(service --whole-archive crti --no-whole-archive)
192192

193-
add_library(multiboot STATIC IMPORTED)
194-
set_target_properties(multiboot PROPERTIES LINKER_LANGUAGE CXX)
195-
set_target_properties(multiboot PROPERTIES IMPORTED_LOCATION $ENV{INCLUDEOS_PREFIX}/includeos/lib/libmultiboot.a)
196-
197-
target_link_libraries(service --whole-archive multiboot --no-whole-archive)
198-
199193
add_library(libos STATIC IMPORTED)
200194
set_target_properties(libos PROPERTIES LINKER_LANGUAGE CXX)
201195
set_target_properties(libos PROPERTIES IMPORTED_LOCATION $ENV{INCLUDEOS_PREFIX}/includeos/lib/libos.a)

src/arch/x86/start.asm

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,35 @@ global _start
2121
global __xsave_enabled
2222
global __avx_enabled
2323

24+
%define MB_MAGIC 0x1BADB002
25+
%define MB_FLAGS 0x3 ;; ALIGN + MEMINFO
26+
27+
extern _MULTIBOOT_START_
28+
extern _LOAD_START_
29+
extern _LOAD_END_
30+
extern _end
31+
32+
ALIGN 4
33+
section .multiboot
34+
dd MB_MAGIC
35+
dd MB_FLAGS
36+
dd -(MB_MAGIC + MB_FLAGS)
37+
dd _MULTIBOOT_START_
38+
dd _LOAD_START_
39+
dd _LOAD_END_
40+
dd _end
41+
dd _start
42+
2443
%define data_segment 0x10
2544
%define code_segment 0x08
2645

46+
section .data
2747
__xsave_enabled:
2848
dw 0x0
2949
__avx_enabled:
3050
dw 0x0
3151

52+
ALIGN32
3253
section .text
3354
;; Multiboot places boot paramters on eax and ebx.
3455
_start:
@@ -57,7 +78,7 @@ rock_bottom:
5778
;; enable SSE before we enter C/C++ land
5879
call enable_sse
5980
;; enable AVX if xsave and avx supported on CPU
60-
call enable_avx
81+
;call enable_avx
6182

6283
;; Place multiboot parameters on stack
6384
push ebx

src/boot/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
add_library(multiboot STATIC multiboot.cpp)
2-
add_dependencies(multiboot PrecompiledLibraries)
31

42
add_custom_command(
53
OUTPUT bootloader
@@ -10,4 +8,3 @@ add_custom_command(
108
add_custom_target(run ALL DEPENDS bootloader)
119

1210
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bootloader DESTINATION includeos/boot)
13-
install(TARGETS multiboot DESTINATION includeos/lib)

src/boot/multiboot.cpp

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/linker.ld

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,14 @@
1818
**/
1919
ENTRY(_start)
2020

21-
PHDRS {
22-
loadable PT_LOAD FLAGS(7);
23-
}
24-
2521
SECTIONS
2622
{
2723
PROVIDE ( _ELF_START_ = . + 0x100000);
2824
PROVIDE ( _LOAD_START_ = _ELF_START_); /* For convenience w. multiboot */
2925

3026
.multiboot (_ELF_START_ + SIZEOF_HEADERS): {
3127
PROVIDE(_MULTIBOOT_START_ = .);
32-
*multiboot.cpp.obj(.rodata);
33-
*multiboot.cpp.o(.rodata);
34-
*multiboot.o(.rodata);
28+
*(.multiboot)
3529
}
3630
PROVIDE ( _TEXT_START_ = . );
3731
.text (_TEXT_START_ ) :
@@ -112,20 +106,6 @@ SECTIONS
112106
_DISK_END_ = .;
113107
}
114108

115-
.symtab :
116-
{
117-
_SYMTAB_START = .;
118-
*(.symtab)
119-
*(.symtab.*)
120-
}:loadable
121-
122-
.strtab :
123-
{
124-
_STRTAB_START = .;
125-
*(.strtab)
126-
*(.strtab.*)
127-
}:loadable
128-
129109
.elf_symbols : {
130110
_ELF_SYM_START_ = .;
131111
LONG (0);
@@ -136,9 +116,9 @@ SECTIONS
136116
_BSS_START_ = .;
137117
*(.bss .bss.* .gnu.linkonce.b.*)
138118
*(COMMON)
139-
_BSS_END_ = .;
140119
. = ALIGN(64 / 8);
141120
}
121+
_BSS_END_ = .;
142122
. = ALIGN(64 / 8);
143123
_end = .;
144124

src/service_name.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717

1818
#include <service>
1919

20-
extern "C" const char* service_name__ = SERVICE_NAME;
21-
extern "C" const char* service_binary_name__ = SERVICE;
20+
const char* service_name__ = SERVICE_NAME;
21+
const char* service_binary_name__ = SERVICE;

test/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ set(TEST_SOURCES
107107
)
108108

109109
set(OS_SOURCES
110-
${SRC}/boot/multiboot.cpp
111110
${SRC}/fs/disk.cpp
112111
${SRC}/fs/fat.cpp
113112
${SRC}/fs/fat_async.cpp

vmbuild/vmbuild.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
#include <iostream>
2222

2323
#include <errno.h>
24-
#include <stdio.h>
25-
#include <stdlib.h>
24+
#include <cstdio>
25+
#include <cstdlib>
2626
#include <sys/stat.h>
27+
#include <cassert>
2728

2829
#include "../api/boot/multiboot.h"
29-
#include <gsl/gsl>
3030
#include "elf.h"
3131
#include "elf_binary.hpp"
3232

@@ -72,7 +72,7 @@ string get_bootloader_path(int argc, char** argv) {
7272
int main(int argc, char** argv) {
7373

7474
// Verify proper command usage
75-
if (argc < 2) {
75+
if (argc <= 2) {
7676
cout << info << usage;
7777
exit(EXIT_FAILURE);
7878
}
@@ -127,7 +127,7 @@ int main(int argc, char** argv) {
127127

128128
const decltype(binary_sectors) img_size_sect {1 + binary_sectors};
129129
const decltype(binary_sectors) img_size_bytes {img_size_sect * SECT_SIZE};
130-
Expects((img_size_bytes & (SECT_SIZE-1)) == 0);
130+
assert((img_size_bytes & (SECT_SIZE-1)) == 0);
131131

132132
INFO("Total disk size: \t%ld bytes, => %ld sectors",
133133
img_size_bytes, img_size_sect);
@@ -175,14 +175,17 @@ int main(int argc, char** argv) {
175175

176176
INFO("Verifying multiboot header:");
177177
INFO("Magic value: 0x%x\n" , multiboot.magic);
178-
Expects(multiboot.magic == MULTIBOOT_HEADER_MAGIC);
178+
if (multiboot.magic != MULTIBOOT_HEADER_MAGIC) {
179+
printf("Multiboot magic mismatch: 0x%08x vs %#x\n", multiboot.magic, MULTIBOOT_HEADER_MAGIC);
180+
}
181+
assert(multiboot.magic == MULTIBOOT_HEADER_MAGIC);
179182

180183
INFO("Flags: 0x%x" , multiboot.flags);
181184
INFO("Checksum: 0x%x" , multiboot.checksum);
182185
INFO("Checksum computed: 0x%x", multiboot.checksum + multiboot.flags + multiboot.magic);
183186

184187
// Verify multiboot header checksum
185-
Expects(multiboot.checksum + multiboot.flags + multiboot.magic == 0);
188+
assert(multiboot.checksum + multiboot.flags + multiboot.magic == 0);
186189

187190
INFO("Header addr: 0x%x" , multiboot.header_addr);
188191
INFO("Load start: 0x%x" , multiboot.load_addr);

0 commit comments

Comments
 (0)