From c3c333e6cf3c3292fe6378899ac47c015c0ec471 Mon Sep 17 00:00:00 2001 From: pepepper Date: Tue, 29 Sep 2020 22:23:30 +0900 Subject: [PATCH] modified: BrainLILODrv.cpp --- BrainLILODrv.cpp | 98 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 76 insertions(+), 22 deletions(-) diff --git a/BrainLILODrv.cpp b/BrainLILODrv.cpp index a542c13..78f9004 100644 --- a/BrainLILODrv.cpp +++ b/BrainLILODrv.cpp @@ -70,6 +70,47 @@ typedef LPVOID (*AllocPhysMemProc)(DWORD,DWORD,DWORD,DWORD,PULONG); typedef void (*NKForceCleanBootProc)(BOOL); +//UART +#define UART_BASE_ADDR 0x80074000 +unsigned int *UARTMappedAddr; + +static serialout(char text){ + *UARTMappedAddr=(unsigned int)text; + return; +} + +static void print(char *string) { + do { + serialout(*string); + string++; + } while (*string != '\0'); +} + +static int pow(int base, int exponent) { + int ans = 1; + for (int i = 0; i < exponent; i++) { + ans *= base; + } + return ans; +} + +static void printhex(int num) { +unsigned char digit=8; + print("0x"); + while (digit) { + int weight = pow(16, digit - 1); + int ans = num / weight; + if (ans < 10){ + serialout('0' + ans); + } + else{ + serialout('A' + ans - 10); + } + num -= ans * weight; + digit--; + } +} + static void disableInterrupts(){ asm volatile("mrs r0, cpsr\n" "orr r0,r0,#0x80\n" @@ -110,10 +151,11 @@ static void EDNA2_physicalInvoker(){ static void EDNA2_installPhysicalInvoker(){ void *ptr=(void *)0xa8000000; - wchar_t buf[256]; - swprintf(buf, L"ResetKit: copying to 0x%08x from 0x%08x\n", - (int)(ptr), (int)(&EDNA2_physicalInvoker)); - OutputDebugString(buf); + print("BrainLILO: Invoker copying to ",1); + printhex((int)(ptr),1); + print(" from ",1); + printhex((int)(&EDNA2_physicalInvoker),1); + print("\n",1); memcpy(ptr, (const void *)&EDNA2_physicalInvoker, 64*4); //clearCache(); } @@ -126,12 +168,14 @@ static void EDNA2_runPhysicalInvoker(unsigned long bootloaderphysaddr,DWORD size "mrc p15,0,r0,c1,c0,0\n" // read ctrl regs "bic r0, r0, #8192\n" // reset vector to lower "mcr p15,0,r0,c1,c0,0\n" // write ctrl regs - - "mrc p15,0,r10,c1,c0,0\n" // read ctrl regs - "bic r10, r10, #5\n" // disable MMU/DCache - "mcr p15,0,r10,c1,c0,0\n" // write ctrl regs ); + print("BrainLILO: U-Boot copying to "); + printhex(0x40002000); + print(" from "); + printhex((int)(bootloaderphysaddr)); + print("\n"); for(unsigned int i=0;i