From: <bob...@us...> - 2006-12-27 09:40:13
|
Revision: 716 http://svn.sourceforge.net/hackndev/?rev=716&view=rev Author: bobofdoom Date: 2006-12-27 01:40:10 -0800 (Wed, 27 Dec 2006) Log Message: ----------- Added simple and very dodgy memory map dump command. Modified Paths: -------------- cocoboot/trunk/include/cocoboot.rcp cocoboot/trunk/include/cocoboot_r.h cocoboot/trunk/m68k/mainform.c Modified: cocoboot/trunk/include/cocoboot.rcp =================================================================== --- cocoboot/trunk/include/cocoboot.rcp 2006-12-26 23:57:02 UTC (rev 715) +++ cocoboot/trunk/include/cocoboot.rcp 2006-12-27 09:40:10 UTC (rev 716) @@ -26,6 +26,7 @@ MENUITEM "LCD registers (PXA only)" MenuItemLCD MENUITEM "LCD test (PXA only)" MenuItemLCDTest MENUITEM "Boot Linux" MenuItemBootLinux + MENUITEM "Dump MMU" MenuItemDumpMMU END END Modified: cocoboot/trunk/include/cocoboot_r.h =================================================================== --- cocoboot/trunk/include/cocoboot_r.h 2006-12-26 23:57:02 UTC (rev 715) +++ cocoboot/trunk/include/cocoboot_r.h 2006-12-27 09:40:10 UTC (rev 716) @@ -14,6 +14,7 @@ #define MenuItemLCD 1002 #define MenuItemLCDTest 1003 #define MenuItemBootLinux 1004 +#define MenuItemDumpMMU 1005 #define ErrorAlert 1000 #define InfoAlert 1001 Modified: cocoboot/trunk/m68k/mainform.c =================================================================== --- cocoboot/trunk/m68k/mainform.c 2006-12-26 23:57:02 UTC (rev 715) +++ cocoboot/trunk/m68k/mainform.c 2006-12-27 09:40:10 UTC (rev 716) @@ -10,6 +10,7 @@ #include <stdlib.h> #include <string.h> #include <DataMgr.h> +#include <VFSMgr.h> UInt32 reg(UInt32 addr); int use_initrd; @@ -100,7 +101,49 @@ } +void dump_mmu() +{ + UInt16 volref; + UInt32 voliter = vfsIteratorStart; + FileRef file; + Err err = VFSVolumeEnumerate(&volref, &voliter); + char msg[255]; + UInt32 addr, phys, lastphys=0xffff, lastvirt=0xffff, startphys=0xffff, startvirt=0xffff; + if (err != errNone) { + FrmCustomAlert(InfoAlert, "Memory card not found.", " ", " "); + return; + } + + if (VFSFileOpen(volref, "/memorymap.txt", vfsModeWrite | vfsModeCreate, &file) != errNone) { + FrmCustomAlert(InfoAlert, "Can't open memorymap.txt for writing", " ", " "); + return; + } + + addr = 0; + while (1) { + phys = virt_to_phys(addr); + if (phys != lastphys + 0x00100000) { + if (startphys && startphys!=0xffff) { + sprintf(msg, "%08lx-%08lx -> %08lx-%08lx\n", startvirt, lastvirt, startphys, lastphys); + VFSFileWrite(file, StrLen(msg), msg, NULL); + } + startphys = phys; + startvirt = addr; + } + lastphys = phys; + lastvirt = addr; + addr += 0x00100000; + if (addr >= 0xff000000) break; + } + sprintf(msg, "%08lx-%08lx -> %08lx-%08lx\n", startvirt, lastvirt, startphys, lastphys); + VFSFileWrite(file, StrLen(msg), msg, NULL); + VFSFileClose(file); + + FrmCustomAlert(InfoAlert, "/memorymap.txt created", " ", " "); +} + + void cpu_info() { char msg[255]; @@ -280,6 +323,10 @@ case MenuItemMem: mem_info(); return true; + case MenuItemDumpMMU: + dump_mmu(); + return true; + } return false; } @@ -330,7 +377,7 @@ cmdline_p = FrmGetObjectPtr(form, FrmGetObjectIndex(form, CommandLine)); cmdline_th = MemHandleNew(size); cmdline_tp = MemHandleLock(cmdline_th); - StrCopy(cmdline_tp, "init=/linuxrc"); /* default value */ + StrCopy(cmdline_tp, "init=/linuxrc root=/dev/mmcblk0p2"); /* default value */ //PrefGetAppPreferences ('CcBt', 1, cmdline_tp, &size, true); MemHandleUnlock(cmdline_th); FldSetTextHandle(cmdline_p, cmdline_th); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-06-24 12:55:50
|
Revision: 1066 http://svn.sourceforge.net/hackndev/?rev=1066&view=rev Author: bobofdoom Date: 2007-06-24 05:55:46 -0700 (Sun, 24 Jun 2007) Log Message: ----------- cocoboot: Let there be version 0.2. Modified Paths: -------------- cocoboot/trunk/Changelog cocoboot/trunk/include/cocoboot.rcp Modified: cocoboot/trunk/Changelog =================================================================== --- cocoboot/trunk/Changelog 2007-06-24 09:46:45 UTC (rev 1065) +++ cocoboot/trunk/Changelog 2007-06-24 12:55:46 UTC (rev 1066) @@ -1,3 +1,4 @@ +version 0.2: - Fixed booting on Palm T|T3 (Marek Vasut) version 0.1: Modified: cocoboot/trunk/include/cocoboot.rcp =================================================================== --- cocoboot/trunk/include/cocoboot.rcp 2007-06-24 09:46:45 UTC (rev 1065) +++ cocoboot/trunk/include/cocoboot.rcp 2007-06-24 12:55:46 UTC (rev 1066) @@ -1,7 +1,7 @@ #include "cocoboot_r.h" APPLICATIONICONNAME ID 1000 "Cocoboot" -VERSION "0.1" +VERSION "0.2" ICON BEGIN This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-10 19:44:33
|
Revision: 1126 http://svn.sourceforge.net/hackndev/?rev=1126&view=rev Author: bobofdoom Date: 2007-07-10 06:06:41 -0700 (Tue, 10 Jul 2007) Log Message: ----------- Cocoboot: Started implementing basic console which will be similar to Haret/P but accessed via USB cable from PC. Modified Paths: -------------- cocoboot/trunk/Changelog cocoboot/trunk/include/cocoboot.h cocoboot/trunk/include/cocoboot.rcp cocoboot/trunk/include/cocoboot_r.h cocoboot/trunk/m68k/cocoboot.c cocoboot/trunk/m68k/mainform.c Modified: cocoboot/trunk/Changelog =================================================================== --- cocoboot/trunk/Changelog 2007-07-10 10:24:09 UTC (rev 1125) +++ cocoboot/trunk/Changelog 2007-07-10 13:06:41 UTC (rev 1126) @@ -1,3 +1,5 @@ + - Added simple USB console. + version 0.2: - Fixed booting on Palm T|T3 (Marek Vasut) Modified: cocoboot/trunk/include/cocoboot.h =================================================================== --- cocoboot/trunk/include/cocoboot.h 2007-07-10 10:24:09 UTC (rev 1125) +++ cocoboot/trunk/include/cocoboot.h 2007-07-10 13:06:41 UTC (rev 1126) @@ -13,3 +13,4 @@ UInt32 get_linux_mach_id(); char *get_mach_name(); void SetFieldTextFromStr(FieldPtr fldP, char *strP, Boolean redraw); +void open_console(); Modified: cocoboot/trunk/include/cocoboot.rcp =================================================================== --- cocoboot/trunk/include/cocoboot.rcp 2007-07-10 10:24:09 UTC (rev 1125) +++ cocoboot/trunk/include/cocoboot.rcp 2007-07-10 13:06:41 UTC (rev 1126) @@ -25,9 +25,12 @@ MENUITEM "Memory" MenuItemMem MENUITEM "LCD registers (PXA only)" MenuItemLCD MENUITEM "LCD test (PXA only)" MenuItemLCDTest - MENUITEM "Boot Linux" MenuItemBootLinux MENUITEM "Dump MMU" MenuItemDumpMMU END + PULLDOWN "Tools" + BEGIN + MENUITEM "USB Console" MenuItemConsole + END END FORM ID MainForm AT (0 0 160 160) NOFRAME USABLE MENUID MainFormMenu HELPID GnuGpl MODAL Modified: cocoboot/trunk/include/cocoboot_r.h =================================================================== --- cocoboot/trunk/include/cocoboot_r.h 2007-07-10 10:24:09 UTC (rev 1125) +++ cocoboot/trunk/include/cocoboot_r.h 2007-07-10 13:06:41 UTC (rev 1126) @@ -15,6 +15,7 @@ #define MenuItemLCDTest 1003 #define MenuItemBootLinux 1004 #define MenuItemDumpMMU 1005 +#define MenuItemConsole 1006 #define ErrorAlert 1000 #define InfoAlert 1001 Modified: cocoboot/trunk/m68k/cocoboot.c =================================================================== --- cocoboot/trunk/m68k/cocoboot.c 2007-07-10 10:24:09 UTC (rev 1125) +++ cocoboot/trunk/m68k/cocoboot.c 2007-07-10 13:06:41 UTC (rev 1126) @@ -21,6 +21,7 @@ #include <MemoryMgr.h> //#include <string.h> #include <stdio.h> +#include <string.h> #include <VFSMgr.h> #include "cocoboot.h" @@ -33,6 +34,9 @@ ArmStack arm_stack[20]; ArmGlobals arm_globals; FormPtr mainform; +UInt16 usb_port; +char console_buffer[128]; +int console_buffer_fill=0; /* A couple of these functions are originally from GaruxNG: * GaruxNG is Copyright (C) 2006 SCL (sc...@he...) @@ -158,15 +162,136 @@ return ret; } +void sendf(const char *template, ...) +{ + char buf[2048]; + Err err; + + va_list ap; + + va_start(ap, template); + vsprintf(buf, template, ap); + va_end(ap); + + if (usb_port) + SrmSend(usb_port, buf, strlen(buf), &err); +} + + +void open_console(void) { + char *ready_text = "[Cocoboot ready]\r\n"; + Err err; + + /* open USB serial port */ + usb_port = 0; + console_buffer_fill = 0; + SrmOpen(serPortCradleUSBPort, 115200, &usb_port); + if (usb_port) { + SrmSend(usb_port, ready_text, strlen(ready_text), &err); + sendf("Cocoboot> "); + SrmSendFlush(usb_port); + } +} + +void close_console() +{ + Err err; + char *exit_text = "[Cocoboot exiting]\r\n"; + if (usb_port) { + SrmSend(usb_port, exit_text, strlen(exit_text), &err), + SrmClose(usb_port); + usb_port = 0; + } +} + +void console_help(void) +{ + sendf("Available commands:\r\n"); + sendf(" exit close the console\r\n"); + sendf(" help show this help\r\n"); + sendf(" ping [text] reply with pong text\r\n"); +} + +/* index(3) - locate character in string */ +char *index(const char *s, int c) +{ + while (*s) { + if(*s == c) return s; + s++; + } + return NULL; +} + +void handle_command(char *cmd) +{ + char *args = index(cmd, ' '); + if (args) { + *(args++) = 0; + } else { + args = cmd + strlen(cmd); + } + + if (!strcmp(cmd, "ping")) { + sendf("pong %s\r\n", args); + } else if (!strcmp(cmd, "help")) { + console_help(); + } else if (!strcmp(cmd, "exit")) { + close_console(); + } else { + sendf("Unknown command '%s'. Type 'help' for help.\r\n", cmd); + } + sendf("Cocoboot> "); +} + +void handle_console(void) +{ + Err err; + UInt32 bytes = 0; + int i; + + SrmReceiveCheck(usb_port, &bytes); + if (!bytes) return; + + if (bytes > sizeof(console_buffer)) + bytes = sizeof(console_buffer); + + /* new data is available, grab it and echo it! */ + bytes = SrmReceive(usb_port, console_buffer + console_buffer_fill, bytes, 1000, &err); + SrmSend(usb_port, console_buffer + console_buffer_fill, bytes, &err); + SrmSendFlush(usb_port); + console_buffer_fill += bytes; + + EvtResetAutoOffTimer(); + + /* do we have a full command? */ + for (i=0; i < console_buffer_fill; i++) { + if (console_buffer[i] == '\r' || console_buffer[i] == '\n') { + sendf("\n"); + /* yes! process it */ + console_buffer[i] = 0; + if (i+1 < console_buffer_fill && console_buffer[i+1] == '\n') + console_buffer[++i] = 0; + handle_command(console_buffer); + + /* pop the command off */ + i++; + memmove(console_buffer, console_buffer + i, console_buffer_fill - i); + console_buffer_fill -= i; + i = 0; + } + } +} + void event_loop() { EventType event; UInt16 err; FormPtr form; Int16 form_id; + int delay=200; do { - EvtGetEvent(&event, 200); + EvtGetEvent(&event, delay); if (SysHandleEvent(&event)) continue; @@ -186,12 +311,18 @@ FrmDrawForm(FrmGetActiveForm()); } + if (usb_port) { + handle_console(); + delay = 10; + } + FrmDispatchEvent(&event); } while (event.eType != appStopEvent); } UInt16 start_app() { + arm_stack[0] = 0; FrmGotoForm(MainForm); @@ -201,6 +332,7 @@ void stop_app() { + close_console(); } UInt32 PilotMain(UInt16 launch_code, MemPtr cmd_PBP, UInt16 launch_flags) Modified: cocoboot/trunk/m68k/mainform.c =================================================================== --- cocoboot/trunk/m68k/mainform.c 2007-07-10 10:24:09 UTC (rev 1125) +++ cocoboot/trunk/m68k/mainform.c 2007-07-10 13:06:41 UTC (rev 1126) @@ -67,6 +67,12 @@ } +void usb_console(void) +{ + open_console(); + FrmCustomAlert(InfoAlert, "USB Console is now enabled.", "Connect to /dev/ttyUSBn on PC.", " "); +} + #define LCCR0_LDM (1<<3) #define LCCR0_DIS (1<<10) @@ -326,7 +332,9 @@ case MenuItemDumpMMU: dump_mmu(); return true; - + case MenuItemConsole: + usb_console(); + return true; } return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-13 08:46:50
|
Revision: 1134 http://svn.sourceforge.net/hackndev/?rev=1134&view=rev Author: bobofdoom Date: 2007-07-13 01:46:48 -0700 (Fri, 13 Jul 2007) Log Message: ----------- Cocoboot: Changed kernel load address from 0x4000 to 0x800000. This prevents the kernel image from clobbering the areas POS uses for DMA such as the framebuffer and audiobuffer, making booting more reliable (and making it work at all) on some devices. Modified Paths: -------------- cocoboot/trunk/Changelog cocoboot/trunk/arm/boot.c Modified: cocoboot/trunk/Changelog =================================================================== --- cocoboot/trunk/Changelog 2007-07-13 01:06:35 UTC (rev 1133) +++ cocoboot/trunk/Changelog 2007-07-13 08:46:48 UTC (rev 1134) @@ -1,3 +1,4 @@ + - Changed kernel load address from 0x4000 to 0x800000. - Added simple USB console. version 0.2: Modified: cocoboot/trunk/arm/boot.c =================================================================== --- cocoboot/trunk/arm/boot.c 2007-07-13 01:06:35 UTC (rev 1133) +++ cocoboot/trunk/arm/boot.c 2007-07-13 08:46:48 UTC (rev 1134) @@ -24,16 +24,14 @@ #define MACH_TYPE_T3XSCALE 829 #ifdef TREO650 -#define KERNEL_OFFSET 0x0800000 #define TAG_OFFSET 0x100 #define INITRD_OFFSET 0x1500000 #else -#define KERNEL_OFFSET 0x8000 #define TAG_OFFSET 0x100 #define INITRD_OFFSET 0x0400000 #endif -#define T3_KERNEL_OFFSET 0x0800000 +#define KERNEL_OFFSET 0x0800000 #define T3_INITRD_OFFSET 0x1500000 static void jump_to_kernel(UInt32 kernel_base, UInt32 tag_base, UInt32 mach) @@ -197,11 +195,10 @@ } #endif + kernel_offset=KERNEL_OFFSET; if (pg->mach_num==MACH_TYPE_T3XSCALE){ - kernel_offset=T3_KERNEL_OFFSET; initrd_offset=T3_INITRD_OFFSET; } else { - kernel_offset=KERNEL_OFFSET; initrd_offset=INITRD_OFFSET; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-13 10:29:21
|
Revision: 1135 http://svn.sourceforge.net/hackndev/?rev=1135&view=rev Author: bobofdoom Date: 2007-07-13 03:29:13 -0700 (Fri, 13 Jul 2007) Log Message: ----------- Cocoboot: Removed kernel relocation. (suggested by phire) Skipping the step of relocating the kernel to a known address should solve the boot problem on T3 and Z31, stop us clobbering the framebuffer and make boot times slightly faster. Modified Paths: -------------- cocoboot/trunk/Changelog cocoboot/trunk/arm/boot.c Modified: cocoboot/trunk/Changelog =================================================================== --- cocoboot/trunk/Changelog 2007-07-13 08:46:48 UTC (rev 1134) +++ cocoboot/trunk/Changelog 2007-07-13 10:29:13 UTC (rev 1135) @@ -1,4 +1,4 @@ - - Changed kernel load address from 0x4000 to 0x800000. + - Removed kernel relocation for speed and reliability (suggested by phire) - Added simple USB console. version 0.2: Modified: cocoboot/trunk/arm/boot.c =================================================================== --- cocoboot/trunk/arm/boot.c 2007-07-13 08:46:48 UTC (rev 1134) +++ cocoboot/trunk/arm/boot.c 2007-07-13 10:29:13 UTC (rev 1135) @@ -31,7 +31,6 @@ #define INITRD_OFFSET 0x0400000 #endif -#define KERNEL_OFFSET 0x0800000 #define T3_INITRD_OFFSET 0x1500000 static void jump_to_kernel(UInt32 kernel_base, UInt32 tag_base, UInt32 mach) @@ -90,7 +89,6 @@ if(!kernel || !cmdline) { return 0xc0ffee; } - UInt32 kernel_offset; UInt32 initrd_offset; /* since we're going to turn off the MMU, we need to translate @@ -195,7 +193,6 @@ } #endif - kernel_offset=KERNEL_OFFSET; if (pg->mach_num==MACH_TYPE_T3XSCALE){ initrd_offset=T3_INITRD_OFFSET; } else { @@ -206,16 +203,13 @@ setup_atags(pg->ram_base + TAG_OFFSET, pg->ram_base, pg->ram_size, cmdline, pg->ram_base + initrd_offset, initrd_size); - /* copy kernel into place */ - copy_image((void*)(pg->ram_base + kernel_offset), kernel, kernel_size); - /* copy initrd into place */ if (initrd) { copy_image((void*)(pg->ram_base + initrd_offset), initrd, initrd_size); } /* bring on the penguin! */ - jump_to_kernel(pg->ram_base + kernel_offset, pg->ram_base + TAG_OFFSET, pg->mach_num); + jump_to_kernel(kernel, pg->ram_base + TAG_OFFSET, pg->mach_num); return 0xe4; /* sadly, this return will never be executed */ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-13 11:32:28
|
Revision: 1136 http://svn.sourceforge.net/hackndev/?rev=1136&view=rev Author: bobofdoom Date: 2007-07-13 04:32:23 -0700 (Fri, 13 Jul 2007) Log Message: ----------- Cocoboot: Integrated treo code (removed all ifdefs). Closes: 5 This commit adjusts the boot procedure to disable all memory protection. This means that we do not need to make a writable copy of translation table on treo devices anymore. All treo #ifdefs have been removed and the translation table base setting has been moved to mach.c as a runtime check. Modified Paths: -------------- cocoboot/trunk/Changelog cocoboot/trunk/Makefile cocoboot/trunk/arm/arm.c cocoboot/trunk/arm/boot.c cocoboot/trunk/include/arm.h cocoboot/trunk/include/cocoboot.h cocoboot/trunk/include/shared.h cocoboot/trunk/m68k/cocoboot.c cocoboot/trunk/m68k/mach.c cocoboot/trunk/m68k/mainform.c cocoboot/trunk/m68k/mem.c Modified: cocoboot/trunk/Changelog =================================================================== --- cocoboot/trunk/Changelog 2007-07-13 10:29:13 UTC (rev 1135) +++ cocoboot/trunk/Changelog 2007-07-13 11:32:23 UTC (rev 1136) @@ -1,3 +1,4 @@ + - Cleaned up treo code (removed all #ifdefs) - Removed kernel relocation for speed and reliability (suggested by phire) - Added simple USB console. Modified: cocoboot/trunk/Makefile =================================================================== --- cocoboot/trunk/Makefile 2007-07-13 10:29:13 UTC (rev 1135) +++ cocoboot/trunk/Makefile 2007-07-13 11:32:23 UTC (rev 1136) @@ -12,7 +12,7 @@ all: cocoboot.prc install: cocoboot.prc - pilot-xfer -p /dev/tts/USB0 -i cocoboot.prc + pilot-xfer -p /dev/ttyUSB1 -i cocoboot.prc cocoboot.prc: arm-objs m68k-objs gui iTbl.bin build-prc -n Cocoboot -c CcBt $(EXECS) *.bin Modified: cocoboot/trunk/arm/arm.c =================================================================== --- cocoboot/trunk/arm/arm.c 2007-07-13 10:29:13 UTC (rev 1135) +++ cocoboot/trunk/arm/arm.c 2007-07-13 11:32:23 UTC (rev 1136) @@ -264,16 +264,9 @@ phys = (fld & 0xfff00000) | (virt & 0x000fffff); } else if ((fld & FLD_MASK) == FLD_COARSE) { /* 2nd level, yuck. Here's hoping we can access it. */ -#ifdef TREO650 - /*Treo 650 tables are in a peice of memory in a 1:1 - *mapping*/ sld_p = (UInt32*) ( ((fld & 0xFFFFFc00) | - ((virt & 0xfF000) >> 10))); -#else - sld_p = (UInt32*) ( ((fld & 0xFFFFFc00) | ((virt & 0xfF000) >> 10)) - - g->ram_base); -#endif + - g->tt_offset); sld = *sld_p; /* crash? */ if((sld & 3) == 2) { /* small page */ phys = (sld & 0xFFFFF000) | (virt & 0xFFF); @@ -285,16 +278,9 @@ } else { /* FIXME: THIS IS WRONG!! */ /* 2nd level, yuck. Here's hoping we can access it. */ -#ifdef TREO650 - /*Treo 650 tables are in a peice of memory in a 1:1 - *mapping*/ sld_p = (UInt32*) ( ((fld & 0xFFFFF000) | - ((virt & 0xff000) >> 10))); -#else - sld_p = (UInt32*) ( ((fld & 0xFFFFF000) | ((virt & 0xff000) >> 10)) - - g->ram_base); -#endif + - g->tt_offset); sld = *sld_p; /* crash? */ if((sld & 3) == 2) { /* small page */ phys = (sld & 0xFFFFF000) | (virt & 0xFFF); @@ -334,13 +320,7 @@ UInt32 map_mem(ArmGlobals *g, UInt32 phys) { -#ifdef TREO650 - /*The treo650 ttb is mapped read only, so we have to modify - *a copy*/ - UInt32 *tt = (UInt32*) g->new_vttb; -#else UInt32 *tt = (UInt32*) g->vttb; -#endif UInt32 i, rec; UInt32 va; @@ -363,89 +343,10 @@ return NULL; } -#ifdef TREO650 -/* The treo650 ttb is in a 1:1 mapping, but cruically it's Readonly - * we still have access to the TTB registers though as we're in System - * mode, so we copy the current TTB to a buffer - * and then we can modify that, this code copies the ttb and then - * switches the mmu to the new copy - */ -void copy_map_and_switch(ArmGlobals *g) -{ - UInt32 *src=(UInt32 *) g->vttb; - UInt32 *dst=(UInt32 *) g->new_vttb; - UInt32 ttbr0; - int i; - - - for (i=0;i<4096;++i) { - dst[i]=src[i]; - } - - asm("mrc p15, 0, r0, c2, c0, 0\nmov %0, r0": "=r"(ttbr0): :"r0"); - - - ttbr0&=0x1fUL; - ttbr0|=g->new_pttb; - - asm volatile ( "mov r0, %0\n" - "mcr p15, 0, r0, c2, c0, 0" - : - : "r"(ttbr0) - : "r0" ); - - - /* invalidate TLB */ - asm volatile ("mov r0, #0"); - asm volatile ("mcr p15, 0, r0, c8, c7, 0"); - - CPWAIT - - - for(i=0; i<100000; i++); - - -} - -/* Restore the MMU to look at the palmos TTB */ -void restore_map(ArmGlobals *g) -{ - UInt32 ttbr0; - int i; - - asm("mrc p15, 0, r0, c2, c0, 0\nmov %0, r0": "=r"(ttbr0): :"r0"); - - ttbr0&=0x1fUL; - ttbr0|=g->pttb; - - asm volatile ( "mov r0, %0\n" - "mcr p15, 0, r0, c2, c0, 0" - : - : "r"(ttbr0) - : "r0" ); - - - /* invalidate TLB */ - asm volatile ("mov r0, #0"); - asm volatile ("mcr p15, 0, r0, c8, c7, 0"); - - CPWAIT - - for(i=0; i<100000; i++); -} -#endif - void map(ArmGlobals *g, UInt32 phys, UInt32 virt) { int i; -#ifdef TREO650 - /*On the treo650 use the copy of the ttb, not the real - *ttb which is read only - */ - UInt32 *tt = (UInt32*) g->new_vttb; -#else UInt32 *tt = (UInt32*) g->vttb; -#endif UInt32 idx = virt >> 20; tt[idx] = (phys & 0xFFF00000) | 0xc1a; Modified: cocoboot/trunk/arm/boot.c =================================================================== --- cocoboot/trunk/arm/boot.c 2007-07-13 10:29:13 UTC (rev 1135) +++ cocoboot/trunk/arm/boot.c 2007-07-13 11:32:23 UTC (rev 1136) @@ -23,17 +23,12 @@ #define MACH_TYPE_T3XSCALE 829 -#ifdef TREO650 #define TAG_OFFSET 0x100 -#define INITRD_OFFSET 0x1500000 -#else -#define TAG_OFFSET 0x100 #define INITRD_OFFSET 0x0400000 -#endif #define T3_INITRD_OFFSET 0x1500000 -static void jump_to_kernel(UInt32 kernel_base, UInt32 tag_base, UInt32 mach) +static void jump_to_kernel(void *kernel_base, UInt32 tag_base, UInt32 mach) { asm volatile ( "mov r0, #0\n" "mov r1, %0\n" /* mach id */ @@ -98,10 +93,6 @@ kernel = (void *)virt_to_phys(g, (UInt32) kernel); cmdline = (char *)virt_to_phys(g, (UInt32) cmdline); -#ifdef TREO650 - g->new_pttb=virt_to_phys(g,g->new_vttb); -#endif - if(initrd) initrd = (void *)virt_to_phys(g, (UInt32) initrd); pg = (void *)virt_to_phys(g, (UInt32) g); @@ -130,18 +121,14 @@ irq_off(); -#ifdef TREO650 - copy_map_and_switch(g); -#endif + /* Disable memory protection (page table is read-only on treos) */ + asm volatile ("mcr p15, 0, %0, c3, c3, 0" : : "r"(0xffffffff) ); /* Map the page containing pphys_jump to identity */ map(g, (UInt32)pphys_jump, (UInt32)pphys_jump); /* make sure the mapping worked */ if(*(UInt32*)(vphys_jump) != *(UInt32*)(pphys_jump)) { -#ifdef TREO650 - restore_map(g); -#endif irq_on(); return 0xc01d; } @@ -184,14 +171,10 @@ #ifdef MOVE_FRAMEBUFFER map_lcd(); #endif -#ifdef TREO650 - setup_treo650_cpu(); -#else /* do CPU-specific configuration (like interrupt masking) */ if (pg->cpu & CPUV_INTEL) { setup_xscale_cpu(); } -#endif if (pg->mach_num==MACH_TYPE_T3XSCALE){ initrd_offset=T3_INITRD_OFFSET; Modified: cocoboot/trunk/include/arm.h =================================================================== --- cocoboot/trunk/include/arm.h 2007-07-13 10:29:13 UTC (rev 1135) +++ cocoboot/trunk/include/arm.h 2007-07-13 11:32:23 UTC (rev 1136) @@ -9,16 +9,7 @@ UInt32 virt_to_phys(ArmGlobals *g, UInt32 virt); void map(ArmGlobals *g, UInt32 phys, UInt32 virt); -#ifdef TREO650 -void copy_map_and_switch(ArmGlobals *g); -void restore_map(ArmGlobals *g); -#endif - - -#ifdef TREO650 /*cpu.c*/ -void setup_treo650_cpu(void); -#endif void setup_xscale_cpu(void); /* boot.c */ Modified: cocoboot/trunk/include/cocoboot.h =================================================================== --- cocoboot/trunk/include/cocoboot.h 2007-07-13 10:29:13 UTC (rev 1135) +++ cocoboot/trunk/include/cocoboot.h 2007-07-13 11:32:23 UTC (rev 1136) @@ -10,6 +10,7 @@ void lprintf (const char *template, ...); UInt32 call_arm(ArmStack *stack, UInt32 func); +UInt32 get_tt_offset(); UInt32 get_linux_mach_id(); char *get_mach_name(); void SetFieldTextFromStr(FieldPtr fldP, char *strP, Boolean redraw); Modified: cocoboot/trunk/include/shared.h =================================================================== --- cocoboot/trunk/include/shared.h 2007-07-13 10:29:13 UTC (rev 1135) +++ cocoboot/trunk/include/shared.h 2007-07-13 11:32:23 UTC (rev 1136) @@ -26,15 +26,16 @@ UInt32 pttb; UInt32 vttb; - UInt32 new_vttb; - UInt32 new_pttb; - UInt32 cpu; + UInt32 tt_offset; + UInt32 ram_base; UInt32 ram_size; UInt32 mach_num; + + UInt32 pad[4]; } ArmGlobals; void push_uint32(ArmStack *stack, UInt32 n); Modified: cocoboot/trunk/m68k/cocoboot.c =================================================================== --- cocoboot/trunk/m68k/cocoboot.c 2007-07-13 10:29:13 UTC (rev 1135) +++ cocoboot/trunk/m68k/cocoboot.c 2007-07-13 11:32:23 UTC (rev 1136) @@ -130,6 +130,7 @@ arm_globals.ram_base = EndianFix32(get_ram_base()); arm_globals.ram_size = EndianFix32(get_ram_size()); arm_globals.mach_num = EndianFix32(835); + arm_globals.tt_offset = get_tt_offset(); } /** Modified: cocoboot/trunk/m68k/mach.c =================================================================== --- cocoboot/trunk/m68k/mach.c 2007-07-13 10:29:13 UTC (rev 1135) +++ cocoboot/trunk/m68k/mach.c 2007-07-13 11:32:23 UTC (rev 1136) @@ -16,6 +16,7 @@ */ #include <PalmOS.h> +#include "mem.h" struct Machine { UInt32 palmos_id; @@ -81,3 +82,21 @@ check_mach(); return mach_table[mach].name; } + +/** + * Offset to subtract from translation table entries. + * On treo's translation table is 1:1 mapped so this is zero. + * On other devices the translation table stuff starts at 0x0 so we + * subtract ram_base. + */ +UInt32 get_tt_offset() +{ + check_mach(); + switch (mach_table[mach].linux_id) { + case 909: /* Treo 650 */ + case 1230: /* Treo 680 */ + return 0; + default: + return get_ram_base(); + } +} Modified: cocoboot/trunk/m68k/mainform.c =================================================================== --- cocoboot/trunk/m68k/mainform.c 2007-07-13 10:29:13 UTC (rev 1135) +++ cocoboot/trunk/m68k/mainform.c 2007-07-13 11:32:23 UTC (rev 1136) @@ -262,48 +262,19 @@ if(!use_initrd || initrd_size) { cmdline = read_command_line(); - //PrefSetAppPreferences ('CcBt', 1, 0, cmdline, 256, true); - //lprintf("Fare thee well 68k world!\n"); - arm_globals.mach_num = EndianFix32(read_mach_id()); -#ifdef TREO650 - { - extern void *MemGluePtrNew(UInt32); - void *ttb=NULL; - UInt32 ttb_aligned; - - ret=65536UL; - ttb=MemGluePtrNew(ret); - - ttb_aligned=(UInt32)ttb; - ttb_aligned+=(UInt32) 16383; - ttb_aligned&=~(UInt32) 16383; - - arm_globals.new_vttb = EndianFix32(ttb_aligned); - } -#endif - push_uint32(arm_stack, (UInt32)cmdline); push_uint32(arm_stack, initrd_size); push_uint32(arm_stack, (UInt32)initrd); push_uint32(arm_stack, kernel_size); push_uint32(arm_stack, (UInt32)kernel); - ret = call_arm(arm_stack, ARM_boot_linux); /* we're back?! Boot must have failed. */ lprintf("Returned: %lx\n", ret); -#if 0 - { - char msg[1024]; - sprintf(msg, "0x%08lx, 0x%08lx, 0x%08lx", ret,(UInt32) ttb, ttb_aligned); - FrmCustomAlert(InfoAlert, "result:", msg, " "); - } -#endif - } if (initrd_size) FtrPtrFree(CREATOR_ID, FEATURE_NUM + 1); @@ -311,7 +282,6 @@ if (kernel_size) FtrPtrFree(CREATOR_ID, FEATURE_NUM); - //lprintf("Boot aborted.\n"); } Boolean mainform_menu_event(Int16 id) Modified: cocoboot/trunk/m68k/mem.c =================================================================== --- cocoboot/trunk/m68k/mem.c 2007-07-13 10:29:13 UTC (rev 1135) +++ cocoboot/trunk/m68k/mem.c 2007-07-13 11:32:23 UTC (rev 1136) @@ -81,11 +81,7 @@ /* FIXME: Hack alert. We're making an assumption about where PalmOS maps the first part of RAM.. * Is there a better way of doing this? we'll need to hardcode the value for T|T2 */ -#ifdef TREO650 - return get_ttb(); -#else - return get_ttb() - get_ram_base(); -#endif + return get_ttb() - get_tt_offset(); } UInt32 virt_to_phys(UInt32 virt) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-13 12:56:32
|
Revision: 1137 http://svn.sourceforge.net/hackndev/?rev=1137&view=rev Author: bobofdoom Date: 2007-07-13 05:56:30 -0700 (Fri, 13 Jul 2007) Log Message: ----------- Cocoboot: Added overflow-buffer as last resort to allocation problem (slapin's idea) Modified Paths: -------------- cocoboot/trunk/Changelog cocoboot/trunk/include/cocoboot.h cocoboot/trunk/m68k/cocoboot.c cocoboot/trunk/m68k/mainform.c Modified: cocoboot/trunk/Changelog =================================================================== --- cocoboot/trunk/Changelog 2007-07-13 11:32:23 UTC (rev 1136) +++ cocoboot/trunk/Changelog 2007-07-13 12:56:30 UTC (rev 1137) @@ -1,3 +1,4 @@ + - Added overflow-buffer as last resort to allocation problem (slapin's idea) - Cleaned up treo code (removed all #ifdefs) - Removed kernel relocation for speed and reliability (suggested by phire) - Added simple USB console. Modified: cocoboot/trunk/include/cocoboot.h =================================================================== --- cocoboot/trunk/include/cocoboot.h 2007-07-13 11:32:23 UTC (rev 1136) +++ cocoboot/trunk/include/cocoboot.h 2007-07-13 12:56:30 UTC (rev 1137) @@ -8,6 +8,7 @@ extern ArmGlobals arm_globals; void lprintf (const char *template, ...); +void log_clear(void); UInt32 call_arm(ArmStack *stack, UInt32 func); UInt32 get_tt_offset(); Modified: cocoboot/trunk/m68k/cocoboot.c =================================================================== --- cocoboot/trunk/m68k/cocoboot.c 2007-07-13 11:32:23 UTC (rev 1136) +++ cocoboot/trunk/m68k/cocoboot.c 2007-07-13 12:56:30 UTC (rev 1137) @@ -94,6 +94,14 @@ } } +void log_clear(void) +{ + char buf[16]; + FieldPtr fldP = FrmGetObjectPtr(mainform, FrmGetObjectIndex(mainform, LogField)); + buf[0] = 0; + SetFieldTextFromStr(fldP, buf, true); +} + void lprintf(const char *template, ...) { char buf[2048]; Modified: cocoboot/trunk/m68k/mainform.c =================================================================== --- cocoboot/trunk/m68k/mainform.c 2007-07-13 11:32:23 UTC (rev 1136) +++ cocoboot/trunk/m68k/mainform.c 2007-07-13 12:56:30 UTC (rev 1137) @@ -195,14 +195,31 @@ Err err=0; char loc[32]; UInt32 size = 1000; + UInt32 ftr_size; Int32 vol, bytes; lprintf("Loading %s... ", name); vol = search_image(name, loc, sizeof(loc), &size); if(vol < -1) goto out; - - if((err=FtrPtrNew (CREATOR_ID, FEATURE_NUM + n, size, image))) { - lprintf("FtrPtrNew "); + + ftr_size = size; + while (ftr_size) { + if(!(err=FtrPtrNew (CREATOR_ID, FEATURE_NUM + n, ftr_size, image))) { + break; + } + + if (ftr_size == size) { + lprintf("alloc error, trying overwrite ram. "); + } + + if (ftr_size < 102400) + ftr_size = 0; + else + ftr_size -= 102400; + } + + if (!ftr_size) { + lprintf("Gave up. Boot "); goto out; } @@ -252,7 +269,7 @@ UInt32 ret; char *cmdline; - + log_clear(); kernel_size = load_parts(0, "/zImage", &kernel); if(kernel_size) { if(use_initrd) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-13 13:37:53
|
Revision: 1141 http://svn.sourceforge.net/hackndev/?rev=1141&view=rev Author: bobofdoom Date: 2007-07-13 06:37:50 -0700 (Fri, 13 Jul 2007) Log Message: ----------- Cocoboot: Version 0.3 Modified Paths: -------------- cocoboot/trunk/Changelog cocoboot/trunk/README cocoboot/trunk/include/cocoboot.rcp Modified: cocoboot/trunk/Changelog =================================================================== --- cocoboot/trunk/Changelog 2007-07-13 13:29:16 UTC (rev 1140) +++ cocoboot/trunk/Changelog 2007-07-13 13:37:50 UTC (rev 1141) @@ -1,3 +1,4 @@ +version 0.3: - Added overflow-buffer as last resort to allocation problem (slapin's idea) - Cleaned up treo code (removed all #ifdefs) - Removed kernel relocation for speed and reliability (suggested by phire) Modified: cocoboot/trunk/README =================================================================== --- cocoboot/trunk/README 2007-07-13 13:29:16 UTC (rev 1140) +++ cocoboot/trunk/README 2007-07-13 13:37:50 UTC (rev 1141) @@ -19,7 +19,19 @@ use "make" to build. You might need to adjust the paths in the Makefile if your SDK is in a non-standard place. +USB Console: +Cocoboot includes a primitive USB console which you can use for dumping +memory and other debugging pruposes. Enable it from Cocoboot's Tools menu. +Plug your PDA's USB into your PC, make sure you have the visor.ko kernel +module loaded and you should see two serial ports appear as /dev/ttyUSB0 +and /dev/ttyUSB1. Connect to /dev/ttyUSB0 using minicom with a baud rate +of 115200 to access the console. + +Note: You may need to use ttyUSB1 on some devices such as the LD. + +License: + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or Modified: cocoboot/trunk/include/cocoboot.rcp =================================================================== --- cocoboot/trunk/include/cocoboot.rcp 2007-07-13 13:29:16 UTC (rev 1140) +++ cocoboot/trunk/include/cocoboot.rcp 2007-07-13 13:37:50 UTC (rev 1141) @@ -79,7 +79,7 @@ -STRING GnuGpl "Cocoboot, PalmOS Linux loader.\n"\ +STRING GnuGpl "Cocoboot 0.3, PalmOS Linux loader.\n"\ "Copyright (C) 2006\n"\ "\n"\ "www.hackndev.com\n"\ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-14 01:17:43
|
Revision: 1144 http://svn.sourceforge.net/hackndev/?rev=1144&view=rev Author: bobofdoom Date: 2007-07-13 18:17:37 -0700 (Fri, 13 Jul 2007) Log Message: ----------- Cocoboot: Removed initrd relocation (suggested by phire) By 4k-aligning the image as we load it from the memory card we no longer need to relocate the image in the ARM, instead we can just leave it where the m68k code left it. Hopefully this will reduce the chance of errors due to images overlapping. Modified Paths: -------------- cocoboot/trunk/Changelog cocoboot/trunk/arm/boot.c cocoboot/trunk/m68k/imgloader.c cocoboot/trunk/m68k/mainform.c Modified: cocoboot/trunk/Changelog =================================================================== --- cocoboot/trunk/Changelog 2007-07-13 21:53:03 UTC (rev 1143) +++ cocoboot/trunk/Changelog 2007-07-14 01:17:37 UTC (rev 1144) @@ -1,3 +1,5 @@ + - Removed initrd relocation for speed and reliability (suggested by phire) + version 0.3: - Added overflow-buffer as last resort to allocation problem (slapin's idea) - Cleaned up treo code (removed all #ifdefs) Modified: cocoboot/trunk/arm/boot.c =================================================================== --- cocoboot/trunk/arm/boot.c 2007-07-13 21:53:03 UTC (rev 1143) +++ cocoboot/trunk/arm/boot.c 2007-07-14 01:17:37 UTC (rev 1144) @@ -24,9 +24,11 @@ #define MACH_TYPE_T3XSCALE 829 #define TAG_OFFSET 0x100 -#define INITRD_OFFSET 0x0400000 -#define T3_INITRD_OFFSET 0x1500000 +UInt32 make_4k_aligned(UInt32 addr) +{ + return addr + 0x1000 - (addr & 0xfff); +} static void jump_to_kernel(void *kernel_base, UInt32 tag_base, UInt32 mach) { @@ -84,7 +86,6 @@ if(!kernel || !cmdline) { return 0xc0ffee; } - UInt32 initrd_offset; /* since we're going to turn off the MMU, we need to translate * all out pointers to physical addresses. @@ -101,6 +102,13 @@ return 0xbadc01a; } + /* force our pointers to be 4k aligned, imgloader will have shifted + * the image forward. + */ + kernel = (void*) make_4k_aligned((UInt32)kernel); + if (initrd) + initrd = (void*) make_4k_aligned((UInt32)initrd); + /* that includes the stack pointer ... */ asm volatile ("mov %0, sp" : "=r"(vstack) ); pstack = (void *)virt_to_phys(g, (UInt32) vstack); @@ -176,21 +184,10 @@ setup_xscale_cpu(); } - if (pg->mach_num==MACH_TYPE_T3XSCALE){ - initrd_offset=T3_INITRD_OFFSET; - } else { - initrd_offset=INITRD_OFFSET; - } - /* place kernel parameters in memory */ setup_atags(pg->ram_base + TAG_OFFSET, pg->ram_base, pg->ram_size, cmdline, - pg->ram_base + initrd_offset, initrd_size); + initrd, initrd_size); - /* copy initrd into place */ - if (initrd) { - copy_image((void*)(pg->ram_base + initrd_offset), initrd, initrd_size); - } - /* bring on the penguin! */ jump_to_kernel(kernel, pg->ram_base + TAG_OFFSET, pg->mach_num); Modified: cocoboot/trunk/m68k/imgloader.c =================================================================== --- cocoboot/trunk/m68k/imgloader.c 2007-07-13 21:53:03 UTC (rev 1143) +++ cocoboot/trunk/m68k/imgloader.c 2007-07-14 01:17:37 UTC (rev 1144) @@ -56,6 +56,9 @@ err = VFSFileOpen(vol_ref, name, vfsModeRead, &f); if(err != errNone) return -2; + /* ensure the image is 4k aligned. */ + offset = 0x1000 - (((UInt32)buffer) & 0xfff); + VFSFileReadData(f, size, buffer, offset, &bytes_read); VFSFileClose(f); @@ -151,7 +154,7 @@ } } else { /* vfs */ - return load_file(name, vol_ref, size, buffer, 0); + return load_file(name, vol_ref, size, buffer, 0x0); } out_unlock: Modified: cocoboot/trunk/m68k/mainform.c =================================================================== --- cocoboot/trunk/m68k/mainform.c 2007-07-13 21:53:03 UTC (rev 1143) +++ cocoboot/trunk/m68k/mainform.c 2007-07-14 01:17:37 UTC (rev 1144) @@ -202,7 +202,7 @@ vol = search_image(name, loc, sizeof(loc), &size); if(vol < -1) goto out; - ftr_size = size; + ftr_size = size + 0x1000; /* allocate an extra 4k so we can align the image */ while (ftr_size) { if(!(err=FtrPtrNew (CREATOR_ID, FEATURE_NUM + n, ftr_size, image))) { break; @@ -372,7 +372,7 @@ cmdline_p = FrmGetObjectPtr(form, FrmGetObjectIndex(form, CommandLine)); cmdline_th = MemHandleNew(size); cmdline_tp = MemHandleLock(cmdline_th); - StrCopy(cmdline_tp, "init=/linuxrc root=/dev/mmcblk0p2"); /* default value */ + StrCopy(cmdline_tp, " "); /* default value */ //PrefGetAppPreferences ('CcBt', 1, cmdline_tp, &size, true); MemHandleUnlock(cmdline_th); FldSetTextHandle(cmdline_p, cmdline_th); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-15 08:33:28
|
Revision: 1151 http://svn.sourceforge.net/hackndev/?rev=1151&view=rev Author: bobofdoom Date: 2007-07-15 01:33:23 -0700 (Sun, 15 Jul 2007) Log Message: ----------- Cocoboot: Reverted initrd copy removal as it's causing trouble and didn't solve the initial problem. Modified Paths: -------------- cocoboot/trunk/Changelog cocoboot/trunk/arm/boot.c cocoboot/trunk/m68k/imgloader.c cocoboot/trunk/m68k/mainform.c Modified: cocoboot/trunk/Changelog =================================================================== --- cocoboot/trunk/Changelog 2007-07-15 08:02:12 UTC (rev 1150) +++ cocoboot/trunk/Changelog 2007-07-15 08:33:23 UTC (rev 1151) @@ -1,5 +1,3 @@ - - Removed initrd relocation for speed and reliability (suggested by phire) - version 0.3: - Added overflow-buffer as last resort to allocation problem (slapin's idea) - Cleaned up treo code (removed all #ifdefs) Modified: cocoboot/trunk/arm/boot.c =================================================================== --- cocoboot/trunk/arm/boot.c 2007-07-15 08:02:12 UTC (rev 1150) +++ cocoboot/trunk/arm/boot.c 2007-07-15 08:33:23 UTC (rev 1151) @@ -24,11 +24,9 @@ #define MACH_TYPE_T3XSCALE 829 #define TAG_OFFSET 0x100 +#define INITRD_OFFSET 0x0400000 -UInt32 make_4k_aligned(UInt32 addr) -{ - return addr + 0x1000 - (addr & 0xfff); -} +#define T3_INITRD_OFFSET 0x1500000 static void jump_to_kernel(void *kernel_base, UInt32 tag_base, UInt32 mach) { @@ -86,6 +84,7 @@ if(!kernel || !cmdline) { return 0xc0ffee; } + UInt32 initrd_offset; /* since we're going to turn off the MMU, we need to translate * all out pointers to physical addresses. @@ -102,13 +101,6 @@ return 0xbadc01a; } - /* force our pointers to be 4k aligned, imgloader will have shifted - * the image forward. - */ - kernel = (void*) make_4k_aligned((UInt32)kernel); - if (initrd) - initrd = (void*) make_4k_aligned((UInt32)initrd); - /* that includes the stack pointer ... */ asm volatile ("mov %0, sp" : "=r"(vstack) ); pstack = (void *)virt_to_phys(g, (UInt32) vstack); @@ -184,10 +176,21 @@ setup_xscale_cpu(); } + if (pg->mach_num==MACH_TYPE_T3XSCALE){ + initrd_offset=T3_INITRD_OFFSET; + } else { + initrd_offset=INITRD_OFFSET; + } + /* place kernel parameters in memory */ setup_atags(pg->ram_base + TAG_OFFSET, pg->ram_base, pg->ram_size, cmdline, - initrd, initrd_size); + pg->ram_base + initrd_offset, initrd_size); + /* copy initrd into place */ + if (initrd) { + copy_image((void*)(pg->ram_base + initrd_offset), initrd, initrd_size); + } + /* bring on the penguin! */ jump_to_kernel(kernel, pg->ram_base + TAG_OFFSET, pg->mach_num); Modified: cocoboot/trunk/m68k/imgloader.c =================================================================== --- cocoboot/trunk/m68k/imgloader.c 2007-07-15 08:02:12 UTC (rev 1150) +++ cocoboot/trunk/m68k/imgloader.c 2007-07-15 08:33:23 UTC (rev 1151) @@ -56,9 +56,6 @@ err = VFSFileOpen(vol_ref, name, vfsModeRead, &f); if(err != errNone) return -2; - /* ensure the image is 4k aligned. */ - offset = 0x1000 - (((UInt32)buffer) & 0xfff); - VFSFileReadData(f, size, buffer, offset, &bytes_read); VFSFileClose(f); @@ -154,7 +151,7 @@ } } else { /* vfs */ - return load_file(name, vol_ref, size, buffer, 0x0); + return load_file(name, vol_ref, size, buffer, 0); } out_unlock: Modified: cocoboot/trunk/m68k/mainform.c =================================================================== --- cocoboot/trunk/m68k/mainform.c 2007-07-15 08:02:12 UTC (rev 1150) +++ cocoboot/trunk/m68k/mainform.c 2007-07-15 08:33:23 UTC (rev 1151) @@ -202,7 +202,7 @@ vol = search_image(name, loc, sizeof(loc), &size); if(vol < -1) goto out; - ftr_size = size + 0x1000; /* allocate an extra 4k so we can align the image */ + ftr_size = size; while (ftr_size) { if(!(err=FtrPtrNew (CREATOR_ID, FEATURE_NUM + n, ftr_size, image))) { break; @@ -372,7 +372,7 @@ cmdline_p = FrmGetObjectPtr(form, FrmGetObjectIndex(form, CommandLine)); cmdline_th = MemHandleNew(size); cmdline_tp = MemHandleLock(cmdline_th); - StrCopy(cmdline_tp, " "); /* default value */ + StrCopy(cmdline_tp, "init=/linuxrc root=/dev/mmcblk0p2"); /* default value */ //PrefGetAppPreferences ('CcBt', 1, cmdline_tp, &size, true); MemHandleUnlock(cmdline_th); FldSetTextHandle(cmdline_p, cmdline_th); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-15 22:37:53
|
Revision: 1156 http://svn.sourceforge.net/hackndev/?rev=1156&view=rev Author: bobofdoom Date: 2007-07-15 15:37:50 -0700 (Sun, 15 Jul 2007) Log Message: ----------- Commit: Added option for skipping prompts. Build with make DEFINES=-DNOPROMPT_MODE and Cocoboot will not prompt for kernel commmand-line etc, it'll just boot straight away. Modified Paths: -------------- cocoboot/trunk/Changelog cocoboot/trunk/m68k/mainform.c Modified: cocoboot/trunk/Changelog =================================================================== --- cocoboot/trunk/Changelog 2007-07-15 20:12:22 UTC (rev 1155) +++ cocoboot/trunk/Changelog 2007-07-15 22:37:50 UTC (rev 1156) @@ -1,3 +1,5 @@ + - Added compile option for skipping prompts. + version 0.3: - Added overflow-buffer as last resort to allocation problem (slapin's idea) - Cleaned up treo code (removed all #ifdefs) Modified: cocoboot/trunk/m68k/mainform.c =================================================================== --- cocoboot/trunk/m68k/mainform.c 2007-07-15 20:12:22 UTC (rev 1155) +++ cocoboot/trunk/m68k/mainform.c 2007-07-15 22:37:50 UTC (rev 1156) @@ -372,7 +372,7 @@ cmdline_p = FrmGetObjectPtr(form, FrmGetObjectIndex(form, CommandLine)); cmdline_th = MemHandleNew(size); cmdline_tp = MemHandleLock(cmdline_th); - StrCopy(cmdline_tp, "init=/linuxrc root=/dev/mmcblk0p2"); /* default value */ + StrCopy(cmdline_tp, " "); /* default value */ //PrefGetAppPreferences ('CcBt', 1, cmdline_tp, &size, true); MemHandleUnlock(cmdline_th); FldSetTextHandle(cmdline_p, cmdline_th); @@ -384,6 +384,10 @@ kernel_ok = check_image("/zImage"); use_initrd = check_image("/initrd.gz"); +#ifdef NOPROMPT_MODE + if (kernel_ok) boot_linux(); +#endif + } else if (event->eType == menuEvent) { return mainform_menu_event(event->data.menu.itemID); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-16 11:51:05
|
Revision: 1160 http://svn.sourceforge.net/hackndev/?rev=1160&view=rev Author: bobofdoom Date: 2007-07-16 04:51:01 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Cocoboot: Added ability to read a config file from memory card. Name the file "cocoboot.conf" and place it in the root directory. See the file cocboot.conf.example to see the syntax and what options are available. Modified Paths: -------------- cocoboot/trunk/Changelog cocoboot/trunk/include/imgloader.h cocoboot/trunk/m68k/Makefile cocoboot/trunk/m68k/cocoboot.c cocoboot/trunk/m68k/mainform.c Added Paths: ----------- cocoboot/trunk/cocoboot.conf.example cocoboot/trunk/include/options.h cocoboot/trunk/m68k/options.c Modified: cocoboot/trunk/Changelog =================================================================== --- cocoboot/trunk/Changelog 2007-07-16 00:05:34 UTC (rev 1159) +++ cocoboot/trunk/Changelog 2007-07-16 11:51:01 UTC (rev 1160) @@ -1,4 +1,5 @@ - - Added compile option for skipping prompts. + - Added reading of a config file. + - Added option for skipping prompts. version 0.3: - Added overflow-buffer as last resort to allocation problem (slapin's idea) Added: cocoboot/trunk/cocoboot.conf.example =================================================================== --- cocoboot/trunk/cocoboot.conf.example (rev 0) +++ cocoboot/trunk/cocoboot.conf.example 2007-07-16 11:51:01 UTC (rev 1160) @@ -0,0 +1,32 @@ +# cocoboot.conf.exaple - example configuration file for Cocboot + +## cmdline +# The value of cmdline is the default kernel command-line. The user can +# edit this via the GUI unless noprompt is enabled. +# +# Default: [blank] + +cmdline = root=/dev/mmcblk0p1 + +## kernel +# Filename of the kernel zImage. Cocoboot will look for this file on all +# attached VFS disks. +# +# Defaut: /zImage + +kernel = /zImage-2.6.21 + +## initrd +# Filename of the initrd or initramfs ramdisk image. +# +# Default: /initrd.gz + +initrd = /initramfs_cpio.gz + +## noprompt +# When this option is 1, Cocoboot will not prompt for the kernel +# command-line and will instead boot Linux immediately when it is started. +# +# Default: 0 + +noprompt = 0 Modified: cocoboot/trunk/include/imgloader.h =================================================================== --- cocoboot/trunk/include/imgloader.h 2007-07-16 00:05:34 UTC (rev 1159) +++ cocoboot/trunk/include/imgloader.h 2007-07-16 11:51:01 UTC (rev 1160) @@ -1,3 +1,3 @@ Int32 search_image(char *name, char *loc, UInt16 loc_len, UInt32 *size); Int32 load_image(char *name, UInt32 size, UInt16 vol_ref, void *buffer); - +int search_file(char *name, UInt16 *vol_ref, UInt32 *size); Added: cocoboot/trunk/include/options.h =================================================================== --- cocoboot/trunk/include/options.h (rev 0) +++ cocoboot/trunk/include/options.h 2007-07-16 11:51:01 UTC (rev 1160) @@ -0,0 +1,9 @@ +#ifndef _OPTIONS_H_ +#define _OPTIONS_H_ + +#define CONFIG_FILE "/cocoboot.conf" + +char *get_option(char *key); +int set_option(char *key, char *value); +int read_config(void); +#endif Modified: cocoboot/trunk/m68k/Makefile =================================================================== --- cocoboot/trunk/m68k/Makefile 2007-07-16 00:05:34 UTC (rev 1159) +++ cocoboot/trunk/m68k/Makefile 2007-07-16 11:51:01 UTC (rev 1160) @@ -2,7 +2,7 @@ CFLAGS = -Wall -O -s -I../include ${DEFINES} LDFLAGS = -static LIBS=-L/software/apps/prc-tools/sdks/sdk-5r3/lib/m68k-palmos-coff/ -lPalmOSGlue -OBJS = cocoboot.o mainform.o mem.o cpu.o imgloader.o mach.o +OBJS = cocoboot.o mainform.o mem.o cpu.o imgloader.o mach.o options.o cocoboot.m68k: $(OBJS) Modified: cocoboot/trunk/m68k/cocoboot.c =================================================================== --- cocoboot/trunk/m68k/cocoboot.c 2007-07-16 00:05:34 UTC (rev 1159) +++ cocoboot/trunk/m68k/cocoboot.c 2007-07-16 11:51:01 UTC (rev 1160) @@ -26,6 +26,7 @@ #include <VFSMgr.h> #include "cocoboot.h" +#include "options.h" #include "cocoboot_r.h" #include "mainform.h" @@ -398,7 +399,7 @@ UInt16 start_app() { - + read_config(); arm_stack[0] = 0; FrmGotoForm(MainForm); Modified: cocoboot/trunk/m68k/mainform.c =================================================================== --- cocoboot/trunk/m68k/mainform.c 2007-07-16 00:05:34 UTC (rev 1159) +++ cocoboot/trunk/m68k/mainform.c 2007-07-16 11:51:01 UTC (rev 1160) @@ -6,6 +6,7 @@ #include "mem.h" #include "regs.h" #include "imgloader.h" +#include "options.h" #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -270,10 +271,10 @@ char *cmdline; log_clear(); - kernel_size = load_parts(0, "/zImage", &kernel); + kernel_size = load_parts(0, get_option("kernel"), &kernel); if(kernel_size) { if(use_initrd) { - initrd_size = load_parts(1, "/initrd.gz", &initrd); + initrd_size = load_parts(1, get_option("initrd"), &initrd); } if(!use_initrd || initrd_size) { @@ -372,7 +373,7 @@ cmdline_p = FrmGetObjectPtr(form, FrmGetObjectIndex(form, CommandLine)); cmdline_th = MemHandleNew(size); cmdline_tp = MemHandleLock(cmdline_th); - StrCopy(cmdline_tp, " "); /* default value */ + StrCopy(cmdline_tp, get_option("cmdline")); /* default value */ //PrefGetAppPreferences ('CcBt', 1, cmdline_tp, &size, true); MemHandleUnlock(cmdline_th); FldSetTextHandle(cmdline_p, cmdline_th); @@ -381,13 +382,13 @@ FrmDrawForm(form); handled = true; - kernel_ok = check_image("/zImage"); - use_initrd = check_image("/initrd.gz"); + kernel_ok = check_image(get_option("kernel")); + use_initrd = check_image(get_option("initrd")); + + /* boot immediately if in noprompt mode */ + if (atoi(get_option("noprompt")) != 0 && kernel_ok) + boot_linux(); -#ifdef NOPROMPT_MODE - if (kernel_ok) boot_linux(); -#endif - } else if (event->eType == menuEvent) { return mainform_menu_event(event->data.menu.itemID); } Added: cocoboot/trunk/m68k/options.c =================================================================== --- cocoboot/trunk/m68k/options.c (rev 0) +++ cocoboot/trunk/m68k/options.c 2007-07-16 11:51:01 UTC (rev 1160) @@ -0,0 +1,202 @@ +/* + * This program is free software ; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <PalmOS.h> +#include <VFSMgr.h> +#include <ctype.h> +#include <stdio.h> +#include <string.h> +#include "cocoboot.h" +#include "options.h" +#include "imgloader.h" +#include "cocoboot_r.h" + +struct option { + char key[1024]; + char value[1024]; +} options[] = { + { + .key = "cmdline", + .value = " ", + }, + { + .key = "kernel", + .value = "/zImage", + }, + { + .key = "initrd", + .value = "/initrd.gz", + }, + { + .key = "noprompt", + .value = "0", + }, + { + .key = "", /* sentinal */ + }, +}; + +//int search_file(char *name, UInt16 *vol_ref, UInt32 *size); + +/** + * Read a single line from file f into the given buffer, stripping linefeeds. + */ +Err read_line(FileRef f, char *buf, int buflen) +{ + Err err; + char c; + int i; + + for (i=0; i<buflen; i++) { + err = VFSFileRead(f, 1, &c, NULL); + if (err != errNone) { + return err; + } + + if (c == '\n') { + buf[i] = 0; + break; + } + + if (c == '\r') { + continue; + } + + buf[i] = c; + } + return errNone; +} + +char *parse_config_line(char *line, char **out_key, char **out_value) +{ + char *p = line; + char *key, *value; + + *out_key = *out_value = NULL; + + /* skip whitespace at the start of the key */ + key = line; + while (*key && isspace(*key)) + key++; + if (!*key || *key == '#') return NULL; /* error: empty line or comment */ + + + /* divide key and value into seperate strings */ + while (*p && *p != '=') p++; + if (!*p) return "no equals sign found"; + *p = 0; + value = p + 1; + + /* work backwards to find the end of the key, again skipping spaces */ + p--; + while (p >= line && *p && isspace(*p)) + p--; + if (p < line) return "empty key"; + p++; + *p = 0; + + /* strip whitespace at the start of the value */ + while (*value && isspace(*value)) + value++; + if (!*value) return "empty value"; + p = value; + + /* find end of value */ + while (*p) p++; + p--; + + /* work backwards to find end of value, again skipping spaces */ + while (p >= value && *p && isspace(*p)) + p--; + p++; + *p = 0; + + *out_key = key; + *out_value = value; + return NULL; +} + +void show_parse_error(char *errmsg, int line_no) +{ + char s_line_no[128]; + sprintf(s_line_no, "\nLine %d of " CONFIG_FILE, line_no); + FrmCustomAlert(ErrorAlert, "Parse Error: ", errmsg, s_line_no); +} + +int set_option(char *key, char *value) +{ + struct option *opt = &options[0]; + + while (opt->key[0]) { + if (!strcmp(key, opt->key)) { + strncpy(opt->value, value, sizeof(opt->value)-1); + return 0; + } + opt++; + } + return -1; +} + +char *get_option(char *key) +{ + struct option *opt = &options[0]; + + while (opt->key[0]) { + if (!strcmp(key, opt->key)) { + return opt->value; + } + opt++; + } + return NULL; +} + +int read_config(void) +{ + Err err; + UInt16 vol; + UInt32 size; + FileRef f; + char buf[2048]; + int line_no; + char *errmsg, *key, *value; + + if (!search_file(CONFIG_FILE, &vol, &size)) { + return -1; + } + + err = VFSFileOpen(vol, CONFIG_FILE, vfsModeRead, &f); + if (err != errNone) { + return err; + } + + for (line_no = 1; 1; line_no++) { + err = read_line(f, buf, sizeof(buf)-1); + if (err != errNone) break; + + + if ((errmsg=parse_config_line(buf, &key, &value))) { + show_parse_error(errmsg, line_no); + continue; + } + + if (set_option(key, value) < 0) { + show_parse_error("unrecognised option", line_no); + continue; + } + } + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-16 13:36:32
|
Revision: 1162 http://svn.sourceforge.net/hackndev/?rev=1162&view=rev Author: bobofdoom Date: 2007-07-16 06:36:17 -0700 (Mon, 16 Jul 2007) Log Message: ----------- Cocoboot: Fixed skipping of blank lines and comments in cocoboot.conf. Modified Paths: -------------- cocoboot/trunk/cocoboot.conf.example cocoboot/trunk/m68k/options.c Modified: cocoboot/trunk/cocoboot.conf.example =================================================================== --- cocoboot/trunk/cocoboot.conf.example 2007-07-16 13:08:24 UTC (rev 1161) +++ cocoboot/trunk/cocoboot.conf.example 2007-07-16 13:36:17 UTC (rev 1162) @@ -1,4 +1,4 @@ -# cocoboot.conf.exaple - example configuration file for Cocboot +# cocoboot.conf.exaple - example configuration file for Cocoboot ## cmdline # The value of cmdline is the default kernel command-line. The user can Modified: cocoboot/trunk/m68k/options.c =================================================================== --- cocoboot/trunk/m68k/options.c 2007-07-16 13:08:24 UTC (rev 1161) +++ cocoboot/trunk/m68k/options.c 2007-07-16 13:36:17 UTC (rev 1162) @@ -85,6 +85,7 @@ { char *p = line; char *key, *value; + char buf[128]; *out_key = *out_value = NULL; @@ -94,7 +95,6 @@ key++; if (!*key || *key == '#') return NULL; /* error: empty line or comment */ - /* divide key and value into seperate strings */ while (*p && *p != '=') p++; if (!*p) return "no equals sign found"; @@ -170,7 +170,6 @@ UInt16 vol; UInt32 size; FileRef f; - char buf[2048]; int line_no; char *errmsg, *key, *value; @@ -193,6 +192,8 @@ continue; } + if (!key) continue; /* blank line or comment */ + if (set_option(key, value) < 0) { show_parse_error("unrecognised option", line_no); continue; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-18 10:18:29
|
Revision: 1175 http://svn.sourceforge.net/hackndev/?rev=1175&view=rev Author: bobofdoom Date: 2007-07-18 03:18:09 -0700 (Wed, 18 Jul 2007) Log Message: ----------- Cocoboot: Version 0.4 Modified Paths: -------------- cocoboot/trunk/Changelog cocoboot/trunk/include/cocoboot.rcp Modified: cocoboot/trunk/Changelog =================================================================== --- cocoboot/trunk/Changelog 2007-07-17 15:21:09 UTC (rev 1174) +++ cocoboot/trunk/Changelog 2007-07-18 10:18:09 UTC (rev 1175) @@ -1,3 +1,5 @@ +version 0.4: + - Fixed 'c01d' error introduced in 0.3 on LD, TX etc. - Added reading of a config file. - Added option for skipping prompts. Modified: cocoboot/trunk/include/cocoboot.rcp =================================================================== --- cocoboot/trunk/include/cocoboot.rcp 2007-07-17 15:21:09 UTC (rev 1174) +++ cocoboot/trunk/include/cocoboot.rcp 2007-07-18 10:18:09 UTC (rev 1175) @@ -1,7 +1,7 @@ #include "cocoboot_r.h" APPLICATIONICONNAME ID 1000 "Cocoboot" -VERSION "0.2" +VERSION "0.4" ICON BEGIN @@ -79,7 +79,7 @@ -STRING GnuGpl "Cocoboot 0.3, PalmOS Linux loader.\n"\ +STRING GnuGpl "Cocoboot 0.4, PalmOS Linux loader.\n"\ "Copyright (C) 2006\n"\ "\n"\ "www.hackndev.com\n"\ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-21 12:34:10
|
Revision: 1193 http://svn.sourceforge.net/hackndev/?rev=1193&view=rev Author: bobofdoom Date: 2007-07-21 05:34:07 -0700 (Sat, 21 Jul 2007) Log Message: ----------- Cocoboot: Dug up some old debugger / IRQ tracing code out of the closet. Modified Paths: -------------- cocoboot/trunk/arm/Makefile cocoboot/trunk/arm/arm.c cocoboot/trunk/include/arm.h cocoboot/trunk/include/cocoboot.rcp cocoboot/trunk/include/cocoboot_r.h cocoboot/trunk/include/shared.h cocoboot/trunk/m68k/mainform.c Added Paths: ----------- cocoboot/trunk/arm/debug.c Modified: cocoboot/trunk/arm/Makefile =================================================================== --- cocoboot/trunk/arm/Makefile 2007-07-21 11:47:19 UTC (rev 1192) +++ cocoboot/trunk/arm/Makefile 2007-07-21 12:34:07 UTC (rev 1193) @@ -1,7 +1,7 @@ CC = arm-palmos-gcc CFLAGS = -Wall -O -s -I../include ${DEFINES} LDFLAGS = -nostartfiles -OBJS = arm.o atag.o boot.o cpu.o +OBJS = arm.o atag.o boot.o cpu.o debug.o all: cocoboot.arm Modified: cocoboot/trunk/arm/arm.c =================================================================== --- cocoboot/trunk/arm/arm.c 2007-07-21 11:47:19 UTC (rev 1192) +++ cocoboot/trunk/arm/arm.c 2007-07-21 12:34:07 UTC (rev 1193) @@ -76,6 +76,10 @@ case 4: ret = foobar(); break; + + case ARM_install_irqhandler: + ret = install_irqhandler(g, (UInt32*)pop_uint32(stack)); + break; default: ret = 0xbadf0000 ^ func; } Added: cocoboot/trunk/arm/debug.c =================================================================== --- cocoboot/trunk/arm/debug.c (rev 0) +++ cocoboot/trunk/arm/debug.c 2007-07-21 12:34:07 UTC (rev 1193) @@ -0,0 +1,217 @@ +/* + * Some parts based on GNU Haret which is: + * (C) Copyright 2006 Kevin O'Connor <ke...@ko...> + * + * This file may be distributed under the terms of the GNU GPL license. + * + */ +#include <PalmOS.h> +#include "arm.h" +#include "mem.h" +#include "regs.h" +#include "cpu.h" + +/* location of the pointer to the IRQ handler */ +#define IRQH (*(void**)0x38) +#define DATAH (*(void**)0x30) + +void irqhandler(); +void datahandler(); + +// Set the IBCR0 software debug register +static inline void set_IBCR0(UInt32 val) { + asm volatile("mcr p15, 0, %0, c14, c8, 0" : : "r"(val)); +} +// Set the IBCR1 software debug register +static inline void set_IBCR1(UInt32 val) { + asm volatile("mcr p15, 0, %0, c14, c9, 0" : : "r"(val)); +} +// Set the EVTSEL performance monitoring register +static inline void set_EVTSEL(UInt32 val) { + asm volatile("mcr p14, 0, %0, c8, c1, 0" : : "r"(val)); +} +// Set the INTEN performance monitoring register +static inline void set_INTEN(UInt32 val) { + asm volatile("mcr p14, 0, %0, c4, c1, 0" : : "r"(val)); +} +// Set the PMNC performance monitoring register +static inline void set_PMNC(UInt32 val) { + asm volatile("mcr p14, 0, %0, c0, c1, 0" : : "r"(val)); +} +// Set the DBCON software debug register +static inline void set_DBCON(UInt32 val) { + asm volatile("mcr p15, 0, %0, c14, c4, 0" : : "r"(val)); +} +// Set the DBR0 software debug register +static inline void set_DBR0(UInt32 val) { + asm volatile("mcr p15, 0, %0, c14, c0, 0" : : "r"(val)); +} +// Set the DBR1 software debug register +static inline void set_DBR1(UInt32 val) { + asm volatile("mcr p15, 0, %0, c14, c3, 0" : : "r"(val)); +} +// Set the DCSR software debug register +static inline void set_DCSR(UInt32 val) { + asm volatile("mcr p14, 0, %0, c10, c0, 0" : : "r"(val)); +} + + +UInt32 install_irqhandler(ArmGlobals *g, UInt32 *buf) +{ + UInt32 *src = 0; + UInt32 *end = 0; + UInt32 *dest = buf; + UInt32 *dataoffset; + + /* new value for the domain access control, this disables memory + * protection allowing us to write directly into the storage heap. + */ + UInt32 domain_ac=0xFFFFFFFF; + asm volatile ("mcr p15, 0, %0, c3, c0, 0" : : "r"(domain_ac)); + + asm volatile ("adr %0, IrqHandlerStart" :"=r"(src) ); + asm volatile ("adr %0, HandlersEnd" :"=r"(end) ); + + asm volatile ("adr %0, DataAbortHandler" :"=r"(dataoffset) ); + + dataoffset = (UInt32*)((UInt32)dataoffset - (UInt32)src + (UInt32)buf); + + /* copy our new IRQ handler into the buffer */ + while (src < end) + *dest++ = *src++; + + /* replace PalmOS handler with our own */ + IRQH = buf; + DATAH = dataoffset; + + set_DBCON(0); /* disable debugging */ + set_DBR0(0x90100000); + set_DBR1(0xffffffff); + set_DCSR(1<<31); /* global enable */ + set_DBCON(2); /* enable DBR0, both load and store */ + +// return *(volatile UInt32*)0x90100000; + return (UInt32)dataoffset; +} + +void irqhandler() { + asm volatile ("IrqHandlerStart:"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + + /* Backup register values */ +#if 0 + asm volatile ("str r0, REG0"); + asm volatile ("str r1, REG1"); + + /* Let PalmOS' irq handler deal with the event. */ + asm volatile ("ChainHandler:"); + asm volatile ("ldr r1, REG1"); /* restore regs from backup */ + asm volatile ("ldr r0, REG0"); +#endif + + asm volatile ("ldr pc, [pc, #-4]"); /* jump to POS' irq handler */ + asm volatile ("OLDHANDLER: .word 0x200a2b94"); + + asm volatile ("REG0: .word 0xdeadbeef"); + asm volatile ("REG1: .word 0xdeadbeef"); + + + asm volatile ("INTH:"); + +} + +void datahandler() +{ + asm volatile ("DataAbortHandler:"); + asm volatile ("nop"); + asm volatile ("nop"); + asm volatile ("nop"); + +#if 0 + asm volatile ("stmdb sp!, {r14}"); /* save r14 */ + asm volatile ("mrc p15, 0, r14, c10, c0, 0");/* DCSR */ + asm volatile ("and r14, r14, #28"); /* get method of entry */ + asm volatile ("cmp r14, #8"); /* data breakpoint? */ + asm volatile ("bne ChainDataAbort"); /* no? lets get of out of here! */ + + + /* I guess we should start by restoring r14 */ + asm volatile ("ldmia sp!, {r14}"); +#endif + + /* okay so we've got a data breakpoint, now what do we do? */ + /* Now let's save all our registers */ + asm volatile ("stmdb sp!, {r0-r12}"); + + /* Store the values of r0 and r1 so we can get them + * without messing with the stack. + */ + asm volatile ("str r0, [pc, #(Reg0 - . - 8)]"); + asm volatile ("str r1, [pc, #(Reg1 - . - 8)]"); +// asm volatile ("mov r1, #0"); + + /* grab the next free spot in the buffer */ +// asm volatile ("ldr r1, [pc, #(DumpOffset - . - 8)]"); +#if 0 + asm volatile ("pcgrab: add r1, r1, pc"); + asm volatile ("add r1, r1, #(HandlersEnd - pcgrab + 8)"); + + /* store "1" to indicate this is a data breakpoint */ + asm volatile ("mov r0, #1"); + asm volatile ("str r0, [r1]"); + asm volatile ("add r1, r1, #4"); + + /* lets save the address of the instruction we broken, as well + * as the instruction itself. + */ + asm volatile ("sub r0, r14, #8"); + asm volatile ("str r0, [r1]"); + asm volatile ("ldr r0, [r0]"); + asm volatile ("str r0, [r1, #4]"); + asm volatile ("add r1, r1, #8"); + + /* now lets start saving registers, first the tricky ones */ + asm volatile ("ldr r0, [pc, #(Reg0 - . - 8)]"); + asm volatile ("str r0, [r1]"); + asm volatile ("ldr r0, [pc, #(Reg1 - . - 8)]"); + asm volatile ("str r0, [r1, #4]"); + asm volatile ("add r1, r1, #8"); + + /* now the rest */ + asm volatile ("str r2, [r1]"); + asm volatile ("str r3, [r1, #4]"); + asm volatile ("str r4, [r1, #8]"); + asm volatile ("str r5, [r1, #0xc]"); + asm volatile ("str r6, [r1, #0x10]"); + asm volatile ("str r7, [r1, #0x14]"); + asm volatile ("str r8, [r1, #0x18]"); + asm volatile ("str r9, [r1, #0x1c]"); + asm volatile ("str r10, [r1, #0x20]"); + asm volatile ("str r11, [r1, #0x24]"); + asm volatile ("str r12, [r1, #0x28]"); + asm volatile ("add r1, r1, #0x2c"); + + /* save our buffer pointer */ + asm volatile ("str r1, [pc, #(DumpOffset - . - 8)]"); +#endif + /* Restore everything we clobbered */ + asm volatile ("ldmia sp!, {r0-r12}"); + + /* return to aborted process */ + asm volatile ("subs pc,r14,#4"); + +#if 0 + + asm volatile ("ChainDataAbort:"); + asm volatile ("ldmia sp!, {r14}"); /* restore r14 */ + asm volatile ("ldr pc, [pc, #-4]"); /* jump to POS' handler */ + asm volatile ("OldDataAbort: .word 0x200a3370"); +#endif + + asm volatile ("Reg0: .word 0"); + asm volatile ("Reg1: .word 0"); + asm volatile ("DumpOffset: .word 0"); + asm volatile ("HandlersEnd: .word 0"); +} Modified: cocoboot/trunk/include/arm.h =================================================================== --- cocoboot/trunk/include/arm.h 2007-07-21 11:47:19 UTC (rev 1192) +++ cocoboot/trunk/include/arm.h 2007-07-21 12:34:07 UTC (rev 1193) @@ -20,6 +20,8 @@ void setup_atags(UInt32 tag_base, UInt32 ram_base, UInt32 ram_size, const char *cmd_line, UInt32 initrd_base, UInt32 initrd_size); +/* debug.c */ +UInt32 install_irqhandler(ArmGlobals *g, UInt32 *buf); /* Disable IRQ and FIQ */ #define irq_off() asm volatile ("mrs r0, cpsr \n" \ Modified: cocoboot/trunk/include/cocoboot.rcp =================================================================== --- cocoboot/trunk/include/cocoboot.rcp 2007-07-21 11:47:19 UTC (rev 1192) +++ cocoboot/trunk/include/cocoboot.rcp 2007-07-21 12:34:07 UTC (rev 1193) @@ -31,6 +31,10 @@ BEGIN MENUITEM "USB Console" MenuItemConsole END + PULLDOWN "Trace" + BEGIN + MENUITEM "IRQ trace" MenuItemStartIrqTrace + END END FORM ID MainForm AT (0 0 160 160) NOFRAME USABLE MENUID MainFormMenu HELPID GnuGpl MODAL Modified: cocoboot/trunk/include/cocoboot_r.h =================================================================== --- cocoboot/trunk/include/cocoboot_r.h 2007-07-21 11:47:19 UTC (rev 1192) +++ cocoboot/trunk/include/cocoboot_r.h 2007-07-21 12:34:07 UTC (rev 1193) @@ -16,6 +16,7 @@ #define MenuItemBootLinux 1004 #define MenuItemDumpMMU 1005 #define MenuItemConsole 1006 +#define MenuItemStartIrqTrace 1007 #define ErrorAlert 1000 #define InfoAlert 1001 Modified: cocoboot/trunk/include/shared.h =================================================================== --- cocoboot/trunk/include/shared.h 2007-07-21 11:47:19 UTC (rev 1192) +++ cocoboot/trunk/include/shared.h 2007-07-21 12:34:07 UTC (rev 1193) @@ -19,6 +19,8 @@ #define ARM_read_cp 1 /* (coproc, reg) */ #define ARM_fb_test 2 /* () */ #define ARM_boot_linux 3 +#define ARM_test 4 +#define ARM_install_irqhandler 5 typedef UInt32 ArmStack; Modified: cocoboot/trunk/m68k/mainform.c =================================================================== --- cocoboot/trunk/m68k/mainform.c 2007-07-21 11:47:19 UTC (rev 1192) +++ cocoboot/trunk/m68k/mainform.c 2007-07-21 12:34:07 UTC (rev 1193) @@ -189,7 +189,31 @@ } +void start_irq_trace() +{ + Err err=0; + UInt32 size = 1024L * 100; /* 100k should be plenty */ + UInt32 ret; + void *buffer = NULL; + char msg[100]; + if((err=FtrPtrNew (CREATOR_ID, FEATURE_NUM, size, &buffer))) { + sprintf(msg, "Error: %d", err); + FrmCustomAlert(InfoAlert, "Unable to allocate trace buffer.", msg, " "); + return; + } + + push_uint32(arm_stack, (UInt32)buffer); + ret = call_arm(arm_stack, ARM_install_irqhandler); + + if (!ret) { + FrmCustomAlert(InfoAlert, "Trace started.", " ", " "); + } else { + sprintf(msg, "Error: 0x%lx", ret); + FrmCustomAlert(InfoAlert, msg, " ", " "); + } +} + UInt32 load_parts(int n, char *name, void **image) { /* more ugly code... */ @@ -323,6 +347,9 @@ case MenuItemConsole: usb_console(); return true; + case MenuItemStartIrqTrace: + start_irq_trace(); + return true; } return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-22 02:47:05
|
Revision: 1194 http://svn.sourceforge.net/hackndev/?rev=1194&view=rev Author: bobofdoom Date: 2007-07-21 19:47:01 -0700 (Sat, 21 Jul 2007) Log Message: ----------- Cocoboot: Added memory tracing. * Adapted IRQ trace code to work for tracing memory accesses. * Added option to dump trace log to a file. * Added primitive log parsing script. Modified Paths: -------------- cocoboot/trunk/arm/debug.c cocoboot/trunk/include/cocoboot.rcp cocoboot/trunk/include/cocoboot_r.h cocoboot/trunk/m68k/mainform.c Added Paths: ----------- cocoboot/trunk/tools/traceparse.py Modified: cocoboot/trunk/arm/debug.c =================================================================== --- cocoboot/trunk/arm/debug.c 2007-07-21 12:34:07 UTC (rev 1193) +++ cocoboot/trunk/arm/debug.c 2007-07-22 02:47:01 UTC (rev 1194) @@ -81,17 +81,20 @@ *dest++ = *src++; /* replace PalmOS handler with our own */ - IRQH = buf; + //IRQH = buf; DATAH = dataoffset; + + *((UInt32**)0x64) = dest; + *((UInt32**)0x68) = dest; set_DBCON(0); /* disable debugging */ - set_DBR0(0x90100000); - set_DBR1(0xffffffff); + set_DBR0(0x90100000); /* this is the address we want to monitor */ + set_DBR1(0x00000000); /* this is the mask (0 = compare bit, 1 = ignore bit) */ + set_DBCON(2 | 1<<8); /* enable DBR0, both load and store */ set_DCSR(1<<31); /* global enable */ - set_DBCON(2); /* enable DBR0, both load and store */ // return *(volatile UInt32*)0x90100000; - return (UInt32)dataoffset; + return dest; //(UInt32)dataoffset; } void irqhandler() { @@ -99,7 +102,6 @@ asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); - /* Backup register values */ #if 0 asm volatile ("str r0, REG0"); @@ -128,7 +130,22 @@ asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); - + //asm volatile ("stmdb sp!, {r14}"); /* save r14 */ + //asm volatile ("mov r14, #0"); + + //asm volatile ("mrc p15, 0, r14, c10, c0, 0");/* DCSR */ + //asm volatile ("and r14, r14, #28"); /* get method of entry */ + //asm volatile ("cmp r14, #8"); /* data breakpoint? */ + //asm volatile ("bne runaway"); /* data breakpoint? */ + //asm volatile ("goof: b goof"); /* data breakpoint? */ + //asm volatile ("runaway:ldmia sp!, {r14}"); + //asm volatile ("mov r0, #0x30000001"); + //asm volatile ("mov r1, #0x30000002"); + //asm volatile ("mov r2, #0x30000003"); + //asm volatile ("mov r3, #0x30000004"); + //asm volatile ("mov r4, #0x30000005"); + //asm volatile ("mov r5, #0x30000006"); + //asm volatile ("subs pc,r14,#4"); /* return to sender */ #if 0 asm volatile ("stmdb sp!, {r14}"); /* save r14 */ asm volatile ("mrc p15, 0, r14, c10, c0, 0");/* DCSR */ @@ -148,54 +165,60 @@ /* Store the values of r0 and r1 so we can get them * without messing with the stack. */ - asm volatile ("str r0, [pc, #(Reg0 - . - 8)]"); - asm volatile ("str r1, [pc, #(Reg1 - . - 8)]"); -// asm volatile ("mov r1, #0"); + + asm volatile ("stmdb sp!, {r14}"); /* save r14 */ + asm volatile ("stmdb sp!, {r12}"); /* save r12 */ - /* grab the next free spot in the buffer */ -// asm volatile ("ldr r1, [pc, #(DumpOffset - . - 8)]"); -#if 0 - asm volatile ("pcgrab: add r1, r1, pc"); - asm volatile ("add r1, r1, #(HandlersEnd - pcgrab + 8)"); - - /* store "1" to indicate this is a data breakpoint */ - asm volatile ("mov r0, #1"); - asm volatile ("str r0, [r1]"); - asm volatile ("add r1, r1, #4"); + asm volatile ("mov r12, r14"); /* copy return addr */ - /* lets save the address of the instruction we broken, as well - * as the instruction itself. - */ - asm volatile ("sub r0, r14, #8"); - asm volatile ("str r0, [r1]"); - asm volatile ("ldr r0, [r0]"); - asm volatile ("str r0, [r1, #4]"); - asm volatile ("add r1, r1, #8"); - - /* now lets start saving registers, first the tricky ones */ - asm volatile ("ldr r0, [pc, #(Reg0 - . - 8)]"); - asm volatile ("str r0, [r1]"); - asm volatile ("ldr r0, [pc, #(Reg1 - . - 8)]"); - asm volatile ("str r0, [r1, #4]"); - asm volatile ("add r1, r1, #8"); - - /* now the rest */ - asm volatile ("str r2, [r1]"); - asm volatile ("str r3, [r1, #4]"); - asm volatile ("str r4, [r1, #8]"); - asm volatile ("str r5, [r1, #0xc]"); - asm volatile ("str r6, [r1, #0x10]"); - asm volatile ("str r7, [r1, #0x14]"); - asm volatile ("str r8, [r1, #0x18]"); - asm volatile ("str r9, [r1, #0x1c]"); - asm volatile ("str r10, [r1, #0x20]"); - asm volatile ("str r11, [r1, #0x24]"); - asm volatile ("str r12, [r1, #0x28]"); - asm volatile ("add r1, r1, #0x2c"); - - /* save our buffer pointer */ - asm volatile ("str r1, [pc, #(DumpOffset - . - 8)]"); -#endif + asm volatile ("mcr p15, 0, %0, c3, c0, 0" : : "r"(0xffffffff)); + + + asm volatile ("mov r14, #0x00000064"); + asm volatile ("orr r14, r14, #0x00000000"); + + asm volatile ("ldr r14, [r14]"); + + /* store some sort of start of frame marker */ + asm volatile ("stmdb sp!, {r12}"); /* save r12 */ + asm volatile ("mov r12, #0x00034"); + asm volatile ("orr r12, r12, #0x1200"); + asm volatile ("str r12, [r14]"); + asm volatile ("ldmia sp!, {r12}"); /* restore r12, this gets us back out return addr */ + + /* save location of read/write instruction */ + asm volatile ("subs r12, r12, #8"); + asm volatile ("str r12, [r14, #0x38]"); + + /* now save the actual instruction itself */ + //asm volatile ("ldr r12, [r12]"); + //asm volatile ("str r12, [r14, #0x3c]"); + + asm volatile ("ldmia sp!, {r12}"); /* restore r12 again, now real value */ + + /* now store all our registers */ + asm volatile ("str r0, [r14, #0x4]"); + asm volatile ("str r1, [r14, #0x8]"); + asm volatile ("str r2, [r14, #0xc]"); + asm volatile ("str r3, [r14, #0x10]"); + asm volatile ("str r4, [r14, #0x14]"); + asm volatile ("str r5, [r14, #0x18]"); + asm volatile ("str r6, [r14, #0x1c]"); + asm volatile ("str r7, [r14, #0x20]"); + asm volatile ("str r8, [r14, #0x24]"); + asm volatile ("str r9, [r14, #0x28]"); + asm volatile ("str r10, [r14, #0x2c]"); + asm volatile ("str r11, [r14, #0x30]"); + asm volatile ("str r12, [r14, #0x34]"); + + /* increment the pointer */ + asm volatile ("mov r0, #0x40"); + asm volatile ("add r14, r14, r0"); + asm volatile ("mov r0, #0x64"); + asm volatile ("str r14, [r0]"); + + asm volatile ("ldmia sp!, {r14}"); + /* Restore everything we clobbered */ asm volatile ("ldmia sp!, {r0-r12}"); @@ -210,8 +233,8 @@ asm volatile ("OldDataAbort: .word 0x200a3370"); #endif - asm volatile ("Reg0: .word 0"); - asm volatile ("Reg1: .word 0"); + asm volatile ("Rego0: .word 0"); + asm volatile ("Rego1: .word 0"); asm volatile ("DumpOffset: .word 0"); asm volatile ("HandlersEnd: .word 0"); } Modified: cocoboot/trunk/include/cocoboot.rcp =================================================================== --- cocoboot/trunk/include/cocoboot.rcp 2007-07-21 12:34:07 UTC (rev 1193) +++ cocoboot/trunk/include/cocoboot.rcp 2007-07-22 02:47:01 UTC (rev 1194) @@ -33,7 +33,8 @@ END PULLDOWN "Trace" BEGIN - MENUITEM "IRQ trace" MenuItemStartIrqTrace + MENUITEM "Start trace" MenuItemStartIrqTrace + MENUITEM "Dump log" MenuItemDumpTraceLog END END Modified: cocoboot/trunk/include/cocoboot_r.h =================================================================== --- cocoboot/trunk/include/cocoboot_r.h 2007-07-21 12:34:07 UTC (rev 1193) +++ cocoboot/trunk/include/cocoboot_r.h 2007-07-22 02:47:01 UTC (rev 1194) @@ -17,6 +17,7 @@ #define MenuItemDumpMMU 1005 #define MenuItemConsole 1006 #define MenuItemStartIrqTrace 1007 +#define MenuItemDumpTraceLog 1008 #define ErrorAlert 1000 #define InfoAlert 1001 Modified: cocoboot/trunk/m68k/mainform.c =================================================================== --- cocoboot/trunk/m68k/mainform.c 2007-07-21 12:34:07 UTC (rev 1193) +++ cocoboot/trunk/m68k/mainform.c 2007-07-22 02:47:01 UTC (rev 1194) @@ -214,6 +214,56 @@ } } +/* find some random volume to save to */ +UInt16 find_some_vol(void) +{ + UInt32 it; + UInt16 vn = 0; + it = vfsIteratorStart; + VFSVolumeEnumerate (&vn, &it); + return vn; +} + +/* dump our memory trace log to the memory card + * TODO: make this safe when no trace has been run. + */ +void dump_trace_log(void) +{ + FileRef f = 0; + UInt16 vn = find_some_vol(); + UInt32 *log = (UInt32*)EndianFix32(*(UInt32*)(0x68)); + UInt32 *end = (UInt32*)EndianFix32(*(UInt32*)(0x64)); + UInt32 val; + Err err; + char buf[256]; + UInt32 bigbuf[100]; + UInt32 i; + + sprintf(buf, "Log: log=%lx end=%lx blocks=%lx", log, end, end-log); + FrmCustomAlert(InfoAlert, "Dumping...", buf, " "); + err = VFSFileOpen (vn, "/cocoboot.trc", vfsModeWrite | vfsModeCreate, &f); + if (err != errNone) goto error1; + + while (log < end) { + /* lets do a bunch at a time for speed */ + for (i=0; i < sizeof(bigbuf)/sizeof(UInt32) && log < end; i++) { + bigbuf[i] = *log; + log++; + } + err = VFSFileWrite(f, i*sizeof(UInt32), bigbuf, NULL); + if (err != errNone) goto error2; + } + + VFSFileClose (f); + FrmCustomAlert(InfoAlert, "Trace log dumped to /cocoboot.trc.", " ", " "); + return; + +error2: + VFSFileClose (f); +error1: + FrmCustomAlert(InfoAlert, "Error writing to /cocoboot.memtrace.", " ", " "); +} + UInt32 load_parts(int n, char *name, void **image) { /* more ugly code... */ @@ -350,6 +400,9 @@ case MenuItemStartIrqTrace: start_irq_trace(); return true; + case MenuItemDumpTraceLog: + dump_trace_log(); + return true; } return false; } Added: cocoboot/trunk/tools/traceparse.py =================================================================== --- cocoboot/trunk/tools/traceparse.py (rev 0) +++ cocoboot/trunk/tools/traceparse.py 2007-07-22 02:47:01 UTC (rev 1194) @@ -0,0 +1,27 @@ +#!/usr/bin/env python +import struct +import sys +if len(sys.argv) < 2: + print 'Usage: %s cocoboot.trc' % sys.argv[0] + print 'Decodes a raw cocoboot trace dump file' + sys.exit(-1) + +f = file(sys.argv[1], 'rb') +while 1: + data = f.read(16*4) + if not data: break + + words = struct.unpack('<16I', data) + for i, w in zip(range(len(words)), words): + s = str(struct.pack('<I', w)) + if i == 0: + reg = ' ' + elif i == 14: + reg = 'PC ' + elif i == 15: + reg = ' ' + else: + reg = 'r%-2d' % (i-1) + print '%s = %08x %-10d %s' % (reg, w,w, repr(s)) + print '-' * 20 + print Property changes on: cocoboot/trunk/tools/traceparse.py ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bob...@us...> - 2007-07-22 06:54:04
|
Revision: 1197 http://svn.sourceforge.net/hackndev/?rev=1197&view=rev Author: bobofdoom Date: 2007-07-21 23:54:01 -0700 (Sat, 21 Jul 2007) Log Message: ----------- Cocoboot: Added GSM unlock code dumping to info menu. * Note: This does NOT allow you to unlock a locked Treo. It only shows the code from an already unlocked phone. Modified Paths: -------------- cocoboot/trunk/Changelog cocoboot/trunk/include/cocoboot.rcp cocoboot/trunk/include/cocoboot_r.h cocoboot/trunk/m68k/mainform.c Modified: cocoboot/trunk/Changelog =================================================================== --- cocoboot/trunk/Changelog 2007-07-22 02:50:44 UTC (rev 1196) +++ cocoboot/trunk/Changelog 2007-07-22 06:54:01 UTC (rev 1197) @@ -1,3 +1,6 @@ + - Added GSM unlock code to info menu (unlocked GSM Treos only). + - Added basic memory tracing. + version 0.4: - Fixed 'c01d' error introduced in 0.3 on LD, TX etc. - Added reading of a config file. Modified: cocoboot/trunk/include/cocoboot.rcp =================================================================== --- cocoboot/trunk/include/cocoboot.rcp 2007-07-22 02:50:44 UTC (rev 1196) +++ cocoboot/trunk/include/cocoboot.rcp 2007-07-22 06:54:01 UTC (rev 1197) @@ -26,6 +26,7 @@ MENUITEM "LCD registers (PXA only)" MenuItemLCD MENUITEM "LCD test (PXA only)" MenuItemLCDTest MENUITEM "Dump MMU" MenuItemDumpMMU + MENUITEM "GSM Unlock Code" MenuItemGsmCode END PULLDOWN "Tools" BEGIN Modified: cocoboot/trunk/include/cocoboot_r.h =================================================================== --- cocoboot/trunk/include/cocoboot_r.h 2007-07-22 02:50:44 UTC (rev 1196) +++ cocoboot/trunk/include/cocoboot_r.h 2007-07-22 06:54:01 UTC (rev 1197) @@ -18,6 +18,7 @@ #define MenuItemConsole 1006 #define MenuItemStartIrqTrace 1007 #define MenuItemDumpTraceLog 1008 +#define MenuItemGsmCode 1009 #define ErrorAlert 1000 #define InfoAlert 1001 Modified: cocoboot/trunk/m68k/mainform.c =================================================================== --- cocoboot/trunk/m68k/mainform.c 2007-07-22 02:50:44 UTC (rev 1196) +++ cocoboot/trunk/m68k/mainform.c 2007-07-22 06:54:01 UTC (rev 1197) @@ -264,6 +264,24 @@ FrmCustomAlert(InfoAlert, "Error writing to /cocoboot.memtrace.", " ", " "); } +void show_gsm_code(void) +{ + char *buf = 0; + UInt16 len; + char buf2[256]; + int i; + SysGetROMToken(0, 'GoUc', &buf, &len); + if (!buf || len == 0xffff) { + FrmCustomAlert(InfoAlert, "Code not found.", "This option only works on unlocked GSM phones. It does not allow you to unlock a locked phone.", " "); + return; + } + strncpy(buf2, buf, len < 256 ? len : 256); + buf2[len] = 0; + for (i=0; i<len; i++) + buf2[i] -= 13; + FrmCustomAlert(InfoAlert, "GSM unlock code:", buf2, " "); +} + UInt32 load_parts(int n, char *name, void **image) { /* more ugly code... */ @@ -402,7 +420,11 @@ return true; case MenuItemDumpTraceLog: dump_trace_log(); + return true; + case MenuItemGsmCode: + show_gsm_code(); return true; + } return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |