Add 2011 host tools: InitrdReader and ramdisk image sample
This commit is contained in:
1 parent
90424967b7
commit
93ec3e6368
17 files changed
+1202
No files matched your search
@@ -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
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* dynamic-arr.c
|
||||||
|
*
|
||||||
|
* Created on: Sep 3, 2011
|
||||||
|
* Author: Tiberiu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.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 = malloc(0x10 * ElemSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicArrayPush (void* item, DynamicArray* arr)
|
||||||
|
{
|
||||||
|
// Make sure we have enough space
|
||||||
|
if (arr->Allocated <= arr->Size)
|
||||||
|
{
|
||||||
|
arr->Allocated += 0x10;
|
||||||
|
arr->Data = realloc(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 = realloc(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
|
||||||
|
free(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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* array.h
|
||||||
|
*
|
||||||
|
* Created on: Sep 3, 2011
|
||||||
|
* Author: Tiberiu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ARRAY_H_
|
||||||
|
#define ARRAY_H_
|
||||||
|
|
||||||
|
#include "fileio.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);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* ARRAY_H_ */
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
#ifndef FILEIO_H_
|
||||||
|
#define FILEIO_H_
|
||||||
|
|
||||||
|
#define MAX_FILENAME_LEN 256
|
||||||
|
#define MAX_MOUNTPOINTNAME_LEN 64
|
||||||
|
|
||||||
|
typedef unsigned int uint32;
|
||||||
|
typedef int int32;
|
||||||
|
typedef unsigned char uint8;
|
||||||
|
typedef char* string;
|
||||||
|
typedef struct { uint32 Date, Time; } TimeSystem;
|
||||||
|
|
||||||
|
// Device routines, will read/write 'BlockSize' bytes per call
|
||||||
|
typedef uint32 (*DevReadRoutine)(uint32 offset, void* buffer);
|
||||||
|
typedef uint32 (*DevWriteRoutine)(uint32 offset, void* buffer);
|
||||||
|
|
||||||
|
enum FileFlags
|
||||||
|
{
|
||||||
|
FileFile = 0x1,
|
||||||
|
FileDirectory = 0x2,
|
||||||
|
FileCharDevice = 0x3,
|
||||||
|
FileBlockDevice = 0x4,
|
||||||
|
FilePipe = 0x5,
|
||||||
|
FileSymbolLink = 0x6,
|
||||||
|
FileMountPoint = 0x7,
|
||||||
|
FileOwnerRead = 0x8,
|
||||||
|
FileOwnerWrite = 0x10,
|
||||||
|
FileOwnerExecute = 0x20,
|
||||||
|
FileGroupRead = 0x40,
|
||||||
|
FileGroupWrite = 0x80,
|
||||||
|
FileGroupExecute = 0x100,
|
||||||
|
FileOtherRead = 0x200,
|
||||||
|
FileOtherWrite = 0x400,
|
||||||
|
FileOtherExecute = 0x800,
|
||||||
|
FileHidden = 0x1000,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32 DeviceId; // The VFS identifies the mounted device that uses this
|
||||||
|
uint32 Id; // The FS identifies files using this field
|
||||||
|
char* Name;
|
||||||
|
|
||||||
|
/*** Flags look like this:
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
} myFILE;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _DirectoryEntry
|
||||||
|
{
|
||||||
|
char Name[MAX_FILENAME_LEN];
|
||||||
|
uint32 Flags, OwnerId, GroupId, Size;
|
||||||
|
TimeSystem TimeCreated, TimeModified, TimeAccessed;
|
||||||
|
|
||||||
|
} __attribute__((packed)) DirectoryEntry;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32 Id, FsId;
|
||||||
|
char Name[MAX_MOUNTPOINTNAME_LEN];
|
||||||
|
|
||||||
|
uint32 BlockSize;
|
||||||
|
DevReadRoutine Read;
|
||||||
|
DevWriteRoutine Write;
|
||||||
|
|
||||||
|
uint32 FsData[8];
|
||||||
|
} MountPoint;
|
||||||
|
|
||||||
|
extern uint32 luxInitrdDevRead (uint32 offset, void* buffer);
|
||||||
|
extern uint32 luxDetect (MountPoint* mp);
|
||||||
|
extern DirectoryEntry* luxTest (MountPoint* mp, string path);
|
||||||
|
extern myFILE* luxOpen (MountPoint* mp, myFILE* f, string path);
|
||||||
|
extern myFILE* luxClose (MountPoint* mp, myFILE* f);
|
||||||
|
extern uint32 luxRead (MountPoint* mp, myFILE* f, uint32 elemsz, uint32 n, uint8* buffer);
|
||||||
|
extern DirectoryEntry* luxReadDir (MountPoint* mp, myFILE* f, uint32 index);
|
||||||
|
|
||||||
|
#endif /* FILEIO_H_ */
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
/*
|
||||||
|
* initrd.c
|
||||||
|
*
|
||||||
|
* Created on: Sep 1, 2011
|
||||||
|
* Author: Tiberiu
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define LUXMAGIC 0xCC23AA90
|
||||||
|
#define OEMSTR "luxram"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include "fileio.h"
|
||||||
|
|
||||||
|
#define Min(a,b) ((a < b) ? (a) : (b))
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DirectoryEntry De;
|
||||||
|
uint32 Offset;
|
||||||
|
} __attribute__((packed)) luxDirectoryEntry;
|
||||||
|
|
||||||
|
/*typedef struct {
|
||||||
|
uint32 Count;
|
||||||
|
luxDirectoryEntry* Entries;
|
||||||
|
} __attribute__((packed)) luxDirectory;
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32 Magic;
|
||||||
|
char Oem[6];
|
||||||
|
uint32 Root; // address of this is address of root. The value is the size of root
|
||||||
|
} __attribute__((packed)) luxHeader;
|
||||||
|
|
||||||
|
/**************************************
|
||||||
|
* DEVICE 'FAKE' READ ROUTINE *
|
||||||
|
**************************************/
|
||||||
|
uint32 luxInitrdDevRead (uint32 offset, void* buffer)
|
||||||
|
{
|
||||||
|
return LUXMAGIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************
|
||||||
|
* OTHER USEFUL ROUTINES *
|
||||||
|
**************************************/
|
||||||
|
// Navigates and returns the directory entry that contains the file/folder
|
||||||
|
luxDirectoryEntry rootDirectoryEntry;
|
||||||
|
luxDirectoryEntry* luxGetFile (string path, uint32 data)
|
||||||
|
{
|
||||||
|
luxHeader* head = (luxHeader*)data;
|
||||||
|
uint32 end = strlen(path);
|
||||||
|
uint32 start, next = 0;
|
||||||
|
char* tmp;
|
||||||
|
|
||||||
|
// Remove ending '/' (if any)
|
||||||
|
if (path[end-1] == '/') --end;
|
||||||
|
|
||||||
|
// 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->Root * sizeof(luxDirectoryEntry);
|
||||||
|
rootDirectoryEntry.Offset = (uint32)(&head->Root) - data; // calculate offset
|
||||||
|
|
||||||
|
return &rootDirectoryEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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->Root;
|
||||||
|
while (next < end)
|
||||||
|
{
|
||||||
|
// 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(&path[start], de[i].De.Name, next-start) == 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************
|
||||||
|
* myFILE SYSTEM INTERFACE ROUTINES *
|
||||||
|
**************************************/
|
||||||
|
uint32 luxDetect (MountPoint* mp)
|
||||||
|
{
|
||||||
|
void* buffer = malloc(mp->BlockSize); // must allocate a buffer for non-initrd devices...
|
||||||
|
uint32 result = mp->Read(0, buffer); // read something
|
||||||
|
free(buffer); // get rid of the not needed buffer
|
||||||
|
|
||||||
|
return (result == LUXMAGIC); // returned magic number? good
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test if a file exists
|
||||||
|
DirectoryEntry* luxTest (MountPoint* mp, string path)
|
||||||
|
{
|
||||||
|
// MountPoint.FsData[0] contains initrd image start address
|
||||||
|
// luxDirectoryEntry contains a DirectoryEntry
|
||||||
|
return (DirectoryEntry*) luxGetFile(path, mp->FsData[0]); // Get a directory and see
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open a file
|
||||||
|
myFILE* luxOpen (MountPoint* mp, myFILE* f, string path)
|
||||||
|
{
|
||||||
|
// Find it first. mp->FsData[0] contains initrd image start address.
|
||||||
|
luxDirectoryEntry* entry = luxGetFile(path, mp->FsData[0]);
|
||||||
|
|
||||||
|
// Invalid entry
|
||||||
|
if (entry == NULL) return NULL;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close a file
|
||||||
|
myFILE* luxClose (MountPoint* mp, myFILE* f)
|
||||||
|
{
|
||||||
|
// Just empty buffer info, so we don't attempt to read it again
|
||||||
|
f->BufStart = f->BufPos = f->BufEnd = NULL;
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read data from a file
|
||||||
|
// Returns byte count read
|
||||||
|
uint32 luxRead (MountPoint* mp, myFILE* f, uint32 elemsz, uint32 n, uint8* buffer)
|
||||||
|
{
|
||||||
|
// Make sure we don't read more than we can
|
||||||
|
uint32 total = Min(elemsz * n, (uint32)f->BufEnd - (uint32)f->BufPos);
|
||||||
|
|
||||||
|
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* mp, myFILE* 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];
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* File: main.c
|
||||||
|
* Author: Tiberiu
|
||||||
|
*
|
||||||
|
* Created on September 3, 2011, 3:54 PM
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "array.h"
|
||||||
|
#include "fileio.h"
|
||||||
|
|
||||||
|
MountPoint Mp = {0, 0, "dev", 0, luxInitrdDevRead, 0, {0,0,0,0,0,0,0,0}};
|
||||||
|
void* buffer;
|
||||||
|
|
||||||
|
void InstallFs(char* file)
|
||||||
|
{
|
||||||
|
// Detect
|
||||||
|
uint32 detect = luxDetect(&Mp);
|
||||||
|
printf("Detection result: %u\n", detect);
|
||||||
|
|
||||||
|
// Read initrd file
|
||||||
|
FILE* f = fopen(file, "r"); // Open
|
||||||
|
fseek(f, 0, SEEK_END); // Seek to the end
|
||||||
|
uint32 size = ftell(f); // Get file size
|
||||||
|
fseek(f, 0, 0);
|
||||||
|
buffer = malloc(size); // Allocate enough space
|
||||||
|
fread(buffer, 1, size, f); // Read it
|
||||||
|
fclose(f); // Close file
|
||||||
|
|
||||||
|
// Set up data
|
||||||
|
Mp.FsData[0] = (uint32)buffer; // ModuleStart
|
||||||
|
Mp.FsData[1] = (uint32)buffer + size; // ModuleEnd
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
|
InstallFs("C:\\Dev\\lux\\Modules\\initrd.lux");
|
||||||
|
|
||||||
|
myFILE file;
|
||||||
|
luxOpen (&Mp, &file, "/info.h");
|
||||||
|
|
||||||
|
uint8* bf = malloc(0x100);
|
||||||
|
uint32 sz, i;
|
||||||
|
while ((sz = luxRead(&Mp, &file, 1, 0x100, bf)))
|
||||||
|
{
|
||||||
|
for (i = 0; i < sz; i++) printf("%c", bf[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
luxClose(&Mp, &file);
|
||||||
|
|
||||||
|
free(bf);
|
||||||
|
free(buffer);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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}/initrd.o \
|
||||||
|
${OBJECTDIR}/main.o \
|
||||||
|
${OBJECTDIR}/array.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/initrdreader.exe
|
||||||
|
|
||||||
|
dist/Debug/MinGW-Windows/initrdreader.exe: ${OBJECTFILES}
|
||||||
|
${MKDIR} -p dist/Debug/MinGW-Windows
|
||||||
|
${LINK.c} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/initrdreader ${OBJECTFILES} ${LDLIBSOPTIONS}
|
||||||
|
|
||||||
|
${OBJECTDIR}/initrd.o: initrd.c
|
||||||
|
${MKDIR} -p ${OBJECTDIR}
|
||||||
|
${RM} $@.d
|
||||||
|
$(COMPILE.c) -g -MMD -MP -MF $@.d -o ${OBJECTDIR}/initrd.o initrd.c
|
||||||
|
|
||||||
|
${OBJECTDIR}/main.o: main.c
|
||||||
|
${MKDIR} -p ${OBJECTDIR}
|
||||||
|
${RM} $@.d
|
||||||
|
$(COMPILE.c) -g -MMD -MP -MF $@.d -o ${OBJECTDIR}/main.o main.c
|
||||||
|
|
||||||
|
${OBJECTDIR}/array.o: array.c
|
||||||
|
${MKDIR} -p ${OBJECTDIR}
|
||||||
|
${RM} $@.d
|
||||||
|
$(COMPILE.c) -g -MMD -MP -MF $@.d -o ${OBJECTDIR}/array.o array.c
|
||||||
|
|
||||||
|
# Subprojects
|
||||||
|
.build-subprojects:
|
||||||
|
|
||||||
|
# Clean Targets
|
||||||
|
.clean-conf: ${CLEAN_SUBPROJECTS}
|
||||||
|
${RM} -r build/Debug
|
||||||
|
${RM} dist/Debug/MinGW-Windows/initrdreader.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}/initrd.o \
|
||||||
|
${OBJECTDIR}/main.o \
|
||||||
|
${OBJECTDIR}/array.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/initrdreader.exe
|
||||||
|
|
||||||
|
dist/Release/MinGW-Windows/initrdreader.exe: ${OBJECTFILES}
|
||||||
|
${MKDIR} -p dist/Release/MinGW-Windows
|
||||||
|
${LINK.c} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/initrdreader ${OBJECTFILES} ${LDLIBSOPTIONS}
|
||||||
|
|
||||||
|
${OBJECTDIR}/initrd.o: initrd.c
|
||||||
|
${MKDIR} -p ${OBJECTDIR}
|
||||||
|
${RM} $@.d
|
||||||
|
$(COMPILE.c) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/initrd.o initrd.c
|
||||||
|
|
||||||
|
${OBJECTDIR}/main.o: main.c
|
||||||
|
${MKDIR} -p ${OBJECTDIR}
|
||||||
|
${RM} $@.d
|
||||||
|
$(COMPILE.c) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/main.o main.c
|
||||||
|
|
||||||
|
${OBJECTDIR}/array.o: array.c
|
||||||
|
${MKDIR} -p ${OBJECTDIR}
|
||||||
|
${RM} $@.d
|
||||||
|
$(COMPILE.c) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/array.o array.c
|
||||||
|
|
||||||
|
# Subprojects
|
||||||
|
.build-subprojects:
|
||||||
|
|
||||||
|
# Clean Targets
|
||||||
|
.clean-conf: ${CLEAN_SUBPROJECTS}
|
||||||
|
${RM} -r build/Release
|
||||||
|
${RM} dist/Release/MinGW-Windows/initrdreader.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=InitrdReader
|
||||||
|
|
||||||
|
# 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=initrdreader
|
||||||
|
CND_ARTIFACT_PATH_Debug=dist/Debug/MinGW-Windows/initrdreader
|
||||||
|
CND_PACKAGE_DIR_Debug=dist/Debug/MinGW-Windows/package
|
||||||
|
CND_PACKAGE_NAME_Debug=initrdreader.tar
|
||||||
|
CND_PACKAGE_PATH_Debug=dist/Debug/MinGW-Windows/package/initrdreader.tar
|
||||||
|
# Release configuration
|
||||||
|
CND_PLATFORM_Release=MinGW-Windows
|
||||||
|
CND_ARTIFACT_DIR_Release=dist/Release/MinGW-Windows
|
||||||
|
CND_ARTIFACT_NAME_Release=initrdreader
|
||||||
|
CND_ARTIFACT_PATH_Release=dist/Release/MinGW-Windows/initrdreader
|
||||||
|
CND_PACKAGE_DIR_Release=dist/Release/MinGW-Windows/package
|
||||||
|
CND_PACKAGE_NAME_Release=initrdreader.tar
|
||||||
|
CND_PACKAGE_PATH_Release=dist/Release/MinGW-Windows/package/initrdreader.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}/initrdreader
|
||||||
|
OUTPUT_BASENAME=initrdreader
|
||||||
|
PACKAGE_TOP_DIR=initrdreader/
|
||||||
|
|
||||||
|
# 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}/initrdreader/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/initrdreader.tar
|
||||||
|
cd ${NBTMPDIR}
|
||||||
|
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/initrdreader.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}/initrdreader
|
||||||
|
OUTPUT_BASENAME=initrdreader
|
||||||
|
PACKAGE_TOP_DIR=initrdreader/
|
||||||
|
|
||||||
|
# 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}/initrdreader/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/initrdreader.tar
|
||||||
|
cd ${NBTMPDIR}
|
||||||
|
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/initrdreader.tar *
|
||||||
|
checkReturnCode
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
cd "${TOP}"
|
||||||
|
rm -rf ${NBTMPDIR}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?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>main.c</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>array.c</itemPath>
|
||||||
|
<itemPath>array.h</itemPath>
|
||||||
|
<itemPath>fileio.h</itemPath>
|
||||||
|
<itemPath>initrd.c</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,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>InitrdReader</name>
|
||||||
|
<make-project-type>0</make-project-type>
|
||||||
|
<c-extensions>c</c-extensions>
|
||||||
|
<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,17 @@
|
|||||||
|
# exp
|
||||||
|
|
||||||
|
Side projects from the original 2011 luxOS development, written as NetBeans
|
||||||
|
(and a few Eclipse) projects. They are user-space programs that were used to
|
||||||
|
build, test and prototype pieces of the OS on the host machine, so they are
|
||||||
|
not part of the kernel build. Each folder is kept as it was, minus build
|
||||||
|
output and NetBeans private settings.
|
||||||
|
|
||||||
|
## Host tools
|
||||||
|
|
||||||
|
- `InitrdReader/` (Sep 2011): reads a luxOS initrd image with the same
|
||||||
|
filesystem code the kernel uses (initrd.c), to check that images produced
|
||||||
|
by the ramdisk writer can be parsed. Windows/MinGW build.
|
||||||
|
- `RamdiskWriter/myram.sys` (Sep 2011): sample ramdisk image produced by the
|
||||||
|
ramdisk writer. The writer's sources are in `Modules/Rom image maker/`;
|
||||||
|
this is the 2011-09-05 variant of the image, which differs from the copy
|
||||||
|
stored there.
|
||||||
Binary file not shown.
Reference in new issue
Block a user