summaryrefslogtreecommitdiff
path: root/Source/Kernel
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-12-21 18:56:08 +0100
committerAlexis211 <alexis211@gmail.com>2009-12-21 18:56:08 +0100
commite7a0a24fa88e369eb3d345573200955e99324156 (patch)
treeafe3d9481f9851da9c26cbd6656b5299d7ea72a2 /Source/Kernel
parenta975053605a0f041fd2003792d81c80391527e71 (diff)
downloadMelon-e7a0a24fa88e369eb3d345573200955e99324156.tar.gz
Melon-e7a0a24fa88e369eb3d345573200955e99324156.zip
More work on the status bar
Diffstat (limited to 'Source/Kernel')
-rw-r--r--Source/Kernel/Core/SB.ns.cpp81
-rw-r--r--Source/Kernel/Core/SB.ns.h3
-rw-r--r--Source/Kernel/Core/kmain.wtf.cpp60
-rw-r--r--Source/Kernel/DeviceManager/Disp.ns.cpp39
-rw-r--r--Source/Kernel/DeviceManager/Disp.ns.h1
-rw-r--r--Source/Kernel/Devices/Display/VESADisplay.class.cpp2
-rw-r--r--Source/Kernel/Shell/KernelShell-sys.class.cpp22
-rw-r--r--Source/Kernel/Shell/KernelShell.class.cpp26
-rw-r--r--Source/Kernel/Shell/KernelShell.class.h1
9 files changed, 141 insertions, 94 deletions
diff --git a/Source/Kernel/Core/SB.ns.cpp b/Source/Kernel/Core/SB.ns.cpp
index 62714a1..f5b21ec 100644
--- a/Source/Kernel/Core/SB.ns.cpp
+++ b/Source/Kernel/Core/SB.ns.cpp
@@ -4,6 +4,8 @@
#include <MemoryManager/PhysMem.ns.h>
#include <DeviceManager/Disp.ns.h>
+#define BOOT_ITEMS 17
+
namespace SB {
SimpleVT *sb = NULL;
@@ -11,50 +13,83 @@ SimpleVT *sb = NULL;
String msg;
u16int boot_progress = 0;
+u16int height;
bool gone_multi = false;
Mutex lock(MUTEX_FALSE);
void init() {
sb = new SimpleVT(1, 80, STATUSBAR_FGCOLOR, STATUSBAR_BGCOLOR);
+ height = 1;
sb->map(0, 0);
sb->hideCursor();
}
-void reinit() {
- if (!gone_multi) return;
- lock.waitLock();
- delete sb;
- sb = new SimpleVT(1, Disp::mode.textCols, STATUSBAR_FGCOLOR, STATUSBAR_BGCOLOR);
- sb->map(0, 0);
- sb->hideCursor();
- lock.unlock();
-}
-
void drawprogress(const String& s) {
- *sb << "\nMelon is loading : {";
+ sb->clear();
+ int d = (sb->width() / 2) - ((BOOT_ITEMS + 4) / 2);
+ if (height == 1) d -= 4;
+ sb->moveCursor(0, d);
+ *sb << "{";
for (u32int i = 0; i < boot_progress; i++) *sb << ":";
*sb << ".";
- sb->moveCursor(0, 45);
+ sb->moveCursor(0, BOOT_ITEMS + d + 3);
*sb << "}";
- sb->moveCursor(0, 51);
- *sb << "[" << s;
- sb->moveCursor(0, 78);
- *sb << "]";
+ if (height > 1) {
+ *sb << "\n";
+ *sb << "Loading : [" << s;
+ sb->moveCursor(1, sb->width() - 2);
+ *sb << "]";
+ } else {
+ sb->moveCursor(0, 0);
+ *sb << "Melon is loading :";
+ sb->moveCursor(0, d + BOOT_ITEMS + 6);
+ *sb << "[" << s;
+ sb->moveCursor(0, sb->width() - 2);
+ *sb << "]";
+ }
}
void drawnormal() {
- *sb << "\n [Up:" << (s64int)Time::uptime() << "s";
+ sb->clear();
+ sb->moveCursor(0, 0);
+ *sb << " [Up:" << (s64int)Time::uptime() << "s";
sb->moveCursor(0, 10);
*sb << "] [Mem:" << (s64int)PhysMem::free() << "/" << (s64int)PhysMem::total();
sb->moveCursor(0, 28);
*sb << "] [Proc.:" << (s64int)Task::processes->size();
- sb->moveCursor(0, 39);
- *sb << "] [Threads:" << (s64int)Task::threads->size();
- sb->moveCursor(0, 52);
- *sb << "] [" << msg;
- sb->moveCursor(0, sb->width() - 2);
- *sb << "]";
+ sb->setCursorCol(39);
+ if (height > 1) {
+ *sb << "]";
+ sb->moveCursor(1, 0);
+ *sb << " [Threads:" << (s64int)Task::threads->size();
+ sb->setCursorCol(12);
+ *sb << "] [" << msg;
+ sb->setCursorCol(sb->width() - 2);
+ *sb << "]";
+ } else {
+ *sb << "] [Threads:" << (s64int)Task::threads->size();
+ sb->setCursorCol(52);
+ *sb << "] [" << msg;
+ sb->setCursorCol(sb->width() - 2);
+ *sb << "]";
+ }
+}
+
+void reinit() {
+ if (!gone_multi) return;
+ lock.waitLock();
+ delete sb;
+ height = (Disp::mode.textCols < 80 ? 2 : 1);
+ sb = new SimpleVT(height, Disp::mode.textCols, STATUSBAR_FGCOLOR, STATUSBAR_BGCOLOR);
+ sb->map(0, 0);
+ sb->hideCursor();
+ if (boot_progress != 0) {
+ drawprogress(msg);
+ } else {
+ drawnormal();
+ }
+ lock.unlock();
}
u32int thread(void*) {
diff --git a/Source/Kernel/Core/SB.ns.h b/Source/Kernel/Core/SB.ns.h
index 687be02..7b3b65c 100644
--- a/Source/Kernel/Core/SB.ns.h
+++ b/Source/Kernel/Core/SB.ns.h
@@ -5,12 +5,13 @@
#include <VTManager/SimpleVT.class.h>
namespace SB {
+ extern u16int height;
+
void init(); //Setup status bar with default 80col configuration
void reinit(); //Setup status bar querying Disp:: for text screen width
void gomulti(); //Launch new thread for status bar
void progress(const String& s); //Update progress
void message(const String& s); //Set a message
-
}
#endif
diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp
index 83fca7b..aa87d49 100644
--- a/Source/Kernel/Core/kmain.wtf.cpp
+++ b/Source/Kernel/Core/kmain.wtf.cpp
@@ -86,38 +86,6 @@ u32int logoAnimation(void* p) {
return 0;
}
-void selectVideoMode(SimpleVT& v) {
- Disp::getModes();
- v << "\nPlease select a graphic mode in the list below:\n";
-
- for (u32int i = 0; i < Disp::modes.size(); i++) {
- Disp::mode_t& m = Disp::modes[i];
- v << (s32int)i << ":\t" << "Text " << m.textRows << "x" << m.textCols << "\t";
- if (m.graphWidth != 0 and m.graphHeight != 0) {
- v << "Graphics " << m.graphWidth << "x" << m.graphHeight << "x" << m.graphDepth << "\t";
- } else {
- v << "No graphics";
- }
- v.setCursorCol(50);
- v << m.device->getName() << "\n";
- }
-
- while (1) {
- v << "\nYour selection: ";
- String answer = v.readLine();
- u32int n = answer.toInt();
- v.unmap();
- if (n >= 0 and n < Disp::modes.size() and Disp::setMode(Disp::modes[n])) {
- SB::reinit();
- return;
- } else {
- Disp::setMode(Disp::modes[1]);
- v.map();
- v << "Error while switching video mode, please select another one.";
- }
- }
-}
-
void kmain(multiboot_info_t* mbd, u32int magic) {
DEBUG("Entering kmain.");
@@ -151,7 +119,12 @@ void kmain(multiboot_info_t* mbd, u32int magic) {
SB::progress("Create kernel VT");
kvt = new ScrollableVT(24, 80, 20, KVT_FGCOLOR, KVT_BGCOLOR);
kvt->map(1, 0);
- kvt->moveCursor(0, 0);
+ kvt->setColor(TXTLOGO_FGCOLOR, TXTLOGO_BGCOLOR);
+ for (int i = 0; i < melonLogoLines; i++) {
+ kvt->setCursorCol(40 - (melonLogoCols / 2));
+ *kvt << melonLogo[i] << "\n";
+ }
+ kvt->setColor(KVT_FGCOLOR, KVT_BGCOLOR);
SB::progress("IDT");
IDT::init(); //Setup interrupts
@@ -225,7 +198,6 @@ void kmain(multiboot_info_t* mbd, u32int magic) {
if (!m.empty() && m[0] != WChar("#")) VFS::mount(m, kvt, mbd);
}
}
-
//*************************************** LOAD SYSTEM STUFF
@@ -242,36 +214,26 @@ void kmain(multiboot_info_t* mbd, u32int magic) {
Usr::load(); //Setup user managment
Log::log(KL_STATUS, "kmain : User list loaded");
+ SB::progress("Video mode selection");
+ Disp::selectMode();
if (init.empty()) {
SB::progress("Start kernel shell");
*kvt << "\n";
new KernelShell(cwd, kvt);
- SB::message("Melon is running \\o/");
+ SB::message("Melon is running");
while (KernelShell::getInstances() > 0) {
Task::currThread()->sleep(100);
}
Sys::halt();
} else {
- SB::progress("Video mode selection");
- selectVideoMode(*kvt);
- SB::progress("Logo setup");
- //Create a VT for handling the Melon bootup logo
- SimpleVT *melonLogoVT = new SimpleVT(melonLogoLines, melonLogoCols, TXTLOGO_FGCOLOR, TXTLOGO_BGCOLOR);
- melonLogoVT->map(1);
- new Thread(logoAnimation, (void*)melonLogoVT, true);
-
SB::progress("Launch INIT");
Process* p = Process::run(init, 0);
if (p == 0) {
PANIC((char*)(u8int*)ByteArray(String("Could not launch init : ") += init));
} else {
Log::log(KL_STATUS, String("kmain : Starting init : ") += init);
- VirtualTerminal* vt = new ScrollableVT(Disp::textRows() - 10, Disp::textCols() - 4,
- 200, SHELL_FGCOLOR, SHELL_BGCOLOR);
- Kbd::setFocus(vt);
- ((ScrollableVT*)vt)->map(9);
- p->setInVT(vt);
- p->setOutVT(vt);
+ p->setInVT(kvt);
+ p->setOutVT(kvt);
p->start();
SB::message("Init started");
while (p->getState() != P_FINISHED) Task::currThread()->sleep(100);
diff --git a/Source/Kernel/DeviceManager/Disp.ns.cpp b/Source/Kernel/DeviceManager/Disp.ns.cpp
index 2827869..7ccf254 100644
--- a/Source/Kernel/DeviceManager/Disp.ns.cpp
+++ b/Source/Kernel/DeviceManager/Disp.ns.cpp
@@ -1,6 +1,8 @@
#include "Disp.ns.h"
#include <DeviceManager/Dev.ns.h>
#include <VTManager/VT.ns.h>
+#include <VTManager/ScrollableVT.class.h>
+#include <Core/SB.ns.h>
namespace Disp {
@@ -52,6 +54,43 @@ bool setMode(mode_t& newmode) {
return false;
}
+void selectMode() {
+ getModes();
+ *kvt << "\nPlease select a graphic mode in the list below:\n";
+
+ for (u32int i = 0; i < Disp::modes.size(); i++) {
+ Disp::mode_t& m = Disp::modes[i];
+ *kvt << (s32int)i << ":\t" << "Text " << m.textRows << "x" << m.textCols;
+ kvt->setCursorCol(21);
+ if (m.graphWidth != 0 and m.graphHeight != 0) {
+ *kvt << "Graphics " << m.graphWidth << "x" << m.graphHeight << "x" << m.graphDepth << "\t";
+ } else {
+ *kvt << "No graphics";
+ }
+ kvt->setCursorCol(45);
+ *kvt << m.device->getName() << "\n";
+ }
+
+ while (1) {
+ *kvt << "\nYour selection: ";
+ String answer = kvt->readLine();
+ u32int n = answer.toInt();
+ kvt->unmap();
+ if (n >= 0 and n < Disp::modes.size() and Disp::setMode(Disp::modes[n])) {
+ delete kvt;
+ SB::reinit();
+ kvt = new ScrollableVT(Disp::mode.textRows - SB::height, Disp::mode.textCols, 100, KVT_FGCOLOR, KVT_BGCOLOR);
+ kvt->map(SB::height);
+ Kbd::setFocus(kvt);
+ return;
+ } else {
+ Disp::setMode(Disp::modes[1]);
+ kvt->map();
+ *kvt << "Error while switching video mode, please select another one.";
+ }
+ }
+}
+
void setText(VGATextOutput* o) {
mode.device = o;
o->clear();
diff --git a/Source/Kernel/DeviceManager/Disp.ns.h b/Source/Kernel/DeviceManager/Disp.ns.h
index 2a10358..d1fac57 100644
--- a/Source/Kernel/DeviceManager/Disp.ns.h
+++ b/Source/Kernel/DeviceManager/Disp.ns.h
@@ -25,6 +25,7 @@ namespace Disp {
void getModes();
bool setMode(mode_t& mode);
+ void selectMode();
void setText(VGATextOutput* o); //To use only once : when display is initializing
}
diff --git a/Source/Kernel/Devices/Display/VESADisplay.class.cpp b/Source/Kernel/Devices/Display/VESADisplay.class.cpp
index d06aaee..11b0882 100644
--- a/Source/Kernel/Devices/Display/VESADisplay.class.cpp
+++ b/Source/Kernel/Devices/Display/VESADisplay.class.cpp
@@ -109,7 +109,7 @@ bool VESADisplay::setMode(mode_t &mode) {
regs.ax = 0x4F02;
regs.bx = mode.identifier | 0x4000;
V86::biosInt(0x10, regs);
- if (regs.ax != 0x004F) return false;
+ if ((regs.ax & 0xFF00) != 0) return false;
if (m_currMode.bpp == 8) {
//Set palette to 8 bit
diff --git a/Source/Kernel/Shell/KernelShell-sys.class.cpp b/Source/Kernel/Shell/KernelShell-sys.class.cpp
index 85ba207..b1ab274 100644
--- a/Source/Kernel/Shell/KernelShell-sys.class.cpp
+++ b/Source/Kernel/Shell/KernelShell-sys.class.cpp
@@ -81,6 +81,28 @@ void KernelShell::mount(Vector<String>& args) {
}
}
+void KernelShell::unmount(Vector<String>& args) {
+ if (args.size() == 2) {
+ FSNode* n = VFS::find(args[1], m_cwd);
+ bool ok = false;
+ if (n == 0) {
+ ok = false;
+ } else {
+ String p = VFS::path(n);
+ for (u32int i = 0; i < VFS::filesystems.size(); i++) {
+ if (VFS::path(VFS::filesystems[i]->getRootNode()) == p) {
+ ok = VFS::unmount(VFS::filesystems[i]);
+ break;
+ }
+ }
+ }
+ if (ok) *m_vt << "Ok, filesystem unmounted.\n";
+ else *m_vt << "Error.\n";
+ } else {
+ *m_vt << "Usage: unmount <mountpoint>\n";
+ }
+}
+
void KernelShell::readblock(Vector<String>& args) {
if (args.size() == 3) {
Vector<Device*> devcs = Dev::findDevices("block");
diff --git a/Source/Kernel/Shell/KernelShell.class.cpp b/Source/Kernel/Shell/KernelShell.class.cpp
index 71a717a..9fec9c7 100644
--- a/Source/Kernel/Shell/KernelShell.class.cpp
+++ b/Source/Kernel/Shell/KernelShell.class.cpp
@@ -5,6 +5,7 @@
#include <MemoryManager/PhysMem.ns.h>
#include <TaskManager/Task.ns.h>
#include <VFS/VFS.ns.h>
+#include <DeviceManager/Disp.ns.h>
u32int KernelShell::m_instances = 0;
@@ -62,6 +63,7 @@ u32int KernelShell::run() {
{"part", &KernelShell::part},
{"readblock", &KernelShell::readblock},
{"mount", &KernelShell::mount},
+ {"unmount", &KernelShell::unmount},
{"hexdump", &KernelShell::hexdump},
{0, 0}
@@ -98,26 +100,10 @@ u32int KernelShell::run() {
} else if (tokens[0] == "exit") {
if (tokens.size() == 1) return 0;
return tokens[1].toInt();
- } else if (tokens[0] == "unmount") {
- if (tokens.size() == 2) {
- FSNode* n = VFS::find(tokens[1], m_cwd);
- bool ok = false;
- if (n == 0) {
- ok = false;
- } else {
- String p = VFS::path(n);
- for (u32int i = 0; i < VFS::filesystems.size(); i++) {
- if (VFS::path(VFS::filesystems[i]->getRootNode()) == p) {
- ok = VFS::unmount(VFS::filesystems[i]);
- break;
- }
- }
- }
- if (ok) *m_vt << "Ok, filesystem unmounted.\n";
- else *m_vt << "Error.\n";
- } else {
- *m_vt << "Usage: unmount <mountpoint>\n";
- }
+ } else if (tokens[0] == "mode") {
+ bool ch = (m_vt == kvt);
+ Disp::selectMode();
+ if (ch) m_vt = kvt;
} else if (tokens[0] != "" or tokens.size() != 1) {
u32int i = 0;
bool found = false;
diff --git a/Source/Kernel/Shell/KernelShell.class.h b/Source/Kernel/Shell/KernelShell.class.h
index 9655def..1552d28 100644
--- a/Source/Kernel/Shell/KernelShell.class.h
+++ b/Source/Kernel/Shell/KernelShell.class.h
@@ -37,6 +37,7 @@ class KernelShell {
void part(Vector<String>& args);
void readblock(Vector<String>& args);
void mount(Vector<String>& args);
+ void unmount(Vector<String>& args);
void setup(DirectoryNode* cwd, VirtualTerminal *vt);