modified: BrainLILO.cpp BrainLILODrv.cpp Makefile

new file:   dummy.cpp
This commit is contained in:
Chiharu Shirasaka 2020-10-09 19:53:40 +09:00
parent 8a8fe81433
commit bf62b2063a
4 changed files with 39 additions and 8 deletions

View File

@ -126,10 +126,32 @@ static void loadDriverIfNeeded(){
HANDLE driver=NULL;
wchar_t driverPath[1024];
getThisDllDirectoryPath(driverPath);
wcscat(driverPath, L"\\BrainLILODrv.dll");
getThisDllDirectoryPath(driverPath);
wcscat(driverPath, L"\\MyJITDebugger.exe");
TCHAR newDriverPath[128];
wcscpy(newDriverPath,L"\\Windows\\MyJITDebugger.exe");
{
wchar_t buf[1024];
swprintf(buf, L"BrainLILO: copying \"%ls\" to \"%ls\"",
driverPath, newDriverPath);
OutputDebugString(buf);
}
if(!CopyFile(driverPath,newDriverPath, FALSE)){
if(GetFileAttributes(newDriverPath)==(DWORD)-1){
OutputDebugString(L"BrainLILO: failed to copy");
return;
}
}
getThisDllDirectoryPath(driverPath);
wcscat(driverPath, L"\\BrainLILODrv.dll");
wcscpy(newDriverPath,L"\\Windows\\BrainLILODrv.dll");
{

View File

@ -68,7 +68,7 @@ static FileSystemPowerFunctionProc FileSystemPowerFunction;
typedef LPVOID (*AllocPhysMemProc)(DWORD,DWORD,DWORD,DWORD,PULONG);
DWORD wReadSize;
DWORD FileSize;
unsigned long bootloaderphysaddr;
static void disableInterrupts(){
@ -129,7 +129,7 @@ static void EDNA2_runPhysicalInvoker(){
"bic r0, r0, #5\n" // disable MMU/DCache
"mcr p15,0,r0,c1,c0,0\n" // write ctrl regs
);
for(DWORD i=0;i<wReadSize;i++)*((char*)(0x40100000+i))=*((char*)bootloaderphysaddr+i);
for(DWORD i=0;i<FileSize;i++)*((char*)(0x40100000+i))=*((char*)bootloaderphysaddr+i);
asm volatile("ldr r0, =0x0000\n"
"ldr r1, =0x0000\n"
"ldr r2, =0x0000\n"
@ -161,10 +161,11 @@ static DWORD EDNA2_callKernelEntryPoint(){
static bool doLinux(){
TCHAR bootloaderFileName[128]=TEXT("\\Storage Card\\loader\\u-boot.bin");
HANDLE hFile;
char *bootloaderptr;
LPVOID bootloaderptr;
wchar_t buf[256];
HINSTANCE dll;
AllocPhysMemProc AllocPhysMem;
DWORD wReadSize;
dll=LoadLibrary(TEXT("COREDLL.DLL"));
if (dll == NULL) {
@ -187,13 +188,16 @@ static bool doLinux(){
swprintf(buf, L"BrainLILO: Bootloader file handle 0x%08x\n",(int)(hFile));
OutputDebugString(buf);
FileSize=GetFileSize(hFile , NULL);
swprintf(buf, L"BrainLILO: Bootloader file size %d Byte\n",FileSize);
OutputDebugString(buf);
bootloaderptr=(char*)AllocPhysMem(GetFileSize(hFile , NULL),PAGE_EXECUTE_READWRITE,0,0,&bootloaderphysaddr);
bootloaderptr=AllocPhysMem(FileSize,PAGE_EXECUTE_READWRITE,0,0,&bootloaderphysaddr);
swprintf(buf, L"BrainLILO: Allocated preload memory Virtual:%p Physical:%p\n",bootloaderptr,bootloaderphysaddr);
OutputDebugString(buf);
OutputDebugString(L"BrainLILO: Copying bootloader to allocated virtual memory...");
ReadFile(hFile , bootloaderptr , GetFileSize(hFile , NULL) , &wReadSize , NULL);
ReadFile(hFile , bootloaderptr , FileSize , &wReadSize , NULL);
OutputDebugString(L"BrainLILO: Bootloader copied! Closing file handle...");
CloseHandle(hFile);

View File

@ -9,7 +9,7 @@ AS=$(PREFIX)/bin/arm-mingw32ce-as
NM=$(PREFIX)/bin/arm-mingw32ce-nm
WINDRES=$(PREFIX)/bin/arm-mingw32ce-windres
OUTPUT=BrainLILO.dll BrainLILODrv.dll BrainLILO.exe
OUTPUT=BrainLILO.dll BrainLILODrv.dll BrainLILO.exe MyJITDebugger.exe
CXXFLAGS= -DEV_PLATFORM_WIN32 -DUNICODE -D_UNICODE -DEV_UNSAFE_SWPRINTF -mwin32 \
-O0 -mcpu=arm926ej-s -D_WIN32_WCE=0x600 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 \
@ -46,3 +46,6 @@ BrainLILO.exe: bootloader.cpp
$(CXX) bootloader.cpp -o BrainLILO.exe $(CXXFLAGS)
$(STRIP) BrainLILO.exe
MyJITDebugger.exe: dummy.cpp
$(CXX) dummy.cpp -o MyJITDebugger.exe $(CXXFLAGS)
$(STRIP) MyJITDebugger.exe

2
dummy.cpp Normal file
View File

@ -0,0 +1,2 @@
//replacement of MyJITDebugger.exe for stopping force reset on abort.
int main(){return 0;}