summaryrefslogtreecommitdiff
path: root/Source/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Kernel')
-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
10 files changed, 51 insertions, 16 deletions
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";