cLK/oem_filter.c
Arif Ali 6092922424 1.3.2: updated
* ROMHDR base addr is spl virtual 0x80000000 = 11800000 physical, LK will relocate to correct address (MEMBASE)
* save reboot reason at 0x2FFB0000 (ramconsole - 0x1000 (PAGE_SIZE)) and @0x2FFB0004 XOR 0x004b4c63 (cLK signature)
* added oem cmd to fastboot and oemcmd.bat for PC
2011-11-07 00:03:59 +00:00

48 lines
1.1 KiB
C

#include <stdio.h>
#include <string.h>
unsigned char hexVal(char c)
{
switch(c)
{
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
return c-'0';
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
return c - 'a' + 10;
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
return c - 'A' + 10;
}
return 0;
}
int main() {
char buff[0x40000];
while(!feof(stdin) && fgetc(stdin)!='\n' );
while(!feof(stdin))
{
size_t len = fread(buff, 1, 5, stdin);
int hLen = -1;
if(strncmp(buff, "INFO", 4)==0) hLen = buff[4];
if(strncmp(buff, "(boot", 5)==0)
{
len += fread(buff+5, 1, 9, stdin);
if(strncmp(buff, "(bootloader) ", 13)==0) hLen = buff[13];
}
if(hLen!=-1)
{
for(;hLen>0;hLen--) fputc(hexVal(fgetc(stdin))<<4 | hexVal(fgetc(stdin)), stdout);
fgetc(stdin);// read \n appended by fastboot
continue;
}
fwrite(buff, 1, len, stdout);
break;
}
while(!feof(stdin))
{
size_t len = fread(buff, 1, sizeof(buff), stdin);
fwrite(buff, 1, len, stdout);
}
}