summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xCopyToFDD.sh10
-rwxr-xr-xCopyToHDD.sh8
-rw-r--r--Grub-menu-fdd.cfg12
-rw-r--r--Grub-menu-hdd.cfg8
-rw-r--r--HDD.imgbin20643840 -> 20643840 bytes
-rw-r--r--README3
-rw-r--r--Source/Kernel/Core/Log.ns.cpp3
-rw-r--r--Source/Kernel/Core/kmain.wtf.cpp9
-rw-r--r--Source/Kernel/Devices/ATA/ATAController.class.cpp4
-rw-r--r--Source/Kernel/Devices/ATA/ATAController.class.h3
-rw-r--r--Source/Kernel/Devices/ATA/ATADrive.class.cpp4
-rw-r--r--Source/Kernel/FileSystems/FAT/FATFS.class.h4
-rw-r--r--Source/Kernel/FileSystems/RamFS/RamFS.class.h4
-rw-r--r--Source/Kernel/Shell/KernelShell-sys.class.cpp2
-rw-r--r--Source/Kernel/VFS/FileSystem.proto.h8
-rw-r--r--Source/Kernel/VFS/VFS.ns.cpp26
16 files changed, 78 insertions, 30 deletions
diff --git a/CopyToFDD.sh b/CopyToFDD.sh
index 5d6a28e..f5d93d6 100755
--- a/CopyToFDD.sh
+++ b/CopyToFDD.sh
@@ -6,13 +6,19 @@
cp Grub-menu-fdd.cfg Mount/boot/menu.cfg
# Create directories
-mkdir Mount/{System,Apps,Mount}
+mkdir Mount/{System,Applications,Volumes}
+mkdir Mount/Applications/Shell
mkdir Mount/System/{Applications,Logs,Configuration}
+mkdir Mount/Volumes/{HDD,InitRFS}
# Copy system files
cp Source/Kernel/Ressources/Configuration/* Mount/System/Configuration
cp Source/Applications/PaperWork/PaperWork Mount/System/Applications/PaperWork.app
-cp Source/Applications/Shell/Shell Mount/Apps/Shell.app
+cp Source/Applications/Shell/Shell Mount/Applications/Shell/Shell.app
+
+# Create mount configuration file
+echo "/Volumes/InitRFS:ramfs:0" > Mount/System/Configuration/Mount
+echo "/Volumes/HDD:block.ata:0:1" >> Mount/System/Configuration/Mount
# Copy demo apps
cp Source/Applications/Demos/GOL Mount/Apps/GOL.app
diff --git a/CopyToHDD.sh b/CopyToHDD.sh
index eb6f82c..d901b1b 100755
--- a/CopyToHDD.sh
+++ b/CopyToHDD.sh
@@ -6,10 +6,10 @@
cp Grub-menu-hdd.cfg Mount/grub/menu.lst
# Create directories
-mkdir Mount/System
+mkdir Mount/{System,Applications,Volumes}
mkdir Mount/System/{Applications,Configuration,Logs,Keymaps}
-mkdir Mount/Applications
mkdir Mount/Applications/{Demos,Shell}
+mkdir Mount/Volumes/{Floppy,InitRFS}
# Copy welcome text
cp Source/Kernel/Ressources/Texts/Welcome.txt Mount
@@ -25,6 +25,10 @@ cp Source/Applications/PaperWork/PaperWork Mount/System/Applications/PaperWork.a
cp Source/Applications/Shell/Shell Mount/Applications/Shell/Shell.app
cp Source/Applications/Shell/Help.txt Mount/Applications/Shell
+# Create mount configuration file
+echo "/Volumes/InitRFS:ramfs:0" > Mount/System/Configuration/Mount
+echo "/Volumes/Floppy:block.floppy:0:0" >> Mount/System/Configuration/Mount
+
# Copy demo apps
cp Source/Applications/Demos/GOL Mount/Applications/Demos/GOL.app
cp Source/Applications/Demos/asmdemo Mount/Applications/Demos/ASMDemo.app
diff --git a/Grub-menu-fdd.cfg b/Grub-menu-fdd.cfg
index 1ee227b..37bcfb0 100644
--- a/Grub-menu-fdd.cfg
+++ b/Grub-menu-fdd.cfg
@@ -2,26 +2,26 @@ default 2
title The Melon Operating System
root (fd0)
-kernel /System/Melon.ke
+kernel /System/Melon.ke root:block.floppy:0:0
module /System/Init.rfs
title Melon without VESA
root (fd0)
-kernel /System/Melon.ke vesa:disabled
+kernel /System/Melon.ke vesa:disabled root:block.floppy:0:0
module /System/Init.rfs
title Melon without init
root (fd0)
-kernel /System/Melon.ke init:
+kernel /System/Melon.ke init: root:block.floppy:0:0
module /System/Init.rfs
-title Melon without init, root is floppy
+title Melon without init, boot on initramfs
root (fd0)
-kernel /System/Melon.ke init: root:block.floppy:0:0:fat mount:/Mount:ramfs:0
+kernel /System/Melon.ke init: root:ramfs:0
module /System/Init.rfs
title Game of life simulator
root (fd0)
-kernel /System/Melon.ke init:/Applications/Demos/GOL.app
+kernel /System/Melon.ke init:/Applications/Demos/GOL.app root:block.floppy:0:0
module /System/Init.rfs
diff --git a/Grub-menu-hdd.cfg b/Grub-menu-hdd.cfg
index d5b8612..d3468b0 100644
--- a/Grub-menu-hdd.cfg
+++ b/Grub-menu-hdd.cfg
@@ -2,21 +2,21 @@ default 2
title The Melon Operating System
root (hd0,0)
-kernel /System/Melon.ke
+kernel /System/Melon.ke root:block.ata:0:1
module /System/Init.rfs
title Melon without VESA
root (hd0,0)
-kernel /System/Melon.ke vesa:disabled
+kernel /System/Melon.ke vesa:disabled root:block.ata:0:1
module /System/Init.rfs
title Melon without init
root (hd0,0)
-kernel /System/Melon.ke init:
+kernel /System/Melon.ke init: root:block.ata:0:1
module /System/Init.rfs
title Game of life simulator
root (hd0,0)
-kernel /System/Melon.ke init:/Applications/Demos/GOL.app
+kernel /System/Melon.ke init:/Applications/Demos/GOL.app root:block.ata:0:1
module /System/Init.rfs
diff --git a/HDD.img b/HDD.img
index b3dcc9d..f795818 100644
--- a/HDD.img
+++ b/HDD.img
Binary files differ
diff --git a/README b/README
index 0d1a934..6ded971 100644
--- a/README
+++ b/README
@@ -21,6 +21,9 @@ You will probably be prompted for your password. We need it to mount the floppy
And run it with Qemu :
$ make qemu
+ OR
+$ make qemu-hdd
+The second option boots from the HDD instead of the floppy
** HOW TO CONFIGURE THE GRUB ENTRIES : **
If you want to change the entries that appear when you `make qemu`, then edit the Grub-menu.cfg and `make floppy` again.
diff --git a/Source/Kernel/Core/Log.ns.cpp b/Source/Kernel/Core/Log.ns.cpp
index c8ccd80..d51aa55 100644
--- a/Source/Kernel/Core/Log.ns.cpp
+++ b/Source/Kernel/Core/Log.ns.cpp
@@ -1,5 +1,6 @@
#include "Log.ns.h"
#include <FileSystems/RamFS/RamFS.class.h>
+#include <VTManager/SimpleVT.class.h>
#include <VFS/VFS.ns.h>
namespace Log {
@@ -13,7 +14,7 @@ void init(u8int loglevel) {
logs[KL_PANIC] = new TextFile("/System/Logs/Panic.log", FM_APPEND);
if (!logs[KL_PANIC]->valid()) { //FS maybee not read/write, mount a ramfs
- RamFS::mount(1024*1024, (DirectoryNode*)VFS::find("/System/Logs"));
+ VFS::mount("/System/Logs:ramfs", kvt);
logs[KL_PANIC] = new TextFile("/System/Logs/Panic.log", FM_APPEND);
}
if (KL_CRITICAL <= loglevel) logs[KL_CRITICAL] = new TextFile("/System/Logs/Critical.log", FM_APPEND);
diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp
index 3eee14b..ad11eaf 100644
--- a/Source/Kernel/Core/kmain.wtf.cpp
+++ b/Source/Kernel/Core/kmain.wtf.cpp
@@ -203,7 +203,14 @@ void kmain(multiboot_info_t* mbd, u32int magic) {
VFS::mount(mount[i], kvt, mbd);
}
- //FATFS::mount(Part::partitions[0], (DirectoryNode*)VFS::createDirectory("/Mount"));
+ {
+ TextFile mounts("/System/Configuration/Mount", FM_READ);
+ while (mounts.valid() && !mounts.eof()) {
+ String m = mounts.readLine();
+ if (!m.empty() && m[0] != WChar("#")) VFS::mount(m, kvt, mbd);
+ }
+ }
+
//*************************************** LOAD SYSTEM STUFF
diff --git a/Source/Kernel/Devices/ATA/ATAController.class.cpp b/Source/Kernel/Devices/ATA/ATAController.class.cpp
index 69a18a4..d8073d0 100644
--- a/Source/Kernel/Devices/ATA/ATAController.class.cpp
+++ b/Source/Kernel/Devices/ATA/ATAController.class.cpp
@@ -27,14 +27,16 @@ void ATAController::detect() {
}
}
-ATAController::ATAController(u32int base, u8int number) {
+ATAController::ATAController(u32int base, u8int number) : Mutex(MUTEX_TRUE) {
m_base = base; m_number = number;
m_drives[0] = NULL; m_drives[1] = NULL;
identify(false); //Identify master device
identify(true); //Identify slave device
+ unlock();
}
void ATAController::identify(bool slave) {
+ if (!locked()) return;
if (m_drives[(slave ? 1 : 0)] != NULL) return;
writeByte(ATA_PORT_DRIVE_SELECT, (slave ? 0xB0 : 0xA0));
writeByte(ATA_PORT_COMMAND, ATA_CMD_IDENTIFY);
diff --git a/Source/Kernel/Devices/ATA/ATAController.class.h b/Source/Kernel/Devices/ATA/ATAController.class.h
index a12b835..89176c9 100644
--- a/Source/Kernel/Devices/ATA/ATAController.class.h
+++ b/Source/Kernel/Devices/ATA/ATAController.class.h
@@ -2,6 +2,7 @@
#define DEF_ATACONTROLLER_CLASS_H
#include <Devices/Device.proto.h>
+#include <Mutex.class.h>
#define ATA_BUS1_BASE 0x1F0
#define ATA_BUS2_BASE 0x170
@@ -21,7 +22,7 @@
class ATADrive;
-class ATAController : public Device {
+class ATAController : public Device, public Mutex {
friend class ATADrive;
private:
ATAController(u32int base, u8int number);
diff --git a/Source/Kernel/Devices/ATA/ATADrive.class.cpp b/Source/Kernel/Devices/ATA/ATADrive.class.cpp
index d9cc4a7..247e798 100644
--- a/Source/Kernel/Devices/ATA/ATADrive.class.cpp
+++ b/Source/Kernel/Devices/ATA/ATADrive.class.cpp
@@ -37,6 +37,7 @@ void ATADrive::cmdCommon(u32int numblock, u32int count) {
bool ATADrive::readBlocks(u64int start, u32int count, u8int* data) {
if (start + count >= m_blockCount) return false;
+ m_ctrlr->waitLock();
cmdCommon(start, count);
m_ctrlr->writeByte(ATA_PORT_COMMAND, ATA_CMD_READ);
@@ -47,6 +48,7 @@ bool ATADrive::readBlocks(u64int start, u32int count, u8int* data) {
data[idx * 2] = (u8int)tmpword;
data[idx * 2 + 1] = (u8int)(tmpword >> 8);
}
+ m_ctrlr->unlock();
return true;
}
@@ -54,6 +56,7 @@ bool ATADrive::writeBlocks(u64int start, u32int count, u8int* data) {
if (start + count >= m_blockCount) return false;
if (readOnly()) return false;
+ m_ctrlr->waitLock();
cmdCommon(start, count);
m_ctrlr->writeByte(ATA_PORT_COMMAND, ATA_CMD_WRITE);
@@ -63,6 +66,7 @@ bool ATADrive::writeBlocks(u64int start, u32int count, u8int* data) {
u16int tmpword = (data[idx * 2]) | (data[idx * 2 + 1] << 8);
m_ctrlr->writeByte(ATA_PORT_DATA, tmpword);
}
+ m_ctrlr->unlock();
return true;
}
diff --git a/Source/Kernel/FileSystems/FAT/FATFS.class.h b/Source/Kernel/FileSystems/FAT/FATFS.class.h
index fbefc02..114622a 100644
--- a/Source/Kernel/FileSystems/FAT/FATFS.class.h
+++ b/Source/Kernel/FileSystems/FAT/FATFS.class.h
@@ -112,8 +112,6 @@ class FATFS : public FileSystem {
bool unmount();
- String getDevDescription() { return Part::partIdentifier(m_part); }
-
bool setName(FSNode* node, String name);
bool setPermissions(FSNode* node, u32int permissions);
bool setUid(FSNode* node, u32int uid);
@@ -128,6 +126,8 @@ class FATFS : public FileSystem {
FileNode* createFile(DirectoryNode* parent, String name);
DirectoryNode* createDirectory(DirectoryNode* parent, String name);
bool remove(DirectoryNode* parent, FSNode* node);
+
+ Partition* getPart() { return m_part; }
};
#endif
diff --git a/Source/Kernel/FileSystems/RamFS/RamFS.class.h b/Source/Kernel/FileSystems/RamFS/RamFS.class.h
index 042baa9..0368e60 100644
--- a/Source/Kernel/FileSystems/RamFS/RamFS.class.h
+++ b/Source/Kernel/FileSystems/RamFS/RamFS.class.h
@@ -35,8 +35,6 @@ class RamFS : public FileSystem {
bool setGid(FSNode* node, u32int gid);
bool setParent(FSNode* node, FSNode* parent);
- String getDevDescription() { return "ramfs"; }
-
u32int read(FileNode* file, u64int position, u32int max_length, u8int *data);
bool write(FileNode* file, u64int position, u32int length, u8int *data);
bool truncate(FileNode* file);
@@ -45,6 +43,8 @@ class RamFS : public FileSystem {
FileNode* createFile(DirectoryNode* parent, String name);
DirectoryNode* createDirectory(DirectoryNode* parent, String name);
bool remove(DirectoryNode* parent, FSNode* node);
+
+ Partition* getPart() { return 0; }
};
#endif
diff --git a/Source/Kernel/Shell/KernelShell-sys.class.cpp b/Source/Kernel/Shell/KernelShell-sys.class.cpp
index 06af11d..da5378b 100644
--- a/Source/Kernel/Shell/KernelShell-sys.class.cpp
+++ b/Source/Kernel/Shell/KernelShell-sys.class.cpp
@@ -64,7 +64,7 @@ void KernelShell::part(Vector<String>& args) {
void KernelShell::mount(Vector<String>& args) {
if (args.size() == 1) {
for (u32int i = 0; i < VFS::filesystems.size(); i++) {
- *m_vt << VFS::filesystems[i]->getDevDescription() << " on " << VFS::path(VFS::filesystems[i]->getRootNode()) << "\n";
+ *m_vt << VFS::filesystems[i]->getIdentifier() << "\n";
}
} else if (args.size() == 2) {
if (args[1] == "help") {
diff --git a/Source/Kernel/VFS/FileSystem.proto.h b/Source/Kernel/VFS/FileSystem.proto.h
index 9216219..172c82c 100644
--- a/Source/Kernel/VFS/FileSystem.proto.h
+++ b/Source/Kernel/VFS/FileSystem.proto.h
@@ -14,6 +14,8 @@ namespace VFS {
//This abstract class describes a filesystem
class FileSystem {
friend bool VFS::unmount(FileSystem*);
+ private:
+ String m_identifier;
protected:
virtual ~FileSystem();
@@ -26,8 +28,6 @@ class FileSystem {
bool isWritable() { return m_isWritable; }
DirectoryNode* getRootNode() { return m_rootNode; }
- virtual String getDevDescription() = 0;
-
//Must be implemented by the filesystem
virtual bool setName(FSNode* node, String name) = 0;
virtual bool setPermissions(FSNode* node, u32int permissions) = 0;
@@ -43,6 +43,10 @@ class FileSystem {
virtual FileNode* createFile(DirectoryNode* parent, String name) = 0;
virtual DirectoryNode* createDirectory(DirectoryNode* parent, String name) = 0;
virtual bool remove(DirectoryNode* parent, FSNode* node) = 0;
+
+ virtual Partition* getPart() = 0;
+ void setIdentifier(String s) { m_identifier = s; }
+ String getIdentifier() { return m_identifier; }
};
#endif
diff --git a/Source/Kernel/VFS/VFS.ns.cpp b/Source/Kernel/VFS/VFS.ns.cpp
index 3b59c5a..cf68653 100644
--- a/Source/Kernel/VFS/VFS.ns.cpp
+++ b/Source/Kernel/VFS/VFS.ns.cpp
@@ -75,15 +75,23 @@ bool mount(String str, VirtualTerminal* vt, multiboot_info_t *mbd) {
*vt << "Invalid module number for filesystem to mount on " << fs[0] << "\n";
return false;
}
- RamFS::mount((u8int*)mods[fs[2].toInt()].mod_start, 1024 * 1024, root);
- return true;
+ FileSystem* wat = RamFS::mount((u8int*)mods[fs[2].toInt()].mod_start, 1024 * 1024, root);
+ if (wat != NULL) {
+ wat->setIdentifier(str);
+ return true;
+ }
+ return false;
} else {
*vt << "Cannot mount kernel modules outside of kernel command line.\n";
return false;
}
} else {
- RamFS::mount(1024 * 1024, root);
- return true;
+ FileSystem* wat = RamFS::mount(1024 * 1024, root);
+ if (wat != NULL) {
+ wat->setIdentifier(str);
+ return true;
+ }
+ return false;
}
} else {
if (fs.size() < 4) {
@@ -94,9 +102,17 @@ bool mount(String str, VirtualTerminal* vt, multiboot_info_t *mbd) {
if (fs.size() < 6) fs.push("ro"); //By default, mount file systems read-only
BlockDevice* d = Part::dev(fs[1], fs[2].toInt());
Partition* p = Part::part(d, fs[3].toInt());
+ for (u32int i = 0; i < filesystems.size(); i++) {
+ if (filesystems[i]->getPart() == p) {
+ *vt << "Cannot mount " << str << " : partition already mounted.\n";
+ return false;
+ }
+ }
for (u32int i = 0; fileSystems[i].cb != 0; i++) {
if (fs[4] == fileSystems[i].name or fs[4] == "") {
- if (fileSystems[i].cb(p, root, (fs[5] == "rw")) != NULL) {
+ FileSystem* mounted = fileSystems[i].cb(p, root, (fs[5] == "rw"));
+ if (mounted != NULL) {
+ mounted->setIdentifier(str);
return true;
} else if (fs[4] != "") {
*vt << "Could not mount filesystem on " << fs[0] << "\n";