Skip to content

Commit 50bae28

Browse files
author
zhiayang
committed
various things
1 parent 595f04d commit 50bae28

File tree

9 files changed

+248
-259
lines changed

9 files changed

+248
-259
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*.dll
66
*.cpp.d
77
*.c.d
8+
*.h.d
9+
*.h.gch
810
*.log
911
build
1012
toolchain-setup

kernel/include/defs.h

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
#include "krt.h"
1212

13+
#ifdef ZPR_FREESTANDING
14+
#undef ZPR_FREESTANDING
15+
#endif
16+
1317
#define ZPR_FREESTANDING 1
1418
#include <zst/zpr.h>
1519

kernel/include/precompile.h

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// precompile.h
2+
// Copyright (c) 2020, zhiayang
3+
// Licensed under the Apache License Version 2.0.
4+
5+
6+
#ifdef ZPR_FREESTANDING
7+
#undef ZPR_FREESTANDING
8+
#endif
9+
10+
#define ZPR_FREESTANDING 1
11+
12+
#include <cstddef>
13+
#include <cstdint>
14+
15+
#include <zst/zpr.h>
16+

kernel/makefile

+22-7
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,25 @@ CDEPS = $(COBJ:.o=.d)
3232
OPTIMISATIONS := $(KERNEL_SSE_DISABLERS) -Og -g
3333
LDFLAGS := -z max-page-size=0x1000 -L$(SYSROOT)/usr/lib -nostdlib
3434

35+
PRECOMP_HDR := include/precompile.h
36+
PRECOMP_GCH := $(PRECOMP_HDR:.h=.h.gch)
37+
3538
DEFINES = -DORION_KERNEL=1 -D__ARCH_x64__=1
3639
INCLUDES = -Iinclude -I$(PROJECT_DIR)/libs -I$(PROJECT_DIR)/libs/libkrt/include -I$(PROJECT_DIR)/libs/miniz -I$(PROJECT_DIR)/efx/zircon-efi
3740

41+
3842
KERNEL = nxkernel64
3943

4044
LIBKRT = $(SYSROOT)/usr/lib/libkrt.a
4145
LIBMINIZ = $(SYSROOT)/usr/lib/libminiz.a
4246

43-
.PHONY: all
47+
UBSAN_FLAG = -fsanitize=undefined
48+
4449
.DEFAULT_GOAL = all
4550

46-
UBSAN_FLAG = -fsanitize=undefined
51+
52+
.PHONY: all
53+
.PRECIOUS: $(PRECOMP_GCH)
4754

4855

4956

@@ -61,21 +68,29 @@ $(SYSROOT)/boot/$(KERNEL): $(SOBJ) $(COBJ) $(CXXOBJ) $(LIBKRT) $(LIBMINIZ)
6168
@echo " $(notdir $<)"
6269
@$(AS) -Isource/arch/$(ARCH)/include $< -o $@
6370

64-
%.cpp.o: %.cpp makefile | print-kernel
65-
@echo " $(notdir $<)"
66-
@$(CXX) $(CXXFLAGS) $(UBSAN_FLAG) $(WARNINGS) $(DEFINES) $(INCLUDES) $(OPTIMISATIONS) -MMD -MP -o $@ $<
67-
6871
%.c.o: %.c makefile | print-kernel
6972
@echo " $(notdir $<)"
7073
@$(CC) $(CFLAGS) $(UBSAN_FLAG) $(WARNINGS) $(DEFINES) $(INCLUDES) $(OPTIMISATIONS) -MMD -MP -o $@ $<
7174

75+
%.cpp.o: %.cpp makefile $(PRECOMP_GCH) | print-kernel
76+
@echo " $(notdir $<)"
77+
@$(CXX) $(CXXFLAGS) $(UBSAN_FLAG) $(WARNINGS) $(DEFINES) $(INCLUDES) $(OPTIMISATIONS) -include $(PRECOMP_HDR) -MMD -MP -o $@ $<
7278

79+
%.h.gch: %.h makefile | print-kernel
80+
@echo " $(notdir $<)"
81+
@$(CXX) $(CXXFLAGS) $(UBSAN_FLAG) $(WARNINGS) $(DEFINES) $(INCLUDES) $(OPTIMISATIONS) -MMD -MP -x c++-header -o $@ $<
7382

7483

84+
-include $(PRECOMP_HDR:.h=.h.d)
7585
-include $(CDEPS)
7686
-include $(CXXDEPS)
7787

78-
88+
clean:
89+
@find . -name "*.o" -delete
90+
@find . -name "*.h.d" -delete
91+
@find . -name "*.cpp.d" -delete
92+
@find . -name "*.h.gch" -delete
93+
@rm -f $(SYSROOT)/boot/$(KERNEL)
7994

8095

8196

kernel/source/misc/disasm.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace nx::disasm
3636

3737
static void print_instr(const x64::Instruction& instr, uint64_t ip)
3838
{
39-
auto print_operand = [&ip](const x64::Operand& op) {
39+
auto print_operand = [&ip, &instr](const x64::Operand& op) {
4040
if(op.isRegister())
4141
{
4242
serial::debugprintf("%{}", op.reg().name());
@@ -60,7 +60,7 @@ namespace nx::disasm
6060
}
6161
else if(op.isRelativeOffset())
6262
{
63-
serial::debugprintf("{#x}", ip + op.ofs().offset());
63+
serial::debugprintf("{#x}", ip + instr.numBytes() + op.ofs().offset());
6464
}
6565
else if(op.isMemory())
6666
{

kernel/source/scheduler/interrupts.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,13 @@ namespace interrupts
8888

8989
if(it->remaining == 0)
9090
{
91-
list.erase(it);
9291
if(!it->handled)
9392
{
9493
warn("irq", "no drivers handled irq {}", num);
9594
sendEOI(num);
9695
}
96+
97+
list.erase(it);
9798
}
9899
}
99100
else

libs/libkrt/include/krt/types/str.h

+26-26
Original file line numberDiff line numberDiff line change
@@ -153,32 +153,32 @@ namespace krt
153153
const char& back() const { return impl::back_const(this); }
154154

155155
void erase_at(size_t idx, size_t num) { impl::erase_at(this, idx, num); }
156-
bool operator== (const string& other) const { return impl::op_cmpeq(this, other); }
157-
bool operator!= (const string& other) const { return impl::op_cmpneq(this, other); }
158-
bool operator< (const string& other) const { return impl::op_cmplt(this, other); }
159-
bool operator> (const string& other) const { return impl::op_cmpgt(this, other); }
160-
bool operator>= (const string& other) const { return impl::op_cmpgeq(this, other); }
161-
bool operator<= (const string& other) const { return impl::op_cmpleq(this, other); }
162-
163-
bool operator== (const char* other) const { return impl::op_cmpeq(this, other, strlen(other)); }
164-
bool operator!= (const char* other) const { return impl::op_cmpneq(this, other, strlen(other)); }
165-
bool operator< (const char* other) const { return impl::op_cmplt(this, other, strlen(other)); }
166-
bool operator> (const char* other) const { return impl::op_cmpgt(this, other, strlen(other)); }
167-
bool operator>= (const char* other) const { return impl::op_cmpgeq(this, other, strlen(other)); }
168-
bool operator<= (const char* other) const { return impl::op_cmpleq(this, other, strlen(other)); }
169-
170-
char& operator[] (size_t idx) { return impl::op_subscript(this, idx); }
171-
const char& operator[] (size_t idx) const { return impl::op_subscript_const(this, idx); }
172-
173-
string& operator+= (const string& other) { this->append(other); return *this; }
174-
string& operator+= (string&& other) { this->append(move(other)); return *this; }
175-
string& operator+= (const char* other) { this->append(other); return *this; }
176-
177-
string operator+ (const string& other) const { auto copy = *this; copy.append(other); return copy; }
178-
string operator+ (const char* other) const { auto copy = *this; copy.append(other); return copy; }
179-
180-
string& operator+= (char other) { this->append(string(&other, 1)); return *this; }
181-
string operator+ (char other) const { auto copy = *this; copy.append(string(&other, 1)); return copy; }
156+
bool operator== (const string& other) const { return impl::op_cmpeq(this, other); }
157+
bool operator!= (const string& other) const { return impl::op_cmpneq(this, other); }
158+
bool operator< (const string& other) const { return impl::op_cmplt(this, other); }
159+
bool operator> (const string& other) const { return impl::op_cmpgt(this, other); }
160+
bool operator>= (const string& other) const { return impl::op_cmpgeq(this, other); }
161+
bool operator<= (const string& other) const { return impl::op_cmpleq(this, other); }
162+
163+
bool operator== (const char* other) const { return impl::op_cmpeq(this, other, strlen(other)); }
164+
bool operator!= (const char* other) const { return impl::op_cmpneq(this, other, strlen(other)); }
165+
bool operator< (const char* other) const { return impl::op_cmplt(this, other, strlen(other)); }
166+
bool operator> (const char* other) const { return impl::op_cmpgt(this, other, strlen(other)); }
167+
bool operator>= (const char* other) const { return impl::op_cmpgeq(this, other, strlen(other)); }
168+
bool operator<= (const char* other) const { return impl::op_cmpleq(this, other, strlen(other)); }
169+
170+
char& operator[] (size_t idx) { return impl::op_subscript(this, idx); }
171+
const char& operator[] (size_t idx) const { return impl::op_subscript_const(this, idx); }
172+
173+
string& operator+= (const string& other) { this->append(other); return *this; }
174+
string& operator+= (string&& other) { this->append(move(other)); return *this; }
175+
string& operator+= (const char* other) { this->append(other); return *this; }
176+
177+
string operator+ (const string& other) const { auto copy = *this; copy.append(other); return copy; }
178+
string operator+ (const char* other) const { auto copy = *this; copy.append(other); return copy; }
179+
180+
string& operator+= (char other) { this->append(string(&other, 1)); return *this; }
181+
string operator+ (char other) const { auto copy = *this; copy.append(string(&other, 1)); return copy; }
182182

183183

184184
iterator begin() { return iterator(this->ptr); }

0 commit comments

Comments
 (0)