Added tools and experiments

This commit is contained in:
Tiberiu Chibici 2021-09-14 19:01:13 +03:00
parent 6faff6dedb
commit f551ca29ce
33 changed files with 1245 additions and 0 deletions

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?>
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.cygwin.exe.debug.115724913">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cygwin.exe.debug.115724913" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cygwin.exe.debug.115724913" name="Debug" parent="cdt.managedbuild.config.gnu.cygwin.exe.debug">
<folderInfo id="cdt.managedbuild.config.gnu.cygwin.exe.debug.115724913." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.exe.debug.892886753" name="Cygwin GCC" superClass="cdt.managedbuild.toolchain.gnu.cygwin.exe.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.cygwin.exe.debug.1849742475" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.cygwin.exe.debug"/>
<builder buildPath="${workspace_loc:/Memory manager/Debug}" id="cdt.managedbuild.target.gnu.builder.cygwin.exe.debug.1722793380" managedBuildOn="true" name="Gnu Make Builder.Debug" superClass="cdt.managedbuild.target.gnu.builder.cygwin.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.debug.1180607088" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.550473301" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.cygwin.base.221799311" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.cygwin.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.debug.1459581613" name="Cygwin C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.debug">
<option id="gnu.cpp.compiler.cygwin.exe.debug.option.optimization.level.318845190" superClass="gnu.cpp.compiler.cygwin.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.cygwin.exe.debug.option.debugging.level.1044717468" superClass="gnu.cpp.compiler.cygwin.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug.1804661896" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.cygwin.exe.debug.option.optimization.level.249174650" superClass="gnu.c.compiler.cygwin.exe.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.cygwin.exe.debug.option.debugging.level.2100439600" superClass="gnu.c.compiler.cygwin.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.544290283" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.debug.1207537489" name="Cygwin C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.debug">
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1366767681" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.debug.981090290" name="Cygwin C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.debug"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.cygwin.exe.release.1614407804">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cygwin.exe.release.1614407804" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cygwin.exe.release.1614407804" name="Release" parent="cdt.managedbuild.config.gnu.cygwin.exe.release">
<folderInfo id="cdt.managedbuild.config.gnu.cygwin.exe.release.1614407804." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.exe.release.1117383569" name="Cygwin GCC" superClass="cdt.managedbuild.toolchain.gnu.cygwin.exe.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.cygwin.exe.release.1496680917" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.cygwin.exe.release"/>
<builder buildPath="${workspace_loc:/Memory manager/Release}" id="cdt.managedbuild.target.gnu.builder.cygwin.exe.release.512812119" managedBuildOn="true" name="Gnu Make Builder.Release" superClass="cdt.managedbuild.target.gnu.builder.cygwin.exe.release"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.release.950327113" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1102338020" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.cygwin.base.1507550678" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.cygwin.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.release.1039422280" name="Cygwin C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.release">
<option id="gnu.cpp.compiler.cygwin.exe.release.option.optimization.level.2005443698" superClass="gnu.cpp.compiler.cygwin.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.cygwin.exe.release.option.debugging.level.1303203798" superClass="gnu.cpp.compiler.cygwin.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release.1043628071" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.cygwin.exe.release.option.optimization.level.1310015612" superClass="gnu.c.compiler.cygwin.exe.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.cygwin.exe.release.option.debugging.level.1946912749" superClass="gnu.c.compiler.cygwin.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.1717193404" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.release.544314131" name="Cygwin C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.release">
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1556032386" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.release.838465677" name="Cygwin C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.release"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="Memory manager.cdt.managedbuild.target.gnu.cygwin.exe.1209943794" name="Executable" projectType="cdt.managedbuild.target.gnu.cygwin.exe"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.exe.debug.115724913;cdt.managedbuild.config.gnu.cygwin.exe.debug.115724913.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug.1804661896;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.544290283">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.exe.release.1614407804;cdt.managedbuild.config.gnu.cygwin.exe.release.1614407804.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release.1043628071;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.1717193404">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
</storageModule>
</cproject>

Binary file not shown.

View File

@ -0,0 +1,3 @@
main.d main.o: ../main.c ../mem.h
../mem.h:

Binary file not shown.

View File

@ -0,0 +1,43 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
-include ../makefile.init
RM := rm -rf
# All of the sources participating in the build are defined here
-include sources.mk
-include subdir.mk
-include objects.mk
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
-include ../makefile.defs
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: Memory\ manager.exe
# Tool invocations
Memory\ manager.exe: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: Cygwin C Linker'
gcc -o "Memory manager.exe" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Other Targets
clean:
-$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) "Memory manager.exe"
-@echo ' '
.PHONY: all clean dependents
.SECONDARY:
-include ../makefile.targets

View File

@ -0,0 +1,3 @@
memory.d memory.o: ../memory.c ../mem.h
../mem.h:

Binary file not shown.

View File

@ -0,0 +1,8 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
USER_OBJS :=
LIBS :=

View File

@ -0,0 +1,17 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
O_SRCS :=
C_SRCS :=
S_UPPER_SRCS :=
OBJ_SRCS :=
ASM_SRCS :=
OBJS :=
C_DEPS :=
EXECUTABLES :=
# Every subdirectory with source files must be described here
SUBDIRS := \
. \

View File

@ -0,0 +1,27 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../main.c \
../memory.c
OBJS += \
./main.o \
./memory.o
C_DEPS += \
./main.d \
./memory.d
# Each subdirectory must supply rules for building sources it contributes
%.o: ../%.c
@echo 'Building file: $<'
@echo 'Invoking: Cygwin C Compiler'
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View File

@ -0,0 +1,12 @@
Exception: STATUS_ACCESS_VIOLATION at eip=004016B3
eax=00A01CB0 ebx=009A0000 ecx=00403100 edx=FFF9E34C esi=00A01CAA edi=00000000
ebp=0022CB18 esp=0022CAF0 program=C:\Users\Tiberiu\workspace\osdev\Memory manager\Debug\Memory manager.exe, pid 5948, thread main
cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
Stack trace:
Frame Function Args
0022CB18 004016B3 (00000050, 00403100, 0000000A, 6112C040)
0022CB38 00401376 (00000002, 0022CB60, 00000000, 00000000)
0022CCA8 00401259 (00403100, 00001000, 00000000, 00401415)
0022CCD8 0040143F (00000001, 009C8608, 009C8508, 00008000)
0022CD68 61007038 (00000000, 0022CDA4, 61006980, 7FFDC000)
End of stack trace

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Memory manager</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/Memory manager/Debug}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
<value>clean</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

33
exp/Memory manager/main.c Normal file
View File

@ -0,0 +1,33 @@
/*
* main.c
*
* Created on: Aug 24, 2011
* Author: Tiberiu
*/
#include <stdio.h>
#include <stdlib.h>
#include "mem.h"
void print_memmap()
{
uint32 i;
printf("memory map:\n");
for (i = 0; i <= TotalFrames>>5; i++)
printf("0x%x ", FrameMap[i]);
printf("\n");
}
int main(int argc, char **argv) {
MemPhInitialize(1024);
MemPhReserveFrames(0, 0x20000);
MemPhReserveFrames(0xF0000, 0x10000);
// Find a free frame
uint32 i;
for (i = 0; i < 10; i++) MemPhAllocFrame(0,0);
return 0;
}

37
exp/Memory manager/mem.h Normal file
View File

@ -0,0 +1,37 @@
/*
* ord-arr.h
*
* Created on: Aug 24, 2011
* Author: Tiberiu
*/
#ifndef ORD_ARR_H_
#define ORD_ARR_H_
#include <stdio.h>
typedef unsigned int uint32;
typedef unsigned char uint8;
#define Log(...) { printf(__VA_ARGS__); }
#define Error(...) { fprintf(stderr, __VA_ARGS__); }
#define Panic(...) { printf("[PANIC] Kernel panic: "); printf(__VA_ARGS__); }
#define LogMem(...) { Log("[MemLog] "); Log(__VA_ARGS__); }
#define ErrorMem(...) { Error("[MemErr] "); Error(__VA_ARGS__); }
extern uint32* FrameMap;
extern uint32 TotalFrames;
extern uint32 TotalMemory;
extern void ConvertIndexToFrame (uint32 index, uint32* address, uint32* offset);
extern uint32 ConvertFrameToIndex (uint32 address, uint32 offset);
extern void MemPhSetFrame (uint32 frame, uint8 value);
extern uint32 MemPhGetFrame (uint32 frame);
extern uint32 MemPhFindFreeFrame();
extern void MemPhAllocFrame(uint8 isKernel, uint8 isWriteable);
extern void MemPhInitialize(uint32 SystemMemoryKb);
extern void MemPhReserveFrames (uint32 address, uint32 length);
#endif /* ORD_ARR_H_ */

102
exp/Memory manager/memory.c Normal file
View File

@ -0,0 +1,102 @@
/*
* mem-phys.c
*
* Created on: Aug 27, 2011
* Author: Tiberiu
*/
#include <stdlib.h>
#include "mem.h"
uint32* FrameMap;
uint32 TotalFrames;
uint32 TotalMemory;
void ConvertIndexToFrame (uint32 index, uint32* address, uint32* offset)
{
*address = (index >> 5);
*offset = index & 0x1f;
}
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) FrameMap[addr] |= 1<<off;
else 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 0;
}
void MemPhAllocFrame(uint8 isKernel, uint8 isWriteable)
{
//if (page->Frame != 0) return;
uint32 free = MemPhFindFreeFrame();
if (!free) return;
LogMem("Physical: allocated frame %u.\n", free);
MemPhSetFrame(free, 1);
/*page->Present = 1;
page->User = (isKernel) ? 0 : 1;
page->Writeable = (isWriteable) ? 1 : 0;
page->Frame = free;*/
}
/*void MemPhFreeFrame()//Page* page)
{
uint32 frame = page->Frame;
if (!frame) return;
MemPhSetFrame(frame, 0);
page->Frame = 0;
}*/
void MemPhInitialize(uint32 SystemMemoryKb)
{
LogMem("Starting physical memory manager...\n");
TotalFrames = SystemMemoryKb >> 2;
TotalMemory = SystemMemoryKb;
FrameMap = (uint32*) malloc(sizeof(uint32) * (1 + (TotalFrames>>5)));
memset(FrameMap, 0, sizeof(uint32) * (1 + (TotalFrames>>5)));
LogMem("Started ok!, found %ukb total_frames=%u\n", SystemMemoryKb, TotalFrames);
}
void MemPhReserveFrames (uint32 address, uint32 length)
{
address >>= 12;
length = (length>>12) + ((length & 0xfff) > 0);
uint32 end = address + length;
for (; address < end && address < TotalFrames ; address++)
MemPhSetFrame(address, 1);
}

View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?>
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.cygwin.exe.debug.1693032095">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cygwin.exe.debug.1693032095" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cygwin.exe.debug.1693032095" name="Debug" parent="cdt.managedbuild.config.gnu.cygwin.exe.debug">
<folderInfo id="cdt.managedbuild.config.gnu.cygwin.exe.debug.1693032095." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.exe.debug.880544018" name="Cygwin GCC" superClass="cdt.managedbuild.toolchain.gnu.cygwin.exe.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.cygwin.exe.debug.1984633086" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.cygwin.exe.debug"/>
<builder buildPath="${workspace_loc:/luxRomImageMaker/Debug}" id="cdt.managedbuild.target.gnu.builder.cygwin.exe.debug.1013963599" managedBuildOn="true" name="Gnu Make Builder.Debug" superClass="cdt.managedbuild.target.gnu.builder.cygwin.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.debug.612089874" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1193470642" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.cygwin.base.1277477143" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.cygwin.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.debug.6471701" name="Cygwin C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.debug">
<option id="gnu.cpp.compiler.cygwin.exe.debug.option.optimization.level.3634191" superClass="gnu.cpp.compiler.cygwin.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.cygwin.exe.debug.option.debugging.level.1454801179" superClass="gnu.cpp.compiler.cygwin.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin.1552536803" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug.1451125513" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.cygwin.exe.debug.option.optimization.level.2082392232" superClass="gnu.c.compiler.cygwin.exe.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.cygwin.exe.debug.option.debugging.level.1993689462" superClass="gnu.c.compiler.cygwin.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.1311330996" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.debug.1749583368" name="Cygwin C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.debug.1204348718" name="Cygwin C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.debug">
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1426701556" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.cygwin.exe.release.1640714783">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cygwin.exe.release.1640714783" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cygwin.exe.release.1640714783" name="Release" parent="cdt.managedbuild.config.gnu.cygwin.exe.release">
<folderInfo id="cdt.managedbuild.config.gnu.cygwin.exe.release.1640714783." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.exe.release.904499734" name="Cygwin GCC" superClass="cdt.managedbuild.toolchain.gnu.cygwin.exe.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.cygwin.exe.release.2034428749" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.cygwin.exe.release"/>
<builder buildPath="${workspace_loc:/luxRomImageMaker/Release}" id="cdt.managedbuild.target.gnu.builder.cygwin.exe.release.1153066742" managedBuildOn="true" name="Gnu Make Builder.Release" superClass="cdt.managedbuild.target.gnu.builder.cygwin.exe.release"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.release.192704857" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1003225280" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.cygwin.base.644475832" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.cygwin.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.release.1904418754" name="Cygwin C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.release">
<option id="gnu.cpp.compiler.cygwin.exe.release.option.optimization.level.1894450888" superClass="gnu.cpp.compiler.cygwin.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.cygwin.exe.release.option.debugging.level.1094892696" superClass="gnu.cpp.compiler.cygwin.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin.1232685873" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release.1460741581" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.cygwin.exe.release.option.optimization.level.280469054" superClass="gnu.c.compiler.cygwin.exe.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.cygwin.exe.release.option.debugging.level.378411429" superClass="gnu.c.compiler.cygwin.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.898602556" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.release.697119764" name="Cygwin C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.release"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.release.1803468435" name="Cygwin C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.release">
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1866883279" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="luxRomImageMaker.cdt.managedbuild.target.gnu.cygwin.exe.1970251545" name="Executable" projectType="cdt.managedbuild.target.gnu.cygwin.exe"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.exe.debug.1693032095;cdt.managedbuild.config.gnu.cygwin.exe.debug.1693032095.;cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.debug.6471701;cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin.1552536803">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.exe.debug.1693032095;cdt.managedbuild.config.gnu.cygwin.exe.debug.1693032095.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug.1451125513;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.1311330996">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.exe.release.1640714783;cdt.managedbuild.config.gnu.cygwin.exe.release.1640714783.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release.1460741581;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.898602556">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.exe.release.1640714783;cdt.managedbuild.config.gnu.cygwin.exe.release.1640714783.;cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.release.1904418754;cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin.1232685873">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
</storageModule>
</cproject>

View File

@ -0,0 +1,3 @@
commands.d commands.o: ../commands.cpp ../app.h
../app.h:

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
main.d main.o: ../main.cpp ../app.h
../app.h:

Binary file not shown.

View File

@ -0,0 +1,58 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
-include ../makefile.init
RM := rm -rf
# All of the sources participating in the build are defined here
-include sources.mk
-include subdir.mk
-include objects.mk
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
endif
-include ../makefile.defs
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: luxRomImageMaker.exe
# Tool invocations
luxRomImageMaker.exe: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: Cygwin C++ Linker'
g++ -o "luxRomImageMaker.exe" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Other Targets
clean:
-$(RM) $(C++_DEPS)$(OBJS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) luxRomImageMaker.exe
-@echo ' '
.PHONY: all clean dependents
.SECONDARY:
-include ../makefile.targets

View File

@ -0,0 +1,8 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
USER_OBJS :=
LIBS :=

View File

@ -0,0 +1,3 @@
romdisk.d romdisk.o: ../romdisk.cpp ../app.h
../app.h:

Binary file not shown.

View File

@ -0,0 +1,27 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
O_SRCS :=
CPP_SRCS :=
C_UPPER_SRCS :=
C_SRCS :=
S_UPPER_SRCS :=
OBJ_SRCS :=
ASM_SRCS :=
CXX_SRCS :=
C++_SRCS :=
CC_SRCS :=
C++_DEPS :=
OBJS :=
C_DEPS :=
CC_DEPS :=
CPP_DEPS :=
EXECUTABLES :=
CXX_DEPS :=
C_UPPER_DEPS :=
# Every subdirectory with source files must be described here
SUBDIRS := \
. \

View File

@ -0,0 +1,30 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
../commands.cpp \
../main.cpp \
../romdisk.cpp
OBJS += \
./commands.o \
./main.o \
./romdisk.o
CPP_DEPS += \
./commands.d \
./main.d \
./romdisk.d
# Each subdirectory must supply rules for building sources it contributes
%.o: ../%.cpp
@echo 'Building file: $<'
@echo 'Invoking: Cygwin C++ Compiler'
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View File

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>luxRomImageMaker</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/luxRomImageMaker/Debug}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
<value>clean</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,71 @@
/*
* app.h
*
* Created on: Aug 31, 2011
* Author: Tiberiu
*/
#ifndef APP_H_
#define APP_H_
#include <vector>
using namespace std;
extern int cmd_create (char** argv, int argc);
extern int cmd_close (char** argv, int argc);
extern int cmd_mkdir (char** argv, int argc);
extern int cmd_cd (char** argv, int argc);
extern int cmd_add (char** argv, int argc);
extern int cmd_setflags (char** argv, int argc);
struct Node {
char Name[256];
unsigned Flags;
vector<Node> Children;
Node* Parent;
};
struct DirectoryEntry {
char Name[256];
unsigned Flags, OwnerId, GroupId, Size;
struct { unsigned Date; unsigned Time; } TimeCreated, TimeModified, TimeAccessed;
unsigned Offset;
};
class RomDisk
{
private:
char OutputFile[256];
unsigned FlagsDefault;
Node Root;
Node* Current;
int IndexOf (char* s);
public:
RomDisk();
void SetOutFile (char* s);
void SetFlags (unsigned n);
int ChangeCurrentDirectory (char* n);
void AddFile (char* name);
void AddDirectory (char* name);
// WRITE TO FILE
private:
void *buffer;
FILE* file;
void prepareBuffer();
void writeToBuffer(void*, unsigned);
void writeNode (Node* n);
long fileSize (char* file);
long nodeSize (Node* n);
public:
void Close();
};
#endif /* APP_H_ */

View File

@ -0,0 +1,97 @@
/*
* commands.cpp
*
* Created on: Aug 31, 2011
* Author: Tiberiu
*/
#include <stdio.h>
#include "app.h"
RomDisk* disk = NULL;
char* remove_quotes (char* str)
{
if (*str == '"') str = str + 1;
int temp = strlen (str);
if (str[temp-1] == '"') str[temp-1] = 0;
return str;
}
int cmd_create (char** argv, int argc)
{
// Check number of parameters
if (argc < 2) return 0;
// Create a new disk
disk = new RomDisk();
// Set path
argv[1] = remove_quotes(argv[1]);
disk->SetOutFile(argv[1]);
printf("Created ramdisk '%s'.", argv[1]);
return 1;
}
int cmd_close (char** argv, int argc)
{
if (!disk) fprintf(stderr, "Error: no romdisk opened!");
disk->Close();
delete disk;
printf("Closed ramdisk '%s'.", argv[1]);
return 1;
}
int cmd_mkdir (char** argv, int argc)
{
if (!disk) fprintf(stderr, "Error: no romdisk opened!");
if (argc < 2) return 0;
argv[1] = remove_quotes(argv[1]);
disk->AddDirectory(argv[1]);
printf("Created directory '%s'.", argv[1]);
return 1;
}
int cmd_cd (char** argv, int argc)
{
if (!disk) fprintf(stderr, "Error: no romdisk opened!");
if (argc < 2) return 0;
argv[1] = remove_quotes(argv[1]);
if (disk->ChangeCurrentDirectory(argv[1]) == -1) fprintf(stderr, "Error: invalid path.");
printf("Changed directory to '%s'.", argv[1]);
return 1;
}
int cmd_add (char** argv, int argc)
{
if (!disk) fprintf(stderr, "Error: no romdisk opened!");
if (argc < 2) return 0;
argv[1] = remove_quotes(argv[1]);
disk->AddFile(argv[1]);
printf("Added file '%s'.", argv[1]);
return 1;
}
int cmd_setflags (char** argv, int argc)
{
if (!disk) fprintf(stderr, "Error: no romdisk opened!");
if (argc < 2) return 0;
argv[1] = remove_quotes(argv[1]);
unsigned flags = strtoul(argv[1], 0, 16);
disk->SetFlags(flags);
printf("Changed flags to 0x%x.", flags);
return 1;
}

View File

@ -0,0 +1,13 @@
Exception: STATUS_ACCESS_VIOLATION at eip=61113783
eax=00001000 ebx=00000000 ecx=FFFFFFFF edx=00001000 esi=00000000 edi=00001000
ebp=0022B4D8 esp=0022B4D4 program=C:\Users\Tiberiu\workspace\osdev\luxRomImageMaker\Debug\luxRomImageMaker.exe, pid 6932, thread main
cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
Stack trace:
Frame Function Args
0022B4D8 61113783 (00001000, 0022BC0A, 00402020, 00000001)
0022BC28 6111B2F4 (0022D000, 611663A0, 00402020, 0022BC58)
0022BC48 6112CF00 (00402020, 00001000, 0000000D, 00401800)
0022BC98 610C3545 (0022BCD0, 00001000, 61166330, 00401212)
0022CCD8 00401247 (00000001, 00A08608, 00A08508, 00008000)
0022CD68 61007038 (00000000, 0022CDA4, 61006980, 7FFD9000)
End of stack trace

View File

@ -0,0 +1,97 @@
/*
* main.cpp
*
* Created on: Aug 31, 2011
* Author: Tiberiu
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "app.h"
using namespace std;
void GetParams (char* buffer, char* params[4], int& count)
{
bool inside_quotes = false;
int len = strlen(buffer);
count = 0;
if (!isspace(buffer[0])) params[count++] = buffer;
else buffer[0] = 0;
for (int i = 1; i < len && count < 4; 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;
}
}
void ProcessLine (char* buffer, int lineno)
{
char* argv[4]; int argc, res;
GetParams(buffer, argv, argc);
printf("%i: ", lineno);
if (strcmp(argv[0], "CREATE") == 0) res = cmd_create(argv, argc);
else if (strcmp(argv[0], "CLOSE") == 0) res = cmd_close(argv, argc);
else if (strcmp(argv[0], "MKDIR") == 0) res = cmd_mkdir(argv, argc);
else if (strcmp(argv[0], "CD") == 0) res = cmd_cd(argv, argc);
else if (strcmp(argv[0], "ADD") == 0) res = cmd_add(argv, argc);
else if (strcmp(argv[0], "SETFLAGS") == 0) res = cmd_setflags(argv, argc);
else if (strcmp(argv[0], "" )) return;
else printf("Invalid command %s, ignored.", argv[0]);
if (!res) {
printf("Syntax error!");
exit(1);
}
printf("\n");
}
int main(int argc, char **argv) {
char buffer[0x1000];
int lineno = 0;
// Make sure we have an argument
if (argc < 2) {
fprintf(stderr, "Missing argument - script file.");
return 0;
}
// Try to open file
FILE* input = fopen(argv[1], "r");
if (!input) { perror(argv[1]); return 0; }
// Read file line by line
printf("Reading script...\n");
while ( fgets(buffer, 0x1000, input) )
ProcessLine(buffer, ++lineno);
// Cleanup
fclose(input);
return 0;
}

View File

@ -0,0 +1,165 @@
/*
* romdisk.cpp
*
* Created on: Aug 31, 2011
* Author: Tiberiu
*/
#include <vector>
#include <string.h>
#include "app.h"
using namespace std;
RomDisk::RomDisk()
{
FlagsDefault = 0xB68;
Current = &Root;
Root.Flags = FlagsDefault;
Root.Parent = &Root;
}
int RomDisk::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 RomDisk::SetOutFile (char* s)
{
strcpy(OutputFile, s);
}
void RomDisk::SetFlags (unsigned n)
{
FlagsDefault = n;
}
int RomDisk::ChangeCurrentDirectory (char* n)
{
int len = strlen(n);
if (!len) return -1;
// See if we need to go to root
if (n[0] == '\\')
{
Current = &Root;
n = n+1;
}
// Process every folder in path
while (char* next = strchr(n, '\\'))
{
// mark next entry to parse
*next = 0; next = next+1;
// previous dir?
if (strcmp(n, "..") == 0) Current = Current->Parent;
else {
// Find next node
int index = IndexOf(n);
if (index == -1 && strcmp(n, ".") != 0) return -1; // Invalid path
// Set as current
Current = &Current->Children[index];
}
n = next;
}
return 0;
}
void RomDisk::AddFile (char* name)
{
Node f;
strcpy(f.Name, name);
f.Flags = (FlagsDefault & 0x497) | 1; // File
f.Parent = Current;
Current->Children.push_back(f);
}
void RomDisk::AddDirectory (char* name)
{
Node dir;
strcpy(dir.Name, name);
dir.Flags = (FlagsDefault & 0x497) | 2; // Directory
dir.Parent = Current;
Current->Children.push_back(dir);
}
void RomDisk::prepareBuffer()
{
buffer = malloc(0x10000);
file = fopen(OutputFile, "w");
if (!file) {
perror(OutputFile);
return;
}
}
#define MIN(a,b) ((a > b) ? (b) : (a))
void RomDisk::writeToBuffer(void* data, unsigned size)
{
while (size)
{
unsigned qty = MIN (size, 0x10000);
memcpy(buffer, data, qty);
size -= qty;
fwrite(buffer, sizeof(unsigned char), qty, file);
}
}
long RomDisk::fileSize(char* fn)
{
FILE* f = fopen(fn, "r");
if (!f) {
fprintf(stderr, "Invalid file: %s.\n", fn);
exit (1);
}
fseek(f, 0, SEEK_END);
long size = ftell(f);
fclose(f);
return size;
}
long RomDisk::nodeSize(Node* n)
{
if (n->Flags & 1) return fileSize(n->Name);
return (n->Children.size() * (sizeof(DirectoryEntry)));
}
void RomDisk::writeNode(Node* n)
{
}
void RomDisk::Close()
{
// Init
prepareBuffer();
// Write ramdisk header (magic number)
unsigned MAGIC = 0x51042A0D;
writeToBuffer(&MAGIC, sizeof(unsigned));
// Write root directory entry
writeNode(&Root);
// Cleanup
free(buffer);
fclose(file);
}