#include #include "screen.h" #include "console.h" #include "config.h" #define NAND_PAGE_SIZE 512 #ifdef NDLESSCX #define BOOT2_NAND_OFFSET (0x0100 * NAND_PAGE_SIZE) #define DIAGS_NAND_OFFSET (0x1900 * NAND_PAGE_SIZE) #else #define BOOT2_NAND_OFFSET (0x0020 * NAND_PAGE_SIZE) #define DIAGS_NAND_OFFSET (0x0B00 * NAND_PAGE_SIZE) #endif #define BOOT2_PAGES_NUM 0x0A60 #define BOOT2_SIZE (BOOT2_PAGES_NUM * NAND_PAGE_SIZE) #define DIAGS_PAGES_NUM 0x0500 #define DIAGS_SIZE (DIAGS_PAGES_NUM * NAND_PAGE_SIZE) #ifndef HAS_NAND // definitions below are needed for Ndless 1.0/1.1/1.1.1 (OSes 1.1.9253 / 1.1.9170) #ifdef NDLESS11 #ifdef CAS #define read_nand_ 0x1015F3D0 #else #define read_nand_ 0x1015F3A0 #endif #endif #ifdef NDLESS31 static const unsigned read_nand_addrs[] = {0,0,0x10071658, 0X100715E8}; // ncas3.1.0, cas3.1.0, OS_NCASCX3.1.0, OS_CASCX3.1.0 #define read_nand SYSCALL_CUSTOM(read_nand_addrs ,void, void* dest, int size, int offset, int, int percent_max, void *progress_cb ) #endif #endif #ifdef NDLESS11 asm(".string \"PRG\"\n"); #define read_nand (_oscall(void, read_nand_, void* dest, int size, int offset, int, int percent_max, void *progress_cb)) #endif #ifdef NDLESS12 asm(".string \"PRG\"\n"); #define read_nand (_oscall(void, read_nand_, void* dest, int size, int offset, int, int percent_max, void *progress_cb)) #endif int main(void) { TCT_Local_Control_Interrupts(0); initScr(); resetConsole(); displn("PolyDumper: TI-Planet.org & Omnimaga.org",0); asm("ldr r1,=0x00000C12"); asm("mrc p15,0,r0,c2,c0,0"); asm("str r1,[r0,#4]"); asm("ldr r0,=0x00100000"); asm("mcr p15,0,r0,c8,c7,1"); disp("Dumping Boot1... ",0); FILE *ofile = fopen("/documents/ndless/boot1.img.tns", "wb"); fwrite((volatile void*)0x00100000, 1, 512*1024, ofile); fclose(ofile); displn("Done! ",0); disp("Dumping Diags... ",0); ofile = fopen("/documents/ndless/diags.img.tns", "wb"); void *buf = malloc(BOOT2_SIZE); read_nand(buf, DIAGS_SIZE, DIAGS_NAND_OFFSET, 0, 0, NULL); fwrite(buf, 1, DIAGS_SIZE, ofile); fclose(ofile); displn("Done! ",0); disp("Dumping Boot2... ",0); ofile = fopen("/documents/ndless/boot2.img.tns", "wb"); read_nand(buf, BOOT2_SIZE, BOOT2_NAND_OFFSET, 0, 0, NULL); fwrite(buf, 1, BOOT2_SIZE, ofile); fclose(ofile); displn("Done! ",0); disp("Dumping OSyst... ",0); ofile = fopen("/documents/ndless/os.img.tns", "wb"); FILE* ifile = fopen("/phoenix/install/TI-Nspire.tnc", "rb"); int i; while( i = fread(buf, 1, BOOT2_SIZE, ifile) ) fwrite(buf, 1, i, ofile); fclose(ofile); fclose(ifile); displn("Done! ",0); free(buf); TCT_Local_Control_Interrupts(0); return 0; }