summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/Applications/PaperWork/PaperWork.cpp9
-rw-r--r--Source/Applications/Shell/Shell-fs.class.cpp4
-rw-r--r--Source/Applications/Shell/Shell.class.cpp2
-rw-r--r--Source/Applications/Shell/main.cpp5
-rw-r--r--Source/Kernel/Core/Sys.ns.cpp4
-rw-r--r--Source/Kernel/Core/Sys.ns.h2
-rw-r--r--Source/Library/Common/OStream.proto.cpp60
-rw-r--r--Source/Library/Common/OStream.proto.h38
-rw-r--r--Source/Library/Common/SimpleList.class.h13
-rw-r--r--Source/Library/Makefile1
-rw-r--r--Source/Library/Userland/Binding/VirtualTerminal.class.h16
11 files changed, 129 insertions, 25 deletions
diff --git a/Source/Applications/PaperWork/PaperWork.cpp b/Source/Applications/PaperWork/PaperWork.cpp
index 4f9cb0e..ac6f26d 100644
--- a/Source/Applications/PaperWork/PaperWork.cpp
+++ b/Source/Applications/PaperWork/PaperWork.cpp
@@ -1,6 +1,7 @@
#include <App/ShellApp.proto.h>
#define DEFAULT_SHELL "/Applications/Shell/Shell.app"
+#define PAPERWORK_PATH "/System/Applications/PaperWork.app"
class PaperWork : public ShellApp {
public:
@@ -20,7 +21,7 @@ int PaperWork::run() {
if (act == "init") {
while (1) {
- Process p = Process::run("/System/Applications/PaperWork.app");
+ Process p = Process::run(PAPERWORK_PATH);
if (p.valid()) {
p.setInVT(invt);
p.setOutVT(outvt);
@@ -35,15 +36,15 @@ int PaperWork::run() {
outvt << "Logging in to Melon\n";
String user, pw;
while (1) {
- outvt << "Username: ";
+ outvt << "Username: " << FLUSH;
user = invt.readLine();
- outvt << "Password: ";
+ outvt << "Password: " << FLUSH;
pw = invt.readLine(false);
if (!Process::get().authenticatePW(user, pw)) {
outvt << "Authentication failed.\n\n";
continue;
}
- outvt << "What shell to run [" << sFlag("shell") << "]? ";
+ outvt << "What shell to run [" << sFlag("shell") << "]? "<< FLUSH;
String sh = invt.readLine();
if (sh == "") sh = sFlag("shell");
Process p = Process::run(sh);
diff --git a/Source/Applications/Shell/Shell-fs.class.cpp b/Source/Applications/Shell/Shell-fs.class.cpp
index 150b877..30faaf7 100644
--- a/Source/Applications/Shell/Shell-fs.class.cpp
+++ b/Source/Applications/Shell/Shell-fs.class.cpp
@@ -28,11 +28,11 @@ void Shell::ls(Vector<String>& args) {
if (((p >> i) & 1) == 0) perm[8 - i] = "-";
}
if (n.type() == NT_FILE) {
- outvt << " FILE " << perm << " " << n.getName();
+ outvt << " FILE " << perm << " " << n.getName() << FLUSH;
outvt.setCsrCol(30);
outvt << (s32int)n.getLength() << " bytes.\n";
} else if (n.type() == NT_DIRECTORY) {
- outvt << " DIR " << perm << " " << n.getName() << "/";
+ outvt << " DIR " << perm << " " << n.getName() << "/" << FLUSH;
outvt.setCsrCol(30);
outvt << (s32int)n.getLength() << " items.\n";
}
diff --git a/Source/Applications/Shell/Shell.class.cpp b/Source/Applications/Shell/Shell.class.cpp
index 3d406c8..bfbf631 100644
--- a/Source/Applications/Shell/Shell.class.cpp
+++ b/Source/Applications/Shell/Shell.class.cpp
@@ -25,7 +25,7 @@ int Shell::run() {
cwd = FS::cwdNode();
while (1) {
- outvt << "{" << cwd.getName() << "}: ";
+ outvt << "{" << cwd.getName() << "}: " << FLUSH;
String s = invt.readLine();
if (s.empty()) continue;
while (s[0] == WChar(" ") or s[0] == WChar("\t")) {
diff --git a/Source/Applications/Shell/main.cpp b/Source/Applications/Shell/main.cpp
deleted file mode 100644
index 66c4269..0000000
--- a/Source/Applications/Shell/main.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "Shell.ns.h"
-
-int main(const Vector<String>& args) {
- return Shell::run();
-}
diff --git a/Source/Kernel/Core/Sys.ns.cpp b/Source/Kernel/Core/Sys.ns.cpp
index c5af3e8..59da244 100644
--- a/Source/Kernel/Core/Sys.ns.cpp
+++ b/Source/Kernel/Core/Sys.ns.cpp
@@ -85,9 +85,9 @@ void dumpRegs(registers_t *regs, VirtualTerminal& vt) {
vt << "eflags=" << (u32int)regs->eflags << ", useresp=" << (u32int)regs->useresp << ", ss=" << (u32int)regs->ss << "\n";
}
-void stackTrace(u32int ebp, VirtualTerminal& vt, u32int maxframes) {
+void stackTrace(u32int ebp, VirtualTerminal& vt, u32int maxframes, bool isUser) {
u32int *stack = (u32int*)ebp;
- for (u32int i = 0; i < maxframes and (u32int)stack > 0xC0000000 and (u32int)stack < (ebp + 0x10000); i++) {
+ for (u32int i = 0; i < maxframes and (isUser or ((u32int)stack > 0xC0000000)) and (u32int)stack < (ebp + 0x10000); i++) {
vt << "Frame: " << (u32int)stack << " n:" << stack[0] << " r:" << stack[1] << "\n";
stack = (u32int*)stack[0];
}
diff --git a/Source/Kernel/Core/Sys.ns.h b/Source/Kernel/Core/Sys.ns.h
index 26f04e6..f386135 100644
--- a/Source/Kernel/Core/Sys.ns.h
+++ b/Source/Kernel/Core/Sys.ns.h
@@ -30,7 +30,7 @@ namespace Sys {
u8int inb(u16int port);
u16int inw(u16int port);
void dumpRegs(registers_t *regs, VirtualTerminal& vt);
- void stackTrace(u32int ebp, VirtualTerminal& vt, u32int maxframes);
+ void stackTrace(u32int ebp, VirtualTerminal& vt, u32int maxframes, bool isUser = false);
void panic(char* message, char *file, u32int line);
void panic(char* message, registers_t *regs, char *file, u32int line);
void panic_assert(char* file, u32int line, char *desc);
diff --git a/Source/Library/Common/OStream.proto.cpp b/Source/Library/Common/OStream.proto.cpp
new file mode 100644
index 0000000..bbf5dc3
--- /dev/null
+++ b/Source/Library/Common/OStream.proto.cpp
@@ -0,0 +1,60 @@
+#include <OStream.proto.h>
+
+OStream::OStream() {
+ m_buffer = NULL;
+ m_last = NULL;
+}
+
+OStream::OStream(const OStream& other) {
+ m_buffer = NULL;
+ m_last = NULL;
+}
+
+void OStream::put(const String &s) {
+ waitLock();
+ if (m_buffer == NULL or m_last == NULL) {
+ m_buffer = m_last = new SimpleList<String>(s);
+ } else {
+ m_last = m_last->addAtEnd(s);
+ }
+ unlock();
+}
+
+void OStream::flush() {
+ if (m_buffer == NULL or m_last == NULL) return;
+
+ waitLock();
+ //Calculate buffer size
+ int size = 0;
+ SimpleList<String>* iter = m_buffer;
+ for (; iter != 0; iter = iter->next()) {
+ size += iter->v().size();
+ }
+ //Get stuff
+ String buff(WChar(" "), size);
+ iter = m_buffer;
+ for (int i = 0, pos = 0; i < size; i++, pos++) {
+ if (pos >= iter->v().size()) {
+ iter = iter->next();
+ pos = 0;
+ }
+ buff[i] = iter->v()[pos];
+ }
+ //Write it
+ write(buff);
+
+ delete m_buffer;
+ m_buffer = NULL;
+ m_last = NULL;
+
+ unlock();
+}
+
+OStream& OStream::operator<< (ostream_modifiers_e m) {
+ if (m == FLUSH) {
+ flush();
+ } else if (m == ENDL) {
+ put("\n");
+ }
+ return *this;
+}
diff --git a/Source/Library/Common/OStream.proto.h b/Source/Library/Common/OStream.proto.h
new file mode 100644
index 0000000..2fc68e1
--- /dev/null
+++ b/Source/Library/Common/OStream.proto.h
@@ -0,0 +1,38 @@
+#ifndef DEF_ISTREAM_PROTO_H
+#define DEF_ISTREAM_PROTO_H
+
+#include <String.class.h>
+#include <SimpleList.class.h>
+#include <Mutex.class.h>
+
+enum ostream_modifiers_e {
+ FLUSH,
+ ENDL
+};
+
+class OStream : private Mutex {
+ private:
+ SimpleList<String> *m_buffer;
+ SimpleList<String> *m_last;
+ void operator =(OStream& other);
+
+ protected:
+ virtual void write(const String &s) = 0;
+
+ public:
+ OStream();
+ OStream(const OStream& other);
+ virtual ~OStream() { flush(); }
+
+ void put(const String& s);
+ void flush();
+
+ //Formatting functions
+ OStream& operator << (const String& s) { put(s); if (s.contains("\n")) flush(); return *this; }
+ OStream& operator << (s64int i) { put(String::number(i)); return *this; }
+ OStream& operator << (s32int i) { put(String::number(i)); return *this; }
+ OStream& operator << (u32int i) { put(String::hex(i)); return *this; }
+ OStream& operator << (ostream_modifiers_e m);
+};
+
+#endif
diff --git a/Source/Library/Common/SimpleList.class.h b/Source/Library/Common/SimpleList.class.h
index 8fcd834..2bbbace 100644
--- a/Source/Library/Common/SimpleList.class.h
+++ b/Source/Library/Common/SimpleList.class.h
@@ -25,6 +25,19 @@ class SimpleList {
return new SimpleList<T>(value, this);
}
+ SimpleList<T>* addAtEnd(const T& value) {
+ if (this == 0) {
+ return new SimpleList<T>(value);
+ } else {
+ if (m_next == 0) {
+ m_next = new SimpleList<T>(value);
+ return m_next;
+ } else {
+ return m_next->addAtEnd(value);
+ }
+ }
+ }
+
SimpleList<T>* next() {
return m_next;
}
diff --git a/Source/Library/Makefile b/Source/Library/Makefile
index b3040d4..ed65ac4 100644
--- a/Source/Library/Makefile
+++ b/Source/Library/Makefile
@@ -19,6 +19,7 @@ Objects = Common/WChar.class.uo \
Common/TextFile.class.uo \
Common/ByteArray.class.uo \
Common/Rand.ns.uo \
+ Common/OStream.proto.uo \
Common/cppsupport.wtf.uo \
Userland/App/ShellApp.proto.uo \
Userland/Syscall/Syscall.wtf.uo \
diff --git a/Source/Library/Userland/Binding/VirtualTerminal.class.h b/Source/Library/Userland/Binding/VirtualTerminal.class.h
index 70c6b23..df44124 100644
--- a/Source/Library/Userland/Binding/VirtualTerminal.class.h
+++ b/Source/Library/Userland/Binding/VirtualTerminal.class.h
@@ -6,10 +6,10 @@
#include <VirtualTerminal.iface.h>
#include <Kbd.iface.h>
-#include <String.class.h>
+#include <OStream.proto.h>
#include <WChar.class.h>
-class VirtualTerminal : public RessourceCaller {
+class VirtualTerminal : public RessourceCaller, public OStream {
public:
static VirtualTerminal getIn() {
u32int id = RessourceCaller::sCall(VTIF_OBJTYPE, VTIF_SGETPRINVT);
@@ -21,13 +21,13 @@ class VirtualTerminal : public RessourceCaller {
}
VirtualTerminal(u32int id) : RessourceCaller(id, VTIF_OBJTYPE) {}
- void writeHex(u32int number) {
+ /*void writeHex(u32int number) {
doCall(VTIF_WRITEHEX, number);
}
void writeDec(s64int number) {
doCall(VTIF_WRITEDEC, (number >> 32), number);
- }
- void write(String s) {
+ }*/
+ void write(const String &s) {
doCall(VTIF_WRITE, (u32int)&s);
}
keypress_t getKeypress(bool show = true, bool block = true) {
@@ -35,6 +35,7 @@ class VirtualTerminal : public RessourceCaller {
return *ptr;
}
String readLine(bool show = true) {
+ flush();
return String::unserialize(doCall(VTIF_READLINE, (show ? 1 : 0)));
}
void setColor(u8int fg, u8int bg = 0xFF) {
@@ -64,11 +65,6 @@ class VirtualTerminal : public RessourceCaller {
void put(u8int line, u8int col, WChar c) {
moveCursor(line, col); put(c);
}
-
- inline VirtualTerminal& operator<<(const String& s) { write(s); return *this; }
- inline VirtualTerminal& operator<<(s32int i) { writeDec(i); return *this; }
- inline VirtualTerminal& operator<<(s64int i) { writeDec(i); return *this; }
- inline VirtualTerminal& operator<<(u32int i) { writeHex(i); return *this; }
};
#endif