mirror of
https://gitlab.com/niansa/minituxi.git
synced 2025-03-06 20:49:18 +01:00
Got project at least somewhat up to my standards
This commit is contained in:
parent
0c160eb956
commit
73a9600d9d
6 changed files with 26 additions and 20 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
|||
bin
|
||||
bzImage
|
||||
CMakeLists.txt.user
|
||||
CMakeLists.txt.user*
|
||||
initramfs.cpio.gz
|
||||
|
|
|
@ -23,12 +23,12 @@ namespace System {
|
|||
void lockup();
|
||||
|
||||
[[noreturn]]
|
||||
void critical_stop(std::string_view msg);
|
||||
void panic(std::string_view msg);
|
||||
|
||||
template<typename T>
|
||||
inline T check_sysc(T v, std::string_view msg = "Syscall failed") {
|
||||
if (v < 0) {
|
||||
critical_stop(msg);
|
||||
panic(msg);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
|
30
src/main.cpp
30
src/main.cpp
|
@ -38,6 +38,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
struct UMain {
|
||||
std::mutex mutex;
|
||||
System::Framebuffer fb;
|
||||
|
@ -60,7 +61,7 @@ struct UMain {
|
|||
|
||||
void drawLoop() {
|
||||
using namespace std::literals::chrono_literals;
|
||||
ProgressWindow pWin(fb.get_centered({500, 50}));
|
||||
ProgressWindow pWin(fb.get_centered({500, 40}));
|
||||
uint8_t p = 0;
|
||||
while (true) {
|
||||
mutex.unlock();
|
||||
|
@ -92,22 +93,25 @@ struct UMain {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
int main() {
|
||||
std::cout << "\033[H\033[J" << std::flush;
|
||||
|
||||
// Initialisations if PID 1 then run
|
||||
try {
|
||||
if (getpid() == 1) {
|
||||
System::Mounts mounts;
|
||||
UMain().run();
|
||||
} else {
|
||||
UMain().run();
|
||||
// Set terminate handle
|
||||
std::set_terminate([] () {
|
||||
try {
|
||||
std::rethrow_exception(std::current_exception());
|
||||
} catch (std::exception& e) {
|
||||
System::panic(e.what());
|
||||
} catch (...) {
|
||||
System::panic("Unknown");
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
System::critical_stop(e.what());
|
||||
} catch (...) {
|
||||
System::critical_stop("Unknown");
|
||||
}
|
||||
});
|
||||
|
||||
// Initialisations if PID 1 then run
|
||||
if (getpid() == 1)
|
||||
new System::Mounts;
|
||||
UMain().run();
|
||||
|
||||
// Lock up
|
||||
System::lockup();
|
||||
|
|
|
@ -16,16 +16,15 @@ void lockup() {
|
|||
}
|
||||
|
||||
[[noreturn]]
|
||||
void critical_stop(std::string_view msg) {
|
||||
void panic(std::string_view msg) {
|
||||
std::cerr << "\n\n\n"
|
||||
"A critical stop has occured: \n"
|
||||
"An unrecoverable userspace error has occurred: \n"
|
||||
"Message: " << msg << "\n"
|
||||
"Errno: " << strerror(errno) << std::endl;
|
||||
lockup();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Framebuffer::draw_text(std::string_view str, Coord coord, pixType color, bool centered) {
|
||||
// Get half pixel width if centered
|
||||
if (centered) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# Config
|
||||
C="c++"
|
||||
CFLAGS="-std=c++17 -static -O3 -I../include"
|
||||
CFLAGS="-std=c++20 -static -O2 -I../include"
|
||||
|
||||
# Init env
|
||||
cd src
|
||||
|
|
3
utils/test.sh
Executable file
3
utils/test.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#! /bin/sh
|
||||
|
||||
exec qemu-system-x86_64 -m 512M -enable-kvm -initrd ./initramfs.cpio.gz -kernel /vmlinuz -append rdinit=/main
|
Loading…
Add table
Reference in a new issue