-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootloader.cpp
More file actions
160 lines (146 loc) · 5.47 KB
/
bootloader.cpp
File metadata and controls
160 lines (146 loc) · 5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// bootloader.cpp
/*
* Boot Loader
*
* Maintainer: Park Jiwoo
*
* Copyright (C) 2024 Park-Jiwoo
*
*/
#include "bootloader.h"
#include "mainwindow.h"
#include <QKeyEvent>
#include <QApplication>
#include <QTimer>
#include <QLabel>
#include <QVBoxLayout>
#include <QThread>
#include <QSpacerItem>
#include <QTextEdit>
#include <QProgressBar>
/*
* @brief Bootloader 생성자
* @param parent 부모 위젯, 기본값은 nullptr
* @details 부트로더 UI를 초기화하고 부팅 시뮬레이션을 시작합니다.
*/
Bootloader::Bootloader(QWidget *parent)
: QWidget(parent)
{
// 배경 그라데이션 스타일 적용 (site_logo.png와 어울리는 밝은 오렌지/베이지 계열)
this->setStyleSheet("background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #FDE9D9, stop:1 #FAD7A0);");
this->setWindowTitle("ImLLM OS Bootloader");
this->setFixedSize(800, 600);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
// 로고 이미지 중앙에 크게
QLabel *logoLabel = new QLabel(this);
QPixmap logoPixmap(":/site_logo.png");
logoLabel->setPixmap(logoPixmap.scaled(300, 300, Qt::KeepAspectRatio, Qt::SmoothTransformation));
logoLabel->setAlignment(Qt::AlignCenter);
logoLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// 부팅 상태 메시지
QLabel *bootMsg = new QLabel("ImLLM OS Booting...", this);
bootMsg->setAlignment(Qt::AlignCenter);
bootMsg->setStyleSheet("color: #FFA500; font-size: 22px; font-weight: bold; font-family: 'Consolas', 'Courier New', monospace; margin-top: 10px;");
// 진행바 (site_logo.png와 어울리는 색상)
progressBar = new QProgressBar(this);
progressBar->setRange(0, 100);
progressBar->setValue(0);
progressBar->setTextVisible(false);
progressBar->setFixedHeight(18);
progressBar->setStyleSheet("QProgressBar { background: #FAD7A0; border-radius: 9px; } QProgressBar::chunk { background: #FFA500; border-radius: 9px; }");
// 부가 메시지
statusLabel = new QLabel("", this);
statusLabel->setAlignment(Qt::AlignCenter);
statusLabel->setStyleSheet("color: #6E5C3C; font-size: 16px; font-family: 'Consolas', 'Courier New', monospace; margin-top: 10px;");
layout->addStretch();
layout->addWidget(logoLabel);
layout->addWidget(bootMsg);
layout->addSpacing(10);
layout->addWidget(progressBar);
layout->addSpacing(10);
layout->addWidget(statusLabel);
layout->addStretch();
setLayout(layout);
// 부팅 시뮬레이션 시작
QTimer::singleShot(500, this, &Bootloader::simulateBootProcess);
}
/*
* @brief Bootloader 소멸자
* @details 부트로더에서 사용한 자원을 해제합니다.
*/
Bootloader::~Bootloader()
{
}
/*
* @brief 키 입력 이벤트 처리
* @param event 키보드 이벤트 객체
* @details Enter 키가 눌리면 OS 부팅을 시작합니다.
*/
void Bootloader::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
startOS();
}
}
/*
* @brief 부팅 시뮬레이션 함수
* @details 부팅 과정을 시뮬레이션하여 텍스트로 표시합니다.
*/
void Bootloader::simulateBootProcess()
{
// td_kernel_engine.c 기반 실제 커널 부트 시퀀스 메시지
QStringList steps = {
"[INFO ] Initializing kernel environment...",
"[INFO ] Creating IPC socket pair...",
"[INFO ] Forking child process...",
"[CHILD] Starting file system test...",
"[CHILD] Running file read test...",
"[CHILD] Creating thread...",
"[CHILD] Thread joined successfully",
"[CHILD] Exiting child process...",
"[PARENT] Sending/receiving IPC messages...",
"[PARENT] Running file read test...",
"[PARENT] Running multithreading test...",
"[PARENT] Running smart pointer test...",
"[PARENT] Running semaphore synchronization test...",
"[PARENT] Running mutex synchronization test...",
"[PARENT] Running error handling test...",
"[PARENT] Running process management simulation...",
"[PARENT] Running memory management simulation...",
"[PARENT] Running device I/O simulation...",
"[PARENT] Running file system simulation...",
"[PARENT] Running network simulation...",
"[PARENT] Running system call simulation...",
"[PARENT] Running hardware interrupt simulation...",
"[PARENT] Kernel panic simulation (skipped)",
"[PARENT] Final cleanup...",
"[ OK ] Kernel boot complete!"
};
int totalSteps = steps.size();
int progressPerStep = 100 / totalSteps;
for (int i = 0; i < totalSteps; ++i) {
QTimer::singleShot(700 * i, this, [this, i, steps, progressPerStep]() {
statusLabel->setText(steps[i]);
progressBar->setValue((i + 1) * progressPerStep);
if (i == steps.size() - 1) {
QTimer::singleShot(900, this, [this]() {
statusLabel->setText("<b style='color:#FFA500;'>Press <Enter> to continue...</b>");
progressBar->setValue(100);
});
}
});
}
}
/*
* @brief OS 부팅 시작 함수
* @details 부팅이 완료되면 메인 윈도우를 표시하고 부트로더 창을 닫습니다.
*/
void Bootloader::startOS()
{
// 메인 윈도우로 전환
MainWindow *mainWindow = new MainWindow();
mainWindow->show();
this->close();
}