[GOOD] BUILD 0.1.0.590 DATE 9/05/2011 AT 2:40 PM
==================================================== Mainly changed: FS.Initrd + (kind of) refractored VFS, bugfixed + Rewrote 'initrd' file system, fixed many problems + Working 'cat' and 'dir' console commands + Wrote 'initrd' image write application (for windows), however it may be bugged
This commit is contained in:
+31
-20
@@ -258,41 +258,45 @@ void CommandRead(string argv[], int32 argc)
|
||||
}
|
||||
|
||||
|
||||
extern MountPoint* mpArray;
|
||||
extern uint32 mpCount;
|
||||
void CommandDir (string argv[], int32 argc)
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
// No parameters? Display root content
|
||||
if (argc < 2) {
|
||||
ConsoleWrite ("Content of root: \n\n");
|
||||
uint32 i = 0;
|
||||
MountPoint* mp = VfsGetMountPoint(0);
|
||||
|
||||
for (i = 0; i < mpCount; i++)
|
||||
ConsoleWrite ("\t\t[DEV] %s\n", mpArray[i].Name);
|
||||
for (i = 1; mp != NULL; i++)
|
||||
{
|
||||
ConsoleWrite ("\t[DEV] %s\n", mp->Name);
|
||||
mp = VfsGetMountPoint(i);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure directory exists
|
||||
DirectoryEntry* temp = VfsTest(argv[1]);
|
||||
|
||||
if (temp == NULL)
|
||||
{
|
||||
ConsoleWrite("%#! Invalid path!\n", ColorLightRed);
|
||||
return;
|
||||
if (temp == NULL) {
|
||||
ConsoleWrite("%#! Invalid path!\n", ColorLightRed); return;
|
||||
}
|
||||
|
||||
// Write contents
|
||||
ConsoleWrite ("Content of directory %#%s:\n\n", ColorWhite, argv[1]);
|
||||
|
||||
FILE dir; VfsOpen(&dir, argv[1]);
|
||||
uint32 i;
|
||||
|
||||
temp = VfsReadDirectory(&dir,0);
|
||||
for (i = 1; temp != NULL; i++, temp = VfsReadDirectory(&dir, 0))
|
||||
for (i = 1; temp != NULL; i++)
|
||||
{
|
||||
ConsoleWrite ("\t\t[%s] ", (temp->Flags & 0x1) ? "FIL" : "DIR" );
|
||||
ConsoleWrite ("\t[%s] ", (temp->Flags & 0x1) ? "FIL" : "DIR" );
|
||||
ConsoleWrite ("%s", temp->Name);
|
||||
Point p = {60, -1}; ConsoleCursorGoto(p);
|
||||
ConsoleWrite ("%u bytes\n", temp->Size);
|
||||
|
||||
temp = VfsReadDirectory(&dir, i);
|
||||
}
|
||||
|
||||
VfsClose(&dir);
|
||||
@@ -305,18 +309,25 @@ void CommandCat (string argv[], int32 argc)
|
||||
return;
|
||||
}
|
||||
|
||||
ConsoleWrite("Contents of file %s:\n--------------------------\n");
|
||||
FILE f;
|
||||
VfsOpen(&f, argv[1]);
|
||||
uint8* buffer = kmalloc(0x1000);
|
||||
uint32 sz, i;
|
||||
|
||||
while ((sz = VfsRead(&f, 1, 0x1000, buffer)))
|
||||
{
|
||||
for (i = 0; i < sz; i++) ConsoleWrite("%c", buffer[i]);
|
||||
// Try to open
|
||||
if (!VfsOpen(&f, argv[1])) {
|
||||
ConsoleWrite ("%#! Invalid file: %s\n.", ColorLightRed, argv[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
ConsoleWrite("\n--------------------------\n");
|
||||
uint8* buffer = kmalloc(0x100);
|
||||
uint32 sz, i;
|
||||
|
||||
ConsoleWrite("----[%s]------\n", argv[1]);
|
||||
|
||||
while ((sz = VfsRead(&f, 1, 0x100, buffer)))
|
||||
{
|
||||
for (i = 0; i < sz; i++) ConsoleWrite("%#%c", ColorLightGray, buffer[i]);
|
||||
}
|
||||
|
||||
ConsoleWrite("\n------------[EOF]------------\n");
|
||||
kfree(buffer);
|
||||
VfsClose(&f);
|
||||
}
|
||||
|
||||
+32
-32
@@ -21,113 +21,113 @@ global Irq_15
|
||||
; 32: IRQ0
|
||||
Irq_0:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 32; Note that these don't push an error code on the stack:
|
||||
push dword 0
|
||||
push dword 32; Note that these don't push an error code on the stack:
|
||||
; We need to push a dummy error code
|
||||
jmp irq_common_stub
|
||||
|
||||
; 33: IRQ1
|
||||
Irq_1:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 33
|
||||
push dword 0
|
||||
push dword 33
|
||||
jmp irq_common_stub
|
||||
|
||||
; 34: IRQ2
|
||||
Irq_2:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 34
|
||||
push dword 0
|
||||
push dword 34
|
||||
jmp irq_common_stub
|
||||
|
||||
; 35: IRQ3
|
||||
Irq_3:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 35
|
||||
push dword 0
|
||||
push dword 35
|
||||
jmp irq_common_stub
|
||||
|
||||
; 36: IRQ4
|
||||
Irq_4:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 36
|
||||
push dword 0
|
||||
push dword 36
|
||||
jmp irq_common_stub
|
||||
|
||||
; 37: IRQ5
|
||||
Irq_5:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 37
|
||||
push dword 0
|
||||
push dword 37
|
||||
jmp irq_common_stub
|
||||
|
||||
; 38: IRQ6
|
||||
Irq_6:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 38
|
||||
push dword 0
|
||||
push dword 38
|
||||
jmp irq_common_stub
|
||||
|
||||
; 39: IRQ7
|
||||
Irq_7:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 39
|
||||
push dword 0
|
||||
push dword 39
|
||||
jmp irq_common_stub
|
||||
|
||||
; 40: IRQ8
|
||||
Irq_8:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 40
|
||||
push dword 0
|
||||
push dword 40
|
||||
jmp irq_common_stub
|
||||
; 41: IRQ9
|
||||
Irq_9:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 41
|
||||
push dword 0
|
||||
push dword 41
|
||||
jmp irq_common_stub
|
||||
|
||||
; 42: IRQ10
|
||||
Irq_10:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 42
|
||||
push dword 0
|
||||
push dword 42
|
||||
jmp irq_common_stub
|
||||
|
||||
; 43: IRQ11
|
||||
Irq_11:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 43
|
||||
push dword 0
|
||||
push dword 43
|
||||
jmp irq_common_stub
|
||||
|
||||
; 44: IRQ12
|
||||
Irq_12:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 44
|
||||
push dword 0
|
||||
push dword 44
|
||||
jmp irq_common_stub
|
||||
|
||||
; 45: IRQ13
|
||||
Irq_13:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 45
|
||||
push dword 0
|
||||
push dword 45
|
||||
jmp irq_common_stub
|
||||
|
||||
; 46: IRQ14
|
||||
Irq_14:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 46
|
||||
push dword 0
|
||||
push dword 46
|
||||
jmp irq_common_stub
|
||||
|
||||
; 47: IRQ15
|
||||
Irq_15:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 47
|
||||
push dword 0
|
||||
push dword 47
|
||||
jmp irq_common_stub
|
||||
|
||||
extern IrqHandler
|
||||
|
||||
+58
-58
@@ -36,158 +36,158 @@ global isr_exception_31
|
||||
|
||||
isr_exception_0:
|
||||
cli
|
||||
push byte 0; A normal ISR stub that pops a dummy error code to keep a
|
||||
push dword 0; A normal ISR stub that pops a dummy error code to keep a
|
||||
; uniform stack frame
|
||||
push byte 0
|
||||
push dword 0
|
||||
jmp isr_common_stub
|
||||
isr_exception_1:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 1
|
||||
push dword 0
|
||||
push dword 1
|
||||
jmp isr_common_stub
|
||||
isr_exception_2:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 2
|
||||
push dword 0
|
||||
push dword 2
|
||||
jmp isr_common_stub
|
||||
isr_exception_3:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 3
|
||||
push dword 0
|
||||
push dword 3
|
||||
jmp isr_common_stub
|
||||
isr_exception_4:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 4
|
||||
push dword 0
|
||||
push dword 4
|
||||
jmp isr_common_stub
|
||||
isr_exception_5:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 5
|
||||
push dword 0
|
||||
push dword 5
|
||||
jmp isr_common_stub
|
||||
isr_exception_6:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 6
|
||||
push dword 0
|
||||
push dword 6
|
||||
jmp isr_common_stub
|
||||
isr_exception_7:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 7
|
||||
push dword 0
|
||||
push dword 7
|
||||
jmp isr_common_stub
|
||||
isr_exception_8:
|
||||
cli
|
||||
push byte 8
|
||||
push dword 8
|
||||
jmp isr_common_stub
|
||||
isr_exception_9:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 9
|
||||
push dword 0
|
||||
push dword 9
|
||||
jmp isr_common_stub
|
||||
isr_exception_10:
|
||||
cli
|
||||
push byte 10
|
||||
push dword 10
|
||||
jmp isr_common_stub
|
||||
isr_exception_11:
|
||||
cli
|
||||
push byte 11
|
||||
push dword 11
|
||||
jmp isr_common_stub
|
||||
isr_exception_12:
|
||||
cli
|
||||
push byte 12
|
||||
push dword 12
|
||||
jmp isr_common_stub
|
||||
isr_exception_13:
|
||||
cli
|
||||
push byte 13
|
||||
push dword 13
|
||||
jmp isr_common_stub
|
||||
isr_exception_14:
|
||||
cli
|
||||
push byte 14
|
||||
push dword 14
|
||||
jmp isr_common_stub
|
||||
isr_exception_15:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 15
|
||||
push dword 0
|
||||
push dword 15
|
||||
jmp isr_common_stub
|
||||
isr_exception_16:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 16
|
||||
push dword 0
|
||||
push dword 16
|
||||
jmp isr_common_stub
|
||||
isr_exception_17:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 17
|
||||
push dword 0
|
||||
push dword 17
|
||||
jmp isr_common_stub
|
||||
isr_exception_18:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 18
|
||||
push dword 0
|
||||
push dword 18
|
||||
jmp isr_common_stub
|
||||
isr_exception_19:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 19
|
||||
push dword 0
|
||||
push dword 19
|
||||
jmp isr_common_stub
|
||||
isr_exception_20:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 20
|
||||
push dword 0
|
||||
push dword 20
|
||||
jmp isr_common_stub
|
||||
isr_exception_21:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 21
|
||||
push dword 0
|
||||
push dword 21
|
||||
jmp isr_common_stub
|
||||
isr_exception_22:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 22
|
||||
push dword 0
|
||||
push dword 22
|
||||
jmp isr_common_stub
|
||||
isr_exception_23:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 23
|
||||
push dword 0
|
||||
push dword 23
|
||||
jmp isr_common_stub
|
||||
isr_exception_24:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 24
|
||||
push dword 0
|
||||
push dword 24
|
||||
jmp isr_common_stub
|
||||
isr_exception_25:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 25
|
||||
push dword 0
|
||||
push dword 25
|
||||
jmp isr_common_stub
|
||||
isr_exception_26:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 26
|
||||
push dword 0
|
||||
push dword 26
|
||||
jmp isr_common_stub
|
||||
isr_exception_27:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 27
|
||||
push dword 0
|
||||
push dword 27
|
||||
jmp isr_common_stub
|
||||
isr_exception_28:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 28
|
||||
push dword 0
|
||||
push dword 28
|
||||
jmp isr_common_stub
|
||||
isr_exception_29:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 29
|
||||
push dword 0
|
||||
push dword 29
|
||||
jmp isr_common_stub
|
||||
isr_exception_30:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 30
|
||||
push dword 0
|
||||
push dword 30
|
||||
jmp isr_common_stub
|
||||
isr_exception_31:
|
||||
cli
|
||||
push byte 0
|
||||
push byte 31
|
||||
push dword 0
|
||||
push dword 31
|
||||
jmp isr_common_stub
|
||||
|
||||
extern IsrsFaultHandler
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Author: Tiberiu
|
||||
*/
|
||||
|
||||
#if NEVER
|
||||
#include <fileio.h>
|
||||
#include <debugio.h>
|
||||
#include "fat.h"
|
||||
@@ -78,3 +79,5 @@ void FatInstall()
|
||||
|
||||
VfsInstallFs(&fat12); VfsInstallFs(&fat16); VfsInstallFs(&fat32);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Author: Tiberiu
|
||||
*/
|
||||
|
||||
#ifdef NEVER
|
||||
#ifndef FAT_H_
|
||||
#define FAT_H_
|
||||
|
||||
@@ -133,3 +134,4 @@ extern uint32 Fat16Detect (DevReadRoutine r, uint32 blocksz);
|
||||
extern uint32 Fat32Detect (DevReadRoutine r, uint32 blocksz);
|
||||
|
||||
#endif /* FAT_H_ */
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* Created on: Aug 29, 2011
|
||||
* Author: Tiberiu
|
||||
*/
|
||||
#if NEVER
|
||||
#include <fileio.h>
|
||||
#include <memory.h>
|
||||
#include "fat.h"
|
||||
@@ -23,3 +24,4 @@ uint32 Fat12Detect (DevReadRoutine r, uint32 blocksz)
|
||||
kfree(buffer);
|
||||
return (res == 12);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* Created on: Aug 31, 2011
|
||||
* Author: Tiberiu
|
||||
*/
|
||||
#ifdef NEVER
|
||||
#include <fileio.h>
|
||||
#include <memory.h>
|
||||
#include "fat.h"
|
||||
@@ -23,4 +24,4 @@ uint32 Fat16Detect (DevReadRoutine r, uint32 blocksz)
|
||||
kfree(buffer);
|
||||
return (res == 16);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* Created on: Aug 31, 2011
|
||||
* Author: Tiberiu
|
||||
*/
|
||||
#if NEVER
|
||||
#include <fileio.h>
|
||||
#include <memory.h>
|
||||
#include "fat.h"
|
||||
@@ -24,3 +25,4 @@ uint32 Fat32Detect (DevReadRoutine r, uint32 blocksz)
|
||||
return (res == 32);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+132
-135
@@ -16,124 +16,76 @@
|
||||
#include "initrd.h"
|
||||
|
||||
|
||||
luxDEVICE *luxDevices;
|
||||
uint32 luxDeviceCount;
|
||||
|
||||
luxFILE *luxFiles;
|
||||
uint32 luxFileCount;
|
||||
uint32 luxFilesAllocated;
|
||||
|
||||
|
||||
/**************************************
|
||||
* DEVICE 'FAKE' READ ROUTINE *
|
||||
**************************************/
|
||||
uint32 luxDevRead (uint32 UNUSED(offset), void* UNUSED(buffer))
|
||||
uint32 luxInitrdDevRead (uint32 UNUSED(offset), void* UNUSED(buffer))
|
||||
{
|
||||
return LUXMAGIC;
|
||||
}
|
||||
|
||||
/**************************************
|
||||
* INITIALIZATION ROUTINE *
|
||||
**************************************/
|
||||
void luxInitrdInstall (MultibootInfo* info)
|
||||
{
|
||||
// Install filesystem
|
||||
FileSystem fs = {0, "luxinitrd", luxDetect, 0, 0,
|
||||
luxOpen, luxClose, luxRead, 0, luxTest, luxReadDir};
|
||||
|
||||
VfsInstallFs(&fs);
|
||||
|
||||
|
||||
// See what modules are loaded in the multiboot info
|
||||
if ((info->Flags & 8) == 0 || info->ModulesCount == 0) return; // nothing was loaded
|
||||
|
||||
uint32 i;
|
||||
MultibootModule* modules = (MultibootModule*) info->ModulesAddress;
|
||||
luxDevices = kmalloc(sizeof(luxDEVICE) * info->ModulesCount);
|
||||
luxDeviceCount = 0;
|
||||
|
||||
for (i = 0; i < info->ModulesCount; i++) {
|
||||
|
||||
// Check magic number, to make sure module is a initrd image
|
||||
luxHeader* head = (luxHeader*) modules[i].ModuleStart;
|
||||
if (head->Magic != LUXMAGIC) {
|
||||
Log("Initrd", "Magic = 0x%x [bad] ModuleStart = 0x%x\n", head->Magic, modules[i].ModuleStart);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set up entry
|
||||
luxDevices[luxDeviceCount].Data = (void*) modules[i].ModuleStart;
|
||||
luxDevices[luxDeviceCount].Size = modules[i].ModuleEnd - modules[i].ModuleStart;
|
||||
|
||||
// Register virtual device. Instead of blocksize, we give the dev no, so we can identify it later
|
||||
VfsMount("initrd", luxDevRead, 0, luxDeviceCount);
|
||||
++luxDeviceCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**************************************
|
||||
* OTHER USEFUL ROUTINES *
|
||||
**************************************/
|
||||
uint32 luxGetFileSlot()
|
||||
{
|
||||
// Find an empty slot
|
||||
uint32 i = 0;
|
||||
for (i = 0; i < luxFileCount; i++)
|
||||
if (luxFiles[i].Id == 0xffffffff) return i;
|
||||
|
||||
// Nothing found? Allocate more slots if necessary
|
||||
if (luxFileCount >= luxFilesAllocated)
|
||||
{
|
||||
luxFilesAllocated += 4;
|
||||
luxFiles = kmrealloc(luxFiles, luxFilesAllocated);
|
||||
}
|
||||
|
||||
// Give last slot
|
||||
++luxFileCount;
|
||||
return (luxFileCount-1);
|
||||
}
|
||||
|
||||
// Navigates and returns the directory entry that contains the file/folder
|
||||
luxDirectoryEntry* luxGetFile (string path, uint32 dev)
|
||||
luxDirectoryEntry rootDirectoryEntry;
|
||||
luxDirectoryEntry* luxGetFile (string path, uint32 data)
|
||||
{
|
||||
luxHeader* root = (luxHeader*) luxDevices[dev].Data;
|
||||
luxDirectory* current = root->Root;
|
||||
luxDirectoryEntry rt = {"root", 0xB68, 0, 0, 0, {0,0}, {0,0}, {0,0}, (uint32)&root->Root};
|
||||
luxHeader* head = (luxHeader*)data;
|
||||
uint32 end = strlen(path);
|
||||
uint32 start, next = 0;
|
||||
char* tmp;
|
||||
|
||||
if (path[0] != '\\')
|
||||
return &rt;
|
||||
// Remove ending '/' (if any)
|
||||
if (path[end-1] == '/') --end;
|
||||
|
||||
path = path + 1;
|
||||
// Empty string? Return the root
|
||||
if (end == 0) {
|
||||
rootDirectoryEntry.De.Flags = 0xB68; // read & execute only
|
||||
rootDirectoryEntry.De.GroupId = 0; // system group
|
||||
rootDirectoryEntry.De.OwnerId = 0; // system owner
|
||||
rootDirectoryEntry.De.Size = sizeof(uint32) + head->RootSize * sizeof(luxDirectoryEntry);
|
||||
rootDirectoryEntry.Offset = (uint32)(&head->RootSize) - data; // calculate offset
|
||||
|
||||
return &rootDirectoryEntry;
|
||||
}
|
||||
|
||||
while (path)
|
||||
// Make sure path is correct
|
||||
if (path[0] != '/') return NULL;
|
||||
|
||||
// Parse each directory until we find the one containing the file;
|
||||
uint32 cDir = (uint32)&head->RootSize;
|
||||
while (next < end)
|
||||
{
|
||||
// Trim the next path separator
|
||||
string tmp = strchr(path, '\\');
|
||||
if (tmp) {
|
||||
*tmp = 0; tmp = tmp + 1;
|
||||
if (!*tmp) tmp = 0;
|
||||
// Parse string
|
||||
start = next + 1; // Skip path separator
|
||||
tmp = strchr(&path[start], '/'); // Find next separator
|
||||
next = (!tmp) ? end : (uint32)(tmp - path) ; // Mark end of string, or next dir position in path
|
||||
|
||||
// strchr doesn't know when to end
|
||||
if (next >= end) { tmp = 0; next = end; }
|
||||
|
||||
// Look for directory
|
||||
uint32 i, find = 0xffffffff;
|
||||
uint32 size = *(uint32*)cDir;
|
||||
luxDirectoryEntry* de = (luxDirectoryEntry*) (cDir + sizeof(uint32));
|
||||
for (i = 0; i < size && find == 0xffffffff; i++)
|
||||
if (strncmp(de[i].De.Name, &path[start], strlen(de[i].De.Name)) == 0)
|
||||
find = i;
|
||||
|
||||
// Not found? Nope, not good
|
||||
if (find == 0xffffffff) return NULL;
|
||||
|
||||
// End of string? Return directory entry
|
||||
if (!tmp) return &de[find];
|
||||
|
||||
// make sure we don't try to read a file as a folder
|
||||
if ((de[find].De.Flags & 0x7) != FileDirectory) return NULL;
|
||||
// Not end of string? Continue
|
||||
cDir = (uint32) (data + de[find].Offset);
|
||||
}
|
||||
|
||||
// Find the folder/file in current directory
|
||||
uint32 i, found = 0xffffffff;
|
||||
for (i = 0; i < current->Count && found == 0xffffffff; i++)
|
||||
if (strcmp(path, current->Entries[i].Name) == 0) found = i;
|
||||
|
||||
// Check if the file/folder was found
|
||||
if (found == 0xffffffff) return NULL;
|
||||
|
||||
// Return entry pointer if done
|
||||
if (!tmp) return ¤t->Entries[found];
|
||||
|
||||
// Go inside
|
||||
current = (luxDirectory*) (current->Entries[found].Offset + (uint32)root);
|
||||
path = tmp;
|
||||
}
|
||||
|
||||
// We shouldn't get here
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -141,62 +93,107 @@ luxDirectoryEntry* luxGetFile (string path, uint32 dev)
|
||||
/**************************************
|
||||
* FILE SYSTEM INTERFACE ROUTINES *
|
||||
**************************************/
|
||||
uint32 luxDetect (DevReadRoutine rd, uint32 blocksz)
|
||||
uint32 luxDetect (MountPoint* mp)
|
||||
{
|
||||
// Check magic result, which is returned by our device read function
|
||||
void* buffer = kmalloc(blocksz);
|
||||
uint32 result = (*rd)(0, buffer);
|
||||
kfree(buffer);
|
||||
void* buffer = kmalloc(mp->BlockSize); // must allocate a buffer for non-initrd devices...
|
||||
uint32 result = mp->Read(0, buffer); // read something
|
||||
kfree(buffer); // get rid of the not needed buffer
|
||||
|
||||
return (result == LUXMAGIC);
|
||||
return (result == LUXMAGIC); // returned magic number? good
|
||||
}
|
||||
|
||||
// Returns element count read
|
||||
uint32 luxRead (const MountPoint* UNUSED(mp), FILE* f, uint32 elemsz, uint32 n, uint8* buffer)
|
||||
// Test if a file exists
|
||||
DirectoryEntry* luxTest (MountPoint* mp, string path)
|
||||
{
|
||||
uint32 temp = Min(n*elemsz, luxFiles[f->Id].Size);
|
||||
|
||||
memcpy(buffer, luxFiles[f->Id].Pos, temp);
|
||||
luxFiles[f->Id].Size -= temp;
|
||||
|
||||
return temp;
|
||||
// MountPoint.FsData[0] contains initrd image start address
|
||||
// luxDirectoryEntry contains a DirectoryEntry
|
||||
return (DirectoryEntry*) luxGetFile(path, mp->FsData[0]); // Get a directory and see
|
||||
}
|
||||
|
||||
FILE* luxOpen (const MountPoint* mp, FILE* f, string path)
|
||||
// Open a file
|
||||
FILE* luxOpen (MountPoint* mp, FILE* f, string path)
|
||||
{
|
||||
f->Id = luxGetFileSlot();
|
||||
luxDirectoryEntry* entry = luxGetFile(path, mp->BlockSize);
|
||||
// Find it first. mp->FsData[0] contains initrd image start address.
|
||||
luxDirectoryEntry* entry = luxGetFile(path, mp->FsData[0]);
|
||||
|
||||
f->Name = entry->Name;
|
||||
f->Flags = entry->Flags;
|
||||
f->GroupId = entry->GroupId;
|
||||
f->OwnerId = entry->OwnerId;
|
||||
f->Size = entry->Size;
|
||||
// Invalid entry
|
||||
if (entry == NULL) return NULL;
|
||||
|
||||
luxFiles[f->Id].Id = f->Id;
|
||||
luxFiles[f->Id].Pos = luxFiles[f->Id].Start = entry->Offset + luxDevices[mp->BlockSize].Data;
|
||||
luxFiles[f->Id].Size = entry->Size;
|
||||
// Set some data fields
|
||||
f->Name = entry->De.Name;
|
||||
f->Flags = entry->De.Flags;
|
||||
f->GroupId = entry->De.GroupId;
|
||||
f->OwnerId = entry->De.OwnerId;
|
||||
f->Size = entry->De.Size;
|
||||
|
||||
// Set up the buffer info. We will use these to read/write the file.
|
||||
f->BufStart = (void*) (mp->FsData[0] + entry->Offset);
|
||||
f->BufPos = f->BufStart;
|
||||
f->BufEnd = f->BufStart + entry->De.Size;
|
||||
|
||||
// And return it
|
||||
return f;
|
||||
}
|
||||
|
||||
DirectoryEntry* luxTest (const MountPoint* mp, string path)
|
||||
// Close a file
|
||||
FILE* luxClose (MountPoint* UNUSED(mp), FILE* f)
|
||||
{
|
||||
return (DirectoryEntry*) luxGetFile(path, mp->BlockSize);
|
||||
}
|
||||
|
||||
FILE* luxClose (const MountPoint* UNUSED(mp), FILE* f)
|
||||
{
|
||||
luxFiles[f->Id].Id = NULL;
|
||||
|
||||
// Just empty buffer info, so we don't attempt to read it again
|
||||
f->BufStart = f->BufPos = f->BufEnd = NULL;
|
||||
return f;
|
||||
}
|
||||
|
||||
DirectoryEntry* luxReadDir (const MountPoint* UNUSED(mp), FILE* f, uint32 index)
|
||||
// Read data from a file
|
||||
// Returns byte count read
|
||||
uint32 luxRead (MountPoint* UNUSED(mp), FILE* f, uint32 elemsz, uint32 n, uint8* buffer)
|
||||
{
|
||||
luxDirectory* dir = luxFiles[f->Id].Start;
|
||||
// Make sure we don't read more than we can
|
||||
uint32 total = Min(elemsz * n, (uint32)f->BufEnd - (uint32)f->BufPos);
|
||||
|
||||
if (index > dir->Count) return NULL;
|
||||
return (DirectoryEntry*) &dir->Entries[index];
|
||||
memcpy(buffer, f->BufPos, total); // Copy data
|
||||
f->BufPos = (void*) ((uint32)f->BufPos + total); // Set new buffer position
|
||||
return total; // Return byte count read
|
||||
}
|
||||
|
||||
// Read contents of a directory
|
||||
DirectoryEntry* luxReadDir (MountPoint* UNUSED(mp), FILE* f, uint32 index)
|
||||
{
|
||||
uint32 size = *(uint32*)f->BufStart;
|
||||
luxDirectoryEntry* de = (luxDirectoryEntry*) ((uint32)f->BufStart + sizeof(uint32));
|
||||
|
||||
if (index >= size) return NULL;
|
||||
return (DirectoryEntry*) &de[index];
|
||||
}
|
||||
|
||||
|
||||
/**************************************
|
||||
* INITIALIZATION ROUTINE *
|
||||
**************************************/
|
||||
void luxInitrdInstall (MultibootInfo* info)
|
||||
{
|
||||
uint32 i;
|
||||
MountPoint* mp;
|
||||
|
||||
// Register file system
|
||||
FileSystem fs = {0, "luxinitrd", luxDetect, 0, 0,
|
||||
luxOpen, luxClose, luxRead, 0, luxTest, luxReadDir};
|
||||
VfsInstallFs(&fs);
|
||||
|
||||
// Check for multiboot info flags to see if any modules are loaded
|
||||
if ((info->Flags & 8) == 0) return;
|
||||
|
||||
// Loop through each module and if it is an initrd image, mount it
|
||||
MultibootModule* modules = (MultibootModule*) info->ModulesAddress;
|
||||
|
||||
for (i = 0; i < info->ModulesCount; i++)
|
||||
if ((*(uint32*) modules[i].ModuleStart) == LUXMAGIC)
|
||||
{
|
||||
// Mount the device
|
||||
Log("Initrd", "Found initrd image at 0x%x.\n", modules[i].ModuleStart);
|
||||
mp = VfsMount("initrd", luxInitrdDevRead, NULL, 0x0);
|
||||
|
||||
// Set up data fields
|
||||
mp->FsData[0] = modules[i].ModuleStart;
|
||||
mp->FsData[1] = modules[i].ModuleEnd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* Author: Tiberiu
|
||||
*/
|
||||
|
||||
|
||||
#ifndef INITDR_H_
|
||||
#define INITDR_H_
|
||||
|
||||
@@ -12,45 +13,15 @@
|
||||
#include <fileio.h>
|
||||
|
||||
typedef struct {
|
||||
char Name[256];
|
||||
uint32 Flags, OwnerId, GroupId, Size;
|
||||
TimeSystem TimeCreated, TimeModified, TimeAccessed;
|
||||
DirectoryEntry De;
|
||||
uint32 Offset;
|
||||
} luxDirectoryEntry;
|
||||
|
||||
typedef struct {
|
||||
uint32 Count;
|
||||
luxDirectoryEntry* Entries;
|
||||
} luxDirectory;
|
||||
} __attribute__((packed)) luxDirectoryEntry;
|
||||
|
||||
typedef struct {
|
||||
uint32 Magic;
|
||||
char Oem[6];
|
||||
luxDirectory* Root;
|
||||
} luxHeader;
|
||||
|
||||
typedef struct {
|
||||
uint32 DeviceId;
|
||||
uint32 Size;
|
||||
void* Data;
|
||||
} luxDEVICE;
|
||||
|
||||
typedef struct {
|
||||
uint32 Id;
|
||||
uint32 Size;
|
||||
void* Start;
|
||||
void* Pos;
|
||||
} luxFILE;
|
||||
|
||||
|
||||
extern uint32 luxDevRead (uint32 offset, void* buffer);
|
||||
extern void luxInitrdInstall (MultibootInfo* info);
|
||||
extern uint32 luxDetect (DevReadRoutine rd, uint32 blocksz);
|
||||
extern uint32 luxRead (const MountPoint* mp, FILE* f, uint32 elemsz, uint32 n, uint8* buffer);
|
||||
extern FILE* luxOpen (const MountPoint* mp, FILE* f, string path);
|
||||
extern DirectoryEntry* luxTest (const MountPoint* mp, string path);
|
||||
extern FILE* luxClose (const MountPoint* mp, FILE* f);
|
||||
extern DirectoryEntry* luxReadDir (const MountPoint* mp, FILE* f, uint32 index);
|
||||
|
||||
uint32 RootSize;
|
||||
// After RootSize is the root content
|
||||
} __attribute__((packed)) luxHeader;
|
||||
|
||||
#endif /* INITDR_H_ */
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@
|
||||
#include "keyboard/keyboard.h"
|
||||
#include "mouse/mouse.h"
|
||||
|
||||
#include "filesys/fat/fat.h"
|
||||
//#include "filesys/fat/fat.h"
|
||||
|
||||
#include <fileio.h>
|
||||
#include <debugio.h>
|
||||
@@ -38,5 +38,5 @@ void HalInitialize()
|
||||
|
||||
// Install VFS
|
||||
VfsInstall();
|
||||
FatInstall();
|
||||
//FatInstall();
|
||||
}
|
||||
|
||||
+133
-108
@@ -1,152 +1,169 @@
|
||||
#include <array.h>
|
||||
#include <memory.h>
|
||||
#include <stdlib.h>
|
||||
#include <fileio.h>
|
||||
#include <debugio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MAX_FS_COUNT 64
|
||||
#define BAD 0xffffffff
|
||||
|
||||
FileSystem* fsArray;
|
||||
uint32 fsCount;
|
||||
DynamicArray fsList;
|
||||
DynamicArray mpList;
|
||||
|
||||
FileSystem* fsArray;
|
||||
MountPoint* mpArray;
|
||||
uint32 mpCount;
|
||||
uint32 mpAllocated;
|
||||
|
||||
void VfsInstall ()
|
||||
{
|
||||
fsArray = (FileSystem*) kmalloc(MAX_FS_COUNT * sizeof(FileSystem));
|
||||
fsCount = 0;
|
||||
DynamicArrayCreate(sizeof(FileSystem), &fsList);
|
||||
DynamicArrayCreate(sizeof(MountPoint), &mpList);
|
||||
|
||||
mpArray = (MountPoint*) kmalloc(32 * sizeof(MountPoint));
|
||||
mpCount = 0;
|
||||
mpAllocated = 32;
|
||||
fsArray = (FileSystem*) fsList.Data;
|
||||
mpArray = (MountPoint*) mpList.Data;
|
||||
|
||||
Log("VFS", "%#VFS now in business.\n", ColorLightGreen);
|
||||
Log("VFS", "%#Vfs now in business.\n", ColorLightGreen);
|
||||
}
|
||||
|
||||
uint8 VfsInstallFs (FileSystem* fs)
|
||||
void VfsInstallFs (FileSystem* fs)
|
||||
{
|
||||
if (fsCount >= MAX_FS_COUNT) {
|
||||
Error("VFS", "%#Failed to install file system '%s': FS count reached.\n", ColorLightRed, fs->Name);
|
||||
return 0;
|
||||
}
|
||||
fs->Id = fsList.Size;
|
||||
DynamicArrayPush(fs, &fsList);
|
||||
|
||||
memcpy(&fsArray[fsCount], fs, sizeof(FileSystem));
|
||||
fsArray[fsCount].Id = fsCount;
|
||||
|
||||
++fsCount;
|
||||
Log("VFS", "Installed file system %#%s.\n", ColorWhite, fs->Name);
|
||||
return 1;
|
||||
Log("VFS", "Installed file system %#%s%# (id=%u).\n", ColorWhite, fs->Name,
|
||||
ColorLightGray, fs->Id);
|
||||
}
|
||||
|
||||
uint32 VfsFindDevice (string dev)
|
||||
int32 _VfsFindDevice (string name)
|
||||
{
|
||||
uint32 i;
|
||||
for (i = 0; i < mpCount; i++)
|
||||
if (mpArray[i].Id != BAD && strcmp(dev, mpArray[i].Name) == 0)
|
||||
return i;
|
||||
int32 i;
|
||||
for (i = 0; (uint32)i < mpList.Size; i++)
|
||||
if (mpArray[i].Id != BAD && strcmp (name, mpArray[i].Name) == 0) return i;
|
||||
|
||||
return BAD;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// Returns mount point index, removes dev name from path
|
||||
uint32 VfsParsePath (string* path)
|
||||
string _VfsGetDevice (string path, int32* dev)
|
||||
{
|
||||
// Sanity check
|
||||
if (!path || !(*path)) return BAD;
|
||||
// Make sure path is valid
|
||||
if (!path || *path != '/') {
|
||||
*dev = -1; return NULL;
|
||||
}
|
||||
|
||||
string dev = *path, p = strchr(*path, ':');
|
||||
if (p == NULL) return BAD; // invalid path
|
||||
// Do we need to return root?
|
||||
path++;
|
||||
if (*path == '\0') return NULL; // Yes, but not implemented yet
|
||||
|
||||
// Split string
|
||||
*path = p+1; *p = '\0';
|
||||
// Find the next '/'
|
||||
int32 i, index = -1, len = strlen(path);
|
||||
for (i = 0; i < len && index == -1; i++)
|
||||
if (path[i] == '/') index = i;
|
||||
|
||||
return VfsFindDevice(dev);
|
||||
if (index == -1) index = len;
|
||||
|
||||
// Find the device
|
||||
*dev = -1;
|
||||
for (i = 0; (uint32)i < mpList.Size && *dev == -1; i++)
|
||||
if (mpArray[i].Id != BAD && strncmp(path, mpArray[i].Name, index) == 0)
|
||||
*dev = i;
|
||||
|
||||
return &path[index];
|
||||
}
|
||||
|
||||
uint8 VfsMount (string Name, DevReadRoutine R, DevWriteRoutine W, uint32 BlockSize)
|
||||
int32 _VfsDetectFs (MountPoint* mp)
|
||||
{
|
||||
uint32 i, fsId = BAD, mpIndex = BAD;
|
||||
int32 i;
|
||||
for (i = 0; (uint32)i < fsList.Size; i++)
|
||||
if (fsArray[i].Detect && fsArray[i].Detect(mp)) return i;
|
||||
|
||||
// Try to figure out the file system
|
||||
for (i = 0; i < fsCount && fsId == BAD; i++)
|
||||
if (fsArray[i].Detect && fsArray[i].Detect(R, BlockSize))
|
||||
fsId = i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fsId == BAD) {
|
||||
Error("VFS", "%#Failed to mount device %s: no file system found.\n", ColorLightRed, Name)
|
||||
return 0; // No file system, no good
|
||||
}
|
||||
int32 VfsTestDevname (string name)
|
||||
{
|
||||
// Check if name exists
|
||||
uint8 success = (_VfsFindDevice(name) == -1);
|
||||
|
||||
// Try to find an empty slot to fill
|
||||
for (i = 0; i < mpCount && mpIndex == BAD; i++)
|
||||
if (mpArray[i].Id == BAD) mpIndex = i;
|
||||
// Set up for search
|
||||
char find;
|
||||
uint32 len = strlen(name);
|
||||
name[len+1] = '\0';
|
||||
|
||||
// No empty slots?
|
||||
if (mpIndex == BAD)
|
||||
{
|
||||
// Make sure we have enough space
|
||||
if (mpCount == mpAllocated) {
|
||||
mpAllocated += 4;
|
||||
mpArray = kmrealloc(mpArray, mpAllocated * sizeof(MountPoint));
|
||||
}
|
||||
|
||||
mpIndex = mpCount++;
|
||||
}
|
||||
|
||||
// Add to mount point list, set up data
|
||||
mpArray[mpIndex].Id = mpIndex;
|
||||
mpArray[mpIndex].FsId = fsId;
|
||||
mpArray[mpIndex].BlockSize = BlockSize;
|
||||
mpArray[mpIndex].Read = R;
|
||||
mpArray[mpIndex].Write = W;
|
||||
|
||||
// Change name if it already exists
|
||||
uint32 find = VfsFindDevice(Name);
|
||||
if (find != BAD)
|
||||
{
|
||||
uint32 len = strlen(Name);
|
||||
uint8 success = 0;
|
||||
Name[len+1] = '\0';
|
||||
|
||||
// Try to find a number index
|
||||
// Name exists? Try a number
|
||||
for (find = '0'; find <= '9' && !success; find++)
|
||||
{
|
||||
Name[len] = find;
|
||||
if (VfsFindDevice(Name) == BAD) success = 1;
|
||||
name[len] = find;
|
||||
success = (_VfsFindDevice(name) == -1);
|
||||
}
|
||||
|
||||
// What? Haven't found anything yet? Try the alphabet
|
||||
// Whoa... nothing? Try the alphabet.
|
||||
for (find = 'a'; find <= 'z' && !success; find++)
|
||||
{
|
||||
Name[len] = find;
|
||||
if (VfsFindDevice(Name) == BAD) success = 1;
|
||||
name[len] = find;
|
||||
success = (_VfsFindDevice(name) == -1);
|
||||
}
|
||||
|
||||
// Still nothing? How in the world is this even possible ?!?!?!
|
||||
if (!success) return 0;
|
||||
}
|
||||
|
||||
memcpy(mpArray[mpIndex].Name, Name, sizeof(char) * MAX_MOUNTPOINTNAME_LEN);
|
||||
|
||||
// Tell file system to mount the device
|
||||
if (fsArray[mpArray[mpIndex].FsId].MountDevice)
|
||||
fsArray[mpArray[mpIndex].FsId].MountDevice(&mpArray[mpIndex]);
|
||||
|
||||
Log("VFS", "Mounted device %#%s%# using the %#%s%# file system.\n", ColorWhite, Name,
|
||||
ColorLightGray, ColorWhite, fsArray[fsId].Name, ColorLightGray);
|
||||
return 1;
|
||||
return success;
|
||||
}
|
||||
|
||||
void VfsUnmount (uint32 dev_id)
|
||||
MountPoint* VfsMount (string devname, DevReadRoutine R, DevWriteRoutine W, uint32 bs)
|
||||
{
|
||||
if (fsArray[mpArray[dev_id].FsId].UnmountDevice)
|
||||
fsArray[mpArray[dev_id].FsId].UnmountDevice(&mpArray[dev_id]);
|
||||
// Create a mount point
|
||||
MountPoint mp ;
|
||||
strcpy(mp.Name, devname);
|
||||
mp.BlockSize = bs;
|
||||
mp.Read = R;
|
||||
mp.Write = W;
|
||||
|
||||
mpArray[dev_id].Id = BAD;
|
||||
mpCount--;
|
||||
// Detect file system
|
||||
int32 fsid = _VfsDetectFs(&mp);
|
||||
if (fsid == -1) {
|
||||
Error("VFS", "%#Failed to mount device %s: could not find a file system.\n", ColorLightRed, devname);
|
||||
return NULL;
|
||||
}
|
||||
mp.FsId = (uint32) fsid;
|
||||
|
||||
// Rename if it has problems
|
||||
if (!VfsTestDevname(mp.Name)) {
|
||||
Error("VFS", "%#Failed to mount device %s: bad name.\n", ColorLightRed, devname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Find an empty slot
|
||||
uint32 empty = BAD, i;
|
||||
for (i = 0; i < mpList.Size && empty == BAD; i++)
|
||||
if (mpArray[i].Id == BAD) empty = i;
|
||||
|
||||
// Mount it
|
||||
if (empty == BAD) {
|
||||
mp.Id = mpList.Size;
|
||||
DynamicArrayPush(&mp, &mpList);
|
||||
}
|
||||
|
||||
else {
|
||||
mp.Id = empty;
|
||||
memcpy ( &mpArray[empty], &mp, sizeof(MountPoint));
|
||||
}
|
||||
|
||||
// Tell the FS to mount the device
|
||||
if (fsArray[fsid].MountDevice)
|
||||
fsArray[fsid].MountDevice(&mpArray[mp.Id]);
|
||||
|
||||
// Log
|
||||
Log("VFS", "Mounted device %#%s%# using the %#%s%# file system.\n", ColorWhite, mp.Name,
|
||||
ColorLightGray, ColorWhite, fsArray[fsid].Name, ColorLightGray);
|
||||
|
||||
return &mpArray[mp.Id];
|
||||
}
|
||||
|
||||
void VfsUnmount (uint32 devid)
|
||||
{
|
||||
if (fsArray[mpArray[devid].FsId].UnmountDevice)
|
||||
fsArray[mpArray[devid].FsId].UnmountDevice(&mpArray[devid],0);
|
||||
|
||||
// Invalidate ID
|
||||
mpArray[devid].Id = BAD;
|
||||
|
||||
// We shouldn't remove it from the array, because it will invalidate
|
||||
// all other devices' IDs.
|
||||
}
|
||||
|
||||
// Returns pointer to FILE structure that was inputed if success, null otherwise
|
||||
@@ -155,23 +172,25 @@ FILE* VfsOpen (FILE* file, string path)
|
||||
if (!file) return NULL;
|
||||
|
||||
// Parse string
|
||||
uint32 dev = VfsParsePath(&path);
|
||||
int32 dev; string temp;
|
||||
temp = _VfsGetDevice(path, &dev);
|
||||
file->DeviceId = dev;
|
||||
|
||||
// Device not found, or Open routine doesn't exist
|
||||
if (dev == BAD || !fsArray[mpArray[dev].FsId].Open) return NULL;
|
||||
if (dev == -1 || !fsArray[mpArray[dev].FsId].Open) return NULL;
|
||||
|
||||
// Ask the FS to do the 'opening'
|
||||
return fsArray[mpArray[dev].FsId].Open(&mpArray[dev],file,path);
|
||||
return fsArray[mpArray[dev].FsId].Open(&mpArray[dev],file,temp);
|
||||
}
|
||||
|
||||
DirectoryEntry* VfsTest (string path)
|
||||
{
|
||||
// Parse string
|
||||
uint32 dev = VfsParsePath(&path);
|
||||
int32 dev;
|
||||
path = _VfsGetDevice(path, &dev);
|
||||
|
||||
// Device not found, or Open routine doesn't exist
|
||||
if (dev == BAD || !fsArray[mpArray[dev].FsId].Test) return NULL;
|
||||
if (dev == -1 || !fsArray[mpArray[dev].FsId].Test) return NULL;
|
||||
|
||||
// Ask the FS to do the 'opening'
|
||||
return fsArray[mpArray[dev].FsId].Test(&mpArray[dev],path);
|
||||
@@ -212,3 +231,9 @@ DirectoryEntry* VfsReadDirectory (FILE* handle, uint32 index)
|
||||
if (!fsArray[mp->FsId].ReadDirectory) return NULL;
|
||||
return fsArray[mp->FsId].ReadDirectory(mp, handle, index);
|
||||
}
|
||||
|
||||
MountPoint* VfsGetMountPoint (uint32 dev_id)
|
||||
{
|
||||
if (dev_id < mpList.Size) return &mpArray[dev_id];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* array.h
|
||||
*
|
||||
* Created on: Sep 3, 2011
|
||||
* Author: Tiberiu
|
||||
*/
|
||||
|
||||
#ifndef ARRAY_H_
|
||||
#define ARRAY_H_
|
||||
|
||||
#include <types.h>
|
||||
|
||||
/*******************************************
|
||||
* Dynamically expanding array *
|
||||
*******************************************/
|
||||
typedef struct {
|
||||
// You can cast the Data to any type of array
|
||||
// because it contains the actual data, not pointers
|
||||
void* Data;
|
||||
uint32 ElemSize;
|
||||
uint32 Size;
|
||||
uint32 Allocated;
|
||||
} DynamicArray;
|
||||
|
||||
extern void DynamicArrayCreate (uint32 ElemSize, DynamicArray* arr);
|
||||
extern void DynamicArrayPush (void* item, DynamicArray* arr);
|
||||
extern void DynamicArrayPop (DynamicArray* arr);
|
||||
extern void DynamicArrayInsert (void* item, uint32 index, DynamicArray* arr);
|
||||
extern void DynamicArrayRemove (uint32 index, DynamicArray* arr);
|
||||
extern void DynamicArraySwap (uint32 a, uint32 b, DynamicArray* arr);
|
||||
extern void DynamicArrayDispose (DynamicArray* arr);
|
||||
|
||||
|
||||
/*******************************************
|
||||
* Ordered array *
|
||||
*******************************************/
|
||||
typedef int (*ComparePredicate) (uint32, uint32);
|
||||
typedef struct {
|
||||
uint32* Data;
|
||||
uint32 Size;
|
||||
uint32 SizeLimit;
|
||||
ComparePredicate Compare;
|
||||
} OrderedArray;
|
||||
|
||||
extern OrderedArray OrderedArrayCreate (uint32 maxSize, ComparePredicate p);
|
||||
extern OrderedArray OrderedArrayPlace (uint32 addr, uint32 maxSize, ComparePredicate p);
|
||||
extern void OrderedArrayDispose (OrderedArray* arr);
|
||||
extern uint32 OrderedArraySearch (uint32 key, OrderedArray* arr, ComparePredicate predicate);
|
||||
extern void OrderedArrayInsert (uint32 item, OrderedArray* arr);
|
||||
extern uint32 OrderedArrayLookup (uint32 index, OrderedArray* arr);
|
||||
extern void OrderedArrayDeleteIndex (uint32 index, OrderedArray* arr);
|
||||
|
||||
|
||||
#endif /* ARRAY_H_ */
|
||||
+29
-31
@@ -43,24 +43,23 @@ enum FileFlags
|
||||
typedef struct
|
||||
{
|
||||
uint32 DeviceId; // The VFS identifies the mounted device that uses this
|
||||
uint32 Id; // The FS idenitifies files using this field
|
||||
//char Name[MAX_FILENAME_LEN];
|
||||
uint32 Id; // The FS identifies files using this field
|
||||
char* Name;
|
||||
|
||||
/*** Looks like this:
|
||||
* bits description
|
||||
* 0-2 file type
|
||||
* 3-5 owner permissions (rwx)
|
||||
* 6-8 group permissions (rwx)
|
||||
* 9-11 other permissions (rwx)
|
||||
* 12 hidden
|
||||
* 13-31 (unassigned yet)
|
||||
/*** Flags look like this:
|
||||
*
|
||||
* Note: In windows FS, the readonly and system
|
||||
* attributes are set using permissions and owner id */
|
||||
uint32 Flags;
|
||||
uint32 OwnerId, GroupId;
|
||||
* bits 31 ... 13 | 12 | 11 10 9 | 8 7 6 | 5 4 3 | 2 1 0
|
||||
* unassigned | Hidden | x w r | x w r | x w r | file type (enum above)
|
||||
* | others | group | owner |
|
||||
* Note: In windows FSs, the readonly and system attributes are set
|
||||
* using permissions mask and owner id (0 = system) */
|
||||
uint32 Flags, OwnerId, GroupId;
|
||||
uint32 Size;
|
||||
|
||||
// Useful for file systems
|
||||
void *BufStart, *BufPos, *BufEnd ;
|
||||
uint32 FsData[8]; // Can store info such as current cluster, etc
|
||||
|
||||
} FILE;
|
||||
|
||||
|
||||
@@ -70,31 +69,32 @@ typedef struct _DirectoryEntry
|
||||
uint32 Flags, OwnerId, GroupId, Size;
|
||||
TimeSystem TimeCreated, TimeModified, TimeAccessed;
|
||||
|
||||
} DirectoryEntry;
|
||||
} __attribute__((packed)) DirectoryEntry;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32 Id;
|
||||
uint32 FsId;
|
||||
uint32 Id, FsId;
|
||||
char Name[MAX_MOUNTPOINTNAME_LEN];
|
||||
|
||||
uint32 BlockSize;
|
||||
DevReadRoutine Read;
|
||||
DevWriteRoutine Write;
|
||||
|
||||
uint32 FsData[8];
|
||||
} MountPoint;
|
||||
|
||||
|
||||
// File system routines
|
||||
typedef uint32 (*FsReadRoutine)(const MountPoint*, FILE*, uint32, uint32, uint8*);
|
||||
typedef uint32 (*FsWriteRoutine)(const MountPoint*, FILE*, uint32, uint32, uint8*);
|
||||
typedef FILE* (*FsOpenRoutine)(const MountPoint*, FILE*,string);
|
||||
typedef DirectoryEntry* (*FsTestRoutine)(const MountPoint*, string); // Test if a file exists, and returns info
|
||||
typedef FILE* (*FsCloseRoutine)(const MountPoint*, FILE*);
|
||||
typedef DirectoryEntry* (*FsReadDirRoutine)(const MountPoint*,FILE*,uint32);
|
||||
typedef uint32 (*FsReadRoutine) (MountPoint*, FILE*, uint32, uint32, uint8*);
|
||||
typedef uint32 (*FsWriteRoutine) (MountPoint*, FILE*, uint32, uint32, uint8*);
|
||||
typedef FILE* (*FsOpenRoutine) (MountPoint*, FILE*, string);
|
||||
typedef DirectoryEntry* (*FsTestRoutine) (MountPoint*, string); // Test if a file exists, and returns info
|
||||
typedef FILE* (*FsCloseRoutine) (MountPoint*, FILE*);
|
||||
typedef DirectoryEntry* (*FsReadDirRoutine) (MountPoint*, FILE*, uint32);
|
||||
|
||||
typedef uint32 (*FsDetectRoutine) (DevReadRoutine, uint32 blocksz);
|
||||
typedef void (*FsMountRoutine) (const MountPoint*);
|
||||
typedef void (*FsUnmountRoutine) (const MountPoint*);
|
||||
typedef uint32 (*FsDetectRoutine) (MountPoint*);
|
||||
typedef void (*FsMountRoutine) (MountPoint*);
|
||||
typedef void (*FsUnmountRoutine) (MountPoint*, uint8 Forced); // If forced, the FS shouldn't try to write to device
|
||||
|
||||
// File system structure
|
||||
typedef struct {
|
||||
@@ -116,10 +116,8 @@ typedef struct {
|
||||
|
||||
// Vfs routines
|
||||
extern void VfsInstall ();
|
||||
extern uint8 VfsInstallFs (FileSystem* fs);
|
||||
extern uint32 VfsFindDevice (string dev);
|
||||
extern uint32 VfsParsePath (string* path);
|
||||
extern uint8 VfsMount (string Name, DevReadRoutine R, DevWriteRoutine W, uint32 BlockSize);
|
||||
extern void VfsInstallFs (FileSystem* fs);
|
||||
extern MountPoint* VfsMount (string devname, DevReadRoutine R, DevWriteRoutine W, uint32 bs);
|
||||
extern void VfsUnmount (uint32 dev_id);
|
||||
extern FILE* VfsOpen (FILE* file, string path);
|
||||
extern DirectoryEntry* VfsTest (string path);
|
||||
@@ -127,6 +125,6 @@ extern FILE* VfsClose (FILE* file);
|
||||
extern uint32 VfsRead (FILE* file, uint32 bsz, uint32 n, uint8* buffer);
|
||||
extern uint32 VfsWrite (FILE* file, uint32 bsz, uint32 n, uint8* buffer);
|
||||
extern DirectoryEntry* VfsReadDirectory (FILE* handle, uint32 index);
|
||||
|
||||
extern MountPoint* VfsGetMountPoint (uint32 dev_id);
|
||||
|
||||
#endif /* FILEIO_H_ */
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <memory.h>
|
||||
#include <stdlib.h>
|
||||
#include <debugio.h>
|
||||
#include <array.h>
|
||||
|
||||
/***************************************************
|
||||
* Paging *
|
||||
|
||||
+1
-18
@@ -23,6 +23,7 @@
|
||||
***************************************************/
|
||||
extern uint32 strlen (string s);
|
||||
extern int32 strcmp (string a, string b);
|
||||
extern int32 strncmp (string a, string b, uint32 n);
|
||||
extern int32 strcasecmp (string a, string b);
|
||||
extern string strcpy (string s1, const string s2);
|
||||
extern char* strchr (string s, int c);
|
||||
@@ -50,23 +51,5 @@ extern int32 ConvertStringToInt (string buffer);
|
||||
extern uint32 ConvertStringToUInt (string buffer);
|
||||
extern uint32 ConvertStringToIntHex (string buffer);
|
||||
|
||||
/***************************************************
|
||||
* Ordered array implementation *
|
||||
***************************************************/
|
||||
typedef int (*ComparePredicate) (uint32, uint32);
|
||||
typedef struct {
|
||||
uint32* Data;
|
||||
uint32 Size;
|
||||
uint32 SizeLimit;
|
||||
ComparePredicate Compare;
|
||||
} OrderedArray;
|
||||
|
||||
extern OrderedArray OrderedArrayCreate (uint32 maxSize, ComparePredicate p);
|
||||
extern OrderedArray OrderedArrayPlace (uint32 addr, uint32 maxSize, ComparePredicate p);
|
||||
extern void OrderedArrayDispose (OrderedArray* arr);
|
||||
extern uint32 OrderedArraySearch (uint32 key, OrderedArray* arr, ComparePredicate predicate);
|
||||
extern void OrderedArrayInsert (uint32 item, OrderedArray* arr);
|
||||
extern uint32 OrderedArrayLookup (uint32 index, OrderedArray* arr);
|
||||
extern void OrderedArrayDeleteIndex (uint32 index, OrderedArray* arr);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define OS_BUILD "0.1.0.551"
|
||||
#define OS_BUILD "0.1.0.590"
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* dynamic-arr.c
|
||||
*
|
||||
* Created on: Sep 3, 2011
|
||||
* Author: Tiberiu
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <array.h>
|
||||
|
||||
void DynamicArrayCreate (uint32 ElemSize, DynamicArray* arr)
|
||||
{
|
||||
// Create a simple array. Allocate 16 elems for start
|
||||
arr->ElemSize = ElemSize;
|
||||
arr->Size = 0;
|
||||
arr->Allocated = 0x10;
|
||||
arr->Data = kmalloc(0x10 * ElemSize);
|
||||
}
|
||||
|
||||
void DynamicArrayPush (void* item, DynamicArray* arr)
|
||||
{
|
||||
// Make sure we have enough space
|
||||
if (arr->Allocated <= arr->Size)
|
||||
{
|
||||
arr->Allocated += 0x10;
|
||||
arr->Data = kmrealloc(arr->Data, arr->Allocated * arr->ElemSize);
|
||||
}
|
||||
|
||||
// Calculate the address of next item
|
||||
uint32 addr = (uint32)arr->Data + arr->Size * arr->ElemSize;
|
||||
|
||||
// Copy data
|
||||
memcpy((void*)addr, item, arr->ElemSize);
|
||||
++arr->Size;
|
||||
}
|
||||
|
||||
void DynamicArrayPop (DynamicArray* arr)
|
||||
{
|
||||
// Decrease size
|
||||
--arr->Size;
|
||||
}
|
||||
|
||||
void DynamicArrayInsert (void* item, uint32 index, DynamicArray* arr)
|
||||
{
|
||||
// Make sure we have enough space
|
||||
if (arr->Allocated <= arr->Size)
|
||||
{
|
||||
arr->Allocated += 0x10;
|
||||
arr->Data = kmrealloc(arr->Data, arr->Allocated * arr->ElemSize);
|
||||
}
|
||||
|
||||
// Move the data out of the way
|
||||
uint8* buffer = (uint8*) arr->Data;
|
||||
uint32 start = index * arr->ElemSize;
|
||||
uint32 end = arr->Size * arr->ElemSize;
|
||||
|
||||
for (--end; end >= start; end--)
|
||||
buffer[end + arr->ElemSize] = buffer[end];
|
||||
|
||||
// Insert item
|
||||
memcpy((void*)((uint32)arr->Data + start), item, arr->ElemSize);
|
||||
++ arr->Size;
|
||||
}
|
||||
|
||||
void DynamicArrayRemove (uint32 index, DynamicArray* arr)
|
||||
{
|
||||
uint8* buffer = (uint8*) arr->Data;
|
||||
uint32 start = index * arr->ElemSize;
|
||||
uint32 end = (arr->Size-1) * arr->ElemSize;
|
||||
|
||||
for (; start < end; start++)
|
||||
buffer[start] = buffer[start + arr->ElemSize];
|
||||
|
||||
-- arr->Size;
|
||||
}
|
||||
|
||||
void DynamicArraySwap (uint32 a, uint32 b, DynamicArray* arr)
|
||||
{
|
||||
uint8 temp, *buffer = (uint8*) arr->Data;
|
||||
uint32 addra = a * arr->ElemSize;
|
||||
uint32 addrb = b * arr->ElemSize;
|
||||
uint32 i;
|
||||
|
||||
for (i = 0; i < arr->ElemSize; i++)
|
||||
{
|
||||
// Swap byte i from elem A with byte i from elem B
|
||||
temp = buffer[addra + i];
|
||||
buffer[addra + i] = buffer[addrb + i];
|
||||
buffer[addrb + i] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicArrayDispose (DynamicArray* arr)
|
||||
{
|
||||
// Free used data
|
||||
kfree(arr->Data);
|
||||
|
||||
// Set everything to 0 so we don't attempt to add more items and stuff
|
||||
arr->Allocated = 0;
|
||||
arr->Size = 0;
|
||||
arr->ElemSize = 0;
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <array.h>
|
||||
|
||||
int StandardComparePredicate (uint32 a, uint32 b)
|
||||
{
|
||||
@@ -29,6 +29,21 @@ int32 strcmp (string a, string b)
|
||||
return ((c1 < c2) ? -1 : (c1 > c2));
|
||||
}
|
||||
|
||||
int32 strncmp (string a, string b, uint32 n)
|
||||
{
|
||||
unsigned char uc1, uc2;
|
||||
if (!n) return 0;
|
||||
|
||||
while (n-- > 0 && *a == *b) {
|
||||
if (n == 0 || (*a == *b && *a == '\0')) return 0;
|
||||
a++; b++;
|
||||
}
|
||||
|
||||
uc1 = (* (unsigned char*)a);
|
||||
uc2 = (* (unsigned char*)b);
|
||||
return ((uc1 < uc2) ? -1 : (uc1 > uc2));
|
||||
}
|
||||
|
||||
int32 strcasecmp (string a, string b)
|
||||
{
|
||||
unsigned char c1, c2;
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* memory-vi.c
|
||||
*
|
||||
* Created on: Aug 23, 2011
|
||||
* Author: Tiberiu
|
||||
*/
|
||||
#include <memory-add.h>
|
||||
#include <stdio.h>
|
||||
/*******************************
|
||||
* Data *
|
||||
*******************************/
|
||||
PageDirectory* CurrentDirectory;
|
||||
PageDirectory* KernelDirectory;
|
||||
|
||||
/*******************************
|
||||
* Useful routines *
|
||||
*******************************/
|
||||
void PagingInitialize(uint32 kernel_used)
|
||||
{
|
||||
LogMem("Virtual memory manager initialization started. End of kernel = 0x%x\n", kernel_used);
|
||||
PageDirectory* kernelPd = (PageDirectory*) kmalloc_a(sizeof(PageDirectory));
|
||||
memset(kernelPd, 0, sizeof(PageDirectory));
|
||||
|
||||
CurrentDirectory = kernelPd;
|
||||
KernelDirectory = kernelPd;
|
||||
|
||||
uint32 i;
|
||||
for (i = 0; i < kernel_used; i+=0x1000)
|
||||
MemPhAllocFrame(PagingGetPage(i, 1, kernelPd), 0, 0);
|
||||
|
||||
LogMem("Identity mapped first 0x%x bytes.\n", kernel_used);
|
||||
|
||||
for (i = KERNEL_HEAP_START; i < KERNEL_HEAP_END; i+=0x1000)
|
||||
MemPhAllocFrame(PagingGetPage(i, 1, kernelPd), 1, 1);
|
||||
|
||||
LogMem("Mapped kernel space.\n");
|
||||
|
||||
PagingSwitchPageDirectory (kernelPd);
|
||||
}
|
||||
|
||||
void PagingSwitchPageDirectory (PageDirectory* dir)
|
||||
{
|
||||
CurrentDirectory = dir;
|
||||
asm volatile ("mov %0, %%cr3":: "r"(&dir->TablesPhysical));
|
||||
LogMem("Switched page directory to 0x%x.\n", (uint32)(&dir->TablesPhysical));
|
||||
|
||||
uint32 cr0;
|
||||
asm volatile ("mov %%cr0, %0": "=r"(cr0));
|
||||
cr0 |= 0x80000000;
|
||||
asm volatile ("mov %0, %%cr0":: "r"(cr0));
|
||||
|
||||
LogMem("Enabled paging.\n");
|
||||
}
|
||||
|
||||
Page* PagingGetPage(uint32 addr, uint8 make, PageDirectory* dir)
|
||||
{
|
||||
addr >>= 12;
|
||||
|
||||
uint32 tableIndex = addr >> 10;
|
||||
|
||||
if (dir->Tables[tableIndex])
|
||||
return &dir->Tables[tableIndex]->Pages[addr&0x3ff];
|
||||
|
||||
else if (make)
|
||||
{
|
||||
uint32 temp;
|
||||
dir->Tables[tableIndex] = (PageTable*)kmalloc_ap(sizeof(PageTable), &temp);
|
||||
memset (dir->Tables[tableIndex], 0, 0x1000);
|
||||
dir->TablesPhysical[tableIndex] = temp | 0x7;
|
||||
return &dir->Tables[tableIndex]->Pages[addr&0x3ff];
|
||||
}
|
||||
|
||||
else return 0;
|
||||
}
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* mem-phys.c
|
||||
*
|
||||
* Created on: Aug 27, 2011
|
||||
* Author: Tiberiu
|
||||
*/
|
||||
#include <memory-add.h>
|
||||
|
||||
uint32* FrameMap;
|
||||
uint32 TotalFrames;
|
||||
uint32 TotalMemory;
|
||||
uint32 UsedFrames;
|
||||
|
||||
inline void ConvertIndexToFrame (uint32 index, uint32* address, uint32* offset)
|
||||
{
|
||||
*address = (index >> 5);
|
||||
*offset = index & 0x1f;
|
||||
}
|
||||
|
||||
inline uint32 ConvertFrameToIndex (uint32 address, uint32 offset)
|
||||
{
|
||||
return (address<<5) | offset;
|
||||
}
|
||||
|
||||
void MemPhSetFrame (uint32 frame, uint8 value)
|
||||
{
|
||||
uint32 addr, off;
|
||||
ConvertIndexToFrame(frame, &addr, &off);
|
||||
|
||||
if (value) {
|
||||
if ((FrameMap[addr] & (1<<off)) == 0) UsedFrames++;
|
||||
FrameMap[addr] |= 1<<off;
|
||||
}
|
||||
|
||||
else {
|
||||
if (FrameMap[addr] & (1<<off)) UsedFrames--;
|
||||
FrameMap[addr] &= ~(1<<off);
|
||||
}
|
||||
}
|
||||
|
||||
uint32 MemPhGetFrame (uint32 frame)
|
||||
{
|
||||
uint32 addr, off;
|
||||
ConvertIndexToFrame(frame, &addr, &off);
|
||||
|
||||
return FrameMap[addr] & (1<<off);
|
||||
}
|
||||
|
||||
uint32 MemPhFindFreeFrame()
|
||||
{
|
||||
uint32 addr, pos;
|
||||
|
||||
for (addr = 0; addr < TotalFrames >> 5; addr++)
|
||||
if (FrameMap[addr] != 0xffffffff)
|
||||
{
|
||||
for (pos = 0; (FrameMap[addr] & (1<<pos)) != 0; pos++) ;
|
||||
|
||||
return ConvertFrameToIndex(addr, pos);
|
||||
}
|
||||
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
void MemPhAllocFrame(Page* page, uint8 isKernel, uint8 isWriteable)
|
||||
{
|
||||
if ((*page & PageFrame) != 0) return;
|
||||
|
||||
uint32 free = MemPhFindFreeFrame();
|
||||
if (free == 0xffffffff) {
|
||||
Panic("%#Failed allocation free=0x%x page=0x%x\n", ColorRed, free, *page);
|
||||
return;
|
||||
}
|
||||
|
||||
MemPhSetFrame(free, 1);
|
||||
*page |= PagePresent;
|
||||
*page |= (isKernel) ? 0 : PageUser;
|
||||
*page |= (isWriteable) ? PageWriteable : 0;
|
||||
*page |= (free<<12) & PageFrame;
|
||||
}
|
||||
|
||||
void MemPhFreeFrame(Page* page)
|
||||
{
|
||||
uint32 frame = *page & PageFrame;
|
||||
if (!frame) return;
|
||||
|
||||
MemPhSetFrame(frame, 0);
|
||||
*page &= ~PageFrame;
|
||||
}
|
||||
|
||||
void MemPhInitialize(uint32 SystemMemoryKb)
|
||||
{
|
||||
LogMem("Starting physical memory manager...\n");
|
||||
TotalFrames = SystemMemoryKb >> 2;
|
||||
TotalMemory = SystemMemoryKb;
|
||||
|
||||
FrameMap = (uint32*) kmalloc(sizeof(uint32) * (1 + (TotalFrames>>5)));
|
||||
memset(FrameMap, 0, sizeof(uint32) * (1 + (TotalFrames>>5)));
|
||||
LogMem("%#Started physical memory manager ok!, found %ukb\n", ColorLightGreen, SystemMemoryKb);
|
||||
}
|
||||
|
||||
void MemPhReserveFrames (uint32 address, uint32 length)
|
||||
{
|
||||
address >>= 12;
|
||||
length = (length>>12) + ((length & 0xfff) > 0);
|
||||
uint32 end = address + length;
|
||||
|
||||
for (; address < end ; address++)
|
||||
MemPhSetFrame(address, 1);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# This code depends on make tool being used
|
||||
DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES}))
|
||||
ifneq (${DEPFILES},)
|
||||
include ${DEPFILES}
|
||||
endif
|
||||
@@ -0,0 +1,128 @@
|
||||
#
|
||||
# There exist several targets which are by default empty and which can be
|
||||
# used for execution of your targets. These targets are usually executed
|
||||
# before and after some main targets. They are:
|
||||
#
|
||||
# .build-pre: called before 'build' target
|
||||
# .build-post: called after 'build' target
|
||||
# .clean-pre: called before 'clean' target
|
||||
# .clean-post: called after 'clean' target
|
||||
# .clobber-pre: called before 'clobber' target
|
||||
# .clobber-post: called after 'clobber' target
|
||||
# .all-pre: called before 'all' target
|
||||
# .all-post: called after 'all' target
|
||||
# .help-pre: called before 'help' target
|
||||
# .help-post: called after 'help' target
|
||||
#
|
||||
# Targets beginning with '.' are not intended to be called on their own.
|
||||
#
|
||||
# Main targets can be executed directly, and they are:
|
||||
#
|
||||
# build build a specific configuration
|
||||
# clean remove built files from a configuration
|
||||
# clobber remove all built files
|
||||
# all build all configurations
|
||||
# help print help mesage
|
||||
#
|
||||
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
|
||||
# .help-impl are implemented in nbproject/makefile-impl.mk.
|
||||
#
|
||||
# Available make variables:
|
||||
#
|
||||
# CND_BASEDIR base directory for relative paths
|
||||
# CND_DISTDIR default top distribution directory (build artifacts)
|
||||
# CND_BUILDDIR default top build directory (object files, ...)
|
||||
# CONF name of current configuration
|
||||
# CND_PLATFORM_${CONF} platform name (current configuration)
|
||||
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
|
||||
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
|
||||
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
|
||||
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
|
||||
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
|
||||
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
|
||||
#
|
||||
# NOCDDL
|
||||
|
||||
|
||||
# Environment
|
||||
MKDIR=mkdir
|
||||
CP=cp
|
||||
CCADMIN=CCadmin
|
||||
|
||||
|
||||
# build
|
||||
build: .build-post
|
||||
|
||||
.build-pre:
|
||||
# Add your pre 'build' code here...
|
||||
|
||||
.build-post: .build-impl
|
||||
# Add your post 'build' code here...
|
||||
|
||||
|
||||
# clean
|
||||
clean: .clean-post
|
||||
|
||||
.clean-pre:
|
||||
# Add your pre 'clean' code here...
|
||||
|
||||
.clean-post: .clean-impl
|
||||
# Add your post 'clean' code here...
|
||||
|
||||
|
||||
# clobber
|
||||
clobber: .clobber-post
|
||||
|
||||
.clobber-pre:
|
||||
# Add your pre 'clobber' code here...
|
||||
|
||||
.clobber-post: .clobber-impl
|
||||
# Add your post 'clobber' code here...
|
||||
|
||||
|
||||
# all
|
||||
all: .all-post
|
||||
|
||||
.all-pre:
|
||||
# Add your pre 'all' code here...
|
||||
|
||||
.all-post: .all-impl
|
||||
# Add your post 'all' code here...
|
||||
|
||||
|
||||
# build tests
|
||||
build-tests: .build-tests-post
|
||||
|
||||
.build-tests-pre:
|
||||
# Add your pre 'build-tests' code here...
|
||||
|
||||
.build-tests-post: .build-tests-impl
|
||||
# Add your post 'build-tests' code here...
|
||||
|
||||
|
||||
# run tests
|
||||
test: .test-post
|
||||
|
||||
.test-pre:
|
||||
# Add your pre 'test' code here...
|
||||
|
||||
.test-post: .test-impl
|
||||
# Add your post 'test' code here...
|
||||
|
||||
|
||||
# help
|
||||
help: .help-post
|
||||
|
||||
.help-pre:
|
||||
# Add your pre 'help' code here...
|
||||
|
||||
.help-post: .help-impl
|
||||
# Add your post 'help' code here...
|
||||
|
||||
|
||||
|
||||
# include project implementation makefile
|
||||
include nbproject/Makefile-impl.mk
|
||||
|
||||
# include project make variables
|
||||
include nbproject/Makefile-variables.mk
|
||||
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
build/Debug/MinGW-Windows/commands.o: commands.cpp info.h types.h
|
||||
|
||||
info.h:
|
||||
|
||||
types.h:
|
||||
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
build/Debug/MinGW-Windows/info.o: info.cpp types.h info.h
|
||||
|
||||
types.h:
|
||||
|
||||
info.h:
|
||||
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
build/Debug/MinGW-Windows/main.o: main.cpp types.h
|
||||
|
||||
types.h:
|
||||
@@ -0,0 +1,246 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include "info.h"
|
||||
using namespace std;
|
||||
|
||||
struct Node
|
||||
{
|
||||
char Name[256];
|
||||
unsigned Flags;
|
||||
unsigned Size;
|
||||
unsigned Offset;
|
||||
|
||||
Node* Parent;
|
||||
vector<Node*> Children;
|
||||
};
|
||||
|
||||
Node Root;
|
||||
Node* Current;
|
||||
vector <Node*> list;
|
||||
unsigned Flags;
|
||||
|
||||
FILE* Out;
|
||||
|
||||
char* removeQuotes (char* s)
|
||||
{
|
||||
if (*s == '"') s = s + 1;
|
||||
char* tmp = strrchr(s, '"');
|
||||
if (tmp) *tmp = '\0';
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
int32 indexOf (char* s)
|
||||
{
|
||||
for (int i = 0; i < (int)Current->Children.size(); i++)
|
||||
if (strcmp(s, Current->Children[i]->Name) == 0) return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CommandCreate (char** argv, int argc)
|
||||
{
|
||||
if (argc < 2) throw ExcSyntaxError;
|
||||
argv[1] = removeQuotes(argv[1]);
|
||||
|
||||
// Set up root
|
||||
Root.Parent = &Root;
|
||||
Root.Flags = 0xB68;
|
||||
Current = &Root;
|
||||
Flags = 0xB68;
|
||||
|
||||
// Open 'root' file
|
||||
Out = fopen(argv[1], "wb");
|
||||
if (!Out) throw ExcCannotOpenOutput;
|
||||
}
|
||||
|
||||
void CommandSetFlags (char** argv, int argc)
|
||||
{
|
||||
if (argc < 2) throw ExcSyntaxError;
|
||||
argv[1] = removeQuotes(argv[1]);
|
||||
|
||||
unsigned long tmp = strtoul(argv[1], NULL, 0x10);
|
||||
Flags = (uint32) tmp & 0x497;
|
||||
}
|
||||
|
||||
void CommandAddFile (char** argv, int argc)
|
||||
{
|
||||
if (argc < 2) throw ExcSyntaxError;
|
||||
argv[1] = removeQuotes(argv[1]);
|
||||
|
||||
Node* node = new Node();
|
||||
memset(node, 0, sizeof(Node));
|
||||
|
||||
strcpy(node->Name, argv[1]);
|
||||
node->Flags = Flags | 0x1; // File
|
||||
node->Parent = Current;
|
||||
|
||||
list.push_back(node);
|
||||
Current->Children.push_back(node);
|
||||
}
|
||||
|
||||
void CommandAddDirectory (char** argv, int argc)
|
||||
{
|
||||
if (argc < 2) throw ExcSyntaxError;
|
||||
argv[1] = removeQuotes(argv[1]);
|
||||
|
||||
Node* node = new Node();
|
||||
memset(node, 0, sizeof(Node));
|
||||
strcpy(node->Name, argv[1]);
|
||||
node->Flags = Flags | 0x2; // Directory
|
||||
node->Parent = Current;
|
||||
|
||||
list.push_back(node);
|
||||
Current->Children.push_back(node);
|
||||
}
|
||||
|
||||
void CommandChangeDirectory (char** argv, int argc)
|
||||
{
|
||||
if (argc < 2) throw ExcSyntaxError;
|
||||
argv[1] = removeQuotes(argv[1]);
|
||||
|
||||
if (argv[1][0] == '\0') return;
|
||||
|
||||
// See if we need to go to root
|
||||
if (argv[1][0] == '\\') {
|
||||
Current = &Root;
|
||||
argv[1] = argv[1] + 1;
|
||||
}
|
||||
|
||||
// Process every folder in path
|
||||
while (argv[1])
|
||||
{
|
||||
char* next = strchr(argv[1], '\\');
|
||||
// mark next entry to parse
|
||||
if (next) { *next = 0; next = next+1; }
|
||||
|
||||
// previous dir?
|
||||
if (strcmp(argv[1], "..") == 0) Current = Current->Parent;
|
||||
|
||||
else {
|
||||
// Find next node
|
||||
int index = indexOf(argv[1]);
|
||||
if (index == -1 && strcmp(argv[1], ".") != 0) throw ExcInvalidPath; // Invalid path
|
||||
|
||||
// Set as current
|
||||
Current = Current->Children[index];
|
||||
}
|
||||
argv[1] = next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
unsigned CurrentOffset;
|
||||
void ProcessNodes(Node* node)
|
||||
{
|
||||
for (int i = 0; i < node->Children.size(); i++)
|
||||
{
|
||||
// Calculate size & offset
|
||||
node->Children[i]->Offset = CurrentOffset;
|
||||
|
||||
// File
|
||||
if (node->Children[i]->Flags & 0x1)
|
||||
node->Children[i]->Size = InfoGetFileSize(node->Children[i]->Name);
|
||||
// Directory
|
||||
else
|
||||
node->Children[i]->Size = sizeof(unsigned) +
|
||||
(sizeof(DirectoryEntry) * node->Children[i]->Children.size());
|
||||
|
||||
CurrentOffset += node->Children[i]->Size;
|
||||
|
||||
// If it is a directory, go in
|
||||
if (node->Children[i]->Flags & 0x2)
|
||||
ProcessNodes(node->Children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
bool NodeSort (Node* a, Node* b)
|
||||
{
|
||||
return (a->Offset < b->Offset);
|
||||
}
|
||||
|
||||
void WriteFile (char* path)
|
||||
{
|
||||
FILE* in = fopen(path, "rb");
|
||||
if (!in) throw ExcCannotOpenInput;
|
||||
|
||||
void* buffer = malloc(0x1000);
|
||||
uint32 r = 0;
|
||||
|
||||
// Copy in 4kb blocks
|
||||
while (r = fread(buffer, sizeof(uint8), 0x1000, in))
|
||||
fwrite(buffer, sizeof(uint8), r, Out );
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
void WriteDirectory (Node* node)
|
||||
{
|
||||
unsigned sz = node->Children.size();
|
||||
|
||||
// Write directory header (items count)
|
||||
fwrite (&sz, 1, sizeof (unsigned), Out);
|
||||
|
||||
for (int i = 0; i < sz; i++)
|
||||
{
|
||||
// Get the info
|
||||
DirectoryEntry dir;
|
||||
memset (&dir, 0, sizeof(DirectoryEntry));
|
||||
|
||||
char* temp = InfoGetFileName(node->Children[i]->Name);
|
||||
strcpy(dir.Name, temp);
|
||||
dir.Flags = node->Children[i]->Flags;
|
||||
dir.OwnerId = dir.GroupId = 0;
|
||||
dir.Size = node->Children[i]->Size;
|
||||
dir.TimeCreated = InfoGetFileCreated(node->Children[i]->Name);
|
||||
dir.TimeModified = InfoGetFileModified(node->Children[i]->Name);
|
||||
dir.TimeAccessed = InfoGetTime();
|
||||
dir.Offset = node->Children[i]->Offset;
|
||||
|
||||
// Write it
|
||||
fwrite (&dir, 1, sizeof(DirectoryEntry), Out);
|
||||
}
|
||||
}
|
||||
|
||||
void CommandClose ()
|
||||
{
|
||||
unsigned MAGIC = 0xCC23AA90;
|
||||
char* OemStr = "luxram";
|
||||
CurrentOffset = sizeof(MAGIC) + strlen(OemStr);
|
||||
|
||||
// Process root
|
||||
Root.Offset = CurrentOffset;
|
||||
Root.Size = sizeof (unsigned) + (Root.Children.size() * sizeof(DirectoryEntry));
|
||||
CurrentOffset += Root.Size;
|
||||
|
||||
// Process recursively all the nodes
|
||||
ProcessNodes(&Root);
|
||||
|
||||
// Now we need to sort the nodes by offset
|
||||
sort(list.begin(), list.end(), NodeSort);
|
||||
|
||||
// And now we need to write everything to output file
|
||||
fwrite(&MAGIC, sizeof(uint8), 4, Out); // Magic number
|
||||
fwrite(OemStr, sizeof(uint8), strlen(OemStr), Out); // Oem string
|
||||
|
||||
WriteDirectory(&Root); // Write the root
|
||||
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
{
|
||||
// If file, write content
|
||||
if (list[i]->Flags & 1) WriteFile(list[i]->Name);
|
||||
|
||||
// If directory, write list
|
||||
else WriteDirectory(list[i]);
|
||||
}
|
||||
|
||||
// Done; cleanup
|
||||
while (list.size()) {
|
||||
delete list.back();
|
||||
list.pop_back();
|
||||
}
|
||||
fclose(Out);
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,70 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include "types.h"
|
||||
#include "info.h"
|
||||
|
||||
string InfoGetFileName (string path)
|
||||
{
|
||||
string t = strrchr(path, '\\');
|
||||
|
||||
if (t == NULL) return path;
|
||||
return (t + 1);
|
||||
}
|
||||
|
||||
uint32 InfoGetFileSize (string path)
|
||||
{
|
||||
FILE* f = fopen (path, "r");
|
||||
if (!f) return 0;
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
uint32 ret = (uint32) ftell(f);
|
||||
fclose (f);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
TimeSystem ConvertTimeToTimeSystem (struct tm t)
|
||||
{
|
||||
TimeSystem sys = {0,0};
|
||||
|
||||
uint32 year = 1900 + t.tm_year - 1;
|
||||
uint32 yday = t.tm_yday;
|
||||
|
||||
sys.Time = (t.tm_hour * 3600000) + (uint32)(t.tm_min * 60000) + (uint32)(t.tm_sec * 1000);
|
||||
sys.Date = (yday) + (uint32)((year/4) * (365*4 + 1)) + (uint32)(year%4 * 365);
|
||||
|
||||
return sys;
|
||||
}
|
||||
|
||||
TimeSystem InfoGetTime ()
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
struct tm* t = gmtime(&now);
|
||||
return ConvertTimeToTimeSystem(*t);
|
||||
}
|
||||
|
||||
TimeSystem InfoGetFileCreated(string file)
|
||||
{
|
||||
struct tm* time;
|
||||
struct stat attrib;
|
||||
|
||||
stat(file, &attrib);
|
||||
time = gmtime(&(attrib.st_ctime));
|
||||
|
||||
if (time == NULL) return InfoGetTime();
|
||||
return ConvertTimeToTimeSystem(*time);
|
||||
}
|
||||
|
||||
TimeSystem InfoGetFileModified(string file)
|
||||
{
|
||||
struct tm* time;
|
||||
struct stat attrib;
|
||||
|
||||
stat(file, &attrib);
|
||||
time = gmtime(&(attrib.st_mtime));
|
||||
|
||||
if (time == NULL) return InfoGetTime();
|
||||
return ConvertTimeToTimeSystem(*time);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* File: info.h
|
||||
* Author: Tiberiu
|
||||
*
|
||||
* Created on August 31, 2011, 3:15 PM
|
||||
*/
|
||||
|
||||
#ifndef INFO_H
|
||||
#define INFO_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
extern string InfoGetFileName (string path);
|
||||
extern uint32 InfoGetFileSize (string path);
|
||||
extern TimeSystem InfoGetTime ();
|
||||
extern TimeSystem InfoGetFileCreated(string file);
|
||||
extern TimeSystem InfoGetFileModified(string file);
|
||||
|
||||
#endif /* INFO_H */
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
CREATE "filename" ; creates a new ramdisk with the filename
|
||||
MKDIR "name" ; creates a new directory (in current dir)
|
||||
CD "\path" ; sets current directory
|
||||
ADD "filename" ; adds a file to current directory!
|
||||
SETFLAGS 1A1B01 ; sets flags for next added files, number is in hex using this mask:
|
||||
* bits description
|
||||
* 0-2 file type; ignored, autocompleted at writing
|
||||
* 3-5 owner permissions (rwx); w ignored (read only device)
|
||||
* 6-8 group permissions (rwx); w ignored
|
||||
* 9-11 other permissions (rwx); w ignored
|
||||
* 12 hidden
|
||||
; default mask is: B68 (no write, everyone can execute and read)
|
||||
#asdf ; comment
|
||||
CLOSE ; writes and closes the ramdisk. You must close before opening another one
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* File: main.cpp
|
||||
* Author: Tiberiu
|
||||
*
|
||||
* Created on August 31, 2011, 2:54 PM
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "types.h"
|
||||
using namespace std;
|
||||
|
||||
extern void CommandCreate (char** argv, int argc);
|
||||
extern void CommandSetFlags (char** argv, int argc);
|
||||
extern void CommandAddFile (char** argv, int argc);
|
||||
extern void CommandAddDirectory (char** argv, int argc);
|
||||
extern void CommandChangeDirectory (char** argv, int argc);
|
||||
extern void CommandClose ();
|
||||
|
||||
void GetParams(char* buffer, char* params[], int &count)
|
||||
{
|
||||
bool inside_quotes = false;
|
||||
int len = strlen(buffer);
|
||||
count = 0;
|
||||
|
||||
if (buffer[0] == '#')
|
||||
{
|
||||
count = 1; params[0] = ""; return;
|
||||
}
|
||||
|
||||
if (!isspace(buffer[0])) params[count++] = buffer;
|
||||
else buffer[0] = 0;
|
||||
|
||||
for (int i = 1; i < len && count < 16; i++)
|
||||
{
|
||||
if (buffer[i] == '"') {
|
||||
inside_quotes = (inside_quotes) ? false : true;
|
||||
if (inside_quotes && buffer[i-1] == 0) params[count++] = &buffer[i];
|
||||
++i;
|
||||
}
|
||||
if (inside_quotes) continue;
|
||||
|
||||
// Comment
|
||||
if (buffer[i] == '#') {
|
||||
buffer[i] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isspace(buffer[i]) && (buffer[i-1]==0))
|
||||
params[count++] = &buffer[i];
|
||||
|
||||
else if (isspace(buffer[i])) buffer[i] = 0;
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
count = 1;
|
||||
params[0] = "";
|
||||
}
|
||||
}
|
||||
|
||||
bool LineEmpty (char* s)
|
||||
{
|
||||
for (int i = 0; i < strlen(s); i++)
|
||||
if (!isspace(s[i])) return false;
|
||||
}
|
||||
|
||||
|
||||
void ExecuteScript (char* input)
|
||||
{
|
||||
char buffer[1024];
|
||||
char* argv[16]; int argc;
|
||||
|
||||
// Try to open file
|
||||
FILE* in = fopen(input, "r");
|
||||
if (!in) { perror(input); return ; }
|
||||
|
||||
// Read file line by line
|
||||
printf("Reading script file %s...\n", input);
|
||||
for (int line = 0; fgets(buffer, 1024, in); line++)
|
||||
{
|
||||
GetParams(buffer, argv, argc);
|
||||
|
||||
try {
|
||||
if (strcmp(argv[0], "CREATE") == 0) CommandCreate(argv, argc);
|
||||
else if (strcmp(argv[0], "CLOSE") == 0) CommandClose();
|
||||
else if (strcmp(argv[0], "MKDIR") == 0) CommandAddDirectory(argv, argc);
|
||||
else if (strcmp(argv[0], "CD") == 0) CommandChangeDirectory(argv, argc);
|
||||
else if (strcmp(argv[0], "ADD") == 0) CommandAddFile(argv, argc);
|
||||
else if (strcmp(argv[0], "SETFLAGS") == 0) CommandSetFlags(argv, argc);
|
||||
else if (LineEmpty(argv[0])) continue;
|
||||
else {
|
||||
fprintf(stderr, "%i: Invalid command.\n", line);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
catch (int exc) {
|
||||
// Exception handler
|
||||
switch (exc) {
|
||||
case ExcCannotOpenInput: fprintf(stderr, "%i: Cannot open input file.\n", line); break;
|
||||
case ExcCannotOpenOutput: fprintf(stderr, "%i: Cannot open output file.\n", line); break;
|
||||
case ExcInvalidCommand: fprintf(stderr, "%i: Invalid command.\n", line); break;
|
||||
case ExcInvalidPath: fprintf(stderr, "%i: Invalid path.\n", line); break;
|
||||
case ExcSyntaxError: fprintf(stderr, "%i: Syntax error, robably missing parameter.\n", line); break;
|
||||
}
|
||||
printf("An error occurred, execution has been terminated.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memset(buffer, 0, 1024 * sizeof(char));
|
||||
}
|
||||
|
||||
fclose (in);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Missing parameter: script file.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
ExecuteScript (argv[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,94 @@
|
||||
#
|
||||
# Generated Makefile - do not edit!
|
||||
#
|
||||
# Edit the Makefile in the project folder instead (../Makefile). Each target
|
||||
# has a -pre and a -post target defined where you can add customized code.
|
||||
#
|
||||
# This makefile implements configuration specific macros and targets.
|
||||
|
||||
|
||||
# Environment
|
||||
MKDIR=mkdir
|
||||
CP=cp
|
||||
GREP=grep
|
||||
NM=nm
|
||||
CCADMIN=CCadmin
|
||||
RANLIB=ranlib
|
||||
CC=gcc.exe
|
||||
CCC=g++.exe
|
||||
CXX=g++.exe
|
||||
FC=
|
||||
AS=as.exe
|
||||
|
||||
# Macros
|
||||
CND_PLATFORM=MinGW-Windows
|
||||
CND_CONF=Debug
|
||||
CND_DISTDIR=dist
|
||||
|
||||
# Include project Makefile
|
||||
include Makefile
|
||||
|
||||
# Object Directory
|
||||
OBJECTDIR=build/${CND_CONF}/${CND_PLATFORM}
|
||||
|
||||
# Object Files
|
||||
OBJECTFILES= \
|
||||
${OBJECTDIR}/main.o \
|
||||
${OBJECTDIR}/commands.o \
|
||||
${OBJECTDIR}/info.o
|
||||
|
||||
|
||||
# C Compiler Flags
|
||||
CFLAGS=
|
||||
|
||||
# CC Compiler Flags
|
||||
CCFLAGS=
|
||||
CXXFLAGS=
|
||||
|
||||
# Fortran Compiler Flags
|
||||
FFLAGS=
|
||||
|
||||
# Assembler Flags
|
||||
ASFLAGS=
|
||||
|
||||
# Link Libraries and Options
|
||||
LDLIBSOPTIONS=
|
||||
|
||||
# Build Targets
|
||||
.build-conf: ${BUILD_SUBPROJECTS}
|
||||
"${MAKE}" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/ramdiskwriter.exe
|
||||
|
||||
dist/Debug/MinGW-Windows/ramdiskwriter.exe: ${OBJECTFILES}
|
||||
${MKDIR} -p dist/Debug/MinGW-Windows
|
||||
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ramdiskwriter ${OBJECTFILES} ${LDLIBSOPTIONS}
|
||||
|
||||
${OBJECTDIR}/main.o: main.cpp
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} $@.d
|
||||
$(COMPILE.cc) -g -MMD -MP -MF $@.d -o ${OBJECTDIR}/main.o main.cpp
|
||||
|
||||
${OBJECTDIR}/commands.o: commands.cpp
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} $@.d
|
||||
$(COMPILE.cc) -g -MMD -MP -MF $@.d -o ${OBJECTDIR}/commands.o commands.cpp
|
||||
|
||||
${OBJECTDIR}/info.o: info.cpp
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} $@.d
|
||||
$(COMPILE.cc) -g -MMD -MP -MF $@.d -o ${OBJECTDIR}/info.o info.cpp
|
||||
|
||||
# Subprojects
|
||||
.build-subprojects:
|
||||
|
||||
# Clean Targets
|
||||
.clean-conf: ${CLEAN_SUBPROJECTS}
|
||||
${RM} -r build/Debug
|
||||
${RM} dist/Debug/MinGW-Windows/ramdiskwriter.exe
|
||||
|
||||
# Subprojects
|
||||
.clean-subprojects:
|
||||
|
||||
# Enable dependency checking
|
||||
.dep.inc: .depcheck-impl
|
||||
|
||||
include .dep.inc
|
||||
@@ -0,0 +1,94 @@
|
||||
#
|
||||
# Generated Makefile - do not edit!
|
||||
#
|
||||
# Edit the Makefile in the project folder instead (../Makefile). Each target
|
||||
# has a -pre and a -post target defined where you can add customized code.
|
||||
#
|
||||
# This makefile implements configuration specific macros and targets.
|
||||
|
||||
|
||||
# Environment
|
||||
MKDIR=mkdir
|
||||
CP=cp
|
||||
GREP=grep
|
||||
NM=nm
|
||||
CCADMIN=CCadmin
|
||||
RANLIB=ranlib
|
||||
CC=gcc.exe
|
||||
CCC=g++.exe
|
||||
CXX=g++.exe
|
||||
FC=
|
||||
AS=as.exe
|
||||
|
||||
# Macros
|
||||
CND_PLATFORM=MinGW-Windows
|
||||
CND_CONF=Release
|
||||
CND_DISTDIR=dist
|
||||
|
||||
# Include project Makefile
|
||||
include Makefile
|
||||
|
||||
# Object Directory
|
||||
OBJECTDIR=build/${CND_CONF}/${CND_PLATFORM}
|
||||
|
||||
# Object Files
|
||||
OBJECTFILES= \
|
||||
${OBJECTDIR}/main.o \
|
||||
${OBJECTDIR}/commands.o \
|
||||
${OBJECTDIR}/info.o
|
||||
|
||||
|
||||
# C Compiler Flags
|
||||
CFLAGS=
|
||||
|
||||
# CC Compiler Flags
|
||||
CCFLAGS=
|
||||
CXXFLAGS=
|
||||
|
||||
# Fortran Compiler Flags
|
||||
FFLAGS=
|
||||
|
||||
# Assembler Flags
|
||||
ASFLAGS=
|
||||
|
||||
# Link Libraries and Options
|
||||
LDLIBSOPTIONS=
|
||||
|
||||
# Build Targets
|
||||
.build-conf: ${BUILD_SUBPROJECTS}
|
||||
"${MAKE}" -f nbproject/Makefile-Release.mk dist/Release/MinGW-Windows/ramdiskwriter.exe
|
||||
|
||||
dist/Release/MinGW-Windows/ramdiskwriter.exe: ${OBJECTFILES}
|
||||
${MKDIR} -p dist/Release/MinGW-Windows
|
||||
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ramdiskwriter ${OBJECTFILES} ${LDLIBSOPTIONS}
|
||||
|
||||
${OBJECTDIR}/main.o: main.cpp
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} $@.d
|
||||
$(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/main.o main.cpp
|
||||
|
||||
${OBJECTDIR}/commands.o: commands.cpp
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} $@.d
|
||||
$(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/commands.o commands.cpp
|
||||
|
||||
${OBJECTDIR}/info.o: info.cpp
|
||||
${MKDIR} -p ${OBJECTDIR}
|
||||
${RM} $@.d
|
||||
$(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/info.o info.cpp
|
||||
|
||||
# Subprojects
|
||||
.build-subprojects:
|
||||
|
||||
# Clean Targets
|
||||
.clean-conf: ${CLEAN_SUBPROJECTS}
|
||||
${RM} -r build/Release
|
||||
${RM} dist/Release/MinGW-Windows/ramdiskwriter.exe
|
||||
|
||||
# Subprojects
|
||||
.clean-subprojects:
|
||||
|
||||
# Enable dependency checking
|
||||
.dep.inc: .depcheck-impl
|
||||
|
||||
include .dep.inc
|
||||
@@ -0,0 +1,133 @@
|
||||
#
|
||||
# Generated Makefile - do not edit!
|
||||
#
|
||||
# Edit the Makefile in the project folder instead (../Makefile). Each target
|
||||
# has a pre- and a post- target defined where you can add customization code.
|
||||
#
|
||||
# This makefile implements macros and targets common to all configurations.
|
||||
#
|
||||
# NOCDDL
|
||||
|
||||
|
||||
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
|
||||
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
|
||||
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
|
||||
# and .clean-reqprojects-conf unless SUB has the value 'no'
|
||||
SUB_no=NO
|
||||
SUBPROJECTS=${SUB_${SUB}}
|
||||
BUILD_SUBPROJECTS_=.build-subprojects
|
||||
BUILD_SUBPROJECTS_NO=
|
||||
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
|
||||
CLEAN_SUBPROJECTS_=.clean-subprojects
|
||||
CLEAN_SUBPROJECTS_NO=
|
||||
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
|
||||
|
||||
|
||||
# Project Name
|
||||
PROJECTNAME=RamdiskWriter
|
||||
|
||||
# Active Configuration
|
||||
DEFAULTCONF=Debug
|
||||
CONF=${DEFAULTCONF}
|
||||
|
||||
# All Configurations
|
||||
ALLCONFS=Debug Release
|
||||
|
||||
|
||||
# build
|
||||
.build-impl: .build-pre .validate-impl .depcheck-impl
|
||||
@#echo "=> Running $@... Configuration=$(CONF)"
|
||||
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf
|
||||
|
||||
|
||||
# clean
|
||||
.clean-impl: .clean-pre .validate-impl .depcheck-impl
|
||||
@#echo "=> Running $@... Configuration=$(CONF)"
|
||||
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf
|
||||
|
||||
|
||||
# clobber
|
||||
.clobber-impl: .clobber-pre .depcheck-impl
|
||||
@#echo "=> Running $@..."
|
||||
for CONF in ${ALLCONFS}; \
|
||||
do \
|
||||
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \
|
||||
done
|
||||
|
||||
# all
|
||||
.all-impl: .all-pre .depcheck-impl
|
||||
@#echo "=> Running $@..."
|
||||
for CONF in ${ALLCONFS}; \
|
||||
do \
|
||||
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \
|
||||
done
|
||||
|
||||
# build tests
|
||||
.build-tests-impl: .build-impl .build-tests-pre
|
||||
@#echo "=> Running $@... Configuration=$(CONF)"
|
||||
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf
|
||||
|
||||
# run tests
|
||||
.test-impl: .build-tests-impl .test-pre
|
||||
@#echo "=> Running $@... Configuration=$(CONF)"
|
||||
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf
|
||||
|
||||
# dependency checking support
|
||||
.depcheck-impl:
|
||||
@echo "# This code depends on make tool being used" >.dep.inc
|
||||
@if [ -n "${MAKE_VERSION}" ]; then \
|
||||
echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
|
||||
echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
|
||||
echo "include \$${DEPFILES}" >>.dep.inc; \
|
||||
echo "endif" >>.dep.inc; \
|
||||
else \
|
||||
echo ".KEEP_STATE:" >>.dep.inc; \
|
||||
echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
|
||||
fi
|
||||
|
||||
# configuration validation
|
||||
.validate-impl:
|
||||
@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
|
||||
then \
|
||||
echo ""; \
|
||||
echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \
|
||||
echo "See 'make help' for details."; \
|
||||
echo "Current directory: " `pwd`; \
|
||||
echo ""; \
|
||||
fi
|
||||
@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
|
||||
then \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
|
||||
# help
|
||||
.help-impl: .help-pre
|
||||
@echo "This makefile supports the following configurations:"
|
||||
@echo " ${ALLCONFS}"
|
||||
@echo ""
|
||||
@echo "and the following targets:"
|
||||
@echo " build (default target)"
|
||||
@echo " clean"
|
||||
@echo " clobber"
|
||||
@echo " all"
|
||||
@echo " help"
|
||||
@echo ""
|
||||
@echo "Makefile Usage:"
|
||||
@echo " make [CONF=<CONFIGURATION>] [SUB=no] build"
|
||||
@echo " make [CONF=<CONFIGURATION>] [SUB=no] clean"
|
||||
@echo " make [SUB=no] clobber"
|
||||
@echo " make [SUB=no] all"
|
||||
@echo " make help"
|
||||
@echo ""
|
||||
@echo "Target 'build' will build a specific configuration and, unless 'SUB=no',"
|
||||
@echo " also build subprojects."
|
||||
@echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no',"
|
||||
@echo " also clean subprojects."
|
||||
@echo "Target 'clobber' will remove all built files from all configurations and,"
|
||||
@echo " unless 'SUB=no', also from subprojects."
|
||||
@echo "Target 'all' will will build all configurations and, unless 'SUB=no',"
|
||||
@echo " also build subprojects."
|
||||
@echo "Target 'help' prints this message."
|
||||
@echo ""
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Generated - do not edit!
|
||||
#
|
||||
# NOCDDL
|
||||
#
|
||||
CND_BASEDIR=`pwd`
|
||||
CND_BUILDDIR=build
|
||||
CND_DISTDIR=dist
|
||||
# Debug configuration
|
||||
CND_PLATFORM_Debug=MinGW-Windows
|
||||
CND_ARTIFACT_DIR_Debug=dist/Debug/MinGW-Windows
|
||||
CND_ARTIFACT_NAME_Debug=ramdiskwriter
|
||||
CND_ARTIFACT_PATH_Debug=dist/Debug/MinGW-Windows/ramdiskwriter
|
||||
CND_PACKAGE_DIR_Debug=dist/Debug/MinGW-Windows/package
|
||||
CND_PACKAGE_NAME_Debug=ramdiskwriter.tar
|
||||
CND_PACKAGE_PATH_Debug=dist/Debug/MinGW-Windows/package/ramdiskwriter.tar
|
||||
# Release configuration
|
||||
CND_PLATFORM_Release=MinGW-Windows
|
||||
CND_ARTIFACT_DIR_Release=dist/Release/MinGW-Windows
|
||||
CND_ARTIFACT_NAME_Release=ramdiskwriter
|
||||
CND_ARTIFACT_PATH_Release=dist/Release/MinGW-Windows/ramdiskwriter
|
||||
CND_PACKAGE_DIR_Release=dist/Release/MinGW-Windows/package
|
||||
CND_PACKAGE_NAME_Release=ramdiskwriter.tar
|
||||
CND_PACKAGE_PATH_Release=dist/Release/MinGW-Windows/package/ramdiskwriter.tar
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
#
|
||||
# Generated - do not edit!
|
||||
#
|
||||
|
||||
# Macros
|
||||
TOP=`pwd`
|
||||
CND_PLATFORM=MinGW-Windows
|
||||
CND_CONF=Debug
|
||||
CND_DISTDIR=dist
|
||||
NBTMPDIR=build/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
|
||||
TMPDIRNAME=tmp-packaging
|
||||
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ramdiskwriter
|
||||
OUTPUT_BASENAME=ramdiskwriter
|
||||
PACKAGE_TOP_DIR=ramdiskwriter/
|
||||
|
||||
# Functions
|
||||
function checkReturnCode
|
||||
{
|
||||
rc=$?
|
||||
if [ $rc != 0 ]
|
||||
then
|
||||
exit $rc
|
||||
fi
|
||||
}
|
||||
function makeDirectory
|
||||
# $1 directory path
|
||||
# $2 permission (optional)
|
||||
{
|
||||
mkdir -p "$1"
|
||||
checkReturnCode
|
||||
if [ "$2" != "" ]
|
||||
then
|
||||
chmod $2 "$1"
|
||||
checkReturnCode
|
||||
fi
|
||||
}
|
||||
function copyFileToTmpDir
|
||||
# $1 from-file path
|
||||
# $2 to-file path
|
||||
# $3 permission
|
||||
{
|
||||
cp "$1" "$2"
|
||||
checkReturnCode
|
||||
if [ "$3" != "" ]
|
||||
then
|
||||
chmod $3 "$2"
|
||||
checkReturnCode
|
||||
fi
|
||||
}
|
||||
|
||||
# Setup
|
||||
cd "${TOP}"
|
||||
mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
|
||||
rm -rf ${NBTMPDIR}
|
||||
mkdir -p ${NBTMPDIR}
|
||||
|
||||
# Copy files and create directories and links
|
||||
cd "${TOP}"
|
||||
makeDirectory "${NBTMPDIR}/ramdiskwriter/bin"
|
||||
copyFileToTmpDir "${OUTPUT_PATH}.exe" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}.exe" 0755
|
||||
|
||||
|
||||
# Generate tar file
|
||||
cd "${TOP}"
|
||||
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/ramdiskwriter.tar
|
||||
cd ${NBTMPDIR}
|
||||
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/ramdiskwriter.tar *
|
||||
checkReturnCode
|
||||
|
||||
# Cleanup
|
||||
cd "${TOP}"
|
||||
rm -rf ${NBTMPDIR}
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
#
|
||||
# Generated - do not edit!
|
||||
#
|
||||
|
||||
# Macros
|
||||
TOP=`pwd`
|
||||
CND_PLATFORM=MinGW-Windows
|
||||
CND_CONF=Release
|
||||
CND_DISTDIR=dist
|
||||
NBTMPDIR=build/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
|
||||
TMPDIRNAME=tmp-packaging
|
||||
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ramdiskwriter
|
||||
OUTPUT_BASENAME=ramdiskwriter
|
||||
PACKAGE_TOP_DIR=ramdiskwriter/
|
||||
|
||||
# Functions
|
||||
function checkReturnCode
|
||||
{
|
||||
rc=$?
|
||||
if [ $rc != 0 ]
|
||||
then
|
||||
exit $rc
|
||||
fi
|
||||
}
|
||||
function makeDirectory
|
||||
# $1 directory path
|
||||
# $2 permission (optional)
|
||||
{
|
||||
mkdir -p "$1"
|
||||
checkReturnCode
|
||||
if [ "$2" != "" ]
|
||||
then
|
||||
chmod $2 "$1"
|
||||
checkReturnCode
|
||||
fi
|
||||
}
|
||||
function copyFileToTmpDir
|
||||
# $1 from-file path
|
||||
# $2 to-file path
|
||||
# $3 permission
|
||||
{
|
||||
cp "$1" "$2"
|
||||
checkReturnCode
|
||||
if [ "$3" != "" ]
|
||||
then
|
||||
chmod $3 "$2"
|
||||
checkReturnCode
|
||||
fi
|
||||
}
|
||||
|
||||
# Setup
|
||||
cd "${TOP}"
|
||||
mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
|
||||
rm -rf ${NBTMPDIR}
|
||||
mkdir -p ${NBTMPDIR}
|
||||
|
||||
# Copy files and create directories and links
|
||||
cd "${TOP}"
|
||||
makeDirectory "${NBTMPDIR}/ramdiskwriter/bin"
|
||||
copyFileToTmpDir "${OUTPUT_PATH}.exe" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}.exe" 0755
|
||||
|
||||
|
||||
# Generate tar file
|
||||
cd "${TOP}"
|
||||
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/ramdiskwriter.tar
|
||||
cd ${NBTMPDIR}
|
||||
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/ramdiskwriter.tar *
|
||||
checkReturnCode
|
||||
|
||||
# Cleanup
|
||||
cd "${TOP}"
|
||||
rm -rf ${NBTMPDIR}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configurationDescriptor version="69">
|
||||
<logicalFolder name="root" displayName="root" projectFiles="true">
|
||||
<logicalFolder name="HeaderFiles"
|
||||
displayName="Header Files"
|
||||
projectFiles="true"
|
||||
kind="SOURCE_LOGICAL_FOLDER">
|
||||
</logicalFolder>
|
||||
<logicalFolder name="ResourceFiles"
|
||||
displayName="Resource Files"
|
||||
projectFiles="true"
|
||||
kind="SOURCE_LOGICAL_FOLDER">
|
||||
</logicalFolder>
|
||||
<logicalFolder name="SourceFiles"
|
||||
displayName="Source Files"
|
||||
projectFiles="true"
|
||||
kind="SOURCE_LOGICAL_FOLDER">
|
||||
<itemPath>commands.cpp</itemPath>
|
||||
<itemPath>info.cpp</itemPath>
|
||||
<itemPath>main.cpp</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="TestFiles"
|
||||
displayName="Test Files"
|
||||
projectFiles="false"
|
||||
kind="TEST_LOGICAL_FOLDER">
|
||||
</logicalFolder>
|
||||
<logicalFolder name="ExternalFiles"
|
||||
displayName="Important Files"
|
||||
projectFiles="false"
|
||||
kind="IMPORTANT_FILES_FOLDER">
|
||||
<itemPath>Makefile</itemPath>
|
||||
</logicalFolder>
|
||||
<itemPath>info.h</itemPath>
|
||||
<itemPath>sample.txt</itemPath>
|
||||
<itemPath>types.h</itemPath>
|
||||
</logicalFolder>
|
||||
<projectmakefile>Makefile</projectmakefile>
|
||||
<confs>
|
||||
<conf name="Debug" type="1">
|
||||
<toolsSet>
|
||||
<developmentServer>localhost</developmentServer>
|
||||
<compilerSet>MinGW|MinGW</compilerSet>
|
||||
<platform>3</platform>
|
||||
</toolsSet>
|
||||
<compileType>
|
||||
</compileType>
|
||||
</conf>
|
||||
<conf name="Release" type="1">
|
||||
<toolsSet>
|
||||
<developmentServer>localhost</developmentServer>
|
||||
<compilerSet>MinGW|MinGW</compilerSet>
|
||||
<platform>3</platform>
|
||||
</toolsSet>
|
||||
<compileType>
|
||||
<cTool>
|
||||
<developmentMode>5</developmentMode>
|
||||
</cTool>
|
||||
<ccTool>
|
||||
<developmentMode>5</developmentMode>
|
||||
</ccTool>
|
||||
<fortranCompilerTool>
|
||||
<developmentMode>5</developmentMode>
|
||||
</fortranCompilerTool>
|
||||
<asmTool>
|
||||
<developmentMode>5</developmentMode>
|
||||
</asmTool>
|
||||
</compileType>
|
||||
</conf>
|
||||
</confs>
|
||||
</configurationDescriptor>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configurationDescriptor version="69">
|
||||
<projectmakefile>Makefile</projectmakefile>
|
||||
<defaultConf>0</defaultConf>
|
||||
<confs>
|
||||
<conf name="Debug" type="1">
|
||||
<gizmo_options version="3">
|
||||
<configurationname>GizmoSimple</configurationname>
|
||||
</gizmo_options>
|
||||
<runprofile version="6">
|
||||
<args>sample.txt</args>
|
||||
<rundir></rundir>
|
||||
<buildfirst>true</buildfirst>
|
||||
<console-type>0</console-type>
|
||||
<terminal-type>0</terminal-type>
|
||||
<remove-instrumentation>0</remove-instrumentation>
|
||||
<environment>
|
||||
</environment>
|
||||
</runprofile>
|
||||
</conf>
|
||||
<conf name="Release" type="1">
|
||||
<gizmo_options version="3">
|
||||
<configurationname>GizmoSimple</configurationname>
|
||||
</gizmo_options>
|
||||
<runprofile version="6">
|
||||
<args></args>
|
||||
<rundir></rundir>
|
||||
<buildfirst>true</buildfirst>
|
||||
<console-type>0</console-type>
|
||||
<terminal-type>0</terminal-type>
|
||||
<remove-instrumentation>0</remove-instrumentation>
|
||||
<environment>
|
||||
</environment>
|
||||
</runprofile>
|
||||
</conf>
|
||||
</confs>
|
||||
</configurationDescriptor>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
|
||||
</project-private>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.cnd.makeproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/make-project/1">
|
||||
<name>RamdiskWriter</name>
|
||||
<make-project-type>0</make-project-type>
|
||||
<c-extensions/>
|
||||
<cpp-extensions>cpp</cpp-extensions>
|
||||
<header-extensions>h</header-extensions>
|
||||
<sourceEncoding>UTF-8</sourceEncoding>
|
||||
<make-dep-projects/>
|
||||
<sourceRootList/>
|
||||
<confList>
|
||||
<confElem>Debug</confElem>
|
||||
<confElem>Release</confElem>
|
||||
</confList>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
||||
@@ -0,0 +1,16 @@
|
||||
# This is a sample script
|
||||
CREATE "myram.sys"
|
||||
|
||||
ADD "info.h"
|
||||
ADD "types.h"
|
||||
|
||||
# We go inside the sources folder
|
||||
MKDIR "sources"
|
||||
CD "sources"
|
||||
ADD "commands.cpp"
|
||||
ADD "info.cpp"
|
||||
SETFLAGS B68 # Change flags mask; B68 is the default mask.
|
||||
ADD "main.cpp"
|
||||
CD ".."
|
||||
|
||||
CLOSE
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* File: types.h
|
||||
* Author: Tiberiu
|
||||
*
|
||||
* Created on August 31, 2011, 2:58 PM
|
||||
*/
|
||||
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
typedef unsigned int uint32;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned char uint8;
|
||||
|
||||
typedef signed int int32;
|
||||
typedef signed short int16;
|
||||
typedef signed char int8;
|
||||
|
||||
typedef char* string;
|
||||
|
||||
typedef struct {
|
||||
uint32 Date, Time;
|
||||
} TimeSystem;
|
||||
|
||||
typedef struct {
|
||||
char Name[256];
|
||||
unsigned Flags, OwnerId, GroupId, Size;
|
||||
TimeSystem TimeCreated, TimeModified, TimeAccessed;
|
||||
unsigned Offset;
|
||||
} __attribute__((packed)) DirectoryEntry;
|
||||
|
||||
enum Exceptions {
|
||||
ExcSyntaxError,
|
||||
ExcCannotOpenOutput,
|
||||
ExcInvalidPath,
|
||||
ExcCannotOpenInput,
|
||||
ExcInvalidCommand
|
||||
};
|
||||
|
||||
#endif /* TYPES_H */
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
CREATE "filename" ; creates a new ramdisk with the filename
|
||||
MKDIR "name" ; creates a new directory (in current dir)
|
||||
CD "\path" ; sets current directory
|
||||
ADD "filename" ; adds a file to current directory!
|
||||
SETFLAGS 1A1B01 ; sets flags for next added files, number is in hex using this mask:
|
||||
* bits description
|
||||
* 0-2 file type; ignored, autocompleted at writing
|
||||
* 3-5 owner permissions (rwx); w ignored (read only device)
|
||||
* 6-8 group permissions (rwx); w ignored
|
||||
* 9-11 other permissions (rwx); w ignored
|
||||
* 12 hidden
|
||||
; default mask is: B68 (no write, everyone can execute and read)
|
||||
#asdf ; comment
|
||||
CLOSE ; writes and closes the ramdisk. You must close before opening another one
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
+10
-1
@@ -1,10 +1,19 @@
|
||||
[GOOD] BUILD 0.1.0.590 DATE 9/05/2011 AT 2:40 PM
|
||||
====================================================
|
||||
Mainly changed: FS.Initrd
|
||||
+ (kind of) refractored VFS, bugfixed
|
||||
+ Rewrote 'initrd' file system, fixed many problems
|
||||
+ Working 'cat' and 'dir' console commands
|
||||
+ Wrote 'initrd' image write application (for windows), however it may be bugged
|
||||
|
||||
[GOOD] BUILD 0.1.0.551 DATE 9/03/2011 AT 9:25 AM
|
||||
====================================================
|
||||
Mainly changed: HAL.FSs
|
||||
+ Updated 'mount' call in floppy driver, now done after controller is initialized
|
||||
+ Added 'detect' function for FAT file systems
|
||||
+ Implemented 'initdr' driver, however still bugged
|
||||
+ Implemented 'initrd' driver, however still bugged
|
||||
+ Improved logger
|
||||
? TODO: Refractoring VFS
|
||||
|
||||
[GOOD] BUILD 0.1.0.470 DATE 8/30/2011 AT 6:40 PM
|
||||
====================================================
|
||||
|
||||
+15
-12
@@ -85,6 +85,21 @@ Kernel/hal/filesys/initrd/initrd.c
|
||||
Libraries :: Character types
|
||||
Kernel/library/ctype.c
|
||||
|
||||
Libraries :: Standard input/output
|
||||
Kernel/library/stdio.c
|
||||
|
||||
Libraries :: Storage
|
||||
Kernel/library/storage.c
|
||||
|
||||
Libraries :: Time
|
||||
Kernel/library/time.c
|
||||
|
||||
Libraries :: Arrays :: Dynamically expanding array
|
||||
Kernel/library/array/dynamic_arr.c
|
||||
|
||||
Libraries :: Arrays :: Ordered array
|
||||
Kernel/library/array/ord_arr.c
|
||||
|
||||
Libraries :: Memory :: Allocation
|
||||
Kernel/library/memory/memory_alloc.c
|
||||
|
||||
@@ -97,9 +112,6 @@ Kernel/library/memory/memory_info.c
|
||||
Libraries :: Memory :: Initialization
|
||||
Kernel/library/memory/memory_init.c
|
||||
|
||||
Libraries :: Standard input/output
|
||||
Kernel/library/stdio.c
|
||||
|
||||
Libraries :: Standard library :: Convert operations
|
||||
Kernel/library/stdlib/convert_ops.c
|
||||
|
||||
@@ -109,18 +121,9 @@ Kernel/library/stdlib/mem_ops.c
|
||||
Libraries :: Standard library :: Number operations
|
||||
Kernel/library/stdlib/num_ops.c
|
||||
|
||||
Libraries :: Standard library :: Ordered array
|
||||
Kernel/library/stdlib/ord_arr.c
|
||||
|
||||
Libraries :: Standard library :: String operations
|
||||
Kernel/library/stdlib/str_ops.c
|
||||
|
||||
Libraries :: Storage
|
||||
Kernel/library/storage.c
|
||||
|
||||
Libraries :: Time
|
||||
Kernel/library/time.c
|
||||
|
||||
Memory Manager :: Memory heap
|
||||
Kernel/memory/mem-heap.c
|
||||
|
||||
|
||||
BIN
Binary file not shown.
@@ -2,5 +2,6 @@
|
||||
|
||||
C:
|
||||
chdir C:\Dev\lux
|
||||
set CYGWIN=nodosfilewarning
|
||||
|
||||
C:\cygwin\bin\bash /cygdrive/c/Dev/lux/build.sh
|
||||
+1
-1
@@ -1 +1 @@
|
||||
551
|
||||
590
|
||||
|
||||
Reference in New Issue
Block a user