summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamFS.class.h2
-rw-r--r--Source/Kernel/Library/String.class.cpp10
-rw-r--r--Source/Kernel/Library/String.class.h10
-rw-r--r--Source/Kernel/Library/Vector.class.cpp10
-rw-r--r--Source/Kernel/Library/Vector.class.h1
-rwxr-xr-xSource/Kernel/Melon.kebin127379 -> 127392 bytes
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.class.cpp2
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.class.h4
-rwxr-xr-xSource/Tools/MakeRamFS/MakeRamFSbin0 -> 12236 bytes
-rw-r--r--Source/Tools/MakeRamFS/Makefile38
-rw-r--r--Source/Tools/MakeRamFS/main.cpp90
12 files changed, 161 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index 32cd382..391efa5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,12 @@
.PHONY: clean, mrproper, Init.img
-Files = Source/Kernel/Melon.ke
+Files = Source/Kernel/Melon.ke Init.rfs
Floppy = Melon.img
-Projects = Kernel
+Projects = Kernel Tools/MakeRamFS
+RamFS = Init.rfs
+RamFSFiles = :/System :/System/Applications :/System/Configuration
all:
for p in $(Projects); do \
@@ -26,7 +28,10 @@ mproper:
make -C Source mrproper -s; \
done
-floppy:
+$(RamFS):
+ Source/Tools/MakeRamFS/MakeRamFS $(RamFS) $(RamFSFiles)
+
+floppy: $(RamFS)
sudo mount $(Floppy) Mount -o loop
for f in $(Files); do \
sudo cp $$f Mount; \
diff --git a/Source/Kernel/FileSystems/RamFS/RamFS.class.h b/Source/Kernel/FileSystems/RamFS/RamFS.class.h
index 427019c..822dc39 100644
--- a/Source/Kernel/FileSystems/RamFS/RamFS.class.h
+++ b/Source/Kernel/FileSystems/RamFS/RamFS.class.h
@@ -10,7 +10,7 @@ class RamFS : public FileSystem {
public:
RamFS(u32int maxSize); //Creates an empty RAM file system
- RamFS(u8int* ptr, u32int maxSize); //Creates a RAM file system from data loaded in memory. format to be defined
+ RamFS(u8int* ptr, u32int maxSize, bool writable = true); //Creates a RAM file system from data loaded in memory. format to be defined
bool setName(FSNode* node, String name);
bool setPermissions(FSNode* node, u32int permissions);
diff --git a/Source/Kernel/Library/String.class.cpp b/Source/Kernel/Library/String.class.cpp
index 8df5cbf..b8e01d5 100644
--- a/Source/Kernel/Library/String.class.cpp
+++ b/Source/Kernel/Library/String.class.cpp
@@ -136,7 +136,7 @@ bool String::operator== (const char* string) {
return true;
}
-String& String::operator+= (String &other) {
+String& String::operator+= (const String &other) {
WChar* newdata = new WChar[m_length + other.m_length + 1];
for (u32int i = 0; i < m_length; i++) {
newdata[i] = m_string[i];
@@ -181,7 +181,7 @@ String& String::operator+= (WChar other) {
return *this;
}
-String& String::operator+ (String &other) { //Can be optimized
+String& String::operator+ (const String &other) { //Can be optimized
String ret(*this);
return (ret += other);
}
@@ -236,11 +236,11 @@ u32int String::toInt16() {
return number;
}
-WChar& String::operator[] (int index) {
+WChar& String::operator[] (int index) const {
return m_string[index];
}
-u32int String::size() {
+u32int String::size() const {
return m_length;
}
@@ -250,7 +250,7 @@ void String::clear() {
m_string = 0;
}
-bool String::empty() {
+bool String::empty() const {
return (m_length == 0);
}
diff --git a/Source/Kernel/Library/String.class.h b/Source/Kernel/Library/String.class.h
index 85ec268..6b48a30 100644
--- a/Source/Kernel/Library/String.class.h
+++ b/Source/Kernel/Library/String.class.h
@@ -25,19 +25,19 @@ class String {
bool operator== (const String &other);
bool operator== (const char* string);
- String &operator+= (String &other);
+ String &operator+= (const String &other);
String &operator+= (const char* other);
String &operator+= (WChar other);
- String &operator+ (String &other);
+ String &operator+ (const String &other);
String &operator+ (const char* other);
String &operator+ (WChar other);
s32int toInt();
u32int toInt16(); //From HEX
- WChar& operator[] (int index);
+ WChar& operator[] (int index) const;
- u32int size();
+ u32int size() const;
void clear();
- bool empty();
+ bool empty() const;
Vector<String> split(WChar c);
diff --git a/Source/Kernel/Library/Vector.class.cpp b/Source/Kernel/Library/Vector.class.cpp
index aaa777f..d0c71a4 100644
--- a/Source/Kernel/Library/Vector.class.cpp
+++ b/Source/Kernel/Library/Vector.class.cpp
@@ -32,6 +32,16 @@ Vector<T>::Vector(const Vector<T> &other) {
}
template <typename T>
+Vector<T>& Vector<T>::operator= (const Vector<T> &other) {
+ if (m_data != 0) delete[] m_data;
+ m_size = other.m_size;
+ m_data = (T*)Mem::kalloc(m_size * sizeof(T));
+ for (u32int i = 0; i < m_size; i++) {
+ new(&m_data[i]) T(other.m_data[i]);
+ }
+}
+
+template <typename T>
Vector<T>::~Vector() {
if (m_data != 0) delete[] m_data;
}
diff --git a/Source/Kernel/Library/Vector.class.h b/Source/Kernel/Library/Vector.class.h
index 9763d2c..f16303b 100644
--- a/Source/Kernel/Library/Vector.class.h
+++ b/Source/Kernel/Library/Vector.class.h
@@ -14,6 +14,7 @@ class Vector {
Vector(u32int size);
Vector(u32int size, T value);
Vector(const Vector<T> &other);
+ Vector<T>& operator= (const Vector<T> &other);
~Vector();
T& operator[] (u32int index);
diff --git a/Source/Kernel/Melon.ke b/Source/Kernel/Melon.ke
index 575395c..89d3f81 100755
--- a/Source/Kernel/Melon.ke
+++ b/Source/Kernel/Melon.ke
Binary files differ
diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.cpp b/Source/Kernel/VTManager/VirtualTerminal.class.cpp
index dde487c..be1299c 100644
--- a/Source/Kernel/VTManager/VirtualTerminal.class.cpp
+++ b/Source/Kernel/VTManager/VirtualTerminal.class.cpp
@@ -129,7 +129,7 @@ void VirtualTerminal::put(WChar c, bool updatecsr) {
if (updatecsr) updateCursor();
}
-void VirtualTerminal::write(String s, bool updatecsr) {
+void VirtualTerminal::write(const String& s, bool updatecsr) {
for (u32int i = 0; i < s.size(); i++) {
put(s[i], false);
}
diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.h b/Source/Kernel/VTManager/VirtualTerminal.class.h
index 5739c72..e0cdff2 100644
--- a/Source/Kernel/VTManager/VirtualTerminal.class.h
+++ b/Source/Kernel/VTManager/VirtualTerminal.class.h
@@ -46,13 +46,13 @@ class VirtualTerminal {
//Display functions
void put(WChar c, bool updatecsr = true);
- void write(String s, bool updatecsr = true);
+ void write(const String& s, bool updatecsr = true);
void writeDec(s32int i, bool updatecsr = true);
void writeHex(u32int i, bool updatecsr = true);
void hexDump(u8int* ptr, u32int sz);
- inline VirtualTerminal& operator<<(String s) { write(s); return *this; }
+ inline VirtualTerminal& operator<<(const String& s) { write(s); return *this; }
//inline VirtualTerminal& operator<<(WChar c) { put(c); return *this; }
inline VirtualTerminal& operator<<(s32int i) { writeDec(i); return *this; }
inline VirtualTerminal& operator<<(u32int i) { writeHex(i); return *this; }
diff --git a/Source/Tools/MakeRamFS/MakeRamFS b/Source/Tools/MakeRamFS/MakeRamFS
new file mode 100755
index 0000000..43a628b
--- /dev/null
+++ b/Source/Tools/MakeRamFS/MakeRamFS
Binary files differ
diff --git a/Source/Tools/MakeRamFS/Makefile b/Source/Tools/MakeRamFS/Makefile
new file mode 100644
index 0000000..019ec29
--- /dev/null
+++ b/Source/Tools/MakeRamFS/Makefile
@@ -0,0 +1,38 @@
+.PHONY: clean, mrproper
+
+CC = gcc
+CXX = g++
+LD = gcc
+LDFLAGS = -lstdc++
+CFLAGS =
+CXXFLAGS =
+
+OutFile = MakeRamFS
+Objects = main.o
+
+all: $(OutFile)
+ echo "* Done with $(OutFile)."
+
+rebuild: mrproper all
+
+$(OutFile): $(Objects)
+ echo "* Linking executable : $(OutFile)..."
+ $(LD) -o $(OutFile) $(LDFLAGS) $^
+
+%.o: %.c
+ echo "* Compiling $<..."
+ $(CC) -c $< -o $@ $(CFLAGS)
+
+%.o: %.cpp
+ echo "* Compiling $<..."
+ $(CXX) -c $< -o $@ $(CXXFLAGS)
+
+clean:
+ echo "* Removing object files..."
+ rm -rf *.o
+ rm -rf */*.o
+ rm -rf */*/*.o
+
+mrproper: clean
+ echo "* Removing executable : $(OutFile)"
+ rm -rf $(OutFile)
diff --git a/Source/Tools/MakeRamFS/main.cpp b/Source/Tools/MakeRamFS/main.cpp
new file mode 100644
index 0000000..df1f0d8
--- /dev/null
+++ b/Source/Tools/MakeRamFS/main.cpp
@@ -0,0 +1,90 @@
+#include <iostream>
+#include <fstream>
+#include <string>
+
+using namespace std;
+
+struct ramfs_header {
+ unsigned int magic; //For error checking
+ unsigned int files;
+};
+
+struct ramfs_file_header {
+ unsigned int name_length;
+ unsigned int file_length;
+};
+
+#define INITRD_MAGIC 0x1337BEEF
+
+int main(int argc, char *argv[]) {
+ if (argc < 2) {
+ cerr << "Error : no output file specified." << endl;
+ cerr << "Usage : MakeRamFS <output.img> [<filename>:<ramfs filename> [...] ]" << endl;
+ return 1;
+ }
+
+ ofstream output(argv[1], ios::out | ios::binary);
+
+ ramfs_header hdr;
+ hdr.magic = INITRD_MAGIC;
+ hdr.files = argc - 2;
+
+ output.write((char*)&hdr, sizeof(ramfs_header));
+
+ for (int i = 2; i < argc; i++) {
+ string name(argv[i]);
+ string file;
+ while (!name.empty()) {
+ if (name[0] == ':') {
+ name = name.substr(1, name.size() - 1);
+ break;
+ }
+ file += name[0];
+ name = name.substr(1, name.size() - 1);
+ }
+
+ ramfs_file_header fhdr;
+
+ if (file == "") { //This is a directory
+ fhdr.name_length = name.size();
+ fhdr.file_length = 0; //File length of 0 means directory
+ output.write((char*)&fhdr, sizeof(ramfs_file_header));
+ output << name;
+ continue;
+ }
+
+ ifstream infile(file.c_str(), ios::in | ios::binary);
+
+ if (!infile) {
+ fhdr.name_length = 0; //Name and length = 0 means invalid file
+ fhdr.file_length = 0;
+ output.write((char*)&fhdr, sizeof(ramfs_file_header));
+ continue;
+ }
+
+ fhdr.name_length = name.size();
+ fhdr.file_length = 0;
+ while (!infile.eof()) {
+ char c;
+ infile.read(&c, 1);
+ fhdr.file_length++;
+ }
+
+ infile.close(); infile.open(file.c_str(), ios::in | ios::binary); //Rewind file
+
+ output.write((char*)&fhdr, sizeof(ramfs_file_header));
+
+ output << name;
+
+ char *c = new char[fhdr.file_length];
+ infile.read(c, fhdr.file_length);
+ output.write(c, fhdr.file_length);
+ delete [] c;
+
+ infile.close();
+ }
+
+ output.close();
+
+ return 0;
+}