├── .gitignore ├── Makefile ├── README ├── guhl ├── gfmod │ ├── COPYING │ ├── Makefile │ ├── gfmod.c │ ├── gfmod.h │ ├── msm_sdcc.h │ └── proc_comm.h ├── gfree_verify │ ├── Makefile │ ├── gfree_verify.c │ ├── soff_verify.c │ └── soff_verify.h ├── gkmem │ ├── COPYING │ ├── Makefile │ └── gkmem.c ├── incsfree │ ├── COPYING │ ├── Makefile │ ├── embedwpthis.pl │ ├── gfmod.h │ ├── gkmem.h │ ├── gopt.c │ ├── gopt.h │ └── incsfree.c ├── misc_version │ ├── LICENSE │ ├── Makefile │ ├── gopt.c │ ├── gopt.h │ └── misc_version.c ├── p7_soff │ ├── gopt.c │ ├── gopt.h │ ├── p7_s-off.c │ ├── soff_verify.c │ └── soff_verify.h └── vision_wipe_efs │ ├── LICENSE │ ├── Makefile │ ├── README │ └── vision_wipe_efs.c ├── scotty2 ├── Makefile ├── gfree │ ├── LICENSE │ ├── Makefile │ ├── embedwpthis.pl │ ├── gfree.c │ ├── gopt.c │ ├── gopt.h │ ├── md5sum.c │ ├── md5sum.h │ └── wpthis.h ├── msm_sdcc.h ├── pbl │ ├── dumppbl.pl │ └── pbl.pl ├── proc_comm.h ├── psneuter │ ├── make │ ├── psneuter │ ├── psneuter.c │ └── run ├── wpthis.c ├── wpthis.h └── wpthis.ko ├── tmzt ├── Makefile ├── foreign │ ├── mod1.c │ ├── mod10.c │ ├── mod11.c │ ├── mod12.c │ ├── mod13.c │ ├── mod14.c │ ├── mod15.c │ ├── mod16.c │ ├── mod18.c │ ├── mod2.c │ ├── mod3.c │ ├── mod4.c │ ├── mod5.c │ ├── mod6.c │ ├── mod7.c │ ├── mod8.c │ ├── mod9.c │ └── sysfind.c ├── g2 │ ├── blkops1.c │ ├── bouncepwrreg1.c │ ├── bouncereg1.c │ ├── debugsmi1.c │ ├── hostoff1.c │ ├── hostoff2.c │ ├── hostoff3.c │ ├── rereg1.c │ ├── rereg2.c │ ├── resume1.c │ ├── smidump1.c │ ├── suspend1.c │ ├── sysdentry17.c │ ├── unreg1.c │ └── unreg2.c ├── rhod500 │ ├── Makefile │ └── speakeroff1.c └── vision │ ├── Makefile │ ├── gp12off1.c │ ├── gp12off2.c │ ├── gpgenoff1.c │ ├── gpio88onoff1.c │ └── pm │ ├── Makefile │ ├── cache1.S │ ├── idle1.S │ ├── pm1.c │ ├── pm2.c │ ├── pm3.c │ ├── pm4.c │ ├── pm5.c │ ├── pm6.c │ ├── pmmod1-panic-1.txt │ ├── pmmod2-panic-1.txt │ ├── pmmod3-output-1.txt │ ├── pmmod3-output-2.txt │ ├── pmmod4-output-1.txt │ ├── pmmod5-hang-1.txt │ └── smd_private1.h └── userspace ├── test1 └── test1.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.o.d 3 | *.mod.c 4 | Module.symvers 5 | .tmp_versions 6 | .*.cmd 7 | modules.order 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | all: modules 4 | 5 | modules: 6 | $(MAKE) -C $(KDIR) M=$(PWD) modules $@ 7 | 8 | clean: 9 | $(MAKE) -C $(KDIR) M=$(PWD) clean 10 | 11 | .PHONY: all clean 12 | 13 | #obj-m += tmzt/g2/suspend1.o 14 | obj-m += tmzt/g2/resume1.o 15 | obj-m += tmzt/g2/unreg2.o 16 | obj-m += tmzt/g2/rereg1.o 17 | obj-m += tmzt/g2/bouncereg1.o 18 | obj-m += tmzt/g2/bouncepwrreg1.o 19 | obj-m += tmzt/g2/smidump1.o 20 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | Welcome to the g2root arm foreign/hostile kernel exploration toolkit. 3 | 4 | syntax: 5 | CROSS_COMPILE=/opt/arm-2008q3/bin/arm-none-eabi- ARCH=arm make KDIR=[KERNEL SOURCE FROM WIKI] [clean|DOSTUFF=0|DOSTUFF=1] 6 | 7 | 8 | Building the toolkit 9 | 10 | You'll need an ARM toolchain. The following assumes you're using the 11 | CodeSourcery tools installed to /opt/arm-2008q3; otherwise, change the 12 | CROSS_COMPILE variable. 13 | 14 | $ git clone git://codeaurora.org/kernel/experimental.git kernel-source 15 | $ git clone git://gist.github.com/619505.git module-source 16 | $ cd kernel-source && git checkout origin/aosp/android-msm-2.6.32-7x30-wip 17 | & # The follow commands may need to be run with CROSS_COMPILE=/opt/arm-2008q3/b 18 | $ ARCH=arm make surf7x30_defconfig 19 | $ ARCH=arm make oldconfig 20 | 21 | At this point you'll need to edit .config to match below: 22 | 23 | CONFIG_LOCALVERSION="-g814e0a1 " 24 | CONFIG_LOCALVERSION_AUTO=n 25 | 26 | Modify Makefile so it starts with this: 27 | 28 | VERSION = 2 29 | PATCHLEVEL = 6 30 | SUBLEVEL = 32 31 | EXTRAVERSION = .17 32 | 33 | Continue as follows: 34 | 35 | $ ARCH=arm make prepare 36 | $ ARCH=arm make scripts 37 | $ cd .. 38 | 39 | taken from: 40 | http://forum.xda-developers.com/wiki/index.php?title=HTC_Vision#Building_a_basic_kernel_module 41 | (thanks FatTire and dpw13_) 42 | 43 | then 44 | 45 | $ # The following line assumes the CodeSourcery cross-compiler 46 | 47 | $ CROSS_COMPILE=/opt/arm-2008q3/bin/arm-none-eabi- ARCH=arm make KDIR=[KERNEL SOURCE FROM WIKI] DOSTUFF=0 48 | 49 | Copy to a place on your G2 (or other device). 50 | 51 | On the G2 (in a root shell): 52 | 53 | g2# dmesg -c 54 | g2# rmmod module.ko 55 | g2# insmod module.ko 56 | g2# dmesg 57 | 58 | Test and make sure it doesn't blow up and the printed (in dmesg) addresses look sane (not 0 or fffx whatever) Then proceed to build the working version: 59 | 60 | $ CROSS_COMPILE=/opt/arm-2008q3/bin/arm-none-eabi- ARCH=arm make KDIR=[KERNEL SOURCE FROM WIKI] clean 61 | 62 | $ CROSS_COMPILE=/opt/arm-2008q3/bin/arm-none-eabi- ARCH=arm make KDIR=[KERNEL SOURCE FROM WIKI] DOSTUFF=1 63 | 64 | Now follow the same instructions to test. 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /guhl/gfmod/Makefile: -------------------------------------------------------------------------------- 1 | ifneq ($(KERNELRELEASE),) 2 | obj-m := gfmod.o 3 | 4 | else 5 | KDIR := /lib/modules/2.6.35.9-g3052235/build 6 | # KDIR := /lib/modules/2.6.35.13-cyanogenmod+/build 7 | # KDIR := /lib/modules/2.6.35.1399999999+/build 8 | PWD := $(shell pwd) 9 | default: 10 | $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules 11 | endif 12 | 13 | -------------------------------------------------------------------------------- /guhl/gfmod/gfmod.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 Guhl 3 | This work is very much based on the module wpthis by scotty2 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef GFMOD_H_ 20 | #define GFMOD_H_ 21 | 22 | #define MOD_RET_OK -ENOSYS 23 | #define MOD_RET_FAILINIT -ENOTEMPTY 24 | #define MOD_RET_FAILWP -ELOOP 25 | #define MOD_RET_FAIL -ENOMSG 26 | #define MOD_RET_NONEED -EXFULL 27 | 28 | #define GFMOD_DODEBUG 1 29 | #if GFMOD_DODEBUG 30 | #define ONDEBUG(x) x 31 | #else 32 | #define ONDEBUG(x) 33 | #endif 34 | 35 | #define dmesg printk("gfmod: "); printk 36 | 37 | #define get_or_die(target, source) \ 38 | target = source; \ 39 | if(!target) \ 40 | { \ 41 | dmesg("%s = %s == null.\n", #source, #target); \ 42 | goto out; \ 43 | } \ 44 | else if(IS_ERR(target)) \ 45 | { \ 46 | dmesg("%s gave us an error for %s: %lu\n", #source, #target, PTR_ERR(target)); \ 47 | goto out; \ 48 | } 49 | 50 | 51 | 52 | 53 | 54 | #define print_dev(device) \ 55 | dmesg("%s: 0x%.8x (%s)\n", #device, (unsigned int)device, dev_name(device)) 56 | 57 | #define print_clock(clock) \ 58 | dmesg("%s: 0x%.8x (%lu)\n", #clock, (unsigned int)clock, clk_get_rate(clock)); 59 | 60 | #define assert(eval) \ 61 | if(!(eval)) \ 62 | { \ 63 | dmesg("assertion failed! !(%s)\n", #eval); \ 64 | goto out; \ 65 | } 66 | 67 | 68 | #endif /* GFMOD_H_ */ 69 | -------------------------------------------------------------------------------- /guhl/gfmod/proc_comm.h: -------------------------------------------------------------------------------- 1 | /* arch/arm/mach-msm/proc_comm.h 2 | * 3 | * Copyright (c) 2007 QUALCOMM Incorporated 4 | * 5 | * This software is licensed under the terms of the GNU General Public 6 | * License version 2, as published by the Free Software Foundation, and 7 | * may be copied, distributed, and modified under those terms. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | */ 15 | 16 | #ifndef _ARCH_ARM_MACH_MSM_PROC_COMM_H_ 17 | #define _ARCH_ARM_MACH_MSM_PROC_COMM_H_ 18 | 19 | enum { 20 | PCOM_CMD_IDLE = 0x0, 21 | PCOM_CMD_DONE, 22 | PCOM_RESET_APPS, 23 | PCOM_RESET_CHIP, 24 | PCOM_CONFIG_NAND_MPU, 25 | PCOM_CONFIG_USB_CLKS, 26 | PCOM_GET_POWER_ON_STATUS, 27 | PCOM_GET_WAKE_UP_STATUS, 28 | PCOM_GET_BATT_LEVEL, 29 | PCOM_CHG_IS_CHARGING, 30 | PCOM_POWER_DOWN, 31 | PCOM_USB_PIN_CONFIG, 32 | PCOM_USB_PIN_SEL, 33 | PCOM_SET_RTC_ALARM, 34 | PCOM_NV_READ, 35 | PCOM_NV_WRITE, 36 | PCOM_GET_UUID_HIGH, 37 | PCOM_GET_UUID_LOW, 38 | PCOM_GET_HW_ENTROPY, 39 | PCOM_RPC_GPIO_TLMM_CONFIG_REMOTE, 40 | PCOM_CLKCTL_RPC_ENABLE, 41 | PCOM_CLKCTL_RPC_DISABLE, 42 | PCOM_CLKCTL_RPC_RESET, 43 | PCOM_CLKCTL_RPC_SET_FLAGS, 44 | PCOM_CLKCTL_RPC_SET_RATE, 45 | PCOM_CLKCTL_RPC_MIN_RATE, 46 | PCOM_CLKCTL_RPC_MAX_RATE, 47 | PCOM_CLKCTL_RPC_RATE, 48 | PCOM_CLKCTL_RPC_PLL_REQUEST, 49 | PCOM_CLKCTL_RPC_ENABLED, 50 | PCOM_VREG_SWITCH, 51 | PCOM_VREG_SET_LEVEL, 52 | PCOM_GPIO_TLMM_CONFIG_GROUP, 53 | PCOM_GPIO_TLMM_UNCONFIG_GROUP, 54 | PCOM_NV_WRITE_BYTES_4_7, 55 | PCOM_CONFIG_DISP, 56 | PCOM_GET_FTM_BOOT_COUNT, 57 | PCOM_RPC_GPIO_TLMM_CONFIG_EX, 58 | PCOM_PM_MPP_CONFIG, 59 | PCOM_GPIO_IN, 60 | PCOM_GPIO_OUT, 61 | PCOM_RESET_MODEM, 62 | PCOM_RESET_CHIP_IMM, 63 | PCOM_PM_VID_EN, 64 | PCOM_VREG_PULLDOWN, 65 | PCOM_GET_MODEM_VERSION, 66 | PCOM_CLK_REGIME_SEC_RESET, 67 | PCOM_CLK_REGIME_SEC_RESET_ASSERT, 68 | PCOM_CLK_REGIME_SEC_RESET_DEASSERT, 69 | PCOM_CLK_REGIME_SEC_PLL_REQUEST_WRP, 70 | PCOM_CLK_REGIME_SEC_ENABLE, 71 | PCOM_CLK_REGIME_SEC_DISABLE, 72 | PCOM_CLK_REGIME_SEC_IS_ON, 73 | PCOM_CLK_REGIME_SEC_SEL_CLK_INV, 74 | PCOM_CLK_REGIME_SEC_SEL_CLK_SRC, 75 | PCOM_CLK_REGIME_SEC_SEL_CLK_DIV, 76 | PCOM_CLK_REGIME_SEC_ICODEC_CLK_ENABLE, 77 | PCOM_CLK_REGIME_SEC_ICODEC_CLK_DISABLE, 78 | PCOM_CLK_REGIME_SEC_SEL_SPEED, 79 | PCOM_CLK_REGIME_SEC_CONFIG_GP_CLK_WRP, 80 | PCOM_CLK_REGIME_SEC_CONFIG_MDH_CLK_WRP, 81 | PCOM_CLK_REGIME_SEC_USB_XTAL_ON, 82 | PCOM_CLK_REGIME_SEC_USB_XTAL_OFF, 83 | PCOM_CLK_REGIME_SEC_SET_QDSP_DME_MODE, 84 | PCOM_CLK_REGIME_SEC_SWITCH_ADSP_CLK, 85 | PCOM_CLK_REGIME_SEC_GET_MAX_ADSP_CLK_KHZ, 86 | PCOM_CLK_REGIME_SEC_GET_I2C_CLK_KHZ, 87 | PCOM_CLK_REGIME_SEC_MSM_GET_CLK_FREQ_KHZ, 88 | PCOM_CLK_REGIME_SEC_SEL_VFE_SRC, 89 | PCOM_CLK_REGIME_SEC_MSM_SEL_CAMCLK, 90 | PCOM_CLK_REGIME_SEC_MSM_SEL_LCDCLK, 91 | PCOM_CLK_REGIME_SEC_VFE_RAIL_OFF, 92 | PCOM_CLK_REGIME_SEC_VFE_RAIL_ON, 93 | PCOM_CLK_REGIME_SEC_GRP_RAIL_OFF, 94 | PCOM_CLK_REGIME_SEC_GRP_RAIL_ON, 95 | PCOM_CLK_REGIME_SEC_VDC_RAIL_OFF, 96 | PCOM_CLK_REGIME_SEC_VDC_RAIL_ON, 97 | PCOM_CLK_REGIME_SEC_LCD_CTRL, 98 | PCOM_CLK_REGIME_SEC_REGISTER_FOR_CPU_RESOURCE, 99 | PCOM_CLK_REGIME_SEC_DEREGISTER_FOR_CPU_RESOURCE, 100 | PCOM_CLK_REGIME_SEC_RESOURCE_REQUEST_WRP, 101 | PCOM_CLK_REGIME_MSM_SEC_SEL_CLK_OWNER, 102 | PCOM_CLK_REGIME_SEC_DEVMAN_REQUEST_WRP, 103 | PCOM_GPIO_CONFIG, 104 | PCOM_GPIO_CONFIGURE_GROUP, 105 | PCOM_GPIO_TLMM_SET_PORT, 106 | PCOM_GPIO_TLMM_CONFIG_EX, 107 | PCOM_SET_FTM_BOOT_COUNT, 108 | PCOM_RESERVED0, 109 | PCOM_RESERVED1, 110 | PCOM_CUSTOMER_CMD1, 111 | PCOM_CUSTOMER_CMD2, 112 | PCOM_CUSTOMER_CMD3, 113 | PCOM_CLK_REGIME_ENTER_APPSBL_CHG_MODE, 114 | PCOM_CLK_REGIME_EXIT_APPSBL_CHG_MODE, 115 | PCOM_CLK_REGIME_SEC_RAIL_DISABLE, 116 | PCOM_CLK_REGIME_SEC_RAIL_ENABLE, 117 | PCOM_CLK_REGIME_SEC_RAIL_CONTROL, 118 | PCOM_SET_SW_WATCHDOG_STATE, 119 | PCOM_PM_MPP_CONFIG_DIGITAL_INPUT, 120 | PCOM_PM_MPP_CONFIG_I_SINK, 121 | PCOM_RESERVED_101, 122 | PCOM_MSM_HSUSB_PHY_RESET, 123 | PCOM_GET_BATT_MV_LEVEL, 124 | PCOM_CHG_USB_IS_PC_CONNECTED, 125 | PCOM_CHG_USB_IS_CHARGER_CONNECTED, 126 | PCOM_CHG_USB_IS_DISCONNECTED, 127 | PCOM_CHG_USB_IS_AVAILABLE, 128 | PCOM_CLK_REGIME_SEC_MSM_SEL_FREQ, 129 | PCOM_CLK_REGIME_SEC_SET_PCLK_AXI_POLICY, 130 | PCOM_CLKCTL_RPC_RESET_ASSERT, 131 | PCOM_CLKCTL_RPC_RESET_DEASSERT, 132 | PCOM_CLKCTL_RPC_RAIL_ON, 133 | PCOM_CLKCTL_RPC_RAIL_OFF, 134 | PCOM_CLKCTL_RPC_RAIL_ENABLE, 135 | PCOM_CLKCTL_RPC_RAIL_DISABLE, 136 | PCOM_CLKCTL_RPC_RAIL_CONTROL, 137 | PCOM_CLKCTL_RPC_MIN_MSMC1, 138 | #if defined(CONFIG_QCT_LTE) 139 | PCOM_CLKCTL_RPC_SRC_REQUEST, 140 | PCOM_NPA_INIT, 141 | PCOM_NPA_ISSUE_REQUIRED_REQUEST, 142 | #else 143 | PCOM_NUM_CMDS, 144 | #endif 145 | }; 146 | 147 | #if defined(CONFIG_QCT_LTE) 148 | enum { 149 | PCOM_OEM_FIRST_CMD = 0x10000000, 150 | PCOM_OEM_TEST_CMD = PCOM_OEM_FIRST_CMD, 151 | 152 | /* add OEM PROC COMM commands here */ 153 | 154 | PCOM_OEM_LAST = PCOM_OEM_TEST_CMD, 155 | }; 156 | #endif 157 | 158 | enum { 159 | PCOM_INVALID_STATUS = 0x0, 160 | PCOM_READY, 161 | PCOM_CMD_RUNNING, 162 | PCOM_CMD_SUCCESS, 163 | PCOM_CMD_FAIL, 164 | PCOM_CMD_FAIL_FALSE_RETURNED, 165 | PCOM_CMD_FAIL_CMD_OUT_OF_BOUNDS_SERVER, 166 | PCOM_CMD_FAIL_CMD_OUT_OF_BOUNDS_CLIENT, 167 | PCOM_CMD_FAIL_CMD_UNREGISTERED, 168 | PCOM_CMD_FAIL_CMD_LOCKED, 169 | PCOM_CMD_FAIL_SERVER_NOT_YET_READY, 170 | PCOM_CMD_FAIL_BAD_DESTINATION, 171 | PCOM_CMD_FAIL_SERVER_RESET, 172 | PCOM_CMD_FAIL_SMSM_NOT_INIT, 173 | PCOM_CMD_FAIL_PROC_COMM_BUSY, 174 | PCOM_CMD_FAIL_PROC_COMM_NOT_INIT, 175 | 176 | }; 177 | 178 | /* List of VREGs that support the Pull Down Resistor setting. */ 179 | enum vreg_pdown_id { 180 | PM_VREG_PDOWN_MSMA_ID, 181 | PM_VREG_PDOWN_MSMP_ID, 182 | PM_VREG_PDOWN_MSME1_ID, /* Not supported in Panoramix */ 183 | PM_VREG_PDOWN_MSMC1_ID, /* Not supported in PM6620 */ 184 | PM_VREG_PDOWN_MSMC2_ID, /* Supported in PM7500 only */ 185 | PM_VREG_PDOWN_GP3_ID, /* Supported in PM7500 only */ 186 | PM_VREG_PDOWN_MSME2_ID, /* Supported in PM7500 and Panoramix only */ 187 | PM_VREG_PDOWN_GP4_ID, /* Supported in PM7500 only */ 188 | PM_VREG_PDOWN_GP1_ID, /* Supported in PM7500 only */ 189 | PM_VREG_PDOWN_TCXO_ID, 190 | PM_VREG_PDOWN_PA_ID, 191 | PM_VREG_PDOWN_RFTX_ID, 192 | PM_VREG_PDOWN_RFRX1_ID, 193 | PM_VREG_PDOWN_RFRX2_ID, 194 | PM_VREG_PDOWN_SYNT_ID, 195 | PM_VREG_PDOWN_WLAN_ID, 196 | PM_VREG_PDOWN_USB_ID, 197 | PM_VREG_PDOWN_MMC_ID, 198 | PM_VREG_PDOWN_RUIM_ID, 199 | PM_VREG_PDOWN_MSMC0_ID, /* Supported in PM6610 only */ 200 | PM_VREG_PDOWN_GP2_ID, /* Supported in PM7500 only */ 201 | PM_VREG_PDOWN_GP5_ID, /* Supported in PM7500 only */ 202 | PM_VREG_PDOWN_GP6_ID, /* Supported in PM7500 only */ 203 | PM_VREG_PDOWN_RF_ID, 204 | PM_VREG_PDOWN_RF_VCO_ID, 205 | PM_VREG_PDOWN_MPLL_ID, 206 | PM_VREG_PDOWN_S2_ID, 207 | PM_VREG_PDOWN_S3_ID, 208 | PM_VREG_PDOWN_RFUBM_ID, 209 | 210 | /* new for HAN */ 211 | PM_VREG_PDOWN_RF1_ID, 212 | PM_VREG_PDOWN_RF2_ID, 213 | PM_VREG_PDOWN_RFA_ID, 214 | PM_VREG_PDOWN_CDC2_ID, 215 | PM_VREG_PDOWN_RFTX2_ID, 216 | PM_VREG_PDOWN_USIM_ID, 217 | PM_VREG_PDOWN_USB2P6_ID, 218 | PM_VREG_PDOWN_USB3P3_ID, 219 | PM_VREG_PDOWN_INVALID_ID, 220 | 221 | /* backward compatible enums only */ 222 | PM_VREG_PDOWN_CAM_ID = PM_VREG_PDOWN_GP1_ID, 223 | PM_VREG_PDOWN_MDDI_ID = PM_VREG_PDOWN_GP2_ID, 224 | PM_VREG_PDOWN_RUIM2_ID = PM_VREG_PDOWN_GP3_ID, 225 | PM_VREG_PDOWN_AUX_ID = PM_VREG_PDOWN_GP4_ID, 226 | PM_VREG_PDOWN_AUX2_ID = PM_VREG_PDOWN_GP5_ID, 227 | PM_VREG_PDOWN_BT_ID = PM_VREG_PDOWN_GP6_ID, 228 | 229 | PM_VREG_PDOWN_MSME_ID = PM_VREG_PDOWN_MSME1_ID, 230 | PM_VREG_PDOWN_MSMC_ID = PM_VREG_PDOWN_MSMC1_ID, 231 | PM_VREG_PDOWN_RFA1_ID = PM_VREG_PDOWN_RFRX2_ID, 232 | PM_VREG_PDOWN_RFA2_ID = PM_VREG_PDOWN_RFTX2_ID, 233 | PM_VREG_PDOWN_XO_ID = PM_VREG_PDOWN_TCXO_ID 234 | }; 235 | 236 | enum { 237 | PCOM_CLKRGM_APPS_RESET_USB_PHY = 34, 238 | PCOM_CLKRGM_APPS_RESET_USBH = 37, 239 | }; 240 | 241 | /* gpio info for PCOM_RPC_GPIO_TLMM_CONFIG_EX */ 242 | 243 | #define GPIO_ENABLE 0 244 | #define GPIO_DISABLE 1 245 | 246 | #define GPIO_INPUT 0 247 | #define GPIO_OUTPUT 1 248 | 249 | #define GPIO_NO_PULL 0 250 | #define GPIO_PULL_DOWN 1 251 | #define GPIO_KEEPER 2 252 | #define GPIO_PULL_UP 3 253 | 254 | #define GPIO_2MA 0 255 | #define GPIO_4MA 1 256 | #define GPIO_6MA 2 257 | #define GPIO_8MA 3 258 | #define GPIO_10MA 4 259 | #define GPIO_12MA 5 260 | #define GPIO_14MA 6 261 | #define GPIO_16MA 7 262 | 263 | #define PCOM_GPIO_CFG(gpio, func, dir, pull, drvstr) \ 264 | ((((gpio) & 0x3FF) << 4) | \ 265 | ((func) & 0xf) | \ 266 | (((dir) & 0x1) << 14) | \ 267 | (((pull) & 0x3) << 15) | \ 268 | (((drvstr) & 0xF) << 17)) 269 | 270 | int msm_proc_comm(unsigned cmd, unsigned *data1, unsigned *data2); 271 | 272 | #endif 273 | -------------------------------------------------------------------------------- /guhl/gfree_verify/Makefile: -------------------------------------------------------------------------------- 1 | VERSION = 0.01 2 | CC = /usr/bin/gcc 3 | CFLAGS = -Wall -g -D_REENTRANT -DVERSION=\"$(VERSION)\" 4 | LDFLAGS = -lm 5 | RM = rm -f 6 | 7 | TRG = gfree_verify 8 | OBJ = soff_verify.o gfree_verify.o 9 | 10 | all: $(OBJ) 11 | $(CC) $(CFLAGS) -o $(TRG) $(OBJ) $(LDFLAGS) 12 | 13 | %.o: %.c 14 | $(CC) $(CFLAGS) -c $< 15 | 16 | clean: 17 | $(RM) *.o 18 | $(RM) *.d 19 | $(RM) gfree_verify 20 | -------------------------------------------------------------------------------- /guhl/gfree_verify/gfree_verify.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2010 Guhl 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "soff_verify.h" 22 | 23 | #define VERSION_A 0 24 | #define VERSION_B 01 25 | 26 | int main() { 27 | if (verify_init_device()!=0){ 28 | fprintf( stderr, "Error: verify could not initialize device!"); 29 | exit (-1); 30 | } 31 | if (verify_init_modem()!=0){ 32 | fprintf( stderr, "Error: verify could not initialize radio!"); 33 | exit (-1); 34 | } 35 | verify_set_verbose(); 36 | verify_cid(); 37 | verify_secu_flag(); 38 | verify_simlock(); 39 | verify_close_device(); 40 | exit (0); 41 | } 42 | -------------------------------------------------------------------------------- /guhl/gfree_verify/soff_verify.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2010 Guhl 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include "soff_verify.h" 19 | 20 | int verify_init_device(){ 21 | fd_radio = 0; 22 | fd_radio = open(MODEMDEVICE, O_RDWR | O_NOCTTY ); 23 | if (fd_radio <0) { 24 | fprintf( stderr, "Error: could not open modem device: %s\n",MODEMDEVICE); 25 | return -1; 26 | } 27 | tcgetattr(fd_radio,&oldtio); // save current serial port settings 28 | memset(&newtio, 0x00, sizeof(newtio)); // clear struct for new port settings 29 | 30 | //get the current options 31 | tcgetattr(fd_radio, &newtio); 32 | 33 | // set raw input, 1 second timeout 34 | newtio.c_cflag |= (CLOCAL | CREAD); 35 | newtio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG ); 36 | newtio.c_oflag &= ~OPOST; 37 | newtio.c_cc[VMIN] = 0; 38 | newtio.c_cc[VTIME] = 10; 39 | 40 | // clean the modem line and activate the settings for the port 41 | tcflush(fd_radio, TCIFLUSH); 42 | tcsetattr(fd_radio,TCSANOW,&newtio); 43 | 44 | return 0; 45 | } 46 | 47 | int verify_init_modem() { 48 | char buffer[255]; // Input buffer 49 | char *bufptr; // Current char in buffer 50 | int nbytes; // Number of bytes read 51 | int tries; // Number of tries so far 52 | 53 | for (tries = 0; tries < 3; tries ++) { 54 | // send an AT command followed by a CR 55 | if (write(fd_radio, "AT\r", 3) < 3) 56 | continue; 57 | // read characters into our string buffer until we get a CR or NL 58 | bufptr = buffer; 59 | while ((nbytes = read(fd_radio, bufptr, buffer + sizeof(buffer) - bufptr - 1)) > 0) { 60 | bufptr += nbytes; 61 | if (bufptr[-1] == '\n' || bufptr[-1] == '\r') 62 | break; 63 | } 64 | // nul terminate the string and see if we got an OK response */ 65 | *bufptr = '\0'; 66 | if ((strncmp(buffer, "0", 1) == 0) || (strncmp(buffer, "\r\nOK", 4) == 0)) 67 | return (0); 68 | } 69 | return (-1); 70 | } 71 | 72 | int verify_set_verbose() { 73 | char buffer[255]; // Input buffer 74 | char *bufptr; // Current char in buffer 75 | int nbytes; // Number of bytes read 76 | int tries; // Number of tries so far 77 | 78 | for (tries = 0; tries < 3; tries ++) { 79 | // send an ATV1 command followed by a CR 80 | if (write(fd_radio, "ATV1\r", 5) < 5) 81 | continue; 82 | // read characters into our string buffer until we get a CR or NL 83 | bufptr = buffer; 84 | while ((nbytes = read(fd_radio, bufptr, buffer + sizeof(buffer) - bufptr - 1)) > 0) { 85 | bufptr += nbytes; 86 | if (bufptr[-1] == '\n' || bufptr[-1] == '\r') 87 | break; 88 | } 89 | // nul terminate the string and see if we got an OK response */ 90 | *bufptr = '\0'; 91 | if (strncmp(buffer, "\r\nOK", 4) == 0) 92 | return (0); 93 | } 94 | return (-1); 95 | } 96 | 97 | int verify_secu_flag() { 98 | char buffer[255]; // Input buffer 99 | char *bufptr; // Current char in buffer 100 | int nbytes; // Number of bytes read 101 | int tries; // Number of tries so far 102 | 103 | for (tries = 0; tries < 3; tries ++) { 104 | // send an ATV1 command followed by a CR 105 | if (write(fd_radio, "AT@SIMLOCK?AA\r", 15) < 15) 106 | continue; 107 | // read characters into our string buffer until we get a CR or NL 108 | bufptr = buffer; 109 | while ((nbytes = read(fd_radio, bufptr, buffer + sizeof(buffer) - bufptr - 1)) > 0) { 110 | bufptr += nbytes; 111 | if (bufptr[-1] == '\n' || bufptr[-1] == '\r') 112 | break; 113 | } 114 | // nul terminate the string and see if we got an OK response */ 115 | *bufptr = '\0'; 116 | fprintf( stdout, "gfree verify_secu_flag returned: %s\n",buffer); 117 | if (strncmp(buffer, "\r\n@secu_flag: 0", 15) == 0) 118 | return (0); 119 | } 120 | return (-1); 121 | } 122 | 123 | void verify_cid() { 124 | char buffer[255]; // Input buffer 125 | char *bufptr; // Current char in buffer 126 | int nbytes; // Number of bytes read 127 | int tries; // Number of tries so far 128 | 129 | for (tries = 0; tries < 3; tries ++) { 130 | // send an ATV1 command followed by a CR 131 | if (write(fd_radio, "AT@CID?\r", 8) < 8) 132 | continue; 133 | // read characters into our string buffer until we get a CR or NL 134 | bufptr = buffer; 135 | while ((nbytes = read(fd_radio, bufptr, buffer + sizeof(buffer) - bufptr - 1)) > 0) { 136 | bufptr += nbytes; 137 | if (bufptr[-1] == '\n' || bufptr[-1] == '\r') 138 | break; 139 | } 140 | // nul terminate the string and see if we got an OK response */ 141 | *bufptr = '\0'; 142 | fprintf( stdout, "gfree verify_cid returned: %s\n",buffer); 143 | return; 144 | } 145 | } 146 | 147 | int verify_simlock() { 148 | char buffer[255]; // Input buffer 149 | char *bufptr; // Current char in buffer 150 | int nbytes; // Number of bytes read 151 | int tries; // Number of tries so far 152 | 153 | for (tries = 0; tries < 3; tries ++) { 154 | // send an ATV1 command followed by a CR 155 | if (write(fd_radio, "AT@SIMLOCK?40\r", 15) < 15) 156 | continue; 157 | // read characters into our string buffer until we get a CR or NL 158 | bufptr = buffer; 159 | while ((nbytes = read(fd_radio, bufptr, buffer + sizeof(buffer) - bufptr - 1)) > 0) { 160 | bufptr += nbytes; 161 | if (bufptr[-1] == '\n' || bufptr[-1] == '\r') 162 | break; 163 | } 164 | // nul terminate the string and see if we got an OK response */ 165 | *bufptr = '\0'; 166 | fprintf( stdout, "gfree verify_simlock returned: %s\n",buffer); 167 | if (strncmp(buffer, "\r\n@SIMLOCK= 00", 14) == 0) 168 | return (0); 169 | } 170 | return (-1); 171 | } 172 | 173 | int verify_close_device() { 174 | // restore the old port settings 175 | tcsetattr(fd_radio,TCSANOW,&oldtio); 176 | close(fd_radio); 177 | return 0; 178 | } 179 | -------------------------------------------------------------------------------- /guhl/gfree_verify/soff_verify.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2010 Guhl 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #ifndef SOFF_VERIFY_H_ 19 | #define SOFF_VERIFY_H_ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #define MODEMDEVICE "/dev/smd0" 31 | #define BAUDRATE B38400 32 | 33 | int fd_radio; 34 | struct termios oldtio,newtio; 35 | 36 | char *squeeze(char *str); 37 | int verify_init_device(); 38 | int verify_init_modem(); 39 | int verify_set_verbose(); 40 | int verify_secu_flag(); 41 | void verify_cid(); 42 | int verify_simlock(); 43 | int verify_close_device(); 44 | 45 | #endif /* SOFF_VERIFY_H_ */ 46 | -------------------------------------------------------------------------------- /guhl/gkmem/Makefile: -------------------------------------------------------------------------------- 1 | ifneq ($(KERNELRELEASE),) 2 | obj-m := gkmem.o 3 | 4 | else 5 | KDIR := /lib/modules/2.6.35.9-g3052235/build 6 | PWD := $(shell pwd) 7 | 8 | default: 9 | $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules 10 | endif 11 | 12 | -------------------------------------------------------------------------------- /guhl/incsfree/Makefile: -------------------------------------------------------------------------------- 1 | VERSION = 0.8 2 | CC = /usr/bin/arm-linux-gnueabi-gcc 3 | CFLAGS = -Wall -g -D_REENTRANT -DVERSION=\"$(VERSION)\" 4 | INCDIR = -I/usr/arm-linux-gnueabi/usr/include/ -I. 5 | LIBDIR = /usr/arm-linux-gnueabi/lib/ 6 | LDFLAGS = -L$(LIBDIR) -static 7 | RM = rm -f 8 | 9 | TRG = incsfree 10 | OBJ = gopt.o incsfree.o 11 | 12 | all: $(OBJ) 13 | $(CC) $(CFLAGS) $(INCDIR) -o $(TRG) $(OBJ) $(LDFLAGS) 14 | 15 | %.o: %.c 16 | $(CC) $(CFLAGS) -c $< 17 | 18 | clean: 19 | $(RM) *.o 20 | $(RM) *.d 21 | $(RM) incsfree 22 | 23 | -------------------------------------------------------------------------------- /guhl/incsfree/embedwpthis.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | $/ = undef; 7 | 8 | if(!open(GFMOD_KO, "../gfmod/gfmod.ko")) 9 | { 10 | print STDERR "Failed to open gfmod.ko\n"; 11 | exit 1; 12 | } 13 | 14 | if(!open(GFMOD_HEADER, ">", "gfmod.h")) 15 | { 16 | print STDERR "Failed to open gfmod.h\n"; 17 | exit 1; 18 | } 19 | 20 | my $gfmod_ko = ; 21 | my @gfmod_koArray = unpack('C*', $gfmod_ko ); 22 | 23 | print GFMOD_HEADER "#include \n"; 24 | print GFMOD_HEADER "static uint8_t gfmod_ko[] = {" . join(', ', @gfmod_koArray), "};\n"; 25 | 26 | if(!open(GKMEM_KO, "../gkmem/gkmem.ko")) 27 | { 28 | print STDERR "Failed to open gkmem.ko\n"; 29 | exit 1; 30 | } 31 | 32 | if(!open(GKMEM_HEADER, ">", "gkmem.h")) 33 | { 34 | print STDERR "Failed to open gkmem.h\n"; 35 | exit 1; 36 | } 37 | 38 | my $gkmem_ko = ; 39 | my @gkmem_koArray = unpack('C*', $gkmem_ko ); 40 | 41 | print GKMEM_HEADER "#include \n"; 42 | print GKMEM_HEADER "static uint8_t gkmem_ko[] = {" . join(', ', @gkmem_koArray), "};\n"; 43 | -------------------------------------------------------------------------------- /guhl/incsfree/gopt.h: -------------------------------------------------------------------------------- 1 | /* gopt.h version 8.1: tom.viza@gmail.com PUBLIC DOMAIN 2003-8 */ 2 | /* 3 | I, Tom Vajzovic, am the author of this software and its documentation and 4 | permanently abandon all copyright and other intellectual property rights in 5 | them, including the right to be identified as the author. 6 | 7 | I am fairly certain that this software does what the documentation says it 8 | does, but I cannot guarantee that it does, or that it does what you think it 9 | should, and I cannot guarantee that it will not have undesirable side effects. 10 | 11 | You are free to use, modify and distribute this software as you please, but 12 | you do so at your own risk. If you remove or hide this warning then you are 13 | responsible for any problems encountered by people that you make the software 14 | available to. 15 | 16 | Before modifying or distributing this software I ask that you would please 17 | read http://www.purposeful.co.uk/tfl/ 18 | */ 19 | 20 | #ifndef GOPT_H_INCLUDED 21 | #define GOPT_H_INCLUDED 22 | 23 | #define GOPT_ONCE 0 24 | #define GOPT_REPEAT 1 25 | #define GOPT_NOARG 0 26 | #define GOPT_ARG 2 27 | 28 | #define gopt_start(...) (const void*)( const struct { int k; int f; const char *s; const char*const*l; }[]){ __VA_ARGS__, {0}} 29 | #define gopt_option(k,f,s,l) { k, f, s, l } 30 | #define gopt_shorts( ... ) (const char*)(const char[]){ __VA_ARGS__, 0 } 31 | #define gopt_longs( ... ) (const char**)(const char*[]){ __VA_ARGS__, NULL } 32 | 33 | 34 | void *gopt_sort( int *argc, const char **argv, const void *opt_specs ); 35 | /* returns a pointer for use in the following calls 36 | * prints to stderr and call exit() on error 37 | */ 38 | size_t gopt( const void *opts, int key ); 39 | /* returns the number of times the option was specified 40 | * which will be 0 or 1 unless GOPT_REPEAT was used 41 | */ 42 | size_t gopt_arg( const void *opts, int key, const char **arg ); 43 | /* returns the number of times the option was specified 44 | * writes a pointer to the option argument from the first (or only) occurance to *arg 45 | */ 46 | const char *gopt_arg_i( const void *opts, int key, size_t i ); 47 | /* returns a pointer to the ith (starting at zero) occurance 48 | * of the option, or NULL if it was not specified that many times 49 | */ 50 | size_t gopt_args( const void *opts, int key, const char **args, size_t args_len ); 51 | /* returns the number of times the option was specified 52 | * writes pointers to the option arguments in the order of occurance to args[]. 53 | * writes at most args_len pointers 54 | * if the return value is less than args_len, also writes a null pointer 55 | */ 56 | void gopt_free( void *opts ); 57 | /* releases memory allocated in the corresponding call to gopt_sort() 58 | * opts can no longer be used 59 | */ 60 | #endif /* GOPT_H_INCLUDED */ 61 | -------------------------------------------------------------------------------- /guhl/misc_version/Makefile: -------------------------------------------------------------------------------- 1 | VERSION = 0.5 2 | CC = /usr/bin/arm-linux-gnueabi-gcc 3 | CFLAGS = -Wall -g -D_REENTRANT -DVERSION=\"$(VERSION)\" 4 | INCDIR = -I/usr/arm-linux-gnueabi/usr/include/ -I. 5 | LIBDIR = /usr/arm-linux-gnueabi/lib/ 6 | LDFLAGS = -L$(LIBDIR) -static 7 | RM = rm -f 8 | 9 | TRG = misc_version 10 | OBJ = gopt.o misc_version.o 11 | 12 | all: $(OBJ) 13 | $(CC) $(CFLAGS) $(INCDIR) -o $(TRG) $(OBJ) $(LDFLAGS) 14 | 15 | %.o: %.c 16 | $(CC) $(CFLAGS) -c $< 17 | 18 | clean: 19 | $(RM) *.o 20 | $(RM) *.d 21 | $(RM) misc_version 22 | -------------------------------------------------------------------------------- /guhl/misc_version/gopt.h: -------------------------------------------------------------------------------- 1 | /* gopt.h version 8.1: tom.viza@gmail.com PUBLIC DOMAIN 2003-8 */ 2 | /* 3 | I, Tom Vajzovic, am the author of this software and its documentation and 4 | permanently abandon all copyright and other intellectual property rights in 5 | them, including the right to be identified as the author. 6 | 7 | I am fairly certain that this software does what the documentation says it 8 | does, but I cannot guarantee that it does, or that it does what you think it 9 | should, and I cannot guarantee that it will not have undesirable side effects. 10 | 11 | You are free to use, modify and distribute this software as you please, but 12 | you do so at your own risk. If you remove or hide this warning then you are 13 | responsible for any problems encountered by people that you make the software 14 | available to. 15 | 16 | Before modifying or distributing this software I ask that you would please 17 | read http://www.purposeful.co.uk/tfl/ 18 | */ 19 | 20 | #ifndef GOPT_H_INCLUDED 21 | #define GOPT_H_INCLUDED 22 | 23 | #define GOPT_ONCE 0 24 | #define GOPT_REPEAT 1 25 | #define GOPT_NOARG 0 26 | #define GOPT_ARG 2 27 | 28 | #define gopt_start(...) (const void*)( const struct { int k; int f; const char *s; const char*const*l; }[]){ __VA_ARGS__, {0}} 29 | #define gopt_option(k,f,s,l) { k, f, s, l } 30 | #define gopt_shorts( ... ) (const char*)(const char[]){ __VA_ARGS__, 0 } 31 | #define gopt_longs( ... ) (const char**)(const char*[]){ __VA_ARGS__, NULL } 32 | 33 | 34 | void *gopt_sort( int *argc, const char **argv, const void *opt_specs ); 35 | /* returns a pointer for use in the following calls 36 | * prints to stderr and call exit() on error 37 | */ 38 | size_t gopt( const void *opts, int key ); 39 | /* returns the number of times the option was specified 40 | * which will be 0 or 1 unless GOPT_REPEAT was used 41 | */ 42 | size_t gopt_arg( const void *opts, int key, const char **arg ); 43 | /* returns the number of times the option was specified 44 | * writes a pointer to the option argument from the first (or only) occurance to *arg 45 | */ 46 | const char *gopt_arg_i( const void *opts, int key, size_t i ); 47 | /* returns a pointer to the ith (starting at zero) occurance 48 | * of the option, or NULL if it was not specified that many times 49 | */ 50 | size_t gopt_args( const void *opts, int key, const char **args, size_t args_len ); 51 | /* returns the number of times the option was specified 52 | * writes pointers to the option arguments in the order of occurance to args[]. 53 | * writes at most args_len pointers 54 | * if the return value is less than args_len, also writes a null pointer 55 | */ 56 | void gopt_free( void *opts ); 57 | /* releases memory allocated in the corresponding call to gopt_sort() 58 | * opts can no longer be used 59 | */ 60 | #endif /* GOPT_H_INCLUDED */ 61 | -------------------------------------------------------------------------------- /guhl/misc_version/misc_version.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2010 - 2012 Guhl 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include "gopt.h" 21 | #include 22 | #include 23 | 24 | #define INFILE "/dev/block/mmcblk0p17" 25 | #define OUTFILE "/dev/block/mmcblk0p17" 26 | #define PATH_FOR_BACKUP "/sdcard" 27 | 28 | //#define INFILE "/opt/install/g2/my_dump/p17/mmcblk0p17.img" 29 | //#define OUTFILE "/opt/install/g2/my_dump/p17/mmcblk0p17-new.img" 30 | //#define BACKUPFILE "/opt/install/g2/my_dump/p17/part17backup-%lu.bin" 31 | 32 | #define VERSION_A 0 33 | #define VERSION_B 5 34 | 35 | int main(int argc, const char **argv) { 36 | 37 | int cid = 0, set_version = 0, help = 0, setRUUflag = 0; 38 | const char* s_set_version; 39 | const char* s_cid; 40 | const char* s_ruu_flag; 41 | const char s_ruu_string[15] = "SetRuuNbhUpdate"; 42 | const char* s_backupPath; 43 | 44 | if (argc>1) { 45 | 46 | void *options= gopt_sort( & argc, argv, gopt_start( 47 | gopt_option( 'h', 0, gopt_shorts( 'h', '?' ), gopt_longs( "help", "HELP" )), 48 | gopt_option( 'v', 0, gopt_shorts( 'v' ), gopt_longs( "version" )), 49 | gopt_option( 'c', GOPT_ARG, gopt_shorts('c'), gopt_longs("cid")), 50 | gopt_option( 'r', GOPT_ARG, gopt_shorts( 'r' ), gopt_longs( "setRUUflag" )), 51 | gopt_option( 'p', GOPT_ARG, gopt_shorts( 'p' ), gopt_longs("path")), 52 | gopt_option( 's', GOPT_ARG, gopt_shorts( 's' ), gopt_longs( "set_version" )))); 53 | 54 | if( gopt( options, 'h' ) ){ 55 | help = 1; 56 | } 57 | 58 | if( gopt( options, 'v' ) ){ 59 | fprintf( stdout, "misc_version version: %d.%d\n",VERSION_A,VERSION_B); 60 | exit (0); 61 | } 62 | 63 | if(gopt_arg(options, 'r', &s_ruu_flag)){ 64 | if( (!strcmp(s_ruu_flag, "on")) && (!strcmp(s_ruu_flag, "off")) ){ 65 | printf("Error: The valid arguments for option setRUUflag are on|off\n"); 66 | exit (1); 67 | } 68 | if(!strcmp(s_ruu_flag, "on")){ 69 | setRUUflag = 1; 70 | printf("--setRUUflag on set. RUU flag will be set!\n"); 71 | } else { 72 | setRUUflag = 2; 73 | printf("--setRUUflag off set. RUU flag will be cleared!\n"); 74 | } 75 | } 76 | 77 | if(gopt_arg(options, 'c', &s_cid)) 78 | { 79 | // if -c or --cid was specified, check s_cid 80 | size_t size; 81 | size = strlen(s_cid); 82 | if(size != 8) 83 | { 84 | printf("Error: CID must be a 8 character string. Length of specified string: %d\n", (int)size); 85 | exit(1); 86 | } 87 | else 88 | { 89 | cid = 1; 90 | printf("--cid set. CID will be changed to: %s\n", s_cid); 91 | } 92 | } 93 | 94 | if( gopt_arg(options, 's', &s_set_version)){ 95 | // if -a or --set_version was specified, check s_set_version 96 | size_t size; 97 | size = strlen(s_set_version); 98 | if (size!=10){ 99 | fprintf( stderr, "Error: VERSION must be a 10 character string. Length of specified string: %d\n",(int)size); 100 | exit (1); 101 | } else { 102 | set_version = 1; 103 | fprintf( stdout, "--set_version set. VERSION will be changed to: %s\n",s_set_version); 104 | } 105 | } 106 | 107 | if(gopt_arg(options, 'p', &s_backupPath)) 108 | { 109 | // if -p or --path was specified, set backup path 110 | printf("--path set. backups will be stored in: %s instead of %s \n", s_backupPath, PATH_FOR_BACKUP); 111 | } 112 | 113 | } else { 114 | help = 1; 115 | } 116 | 117 | if (help!=0){ 118 | //if any of the help options was specified 119 | fprintf( stdout, "misc_version usage:\n" ); 120 | fprintf( stdout, "misc_version [-h|-?|--help] [-v|--version] [-s|--set_version ]\n" ); 121 | fprintf( stdout, "\t-h | -? | --help: display this message\n" ); 122 | fprintf( stdout, "\t-v | --version: display program version\n" ); 123 | fprintf( stdout, "\t-c | --cid : set the CID in misc to the 8-char long CID\n"); 124 | fprintf( stdout, "\t-s | --set_version : set the version in misc to the 10-char long VERSION\n" ); 125 | fprintf( stdout, "\t-p | --path: : create backup files in directory \n"); 126 | fprintf( stdout, "\t-r | --setRUUflag . Set of clear the RUU flag\n" ); 127 | exit(0); 128 | } 129 | 130 | if (s_backupPath == NULL) 131 | s_backupPath = PATH_FOR_BACKUP; 132 | 133 | char *backupFile; 134 | time_t ourTime; 135 | 136 | ourTime = time(0); 137 | backupFile = malloc(snprintf(0, 0, "%s/part17backup-%lu.bin", s_backupPath, ourTime) + 1); 138 | sprintf(backupFile, "%s/part17backup-%lu.bin", s_backupPath, ourTime); 139 | 140 | FILE *fdin, *fdout; 141 | char ch; 142 | 143 | printf("Patching and backing up partition 17...\n"); 144 | fdin = fopen(INFILE, "rb"); 145 | if (fdin == NULL){ 146 | printf("Error opening input file.\n"); 147 | return -1; 148 | } 149 | 150 | fdout = fopen(backupFile, "wb"); 151 | if (fdout == NULL){ 152 | printf("Error opening backup file.\n"); 153 | return -1; 154 | } 155 | 156 | // create a copy of the partition 157 | while(!feof(fdin)) { 158 | ch = fgetc(fdin); 159 | if(ferror(fdin)) { 160 | printf("Error reading input file.\n"); 161 | exit(1); 162 | } 163 | if(!feof(fdin)) fputc(ch, fdout); 164 | if(ferror(fdout)) { 165 | printf("Error writing backup file.\n"); 166 | exit(1); 167 | } 168 | } 169 | if(fclose(fdin)==EOF) { 170 | printf("Error closing input file.\n"); 171 | exit(1); 172 | } 173 | 174 | if(fclose(fdout)==EOF) { 175 | printf("Error closing backup file.\n"); 176 | exit(1); 177 | } 178 | 179 | // copy back and patch 180 | long j; 181 | 182 | fdin = fopen(backupFile, "rb"); 183 | if (fdin == NULL){ 184 | printf("Error opening backup file.\n"); 185 | return -1; 186 | } 187 | 188 | fdout = fopen(OUTFILE, "wb"); 189 | if (fdout == NULL){ 190 | printf("Error opening output file.\n"); 191 | return -1; 192 | } 193 | 194 | j = 0; 195 | 196 | while(!feof(fdin)) { 197 | ch = fgetc(fdin); 198 | if(ferror(fdin)) { 199 | printf("Error reading backup file.\n"); 200 | exit(1); 201 | } 202 | // CID 203 | if ((j>=0x0 && j<=0x7) && (cid!=0)) { 204 | ch = s_cid[j]; 205 | } 206 | // VERSION 207 | if ((j>=0xa0 && j<=0xa9) && (set_version!=0)) { 208 | ch = s_set_version[j-0xa0]; 209 | } 210 | // RUU flag 211 | if ((j>=0xb0 && j<=0xbe) && (setRUUflag==1)) { 212 | ch = s_ruu_string[j-0xb0]; 213 | } 214 | if ((j>=0xb0 && j<=0xbe) && (setRUUflag==2)) { 215 | ch = 0; 216 | } 217 | if(!feof(fdin)) fputc(ch, fdout); 218 | if(ferror(fdout)) { 219 | printf("Error writing output file.\n"); 220 | exit(1); 221 | } 222 | j++; 223 | } 224 | if(fclose(fdin)==EOF) { 225 | printf("Error closing backup file.\n"); 226 | exit(1); 227 | } 228 | 229 | if(fclose(fdout)==EOF) { 230 | printf("Error closing output file.\n"); 231 | exit(1); 232 | } 233 | 234 | return 0; 235 | } 236 | -------------------------------------------------------------------------------- /guhl/p7_soff/gopt.h: -------------------------------------------------------------------------------- 1 | /* gopt.h version 8.1: tom.viza@gmail.com PUBLIC DOMAIN 2003-8 */ 2 | /* 3 | I, Tom Vajzovic, am the author of this software and its documentation and 4 | permanently abandon all copyright and other intellectual property rights in 5 | them, including the right to be identified as the author. 6 | 7 | I am fairly certain that this software does what the documentation says it 8 | does, but I cannot guarantee that it does, or that it does what you think it 9 | should, and I cannot guarantee that it will not have undesirable side effects. 10 | 11 | You are free to use, modify and distribute this software as you please, but 12 | you do so at your own risk. If you remove or hide this warning then you are 13 | responsible for any problems encountered by people that you make the software 14 | available to. 15 | 16 | Before modifying or distributing this software I ask that you would please 17 | read http://www.purposeful.co.uk/tfl/ 18 | */ 19 | 20 | #ifndef GOPT_H_INCLUDED 21 | #define GOPT_H_INCLUDED 22 | 23 | #define GOPT_ONCE 0 24 | #define GOPT_REPEAT 1 25 | #define GOPT_NOARG 0 26 | #define GOPT_ARG 2 27 | 28 | #define gopt_start(...) (const void*)( const struct { int k; int f; const char *s; const char*const*l; }[]){ __VA_ARGS__, {0}} 29 | #define gopt_option(k,f,s,l) { k, f, s, l } 30 | #define gopt_shorts( ... ) (const char*)(const char[]){ __VA_ARGS__, 0 } 31 | #define gopt_longs( ... ) (const char**)(const char*[]){ __VA_ARGS__, NULL } 32 | 33 | 34 | void *gopt_sort( int *argc, const char **argv, const void *opt_specs ); 35 | /* returns a pointer for use in the following calls 36 | * prints to stderr and call exit() on error 37 | */ 38 | size_t gopt( const void *opts, int key ); 39 | /* returns the number of times the option was specified 40 | * which will be 0 or 1 unless GOPT_REPEAT was used 41 | */ 42 | size_t gopt_arg( const void *opts, int key, const char **arg ); 43 | /* returns the number of times the option was specified 44 | * writes a pointer to the option argument from the first (or only) occurance to *arg 45 | */ 46 | const char *gopt_arg_i( const void *opts, int key, size_t i ); 47 | /* returns a pointer to the ith (starting at zero) occurance 48 | * of the option, or NULL if it was not specified that many times 49 | */ 50 | size_t gopt_args( const void *opts, int key, const char **args, size_t args_len ); 51 | /* returns the number of times the option was specified 52 | * writes pointers to the option arguments in the order of occurance to args[]. 53 | * writes at most args_len pointers 54 | * if the return value is less than args_len, also writes a null pointer 55 | */ 56 | void gopt_free( void *opts ); 57 | /* releases memory allocated in the corresponding call to gopt_sort() 58 | * opts can no longer be used 59 | */ 60 | #endif /* GOPT_H_INCLUDED */ 61 | -------------------------------------------------------------------------------- /guhl/p7_soff/p7_s-off.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2010 Guhl 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "gopt.h" 22 | #include "soff_verify.h" 23 | 24 | /* 25 | #define INFILE "/dev/block/mmcblk0p7" 26 | #define CPYFILE "/sdcard/mmcblk0p7.ori.img" 27 | #define OUTFILE "/dev/block/mmcblk0p7" 28 | */ 29 | #define INFILE "/opt/install/g2/my_dump/p7/mmcblk0p7.ori.img" 30 | #define CPYFILE "/opt/install/g2/my_dump/p7/mmcblk0p7.cpy.img" 31 | #define OUTFILE "/opt/install/g2/my_dump/p7/mmcblk0p7.out.img" 32 | 33 | #define VERSION_A 0 34 | #define VERSION_B 11 35 | 36 | int main(int argc, const char **argv) { 37 | FILE *fdin, *fdout; 38 | char ch; 39 | int cid, secu_flag, sim_unlock, verify = 0; 40 | const char* s_secu_flag; 41 | const char* s_cid; 42 | 43 | if (argc>1) { 44 | 45 | void *options= gopt_sort( & argc, argv, gopt_start( 46 | gopt_option( 'h', 0, gopt_shorts( 'h', '?' ), gopt_longs( "help", "HELP" )), 47 | gopt_option( 'v', 0, gopt_shorts( 'v' ), gopt_longs( "version" )), 48 | gopt_option( 's', GOPT_ARG, gopt_shorts( 's' ), gopt_longs( "secu_flag" )), 49 | gopt_option( 'c', GOPT_ARG, gopt_shorts( 'c' ), gopt_longs( "cid" )), 50 | gopt_option( 'S', 0, gopt_shorts( 'S' ), gopt_longs( "sim_unlock" )), 51 | gopt_option( 'V', 0, gopt_shorts( 'V' ), gopt_longs( "verify" )))); 52 | /* 53 | * there are possible options to this program, some of which have multiple names: 54 | * 55 | * -h -? --help --HELP 56 | * -v --version 57 | * -s --secu_flag (which requires an option argument on|off) 58 | * -c --cid (which requires an option 8-character string argument ) 59 | * -S --sim_unlock 60 | */ 61 | 62 | if( gopt( options, 'h' ) ){ 63 | //if any of the help options was specified 64 | fprintf( stdout, "gfree usage:\n" ); 65 | fprintf( stdout, "gfree [-h|-?|--help] [-v|--version] [-s|--secu_flag on|off]\n" ); 66 | fprintf( stdout, "\t-h | -? | --help: display this message\n" ); 67 | fprintf( stdout, "\t-v | --version: display program version\n" ); 68 | fprintf( stdout, "\t-s | --secu_flag on|off: turn secu_flag on or off\n" ); 69 | fprintf( stdout, "\t-c | --cid : set the CID to the 8-char long CID\n" ); 70 | fprintf( stdout, "\t-S | --sim_unlock: remove the SIMLOCK\n" ); 71 | fprintf( stdout, "\t-V | --verify: verify the CID, secu_flag, SIMLOCK\n" ); 72 | fprintf( stdout, "\n" ); 73 | fprintf( stdout, "calling gfree without arguments is the same as calling it:\n" ); 74 | fprintf( stdout, "\tgfree --secu_flag off --sim_unlock --cid 11111111\n" ); 75 | exit( 0 ); 76 | } 77 | 78 | if( gopt( options, 'v' ) ){ 79 | //if any of the version options was specified 80 | fprintf( stdout, "gfree version: %d.%d\n",VERSION_A,VERSION_B); 81 | exit (0); 82 | } 83 | 84 | if( gopt_arg(options, 's', &s_secu_flag)){ 85 | // if -s or --secu_flag was specified, check s_secu_flag 86 | if (strcmp(s_secu_flag, "on")==0){ 87 | secu_flag = 1; 88 | fprintf( stdout, "--secu_flag on set\n"); 89 | } else if (strcmp(s_secu_flag, "off")==0){ 90 | secu_flag = 2; 91 | fprintf( stdout, "--secu_flag off set\n"); 92 | } 93 | } 94 | 95 | if( gopt_arg(options, 'c', &s_cid)){ 96 | // if -c or --cid was specified, check s_cid 97 | size_t size; 98 | size = strlen(s_cid); 99 | if (size!=8){ 100 | fprintf( stderr, "Error: CID must be a 8 character string. Length of specified string: %d\n",(int)size); 101 | exit (1); 102 | } else { 103 | cid = 1; 104 | fprintf( stdout, "--cid set. CID will be changed to: %s\n",s_cid); 105 | } 106 | } 107 | 108 | if( gopt( options, 'S' ) ){ 109 | //if any of the sim_unlock options was specified 110 | sim_unlock = 1; 111 | fprintf( stdout, "--sim_unlock. SIMLOCK will be removed\n"); 112 | } 113 | 114 | if( gopt( options, 'V' ) ){ 115 | //if any of the sim_unlock options was specified 116 | verify = 1; 117 | fprintf( stdout, "--verify. CID, secu_flag, SIMLOCK will be verified\n"); 118 | } 119 | 120 | } else { 121 | secu_flag = 2; 122 | fprintf( stdout, "--secu_flag off set\n"); 123 | cid = 1; 124 | s_cid = "11111111"; 125 | fprintf( stdout, "--cid set. CID will be changed to: %s\n",s_cid); 126 | sim_unlock = 1; 127 | fprintf( stdout, "--sim_unlock. SIMLOCK will be removed\n"); 128 | } 129 | 130 | // if verify is set just verify and exit 131 | if (verify==1){ 132 | if (verify_init_device()!=0){ 133 | fprintf( stderr, "Error: verify could not initialize device!"); 134 | exit (-1); 135 | } 136 | if (verify_init_modem()!=0){ 137 | fprintf( stderr, "Error: verify could not initialize radio!"); 138 | exit (-1); 139 | } 140 | verify_set_verbose(); 141 | verify_cid(); 142 | verify_secu_flag(); 143 | verify_simlock(); 144 | verify_close_device(); 145 | exit (0); 146 | } 147 | 148 | fdin = fopen(INFILE, "rb"); 149 | if (fdin == NULL){ 150 | printf("Error opening input file.\n"); 151 | return -1; 152 | } 153 | 154 | fdout = fopen(CPYFILE, "wb"); 155 | if (fdout == NULL){ 156 | printf("Error opening copy file.\n"); 157 | return -1; 158 | } 159 | 160 | // create a copy of the partition 161 | while(!feof(fdin)) { 162 | ch = fgetc(fdin); 163 | if(ferror(fdin)) { 164 | printf("Error reading input file.\n"); 165 | exit(1); 166 | } 167 | if(!feof(fdin)) fputc(ch, fdout); 168 | if(ferror(fdout)) { 169 | printf("Error writing copy file.\n"); 170 | exit(1); 171 | } 172 | } 173 | if(fclose(fdin)==EOF) { 174 | printf("Error closing input file.\n"); 175 | exit(1); 176 | } 177 | 178 | if(fclose(fdout)==EOF) { 179 | printf("Error closing copy file.\n"); 180 | exit(1); 181 | } 182 | 183 | // copy back and patch 184 | long i; 185 | 186 | fdin = fopen(CPYFILE, "rb"); 187 | if (fdin == NULL){ 188 | printf("Error opening copy file.\n"); 189 | return -1; 190 | } 191 | 192 | fdout = fopen(OUTFILE, "wb"); 193 | if (fdout == NULL){ 194 | printf("Error opening output file.\n"); 195 | return -1; 196 | } 197 | 198 | i = 0; 199 | 200 | while(!feof(fdin)) { 201 | ch = fgetc(fdin); 202 | if(ferror(fdin)) { 203 | printf("Error reading copy file.\n"); 204 | exit(1); 205 | } 206 | // secu_flag 207 | if (i==0xa00 && secu_flag!=0) { 208 | ch = secu_flag==2 ? 0x00 : 0x01; 209 | } 210 | // CID 211 | if ((i>=0x200 && i<=0x207)&& (cid!=0)) { 212 | ch = s_cid[i-0x200]; 213 | } 214 | // SIM LOCK 215 | if (sim_unlock!=0){ 216 | if ((i>0x80003 && i<0x807fc) || (i>=0x80800 && i<=0x82fff)){ 217 | ch = 0x00; 218 | } else if (i==0x80000) { 219 | ch = 0x78; 220 | } else if (i==0x80001) { 221 | ch = 0x56; 222 | } else if (i==0x80002) { 223 | ch = 0xF3; 224 | } else if (i==0x80003) { 225 | ch = 0xC9; 226 | } else if (i==0x807fc) { 227 | ch = 0x49; 228 | } else if (i==0x807fd) { 229 | ch = 0x53; 230 | } else if (i==0x807fe) { 231 | ch = 0xF4; 232 | } else if (i==0x807ff) { 233 | ch = 0x7D; 234 | } 235 | } 236 | if(!feof(fdin)) fputc(ch, fdout); 237 | if(ferror(fdout)) { 238 | printf("Error writing output file.\n"); 239 | exit(1); 240 | } 241 | i++; 242 | } 243 | if(fclose(fdin)==EOF) { 244 | printf("Error closing copy file.\n"); 245 | exit(1); 246 | } 247 | 248 | if(fclose(fdout)==EOF) { 249 | printf("Error closing output file.\n"); 250 | exit(1); 251 | } 252 | 253 | return 0; 254 | } 255 | -------------------------------------------------------------------------------- /guhl/p7_soff/soff_verify.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2010 Guhl 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include "soff_verify.h" 19 | 20 | int verify_init_device(){ 21 | fd_radio = 0; 22 | fd_radio = open(MODEMDEVICE, O_RDWR | O_NOCTTY ); 23 | if (fd_radio <0) { 24 | fprintf( stderr, "Error: could not open modem device: %s\n",MODEMDEVICE); 25 | return -1; 26 | } 27 | tcgetattr(fd_radio,&oldtio); // save current serial port settings 28 | memset(&newtio, 0x00, sizeof(newtio)); // clear struct for new port settings 29 | 30 | //get the current options 31 | tcgetattr(fd_radio, &newtio); 32 | 33 | // set raw input, 1 second timeout 34 | newtio.c_cflag |= (CLOCAL | CREAD); 35 | newtio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG ); 36 | newtio.c_oflag &= ~OPOST; 37 | newtio.c_cc[VMIN] = 0; 38 | newtio.c_cc[VTIME] = 10; 39 | 40 | // clean the modem line and activate the settings for the port 41 | tcflush(fd_radio, TCIFLUSH); 42 | tcsetattr(fd_radio,TCSANOW,&newtio); 43 | 44 | return 0; 45 | } 46 | 47 | int verify_init_modem() { 48 | char buffer[255]; // Input buffer 49 | char *bufptr; // Current char in buffer 50 | int nbytes; // Number of bytes read 51 | int tries; // Number of tries so far 52 | 53 | for (tries = 0; tries < 3; tries ++) { 54 | // send an AT command followed by a CR 55 | if (write(fd_radio, "AT\r", 3) < 3) 56 | continue; 57 | // read characters into our string buffer until we get a CR or NL 58 | bufptr = buffer; 59 | while ((nbytes = read(fd_radio, bufptr, buffer + sizeof(buffer) - bufptr - 1)) > 0) { 60 | bufptr += nbytes; 61 | if (bufptr[-1] == '\n' || bufptr[-1] == '\r') 62 | break; 63 | } 64 | // nul terminate the string and see if we got an OK response */ 65 | *bufptr = '\0'; 66 | if ((strncmp(buffer, "0", 1) == 0) || (strncmp(buffer, "\r\nOK", 4) == 0)) 67 | return (0); 68 | } 69 | return (-1); 70 | } 71 | 72 | int verify_set_verbose() { 73 | char buffer[255]; // Input buffer 74 | char *bufptr; // Current char in buffer 75 | int nbytes; // Number of bytes read 76 | int tries; // Number of tries so far 77 | 78 | for (tries = 0; tries < 3; tries ++) { 79 | // send an ATV1 command followed by a CR 80 | if (write(fd_radio, "ATV1\r", 5) < 5) 81 | continue; 82 | // read characters into our string buffer until we get a CR or NL 83 | bufptr = buffer; 84 | while ((nbytes = read(fd_radio, bufptr, buffer + sizeof(buffer) - bufptr - 1)) > 0) { 85 | bufptr += nbytes; 86 | if (bufptr[-1] == '\n' || bufptr[-1] == '\r') 87 | break; 88 | } 89 | // nul terminate the string and see if we got an OK response */ 90 | *bufptr = '\0'; 91 | if (strncmp(buffer, "\r\nOK", 4) == 0) 92 | return (0); 93 | } 94 | return (-1); 95 | } 96 | 97 | int verify_secu_flag() { 98 | char buffer[255]; // Input buffer 99 | char *bufptr; // Current char in buffer 100 | int nbytes; // Number of bytes read 101 | int tries; // Number of tries so far 102 | 103 | for (tries = 0; tries < 3; tries ++) { 104 | // send an ATV1 command followed by a CR 105 | if (write(fd_radio, "AT@SIMLOCK?AA\r", 15) < 15) 106 | continue; 107 | // read characters into our string buffer until we get a CR or NL 108 | bufptr = buffer; 109 | while ((nbytes = read(fd_radio, bufptr, buffer + sizeof(buffer) - bufptr - 1)) > 0) { 110 | bufptr += nbytes; 111 | if (bufptr[-1] == '\n' || bufptr[-1] == '\r') 112 | break; 113 | } 114 | // nul terminate the string and see if we got an OK response */ 115 | *bufptr = '\0'; 116 | fprintf( stdout, "gfree verify_secu_flag returned: %s\n",buffer); 117 | if (strncmp(buffer, "\r\n@secu_flag: 0", 15) == 0) 118 | return (0); 119 | } 120 | return (-1); 121 | } 122 | 123 | void verify_cid() { 124 | char buffer[255]; // Input buffer 125 | char *bufptr; // Current char in buffer 126 | int nbytes; // Number of bytes read 127 | int tries; // Number of tries so far 128 | 129 | for (tries = 0; tries < 3; tries ++) { 130 | // send an ATV1 command followed by a CR 131 | if (write(fd_radio, "AT@CID?\r", 8) < 8) 132 | continue; 133 | // read characters into our string buffer until we get a CR or NL 134 | bufptr = buffer; 135 | while ((nbytes = read(fd_radio, bufptr, buffer + sizeof(buffer) - bufptr - 1)) > 0) { 136 | bufptr += nbytes; 137 | if (bufptr[-1] == '\n' || bufptr[-1] == '\r') 138 | break; 139 | } 140 | // nul terminate the string and see if we got an OK response */ 141 | *bufptr = '\0'; 142 | fprintf( stdout, "gfree verify_cid returned: %s\n",buffer); 143 | return; 144 | } 145 | } 146 | 147 | int verify_simlock() { 148 | char buffer[255]; // Input buffer 149 | char *bufptr; // Current char in buffer 150 | int nbytes; // Number of bytes read 151 | int tries; // Number of tries so far 152 | 153 | for (tries = 0; tries < 3; tries ++) { 154 | // send an ATV1 command followed by a CR 155 | if (write(fd_radio, "AT@SIMLOCK?40\r", 15) < 15) 156 | continue; 157 | // read characters into our string buffer until we get a CR or NL 158 | bufptr = buffer; 159 | while ((nbytes = read(fd_radio, bufptr, buffer + sizeof(buffer) - bufptr - 1)) > 0) { 160 | bufptr += nbytes; 161 | if (bufptr[-1] == '\n' || bufptr[-1] == '\r') 162 | break; 163 | } 164 | // nul terminate the string and see if we got an OK response */ 165 | *bufptr = '\0'; 166 | fprintf( stdout, "gfree verify_simlock returned: %s\n",buffer); 167 | if (strncmp(buffer, "\r\n@SIMLOCK= 00", 14) == 0) 168 | return (0); 169 | } 170 | return (-1); 171 | } 172 | 173 | int verify_close_device() { 174 | // restore the old port settings 175 | tcsetattr(fd_radio,TCSANOW,&oldtio); 176 | close(fd_radio); 177 | return 0; 178 | } 179 | -------------------------------------------------------------------------------- /guhl/p7_soff/soff_verify.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2010 Guhl 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #ifndef SOFF_VERIFY_H_ 19 | #define SOFF_VERIFY_H_ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #define MODEMDEVICE "/dev/ttyUSB2" 31 | #define BAUDRATE B38400 32 | 33 | int fd_radio; 34 | struct termios oldtio,newtio; 35 | 36 | char *squeeze(char *str); 37 | int verify_init_device(); 38 | int verify_init_modem(); 39 | int verify_set_verbose(); 40 | int verify_secu_flag(); 41 | void verify_cid(); 42 | int verify_simlock(); 43 | int verify_close_device(); 44 | 45 | #endif /* SOFF_VERIFY_H_ */ 46 | -------------------------------------------------------------------------------- /guhl/vision_wipe_efs/Makefile: -------------------------------------------------------------------------------- 1 | VERSION = 0.1 2 | CC = /usr/bin/arm-linux-gnueabi-gcc 3 | CFLAGS = -Wall -g -D_REENTRANT -DVERSION=\"$(VERSION)\" 4 | INCDIR = -I/usr/arm-linux-gnueabi/usr/include/ -I. 5 | LIBDIR = /usr/arm-linux-gnueabi/lib/ 6 | LDFLAGS = -L$(LIBDIR) -static 7 | RM = rm -f 8 | 9 | TRG = vision_wipe_efs 10 | OBJ = vision_wipe_efs.o 11 | 12 | all: $(OBJ) 13 | $(CC) $(CFLAGS) $(INCDIR) -o $(TRG) $(OBJ) $(LDFLAGS) 14 | 15 | %.o: %.c 16 | $(CC) $(CFLAGS) -c $< 17 | 18 | clean: 19 | $(RM) *.o 20 | $(RM) *.d 21 | $(RM) vision_wipe_efs 22 | -------------------------------------------------------------------------------- /guhl/vision_wipe_efs/README: -------------------------------------------------------------------------------- 1 | vision_wipe_efs: 2 | 3 | vision_wipe_efs is a program that creates a backup of the visions efs partition 13 and 14 and wipes the partitions afterwards. 4 | 5 | Version history: 6 | 7 | vision_wipe_efs 0.1: 8 | Version 0.1 wipes the efs data in partitions 13 and 14. It will create backups of the partition 13 and 14 on the sdcard using the name "/sdcard/part13backup-