├── firmwares ├── .gitignore ├── mw300 │ ├── structs.common.h │ └── lumi-gateway_141_156 │ │ ├── section2_0x1f003768_mod.bin │ │ ├── definitions.mk │ │ └── structs.h └── Makefile ├── patches ├── .gitignore ├── mw300 │ └── lumi-gateway_141_156 │ │ └── demo │ │ ├── patch.ld │ │ ├── builder.sh │ │ ├── src │ │ └── patch.c │ │ └── Makefile ├── include │ ├── types.h │ ├── helper.h │ ├── wrapper.h │ ├── sendframe.h │ ├── capabilities.h │ ├── rates.h │ ├── nexioctls.h │ ├── firmware_version.h │ ├── patcher.h │ ├── objmem.h │ ├── ieee80211_radiotap.h │ └── debug.h └── common │ ├── header.mk │ └── wrapper.c ├── firmwaretools ├── Marvel_MW30x │ ├── openocd.txt │ ├── axf2firmware │ ├── axf2firmware.exe │ ├── Marvell-firmware-format.xlsx │ └── megaparser.py └── Mediatek │ └── megaparser.py ├── Makefile ├── README.md ├── setup_env.sh └── LICENSE.txt /firmwares/.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | !/.gitignore 3 | ucode.bin 4 | flashpatches.c 5 | -------------------------------------------------------------------------------- /patches/.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | !.gitignore 3 | obj 4 | log 5 | gen 6 | *.o 7 | *.elf 8 | -------------------------------------------------------------------------------- /firmwaretools/Marvel_MW30x/openocd.txt: -------------------------------------------------------------------------------- 1 | openocd -f interface/ftdi.cfg -c "transport select swd" -f target/wmcore.cfg 2 | -------------------------------------------------------------------------------- /firmwaretools/Marvel_MW30x/axf2firmware: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgiese/dustcloud-nexmon/HEAD/firmwaretools/Marvel_MW30x/axf2firmware -------------------------------------------------------------------------------- /firmwares/mw300/structs.common.h: -------------------------------------------------------------------------------- 1 | #ifndef STRUCTS_COMMON_H 2 | #define STRUCTS_COMMON_H 3 | 4 | //TODO 5 | 6 | #endif /*STRUCTS_COMMON_H */ 7 | -------------------------------------------------------------------------------- /firmwaretools/Marvel_MW30x/axf2firmware.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgiese/dustcloud-nexmon/HEAD/firmwaretools/Marvel_MW30x/axf2firmware.exe -------------------------------------------------------------------------------- /patches/mw300/lumi-gateway_141_156/demo/patch.ld: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | INCLUDE gen/memory.ld 4 | } 5 | 6 | SECTIONS 7 | { 8 | INCLUDE gen/nexmon.ld 9 | } 10 | -------------------------------------------------------------------------------- /firmwaretools/Marvel_MW30x/Marvell-firmware-format.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgiese/dustcloud-nexmon/HEAD/firmwaretools/Marvel_MW30x/Marvell-firmware-format.xlsx -------------------------------------------------------------------------------- /firmwares/mw300/lumi-gateway_141_156/section2_0x1f003768_mod.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgiese/dustcloud-nexmon/HEAD/firmwares/mw300/lumi-gateway_141_156/section2_0x1f003768_mod.bin -------------------------------------------------------------------------------- /firmwares/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS = $(dir $(wildcard */Makefile)) 2 | 3 | all: $(SUBDIRS) 4 | 5 | $(SUBDIRS): FORCE 6 | @printf "\033[0;31m EXECUTING MAKE FOR CHIP VERSION\033[0m %s\n" $@ 7 | $(Q)make -C $@ 8 | 9 | FORCE: 10 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: buildtools firmwares 2 | 3 | firmwares: buildtools FORCE 4 | @printf "\033[0;31m EXTRACTING FLASHPATCHES AND UCODE\033[0m\n" 5 | $(Q)make -C $@ 6 | 7 | buildtools: FORCE 8 | @printf "\033[0;31m BUILDING BUILDTOOLS\033[0m\n" 9 | $(Q)make -C $@ 10 | 11 | FORCE: 12 | -------------------------------------------------------------------------------- /firmwares/mw300/lumi-gateway_141_156/definitions.mk: -------------------------------------------------------------------------------- 1 | NEXMON_CHIP=CHIP_VER_MW300_GW 2 | NEXMON_CHIP_NUM=`$(NEXMON_ROOT)/buildtools/scripts/getdefine.sh $(NEXMON_CHIP)` 3 | NEXMON_FW_VERSION=FW_VER_MW300_GW_141_151 4 | NEXMON_FW_VERSION_NUM=`$(NEXMON_ROOT)/buildtools/scripts/getdefine.sh $(NEXMON_FW_VERSION)` 5 | 6 | NEXMON_ARCH=armv7-m 7 | 8 | RAM_FILE=section2_0x1f003740.bin 9 | RAMSTART=0x1f003740 10 | RAMSIZE=0x827DF 11 | 12 | PATCHSTART=0x1F085F1F # RAMSTART + RAMSIZE 13 | PATCHSIZE=0x500 14 | -------------------------------------------------------------------------------- /patches/mw300/lumi-gateway_141_156/demo/builder.sh: -------------------------------------------------------------------------------- 1 | arm-none-eabi-objcopy -I binary -O elf32-littlearm --set-start 0x1f003741 --adjust-vma 0x100000 --binary-architecture arm --rename-section .data=.text,contents,alloc,load,readonly,code --add-section .text2=section2_0x1f003740.bin --set-section-flags .text2=contents,alloc,load,readonly,code --change-section-address .text2=0x1f003740 --add-section .text3=section3_0x20000040.bin --set-section-flags .text3=contents,alloc,load,readonly,code --change-section-address .text3=0x20000040 section1_0x100000.bin 31ed49d49a6e4727c84d24192ce944a6_upd_lumi.gateway.v3.bin_patched.elf 2 | arm-none-eabi-ld 31ed49d49a6e4727c84d24192ce944a6_upd_lumi.gateway.v3.bin_patched.elf -e 0x1f003741 -T 31ed49d49a6e4727c84d24192ce944a6_upd_lumi.gateway.v3.bin_script.lds 3 | ./axf2firmware a.out nexmontest_upd_lumi.gateway_141_151.v3.bin 4 | rm a.out -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a simplified version of the Nexmon Framework by Daniel Wegemer and Matthias Schulz (https://github.com/seemoo-lab/nexmon) 2 | 3 | I presented in 2018 at DEFCON how to use the Nexmon framework to modify Xiaomi firmwares, which are based on Marvel or Mediatek Cortex-M chips. You find the presentation here: http://dontvacuum.me/talks/DEFCON26-IoT-Village/DEFCON26-IoT-Village_How_to_Modify_Cortex_M_Firmware-Xiaomi.html 4 | 5 | This release does not contain the buildtools, please download them from the nexmon repository. 6 | # Steps: 7 | * import folder buildtools from (https://github.com/seemoo-lab/nexmon/tree/master/buildtools) 8 | * `source setup.env.sh` 9 | * Maybe: `cd buildutils/` and `make` 10 | * Edit: `patches/common/wrapper.c` to add more firmware functions (see *blinkenlights*) 11 | * Edit: `patches/mw300/1/demo/src/patch.c` to add new code to your firmware 12 | * Edit: `firmwares/mw300/1/definitions.mk` to define where new patches have to go 13 | -------------------------------------------------------------------------------- /patches/mw300/lumi-gateway_141_156/demo/src/patch.c: -------------------------------------------------------------------------------- 1 | #pragma NEXMON targetregion "patch" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | 9 | 10 | void 11 | ping_server(char *url) 12 | { 13 | http_session_t handle; 14 | http_resp_t *resp = 0; 15 | wmprintf("Register at Server with url:\r\n"); 16 | wmprintf(url); 17 | wmprintf("\r\n"); 18 | httpc_get(url, &handle, &resp, 0); 19 | } 20 | 21 | int 22 | hook(char *buffer, int a, const char *format, ...) { 23 | wmprintf("=== Dustcloud Registration ===\r\n"); 24 | const char * aTag_mac = (const char *)0x2000037E; 25 | const char * aTag_did = (const char *)0x20000386; 26 | const char * aTag_key = (const char *)0x2000038E; 27 | char hookbuffer[140]; 28 | char hexkey[48]; 29 | bin2hex(aTag_key, hexkey, 16, 48); 30 | snprintf(hookbuffer,135,"http://192.168.1.2/register.php?key=%s",hexkey); 31 | ping_server(hookbuffer); 32 | return snprintf(buffer, a, format); // Jump into original function to not break functionality 33 | } 34 | // Trigger at snprintf in otu_timer_info 35 | __attribute__((at(0x1F046152, "", CHIP_VER_MW300_GW, FW_VER_MW300_GW_141_156))) 36 | BLPatch(hook, hook); 37 | -------------------------------------------------------------------------------- /patches/include/types.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_H 2 | #define TYPES_H 3 | 4 | typedef unsigned char byte; 5 | typedef unsigned short word; 6 | typedef unsigned int dword; 7 | typedef unsigned char bool; 8 | typedef signed char int8_t; 9 | typedef unsigned char uint8_t; 10 | typedef signed short int int16_t; 11 | typedef unsigned short int uint16_t; 12 | typedef signed int int32_t; 13 | typedef unsigned int uint32_t; 14 | typedef unsigned long long uint64_t; 15 | typedef long long int64_t; 16 | typedef int8_t int8; 17 | typedef uint8_t uint8; 18 | typedef int16_t int16; 19 | typedef uint16_t uint16; 20 | typedef int32_t int32; 21 | typedef uint32_t uint32; 22 | typedef int64_t int64; 23 | typedef uint64_t uint64; 24 | typedef unsigned char uchar_t; 25 | typedef uint32_t wchar_t; 26 | typedef uint32_t size_t; 27 | typedef uint32_t addr_t; 28 | typedef int32_t pid_t; 29 | typedef uint32_t uint; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /setup_env.sh: -------------------------------------------------------------------------------- 1 | OLD_PWD=$(pwd) 2 | cd $(dirname ${BASH_SOURCE[0]}) 3 | 4 | export ARCH=arm 5 | export SUBARCH=arm 6 | export KERNEL=kernel7 7 | 8 | export HOSTUNAME=$(uname -s) 9 | export PLATFORMUNAME=$(uname -m) 10 | 11 | export NEXMON_ROOT=$(pwd) 12 | 13 | if [ $HOSTUNAME == "Darwin" ]; then 14 | export CC=$NEXMON_ROOT/buildtools/gcc-arm-none-eabi-5_4-2016q2-osx/bin/arm-none-eabi- 15 | export CCPLUGIN=$NEXMON_ROOT/buildtools/gcc-nexmon-plugin-osx/nexmon.so 16 | export ZLIBFLATE="openssl zlib" 17 | else if [ $HOSTUNAME == "Linux" ] && [ $PLATFORMUNAME == "x86_64" ]; then 18 | export CC=$NEXMON_ROOT/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- 19 | export CCPLUGIN=$NEXMON_ROOT/buildtools/gcc-nexmon-plugin/nexmon.so 20 | export ZLIBFLATE="zlib-flate -compress" 21 | else if [[ $HOSTUNAME == "Linux" ]] && [[ $PLATFORMUNAME == "armv7l" || $PLATFORMUNAME == "armv6l" ]]; then 22 | export CC=$NEXMON_ROOT/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-armv7l/bin/arm-none-eabi- 23 | export CCPLUGIN=$NEXMON_ROOT/buildtools/gcc-nexmon-plugin-arm/nexmon.so 24 | export ZLIBFLATE="zlib-flate -compress" 25 | else 26 | echo "Platform not supported!" 27 | fi 28 | fi 29 | fi 30 | 31 | export Q=@ 32 | export NEXMON_SETUP_ENV=1 33 | 34 | cd "$OLD_PWD" 35 | -------------------------------------------------------------------------------- /patches/include/helper.h: -------------------------------------------------------------------------------- 1 | #ifndef HELPER_H 2 | #define HELPER_H 3 | 4 | #include "types.h" 5 | 6 | void * 7 | skb_push(sk_buff *p, unsigned int len); 8 | 9 | void * 10 | skb_pull(sk_buff *p, unsigned int len); 11 | 12 | void 13 | hexdump(char *desc, void *addr, int len); 14 | 15 | // somehow the strings are not removed during optimization, so that they end up in the binary, hence, move the functions somewhere else, where they are only included if they are needed. 16 | inline uint16 17 | htons(uint16 a) 18 | { 19 | return (a & 0xff00) >> 8 | (a & 0xff) << 8; 20 | } 21 | /* 22 | 23 | inline uint32 24 | htonl(uint32 a) 25 | { 26 | return (a & 0xff000000) >> 24 | (a & 0xff0000) >> 8 | (a & 0xff00) << 8 | (a & 0xff) << 24; 27 | } 28 | 29 | inline uint16 30 | ntohs(uint16 a) 31 | { 32 | return htons(a); 33 | } 34 | 35 | inline uint32 36 | ntohl(uint32 a) 37 | { 38 | return htonl(a); 39 | }*/ 40 | 41 | inline void * 42 | get_stack_ptr() { 43 | void *stack = 0x0; 44 | __asm("mov %0, sp" : "=r" (stack)); 45 | return stack; 46 | } 47 | 48 | /* 49 | inline int 50 | get_register(int reg_nr) { 51 | int reg_content = 0; 52 | switch(reg_nr) { 53 | case 0: 54 | __asm("mov %0, r0" : "=r" (reg_content)); 55 | break; 56 | case 1: 57 | __asm("mov %0, r1" : "=r" (reg_content)); 58 | break; 59 | case 2: 60 | __asm("mov %0, r2" : "=r" (reg_content)); 61 | break; 62 | case 3: 63 | __asm("mov %0, r3" : "=r" (reg_content)); 64 | break; 65 | case 10: 66 | __asm("mov %0, r10" : "=r" (reg_content)); 67 | break; 68 | default: 69 | // not impl. do nothing 70 | break; 71 | } 72 | return reg_content; 73 | } 74 | 75 | inline void 76 | copy_stack(void *dest, int copy_size) { 77 | printf("copy_stack: %d\n", copy_size); 78 | if(copy_size > 0) { 79 | memcpy( (void *) (dest), get_stack_ptr(), copy_size); 80 | } 81 | return; 82 | } 83 | */ 84 | 85 | #endif /* HELPER_H */ 86 | -------------------------------------------------------------------------------- /firmwaretools/Mediatek/megaparser.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from binascii import hexlify, unhexlify 3 | import struct 4 | import datetime 5 | import sys 6 | import lzma as xz 7 | 8 | filename = sys.argv[1] 9 | with open(filename, "rb") as file: 10 | s = file.read() 11 | print(str(len(s)) + ' bytes') 12 | print "Magic: %s" % s[:3] 13 | sections = int(hex( struct.unpack( '. * 32 | * * 33 | **************************************************************************/ 34 | 35 | #ifndef WRAPPER_H 36 | #define WRAPPER_H 37 | 38 | #include "../common/wrapper.c" // wrapper definitions for functions that already exist in the firmware 39 | 40 | #endif /*WRAPPER_H*/ 41 | -------------------------------------------------------------------------------- /patches/include/sendframe.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * ########### ########### ########## ########## * 4 | * ############ ############ ############ ############ * 5 | * ## ## ## ## ## ## ## * 6 | * ## ## ## ## ## ## ## * 7 | * ########### #### ###### ## ## ## ## ###### * 8 | * ########### #### # ## ## ## ## # # * 9 | * ## ## ###### ## ## ## ## # # * 10 | * ## ## # ## ## ## ## # # * 11 | * ############ ##### ###### ## ## ## ##### ###### * 12 | * ########### ########### ## ## ## ########## * 13 | * * 14 | * S E C U R E M O B I L E N E T W O R K I N G * 15 | * * 16 | * This file is part of NexMon. * 17 | * * 18 | * Copyright (c) 2016 NexMon Team * 19 | * * 20 | * NexMon is free software: you can redistribute it and/or modify * 21 | * it under the terms of the GNU General Public License as published by * 22 | * the Free Software Foundation, either version 3 of the License, or * 23 | * (at your option) any later version. * 24 | * * 25 | * NexMon is distributed in the hope that it will be useful, * 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 28 | * GNU General Public License for more details. * 29 | * * 30 | * You should have received a copy of the GNU General Public License * 31 | * along with NexMon. If not, see . * 32 | * * 33 | **************************************************************************/ 34 | 35 | #ifndef SENDFRAME_H 36 | #define SENDFRAME_H 37 | 38 | #include 39 | 40 | void sendframe(struct wlc_info *wlc, struct sk_buff *p, unsigned int fifo, unsigned int rate); 41 | 42 | #endif /* SENDFRAME_H */ 43 | -------------------------------------------------------------------------------- /patches/include/capabilities.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * ########### ########### ########## ########## * 4 | * ############ ############ ############ ############ * 5 | * ## ## ## ## ## ## ## * 6 | * ## ## ## ## ## ## ## * 7 | * ########### #### ###### ## ## ## ## ###### * 8 | * ########### #### # ## ## ## ## # # * 9 | * ## ## ###### ## ## ## ## # # * 10 | * ## ## # ## ## ## ## # # * 11 | * ############ ##### ###### ## ## ## ##### ###### * 12 | * ########### ########### ## ## ## ########## * 13 | * * 14 | * S E C U R E M O B I L E N E T W O R K I N G * 15 | * * 16 | * This file is part of NexMon. * 17 | * * 18 | * Copyright (c) 2016 NexMon Team * 19 | * * 20 | * NexMon is free software: you can redistribute it and/or modify * 21 | * it under the terms of the GNU General Public License as published by * 22 | * the Free Software Foundation, either version 3 of the License, or * 23 | * (at your option) any later version. * 24 | * * 25 | * NexMon is distributed in the hope that it will be useful, * 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 28 | * GNU General Public License for more details. * 29 | * * 30 | * You should have received a copy of the GNU General Public License * 31 | * along with NexMon. If not, see . * 32 | * * 33 | **************************************************************************/ 34 | 35 | // external definition to define the capabilities 36 | extern int capabilities; 37 | 38 | // Capabilities of the Nexmon Patch 39 | #define NEX_CAP_MONITOR_MODE (1 << 0) 40 | #define NEX_CAP_MONITOR_MODE_RADIOTAP (1 << 1) 41 | #define NEX_CAP_FRAME_INJECTION (1 << 2) 42 | -------------------------------------------------------------------------------- /firmwares/mw300/lumi-gateway_141_156/structs.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * ########### ########### ########## ########## * 4 | * ############ ############ ############ ############ * 5 | * ## ## ## ## ## ## ## * 6 | * ## ## ## ## ## ## ## * 7 | * ########### #### ###### ## ## ## ## ###### * 8 | * ########### #### # ## ## ## ## # # * 9 | * ## ## ###### ## ## ## ## # # * 10 | * ## ## # ## ## ## ## # # * 11 | * ############ ##### ###### ## ## ## ##### ###### * 12 | * ########### ########### ## ## ## ########## * 13 | * * 14 | * S E C U R E M O B I L E N E T W O R K I N G * 15 | * * 16 | * This file is part of NexMon. * 17 | * * 18 | * Copyright (c) 2016 NexMon Team * 19 | * * 20 | * NexMon is free software: you can redistribute it and/or modify * 21 | * it under the terms of the GNU General Public License as published by * 22 | * the Free Software Foundation, either version 3 of the License, or * 23 | * (at your option) any later version. * 24 | * * 25 | * NexMon is distributed in the hope that it will be useful, * 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 28 | * GNU General Public License for more details. * 29 | * * 30 | * You should have received a copy of the GNU General Public License * 31 | * along with NexMon. If not, see . * 32 | * * 33 | **************************************************************************/ 34 | 35 | #ifndef STRUCTS_H 36 | #define STRUCTS_H 37 | 38 | #ifndef PAD 39 | #define _PADLINE(line) pad ## line 40 | #define _XSTR(line) _PADLINE(line) 41 | #define PAD _XSTR(__LINE__) 42 | #endif 43 | 44 | #include "../structs.common.h" 45 | 46 | #endif /*STRUCTS_H */ 47 | -------------------------------------------------------------------------------- /patches/include/rates.h: -------------------------------------------------------------------------------- 1 | #ifndef RATES_H 2 | #define RATES_H 3 | 4 | /* Rate Defines */ 5 | 6 | /* Valid rates for the Supported Rates and Extended Supported Rates IEs. 7 | * Encoding is the rate in 500kbps units, rouding up for fractional values. 8 | * 802.11-2012, section 6.5.5.2, DATA_RATE parameter enumerates all the values. 9 | * The rate values cover DSSS, HR/DSSS, ERP, and OFDM phy rates. 10 | * The defines below do not cover the rates specific to 10MHz, {3, 4.5, 27}, 11 | * and 5MHz, {1.5, 2.25, 3, 4.5, 13.5}, which are not supported by Broadcom devices. 12 | */ 13 | 14 | #define RATES_RATE_1M 2 /* 1 Mbps in 500kbps units DSSS */ 15 | #define RATES_RATE_2M 4 /* 2 Mbps in 500kbps units DSSS */ 16 | #define RATES_RATE_5M5 11 /* 5.5 Mbps in 500kbps units DSSS */ 17 | #define RATES_RATE_11M 22 /* 11 Mbps in 500kbps units DSSS */ 18 | #define RATES_RATE_6M 12 /* 6 Mbps in 500kbps units OFDM */ 19 | #define RATES_RATE_9M 18 /* 9 Mbps in 500kbps units OFDN */ 20 | #define RATES_RATE_12M 24 /* 12 Mbps in 500kbps units OFDM */ 21 | #define RATES_RATE_18M 36 /* 18 Mbps in 500kbps units OFDM */ 22 | #define RATES_RATE_24M 48 /* 24 Mbps in 500kbps units OFDM */ 23 | #define RATES_RATE_36M 72 /* 36 Mbps in 500kbps units OFDM */ 24 | #define RATES_RATE_48M 96 /* 48 Mbps in 500kbps units OFDM */ 25 | #define RATES_RATE_54M 108 /* 54 Mbps in 500kbps units OFDM */ 26 | #define RATES_RATE_MAX 108 /* highest rate (54 Mbps) in 500kbps units */ 27 | 28 | #define RATES_RATE_MASK 0x000000FF 29 | #define RATES_VHT_MCS_MASK 0x0000000F 30 | #define RATES_VHT_NSS_MASK 0x000000F0 31 | #define RATES_VHT_NSS_SHIFT 4 32 | 33 | #define RATES_HT_MCS_MASK 0x00000007 34 | #define RATES_HT_NSS_MASK 0x00000078 35 | #define RATES_HT_NSS_SHIFT 3 36 | 37 | #define RATES_TXEXP_MASK 0x00000300 38 | #define RATES_TXEXP_SHIFT 8 39 | 40 | #define RATES_BW_MASK 0x00070000 41 | #define RATES_BW_SHIFT 16 42 | 43 | #define RATES_STBC 0x00100000 44 | #define RATES_TXBF 0x00200000 45 | #define RATES_LDPC_CODING 0x00400000 46 | #define RATES_SHORT_GI 0x00800000 47 | #define RATES_SHORT_PREAMBLE 0x00800000 48 | #define RATES_ENCODING_MASK 0x03000000 49 | #define RATES_OVERRIDE_RATE 0x40000000 50 | #define RATES_OVERRIDE_MODE 0x80000000 51 | 52 | #define RATES_ENCODE_RATE 0x00000000 53 | #define RATES_ENCODE_HT 0x01000000 54 | #define RATES_ENCODE_VHT 0x02000000 55 | 56 | #define BW_20MHZ 1 57 | #define BW_40MHZ 2 58 | #define BW_80MHZ 3 59 | #define BW_160MHZ 4 60 | 61 | #define RATES_BW_UNSPECIFIED 0x00000000 62 | #define RATES_BW_20MHZ (BW_20MHZ << RATES_BW_SHIFT) 63 | #define RATES_BW_40MHZ (BW_40MHZ << RATES_BW_SHIFT) 64 | #define RATES_BW_80MHZ (BW_80MHZ << RATES_BW_SHIFT) 65 | #define RATES_BW_160MHZ (BW_160MHZ << RATES_BW_SHIFT) 66 | 67 | #endif /* RATES_H */ 68 | -------------------------------------------------------------------------------- /patches/include/nexioctls.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * ########### ########### ########## ########## * 4 | * ############ ############ ############ ############ * 5 | * ## ## ## ## ## ## ## * 6 | * ## ## ## ## ## ## ## * 7 | * ########### #### ###### ## ## ## ## ###### * 8 | * ########### #### # ## ## ## ## # # * 9 | * ## ## ###### ## ## ## ## # # * 10 | * ## ## # ## ## ## ## # # * 11 | * ############ ##### ###### ## ## ## ##### ###### * 12 | * ########### ########### ## ## ## ########## * 13 | * * 14 | * S E C U R E M O B I L E N E T W O R K I N G * 15 | * * 16 | * This file is part of NexMon. * 17 | * * 18 | * Copyright (c) 2016 NexMon Team * 19 | * * 20 | * NexMon is free software: you can redistribute it and/or modify * 21 | * it under the terms of the GNU General Public License as published by * 22 | * the Free Software Foundation, either version 3 of the License, or * 23 | * (at your option) any later version. * 24 | * * 25 | * NexMon is distributed in the hope that it will be useful, * 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 28 | * GNU General Public License for more details. * 29 | * * 30 | * You should have received a copy of the GNU General Public License * 31 | * along with NexMon. If not, see . * 32 | * * 33 | **************************************************************************/ 34 | 35 | #define IOCTL_ERROR -23 36 | #define IOCTL_SUCCESS 0 37 | 38 | // IOCTLs used by Nexmon 39 | #define NEX_GET_CAPABILITIES 400 40 | #define NEX_WRITE_TO_CONSOLE 401 41 | #define NEX_CT_EXPERIMENTS 402 42 | #define NEX_GET_CONSOLE 403 43 | #define NEX_GET_PHYREG 404 44 | #define NEX_SET_PHYREG 405 45 | #define NEX_READ_OBJMEM 406 46 | #define NEX_WRITE_OBJMEM 407 47 | -------------------------------------------------------------------------------- /patches/include/firmware_version.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * ########### ########### ########## ########## * 4 | * ############ ############ ############ ############ * 5 | * ## ## ## ## ## ## ## * 6 | * ## ## ## ## ## ## ## * 7 | * ########### #### ###### ## ## ## ## ###### * 8 | * ########### #### # ## ## ## ## # # * 9 | * ## ## ###### ## ## ## ## # # * 10 | * ## ## # ## ## ## ## # # * 11 | * ############ ##### ###### ## ## ## ##### ###### * 12 | * ########### ########### ## ## ## ########## * 13 | * * 14 | * S E C U R E M O B I L E N E T W O R K I N G * 15 | * * 16 | * This file is part of NexMon. * 17 | * * 18 | * Copyright (c) 2016 NexMon Team * 19 | * * 20 | * NexMon is free software: you can redistribute it and/or modify * 21 | * it under the terms of the GNU General Public License as published by * 22 | * the Free Software Foundation, either version 3 of the License, or * 23 | * (at your option) any later version. * 24 | * * 25 | * NexMon is distributed in the hope that it will be useful, * 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 28 | * GNU General Public License for more details. * 29 | * * 30 | * You should have received a copy of the GNU General Public License * 31 | * along with NexMon. If not, see . * 32 | * * 33 | **************************************************************************/ 34 | 35 | #ifndef FIRMWARE_VERSION_H 36 | #define FIRMWARE_VERSION_H 37 | 38 | #define CHIP_VER_ALL 0 39 | 40 | 41 | #define CHIP_VER_MW300_LED 6 42 | #define CHIP_VER_MW300_GW 7 43 | #define CHIP_VER_MW300_COLORBULB1 8 44 | #define CHIP_VER_MW300_MONO1 9 45 | 46 | #define FW_VER_ALL 0 47 | 48 | #define FW_VER_MW300_LED_141_40 60 49 | 50 | #define FW_VER_MW300_GW_141_150 70 51 | #define FW_VER_MW300_GW_141_151 71 52 | #define FW_VER_MW300_GW_141_156 72 53 | 54 | #define FW_VER_MW300_COLORBULB1_141_56 80 55 | 56 | #define FW_VER_MW300_MONO1_142_0055 90 57 | 58 | 59 | #endif /*FIRMWARE_VERSION_H*/ 60 | -------------------------------------------------------------------------------- /patches/include/patcher.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * ########### ########### ########## ########## * 4 | * ############ ############ ############ ############ * 5 | * ## ## ## ## ## ## ## * 6 | * ## ## ## ## ## ## ## * 7 | * ########### #### ###### ## ## ## ## ###### * 8 | * ########### #### # ## ## ## ## # # * 9 | * ## ## ###### ## ## ## ## # # * 10 | * ## ## # ## ## ## ## # # * 11 | * ############ ##### ###### ## ## ## ##### ###### * 12 | * ########### ########### ## ## ## ########## * 13 | * * 14 | * S E C U R E M O B I L E N E T W O R K I N G * 15 | * * 16 | * This file is part of NexMon. * 17 | * * 18 | * Copyright (c) 2016 NexMon Team * 19 | * * 20 | * NexMon is free software: you can redistribute it and/or modify * 21 | * it under the terms of the GNU General Public License as published by * 22 | * the Free Software Foundation, either version 3 of the License, or * 23 | * (at your option) any later version. * 24 | * * 25 | * NexMon is distributed in the hope that it will be useful, * 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 28 | * GNU General Public License for more details. * 29 | * * 30 | * You should have received a copy of the GNU General Public License * 31 | * along with NexMon. If not, see . * 32 | * * 33 | **************************************************************************/ 34 | 35 | #define BLPatch(name, func) \ 36 | __attribute__((naked)) void \ 37 | bl_ ## name(void) { asm("bl " #func "\n"); } 38 | 39 | #define BPatch(name, func) \ 40 | __attribute__((naked)) void \ 41 | b_ ## name(void) { asm("b " #func "\n"); } 42 | 43 | #define HookPatch4(name, func, inst) \ 44 | void b_ ## name(void); \ 45 | __attribute__((naked)) void \ 46 | hook_ ## name(void) \ 47 | { \ 48 | asm( \ 49 | "push {r0-r3,lr}\n" \ 50 | "bl " #func "\n" \ 51 | "pop {r0-r3,lr}\n" \ 52 | inst "\n" \ 53 | "b b_" #name " + 4\n" \ 54 | ); \ 55 | } \ 56 | __attribute__((naked)) void \ 57 | b_ ## name(void) { asm("b hook_" #name "\n"); } 58 | 59 | #define GenericPatch4(name, val) \ 60 | const unsigned int gp4_ ## name = (unsigned int) (val); 61 | 62 | #define GenericPatch2(name, val) \ 63 | unsigned short gp2_ ## name = (unsigned short) (val); 64 | 65 | #define GenericPatch1(name, val) \ 66 | unsigned char gp1_ ## name = (unsigned char) (val); 67 | 68 | #define StringPatch(name, val) \ 69 | __attribute__((naked)) \ 70 | void str_ ## name(void) { asm(".ascii \"" val "\"\n.byte 0x00"); } 71 | 72 | #define Dummy(name) \ 73 | void dummy_ ## name(void) { ; } 74 | -------------------------------------------------------------------------------- /patches/include/objmem.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * ########### ########### ########## ########## * 4 | * ############ ############ ############ ############ * 5 | * ## ## ## ## ## ## ## * 6 | * ## ## ## ## ## ## ## * 7 | * ########### #### ###### ## ## ## ## ###### * 8 | * ########### #### # ## ## ## ## # # * 9 | * ## ## ###### ## ## ## ## # # * 10 | * ## ## # ## ## ## ## # # * 11 | * ############ ##### ###### ## ## ## ##### ###### * 12 | * ########### ########### ## ## ## ########## * 13 | * * 14 | * S E C U R E M O B I L E N E T W O R K I N G * 15 | * * 16 | * This file is part of NexMon. * 17 | * * 18 | * Copyright (c) 2016 NexMon Team * 19 | * * 20 | * NexMon is free software: you can redistribute it and/or modify * 21 | * it under the terms of the GNU General Public License as published by * 22 | * the Free Software Foundation, either version 3 of the License, or * 23 | * (at your option) any later version. * 24 | * * 25 | * NexMon is distributed in the hope that it will be useful, * 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 28 | * GNU General Public License for more details. * 29 | * * 30 | * You should have received a copy of the GNU General Public License * 31 | * along with NexMon. If not, see . * 32 | * * 33 | **************************************************************************/ 34 | 35 | #include // structures that are used by the code in the firmware 36 | 37 | void wlc_bmac_read_objmem32_objaddr(struct wlc_hw_info *wlc_hw, unsigned int objaddr, unsigned int *val); 38 | void wlc_bmac_read_objmem32(struct wlc_hw_info *wlc_hw, unsigned int offset, unsigned int *val, int sel); 39 | void wlc_bmac_read_objmem64_objaddr(struct wlc_hw_info *wlc_hw, unsigned int objaddr, unsigned int *val_low, unsigned int *val_high); 40 | void wlc_bmac_read_objmem64(struct wlc_hw_info *wlc_hw, unsigned int offset, unsigned int *val_low, unsigned int *val_high, int sel); 41 | void wlc_bmac_write_objmem64_objaddr(struct wlc_hw_info *wlc_hw, unsigned int objaddr, unsigned int val_low, unsigned int val_high); 42 | void wlc_bmac_write_objmem64(struct wlc_hw_info *wlc_hw, unsigned int offset, unsigned int val_low, unsigned int val_high, int sel); 43 | void wlc_bmac_write_objmem32_objaddr(struct wlc_hw_info *wlc_hw, unsigned int objaddr, unsigned int value); 44 | void wlc_bmac_write_objmem32(struct wlc_hw_info *wlc_hw, unsigned int offset, unsigned int value, int sel); 45 | void wlc_bmac_write_objmem_byte(struct wlc_hw_info *wlc_hw, unsigned int offset, unsigned char value, int sel); 46 | unsigned char wlc_bmac_read_objmem_byte(struct wlc_hw_info *wlc_hw, unsigned int offset, int sel); 47 | -------------------------------------------------------------------------------- /patches/mw300/lumi-gateway_141_156/demo/Makefile: -------------------------------------------------------------------------------- 1 | FW_PATH=$(NEXMON_ROOT)/firmwares/mw300/lumi-gateway_141_156/ 2 | include $(FW_PATH)/definitions.mk 3 | 4 | LOCAL_SRCS=$(wildcard src/*.c) 5 | COMMON_SRCS=$(wildcard $(NEXMON_ROOT)/patches/common/*.c) 6 | FW_SRCS=$(wildcard $(FW_PATH)/*.c) 7 | 8 | OBJS=$(addprefix obj/,$(notdir $(LOCAL_SRCS:.c=.o)) $(notdir $(COMMON_SRCS:.c=.o)) $(notdir $(FW_SRCS:.c=.o))) 9 | 10 | CFLAGS= \ 11 | -fplugin=$(CCPLUGIN) \ 12 | -fplugin-arg-nexmon-objfile=$@ \ 13 | -fplugin-arg-nexmon-prefile=gen/nexmon.pre \ 14 | -fplugin-arg-nexmon-chipver=$(NEXMON_CHIP_NUM) \ 15 | -fplugin-arg-nexmon-fwver=$(NEXMON_FW_VERSION_NUM) \ 16 | -DNEXMON_CHIP=$(NEXMON_CHIP) \ 17 | -DNEXMON_FW_VERSION=$(NEXMON_FW_VERSION) \ 18 | -Wall -Werror -O2 -nostdlib -nostartfiles -ffreestanding -mthumb -march=$(NEXMON_ARCH) \ 19 | -ffunction-sections -fdata-sections \ 20 | -I$(NEXMON_ROOT)/patches/include \ 21 | -I$(FW_PATH) 22 | 23 | all: $(RAM_FILE) 24 | 25 | init: FORCE 26 | $(Q)make -s -f $(NEXMON_ROOT)/patches/common/header.mk 27 | $(Q)mkdir -p obj gen log 28 | 29 | obj/%.o: src/%.c 30 | @printf "\033[0;31m COMPILING\033[0m %s => %s (details: log/compiler.log)\n" $< $@ 31 | $(Q)cat gen/nexmon.pre 2>>log/error.log | gawk '{ if ($$3 != "$@") print; }' > tmp && mv tmp gen/nexmon.pre 32 | $(Q)$(CC)gcc $(CFLAGS) -c $< -o $@ >>log/compiler.log 33 | 34 | obj/%.o: $(NEXMON_ROOT)/patches/common/%.c 35 | @printf "\033[0;31m COMPILING\033[0m %s => %s (details: log/compiler.log)\n" $< $@ 36 | $(Q)cat gen/nexmon.pre 2>>log/error.log | gawk '{ if ($$3 != "$@") print; }' > tmp && mv tmp gen/nexmon.pre 37 | $(Q)$(CC)gcc $(CFLAGS) -c $< -o $@ >>log/compiler.log 38 | 39 | obj/%.o: $(FW_PATH)/%.c 40 | @printf "\033[0;31m COMPILING\033[0m %s => %s (details: log/compiler.log)\n" $< $@ 41 | $(Q)cat gen/nexmon.pre 2>>log/error.log | gawk '{ if ($$3 != "$@") print; }' > tmp && mv tmp gen/nexmon.pre 42 | $(Q)$(CC)gcc $(CFLAGS) -c $< -o $@ >>log/compiler.log 43 | 44 | gen/nexmon.ld: $(OBJS) 45 | @printf "\033[0;31m GENERATING LINKER FILE\033[0m gen/nexmon.pre => %s\n" $@ 46 | $(Q)sort gen/nexmon.pre | gawk -f $(NEXMON_ROOT)/buildtools/scripts/nexmon.ld.awk > $@ 47 | 48 | gen/nexmon.mk: $(OBJS) $(FW_PATH)/definitions.mk 49 | @printf "\033[0;31m GENERATING MAKE FILE\033[0m gen/nexmon.pre => %s\n" $@ 50 | $(Q)printf "$(RAM_FILE): gen/patch.elf FORCE\n" > $@ 51 | $(Q)sort gen/nexmon.pre | \ 52 | gawk -v src_file=gen/patch.elf -f $(NEXMON_ROOT)/buildtools/scripts/nexmon.mk.1.awk | \ 53 | gawk -v ramstart=$(RAMSTART) -f $(NEXMON_ROOT)/buildtools/scripts/nexmon.mk.2.awk >> $@ 54 | $(Q)printf "\nFORCE:\n" >> $@ 55 | $(Q)gawk '!a[$$0]++' $@ > tmp && mv tmp $@ 56 | 57 | gen/memory.ld: $(FW_PATH)/definitions.mk 58 | @printf "\033[0;31m GENERATING LINKER FILE\033[0m %s\n" $@ 59 | $(Q)printf "rom : ORIGIN = 0x%08x, LENGTH = 0x%08x\n" $(ROMSTART) $(ROMSIZE) > $@ 60 | $(Q)printf "ram : ORIGIN = 0x%08x, LENGTH = 0x%08x\n" $(RAMSTART) $(RAMSIZE) >> $@ 61 | $(Q)printf "patch : ORIGIN = 0x%08x, LENGTH = 0x%08x\n" $(PATCHSTART) $(PATCHSIZE) >> $@ 62 | 63 | gen/patch.elf: patch.ld gen/nexmon.ld gen/memory.ld $(OBJS) 64 | @printf "\033[0;31m LINKING OBJECTS\033[0m => %s (details: log/linker.log, log/linker.err)\n" $@ 65 | $(Q)$(CC)ld -T $< -o $@ --gc-sections --print-gc-sections -M >>log/linker.log 2>>log/linker.err 66 | 67 | $(RAM_FILE): init gen/patch.elf $(FW_PATH)/$(RAM_FILE) gen/nexmon.mk 68 | $(Q)cp $(FW_PATH)/$(RAM_FILE) $@ 69 | @printf "\033[0;31m APPLYING PATCHES\033[0m gen/nexmon.mk => %s (details: log/patches.log)\n" $@ 70 | $(Q)make -f gen/nexmon.mk >>log/patches.log 2>>log/flashpatches.log 71 | $(Q)sh builder.sh 72 | 73 | ################################################################### 74 | 75 | check-nexmon-setup-env: 76 | ifndef NEXMON_SETUP_ENV 77 | $(error run 'source setup_env.sh' first in the repository\'s root directory) 78 | endif 79 | 80 | clean: FORCE 81 | @printf "\033[0;31m CLEANING\033[0m\n" 82 | $(Q)rm -fr $(RAM_FILE) obj gen log 83 | 84 | FORCE: 85 | -------------------------------------------------------------------------------- /patches/common/wrapper.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * ########### ########### ########## ########## * 4 | * ############ ############ ############ ############ * 5 | * ## ## ## ## ## ## ## * 6 | * ## ## ## ## ## ## ## * 7 | * ########### #### ###### ## ## ## ## ###### * 8 | * ########### #### # ## ## ## ## # # * 9 | * ## ## ###### ## ## ## ## # # * 10 | * ## ## # ## ## ## ## # # * 11 | * ############ ##### ###### ## ## ## ##### ###### * 12 | * ########### ########### ## ## ## ########## * 13 | * * 14 | * S E C U R E M O B I L E N E T W O R K I N G * 15 | * * 16 | * This file is part of NexMon. * 17 | * * 18 | * Copyright (c) 2016 NexMon Team * 19 | * * 20 | * NexMon is free software: you can redistribute it and/or modify * 21 | * it under the terms of the GNU General Public License as published by * 22 | * the Free Software Foundation, either version 3 of the License, or * 23 | * (at your option) any later version. * 24 | * * 25 | * NexMon is distributed in the hope that it will be useful, * 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 28 | * GNU General Public License for more details. * 29 | * * 30 | * You should have received a copy of the GNU General Public License * 31 | * along with NexMon. If not, see . * 32 | * * 33 | **************************************************************************/ 34 | 35 | #ifndef WRAPPER_C 36 | #define WRAPPER_C 37 | 38 | #include 39 | #include 40 | 41 | #ifndef WRAPPER_H 42 | // if this file is not included in the wrapper.h file, create dummy functions 43 | #define VOID_DUMMY { ; } 44 | #define RETURN_DUMMY { ; return 0; } 45 | 46 | #define AT(CHIPVER, FWVER, ADDR) __attribute__((at(ADDR, "dummy", CHIPVER, FWVER))) 47 | #else 48 | // if this file is included in the wrapper.h file, create prototypes 49 | #define VOID_DUMMY ; 50 | #define RETURN_DUMMY ; 51 | #define AT(CHIPVER, FWVER, ADDR) 52 | #endif 53 | 54 | typedef int bool; 55 | 56 | typedef int http_session_t; 57 | 58 | typedef enum { 59 | HTTP_VER_1_0, 60 | HTTP_VER_1_1, 61 | } http_ver_t; 62 | 63 | /** 64 | * Structure used to give back http header response fields to the caller. 65 | */ 66 | typedef struct { 67 | /** The value of the protocol field in the first line of the HTTP 68 | header response. e.g. "HTTP". */ 69 | const char *protocol; 70 | /** HTTP version */ 71 | http_ver_t version; 72 | /** The status code returned as a part of the first line of the 73 | HTTP response e.g. 200 if success 74 | */ 75 | int status_code; 76 | /** The ASCII string present in the first line of HTTP response. It 77 | is the verbose representation of status code. e.g. "OK" if 78 | status_code is 200 79 | */ 80 | const char *reason_phrase; 81 | /** HTTP "Server" header field value */ 82 | const char *server; 83 | #ifdef CONFIG_ENABLE_HTTPC_MODIFY_TIME 84 | /** Last-Modified header field value in POSIX time format */ 85 | time_t modify_time; 86 | #endif /* CONFIG_ENABLE_HTTPC_MODIFY_TIME */ 87 | /** The value of "Content-Type" header field. e.g. "text/html" */ 88 | const char *content_type; 89 | /** The value of "Content-Encoding" header field e.g. "gzip" */ 90 | const char *content_encoding; 91 | /** If "Keep-Alive" field is present or if the value of 92 | "Connection" field is "Keep-Alive" then this member is set to 93 | 'true'. It is set to 'false' in other cases 94 | */ 95 | bool keep_alive_ack; 96 | /** If "Keep-Alive" field is present in the response, this member 97 | contains the value of the "timeout" sub-field of this 98 | field. This is the time the server will allow an idle 99 | connection to remain open before it is closed. 100 | */ 101 | int keep_alive_timeout; 102 | /** If "Keep-Alive" field is present in the response, this member 103 | contains the value of the "max" sub-field of this field. The 104 | max parameter indicates the maximum number of requests that a 105 | client will make, or that a server will allow to be made on the 106 | persistent connection. 107 | */ 108 | int keep_alive_max; 109 | /** This will be 'true' if "Transfer-Encoding" field is set to 110 | "chunked". Note that this is only for information and the API 111 | http_read_content() transparently handles chunked reads. 112 | */ 113 | bool chunked; 114 | /** Set to 'true' when "Content-Length" header field is present in 115 | server response. 116 | */ 117 | bool content_length_field_present; 118 | /** Value of the "Content-Length" field. If "Transfer-Encoding" is 119 | set to chunked then this value will be zero. If 120 | 'content_length_present' is 'false' ignore this field value. 121 | */ 122 | int content_length; 123 | } http_resp_t; 124 | 125 | AT(CHIP_VER_MW300_LED, FW_VER_MW300_LED_141_40, 0x1F01ABF4) 126 | AT(CHIP_VER_MW300_GW, FW_VER_MW300_GW_141_150, 0x1F045890) 127 | AT(CHIP_VER_MW300_GW, FW_VER_MW300_GW_141_151, 0x1F046A00) 128 | AT(CHIP_VER_MW300_GW, FW_VER_MW300_GW_141_156, 0x1F04C50C) 129 | AT(CHIP_VER_MW300_COLORBULB1, FW_VER_MW300_COLORBULB1_141_56, 0x1F01AD94) 130 | AT(CHIP_VER_MW300_MONO1, FW_VER_MW300_MONO1_142_0055, 0x1F01AA84) 131 | int 132 | httpc_get(const char *url_str, http_session_t *handle, http_resp_t **http_resp, int null) 133 | RETURN_DUMMY 134 | 135 | AT(CHIP_VER_MW300_LED, FW_VER_MW300_LED_141_40, 0x1F0178A8) 136 | AT(CHIP_VER_MW300_GW, FW_VER_MW300_GW_141_150, 0x1F06A9F4) 137 | AT(CHIP_VER_MW300_GW, FW_VER_MW300_GW_141_151, 0x1F06BB64) 138 | AT(CHIP_VER_MW300_GW, FW_VER_MW300_GW_141_156, 0x1F071670) 139 | AT(CHIP_VER_MW300_COLORBULB1, FW_VER_MW300_COLORBULB1_141_56, 0x1F017A48) 140 | AT(CHIP_VER_MW300_MONO1, FW_VER_MW300_MONO1_142_0055, 0x1F0176FC) 141 | void bin2hex(char *src, char *dest, unsigned int src_len, 142 | unsigned int dest_len) 143 | VOID_DUMMY 144 | 145 | AT(CHIP_VER_MW300_LED, FW_VER_MW300_LED_141_40, 0x1F018238) 146 | AT(CHIP_VER_MW300_GW, FW_VER_MW300_GW_141_150, 0x1F0423C4) 147 | AT(CHIP_VER_MW300_GW, FW_VER_MW300_GW_141_151, 0x1F043534) 148 | AT(CHIP_VER_MW300_GW, FW_VER_MW300_GW_141_156, 0x1F04903C) 149 | AT(CHIP_VER_MW300_COLORBULB1, FW_VER_MW300_COLORBULB1_141_56, 0x1F01842C) 150 | AT(CHIP_VER_MW300_MONO1, FW_VER_MW300_MONO1_142_0055, 0x1F0180AA) 151 | int 152 | snprintf(char *buffer, int a, const char *format,...) 153 | RETURN_DUMMY 154 | 155 | AT(CHIP_VER_MW300_LED, FW_VER_MW300_LED_141_40, 0x1F017098) 156 | AT(CHIP_VER_MW300_GW, FW_VER_MW300_GW_141_150, 0x1F0416E4) 157 | AT(CHIP_VER_MW300_GW, FW_VER_MW300_GW_141_151, 0x1F042854) 158 | AT(CHIP_VER_MW300_GW, FW_VER_MW300_GW_141_156, 0x1F04835C) 159 | AT(CHIP_VER_MW300_COLORBULB1, FW_VER_MW300_COLORBULB1_141_56, 0x1F017238) 160 | AT(CHIP_VER_MW300_MONO1, FW_VER_MW300_MONO1_142_0055, 0x1F016EEC) 161 | int 162 | wmprintf(const char *format, ...) 163 | RETURN_DUMMY 164 | 165 | 166 | 167 | #undef VOID_DUMMY 168 | #undef RETURN_DUMMY 169 | #undef AT 170 | 171 | #endif /*WRAPPER_C*/ 172 | -------------------------------------------------------------------------------- /patches/include/ieee80211_radiotap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2004 David Young. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. The name of David Young may not be used to endorse or promote 13 | * products derived from this software without specific prior 14 | * written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 18 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID 20 | * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | * OF SUCH DAMAGE. 28 | */ 29 | 30 | /* 31 | * Modifications to fit into the linux IEEE 802.11 stack, 32 | * Mike Kershaw (dragorn@kismetwireless.net) 33 | */ 34 | 35 | #ifndef IEEE80211RADIOTAP_H 36 | #define IEEE80211RADIOTAP_H 37 | 38 | #include 39 | 40 | /* Base version of the radiotap packet header data */ 41 | #define PKTHDR_RADIOTAP_VERSION 0 42 | 43 | /* A generic radio capture format is desirable. There is one for 44 | * Linux, but it is neither rigidly defined (there were not even 45 | * units given for some fields) nor easily extensible. 46 | * 47 | * I suggest the following extensible radio capture format. It is 48 | * based on a bitmap indicating which fields are present. 49 | * 50 | * I am trying to describe precisely what the application programmer 51 | * should expect in the following, and for that reason I tell the 52 | * units and origin of each measurement (where it applies), or else I 53 | * use sufficiently weaselly language ("is a monotonically nondecreasing 54 | * function of...") that I cannot set false expectations for lawyerly 55 | * readers. 56 | */ 57 | 58 | struct tsf { 59 | unsigned int tsf_l; 60 | unsigned int tsf_h; 61 | } __attribute__((packed)); 62 | 63 | /* 64 | * The radio capture header precedes the 802.11 header. 65 | * All data in the header is little endian on all platforms. 66 | */ 67 | struct ieee80211_radiotap_header { 68 | uint8 it_version; /* Version 0. Only increases 69 | * for drastic changes, 70 | * introduction of compatible 71 | * new fields does not count. 72 | */ 73 | uint8 it_pad; 74 | uint16 it_len; /* length of the whole 75 | * header in bytes, including 76 | * it_version, it_pad, 77 | * it_len, and data fields. 78 | */ 79 | uint32 it_present; /* A bitmap telling which 80 | * fields are present. Set bit 31 81 | * (0x80000000) to extend the 82 | * bitmap by another 32 bits. 83 | * Additional extensions are made 84 | * by setting bit 31. 85 | */ 86 | } __attribute__((packed)); 87 | 88 | struct nexmon_radiotap_header { 89 | struct ieee80211_radiotap_header header; 90 | struct tsf tsf; 91 | char flags; 92 | unsigned char data_rate; 93 | unsigned short chan_freq; 94 | unsigned short chan_flags; 95 | char dbm_antsignal; 96 | char dbm_antnoise; 97 | #ifdef RADIOTAP_MCS 98 | char mcs[3]; 99 | char PAD; 100 | #endif 101 | #ifdef RADIOTAP_VHT 102 | unsigned short vht_known; 103 | unsigned char vht_flags; 104 | unsigned char vht_bandwidth; 105 | unsigned char vht_mcs_nss[4]; 106 | unsigned char vht_coding; 107 | unsigned char vht_group_id; 108 | unsigned short vht_partial_aid; 109 | #endif 110 | #ifdef RADIOTAP_VENDOR 111 | unsigned char vendor_oui[3]; 112 | unsigned char vendor_sub_namespace; 113 | unsigned short vendor_skip_length; 114 | #endif 115 | } __attribute__((packed)); 116 | 117 | /* Name Data type Units 118 | * ---- --------- ----- 119 | * 120 | * IEEE80211_RADIOTAP_TSFT __le64 microseconds 121 | * 122 | * Value in microseconds of the MAC's 64-bit 802.11 Time 123 | * Synchronization Function timer when the first bit of the 124 | * MPDU arrived at the MAC. For received frames, only. 125 | * 126 | * IEEE80211_RADIOTAP_CHANNEL 2 x __le16 MHz, bitmap 127 | * 128 | * Tx/Rx frequency in MHz, followed by flags (see below). 129 | * 130 | * IEEE80211_RADIOTAP_FHSS __le16 see below 131 | * 132 | * For frequency-hopping radios, the hop set (first byte) 133 | * and pattern (second byte). 134 | * 135 | * IEEE80211_RADIOTAP_RATE u8 500kb/s 136 | * 137 | * Tx/Rx data rate 138 | * 139 | * IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from 140 | * one milliwatt (dBm) 141 | * 142 | * RF signal power at the antenna, decibel difference from 143 | * one milliwatt. 144 | * 145 | * IEEE80211_RADIOTAP_DBM_ANTNOISE s8 decibels from 146 | * one milliwatt (dBm) 147 | * 148 | * RF noise power at the antenna, decibel difference from one 149 | * milliwatt. 150 | * 151 | * IEEE80211_RADIOTAP_DB_ANTSIGNAL u8 decibel (dB) 152 | * 153 | * RF signal power at the antenna, decibel difference from an 154 | * arbitrary, fixed reference. 155 | * 156 | * IEEE80211_RADIOTAP_DB_ANTNOISE u8 decibel (dB) 157 | * 158 | * RF noise power at the antenna, decibel difference from an 159 | * arbitrary, fixed reference point. 160 | * 161 | * IEEE80211_RADIOTAP_LOCK_QUALITY __le16 unitless 162 | * 163 | * Quality of Barker code lock. Unitless. Monotonically 164 | * nondecreasing with "better" lock strength. Called "Signal 165 | * Quality" in datasheets. (Is there a standard way to measure 166 | * this?) 167 | * 168 | * IEEE80211_RADIOTAP_TX_ATTENUATION __le16 unitless 169 | * 170 | * Transmit power expressed as unitless distance from max 171 | * power set at factory calibration. 0 is max power. 172 | * Monotonically nondecreasing with lower power levels. 173 | * 174 | * IEEE80211_RADIOTAP_DB_TX_ATTENUATION __le16 decibels (dB) 175 | * 176 | * Transmit power expressed as decibel distance from max power 177 | * set at factory calibration. 0 is max power. Monotonically 178 | * nondecreasing with lower power levels. 179 | * 180 | * IEEE80211_RADIOTAP_DBM_TX_POWER s8 decibels from 181 | * one milliwatt (dBm) 182 | * 183 | * Transmit power expressed as dBm (decibels from a 1 milliwatt 184 | * reference). This is the absolute power level measured at 185 | * the antenna port. 186 | * 187 | * IEEE80211_RADIOTAP_FLAGS u8 bitmap 188 | * 189 | * Properties of transmitted and received frames. See flags 190 | * defined below. 191 | * 192 | * IEEE80211_RADIOTAP_ANTENNA u8 antenna index 193 | * 194 | * Unitless indication of the Rx/Tx antenna for this packet. 195 | * The first antenna is antenna 0. 196 | * 197 | * IEEE80211_RADIOTAP_RX_FLAGS __le16 bitmap 198 | * 199 | * Properties of received frames. See flags defined below. 200 | * 201 | * IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap 202 | * 203 | * Properties of transmitted frames. See flags defined below. 204 | * 205 | * IEEE80211_RADIOTAP_RTS_RETRIES u8 data 206 | * 207 | * Number of rts retries a transmitted frame used. 208 | * 209 | * IEEE80211_RADIOTAP_DATA_RETRIES u8 data 210 | * 211 | * Number of unicast retries a transmitted frame used. 212 | * 213 | * IEEE80211_RADIOTAP_MCS u8, u8, u8 unitless 214 | * 215 | * Contains a bitmap of known fields/flags, the flags, and 216 | * the MCS index. 217 | * 218 | * IEEE80211_RADIOTAP_AMPDU_STATUS u32, u16, u8, u8 unitless 219 | * 220 | * Contains the AMPDU information for the subframe. 221 | * 222 | * IEEE80211_RADIOTAP_VHT u16, u8, u8, u8[4], u8, u8, u16 223 | * 224 | * Contains VHT information about this frame. 225 | */ 226 | enum ieee80211_radiotap_type { 227 | IEEE80211_RADIOTAP_TSFT = 0, 228 | IEEE80211_RADIOTAP_FLAGS = 1, 229 | IEEE80211_RADIOTAP_RATE = 2, 230 | IEEE80211_RADIOTAP_CHANNEL = 3, 231 | IEEE80211_RADIOTAP_FHSS = 4, 232 | IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, 233 | IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, 234 | IEEE80211_RADIOTAP_LOCK_QUALITY = 7, 235 | IEEE80211_RADIOTAP_TX_ATTENUATION = 8, 236 | IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, 237 | IEEE80211_RADIOTAP_DBM_TX_POWER = 10, 238 | IEEE80211_RADIOTAP_ANTENNA = 11, 239 | IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, 240 | IEEE80211_RADIOTAP_DB_ANTNOISE = 13, 241 | IEEE80211_RADIOTAP_RX_FLAGS = 14, 242 | IEEE80211_RADIOTAP_TX_FLAGS = 15, 243 | IEEE80211_RADIOTAP_RTS_RETRIES = 16, 244 | IEEE80211_RADIOTAP_DATA_RETRIES = 17, 245 | 246 | IEEE80211_RADIOTAP_MCS = 19, 247 | IEEE80211_RADIOTAP_AMPDU_STATUS = 20, 248 | IEEE80211_RADIOTAP_VHT = 21, 249 | 250 | /* valid in every it_present bitmap, even vendor namespaces */ 251 | IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, 252 | IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30, 253 | IEEE80211_RADIOTAP_EXT = 31 254 | }; 255 | 256 | /* Channel flags. */ 257 | #define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ 258 | #define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ 259 | #define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ 260 | #define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */ 261 | #define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ 262 | #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ 263 | #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ 264 | #define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */ 265 | #define IEEE80211_CHAN_GSM 0x1000 /* GSM (900 MHz) */ 266 | #define IEEE80211_CHAN_STURBO 0x2000 /* Static Turbo */ 267 | #define IEEE80211_CHAN_HALF 0x4000 /* Half channel (10 MHz wide) */ 268 | #define IEEE80211_CHAN_QUARTER 0x8000 /* Quarter channel (5 MHz wide) */ 269 | 270 | /* For IEEE80211_RADIOTAP_FLAGS */ 271 | #define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received 272 | * during CFP 273 | */ 274 | #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received 275 | * with short 276 | * preamble 277 | */ 278 | #define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received 279 | * with WEP encryption 280 | */ 281 | #define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received 282 | * with fragmentation 283 | */ 284 | #define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ 285 | #define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between 286 | * 802.11 header and payload 287 | * (to 32-bit boundary) 288 | */ 289 | #define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* bad FCS */ 290 | 291 | /* For IEEE80211_RADIOTAP_RX_FLAGS */ 292 | #define IEEE80211_RADIOTAP_F_RX_BADPLCP 0x0002 /* frame has bad PLCP */ 293 | 294 | /* For IEEE80211_RADIOTAP_TX_FLAGS */ 295 | #define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive 296 | * retries */ 297 | #define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ 298 | #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ 299 | #define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 /* don't expect an ack */ 300 | 301 | 302 | /* For IEEE80211_RADIOTAP_MCS */ 303 | #define IEEE80211_RADIOTAP_MCS_HAVE_BW 0x01 304 | #define IEEE80211_RADIOTAP_MCS_HAVE_MCS 0x02 305 | #define IEEE80211_RADIOTAP_MCS_HAVE_GI 0x04 306 | #define IEEE80211_RADIOTAP_MCS_HAVE_FMT 0x08 307 | #define IEEE80211_RADIOTAP_MCS_HAVE_FEC 0x10 308 | #define IEEE80211_RADIOTAP_MCS_HAVE_STBC 0x20 309 | 310 | #define IEEE80211_RADIOTAP_MCS_BW_MASK 0x03 311 | #define IEEE80211_RADIOTAP_MCS_BW_20 0 312 | #define IEEE80211_RADIOTAP_MCS_BW_40 1 313 | #define IEEE80211_RADIOTAP_MCS_BW_20L 2 314 | #define IEEE80211_RADIOTAP_MCS_BW_20U 3 315 | #define IEEE80211_RADIOTAP_MCS_SGI 0x04 316 | #define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08 317 | #define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 318 | #define IEEE80211_RADIOTAP_MCS_STBC_MASK 0x60 319 | #define IEEE80211_RADIOTAP_MCS_STBC_1 1 320 | #define IEEE80211_RADIOTAP_MCS_STBC_2 2 321 | #define IEEE80211_RADIOTAP_MCS_STBC_3 3 322 | 323 | #define IEEE80211_RADIOTAP_MCS_STBC_SHIFT 5 324 | 325 | /* For IEEE80211_RADIOTAP_AMPDU_STATUS */ 326 | #define IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN 0x0001 327 | #define IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN 0x0002 328 | #define IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN 0x0004 329 | #define IEEE80211_RADIOTAP_AMPDU_IS_LAST 0x0008 330 | #define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR 0x0010 331 | #define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN 0x0020 332 | 333 | /* For IEEE80211_RADIOTAP_VHT */ 334 | #define IEEE80211_RADIOTAP_VHT_KNOWN_STBC 0x0001 335 | #define IEEE80211_RADIOTAP_VHT_KNOWN_TXOP_PS_NA 0x0002 336 | #define IEEE80211_RADIOTAP_VHT_KNOWN_GI 0x0004 337 | #define IEEE80211_RADIOTAP_VHT_KNOWN_SGI_NSYM_DIS 0x0008 338 | #define IEEE80211_RADIOTAP_VHT_KNOWN_LDPC_EXTRA_OFDM_SYM 0x0010 339 | #define IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED 0x0020 340 | #define IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH 0x0040 341 | #define IEEE80211_RADIOTAP_VHT_KNOWN_GROUP_ID 0x0080 342 | #define IEEE80211_RADIOTAP_VHT_KNOWN_PARTIAL_AID 0x0100 343 | 344 | #define IEEE80211_RADIOTAP_VHT_FLAG_STBC 0x01 345 | #define IEEE80211_RADIOTAP_VHT_FLAG_TXOP_PS_NA 0x02 346 | #define IEEE80211_RADIOTAP_VHT_FLAG_SGI 0x04 347 | #define IEEE80211_RADIOTAP_VHT_FLAG_SGI_NSYM_M10_9 0x08 348 | #define IEEE80211_RADIOTAP_VHT_FLAG_LDPC_EXTRA_OFDM_SYM 0x10 349 | #define IEEE80211_RADIOTAP_VHT_FLAG_BEAMFORMED 0x20 350 | 351 | #define IEEE80211_RADIOTAP_CODING_LDPC_USER0 0x01 352 | #define IEEE80211_RADIOTAP_CODING_LDPC_USER1 0x02 353 | #define IEEE80211_RADIOTAP_CODING_LDPC_USER2 0x04 354 | #define IEEE80211_RADIOTAP_CODING_LDPC_USER3 0x08 355 | 356 | /** 357 | * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args 358 | * @rtheader: pointer to the radiotap header we are walking through 359 | * @max_length: length of radiotap header in cpu byte ordering 360 | * @this_arg_index: IEEE80211_RADIOTAP_... index of current arg 361 | * @this_arg: pointer to current radiotap arg 362 | * @arg_index: internal next argument index 363 | * @arg: internal next argument pointer 364 | * @next_bitmap: internal pointer to next present u32 365 | * @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present 366 | */ 367 | 368 | struct ieee80211_radiotap_iterator { 369 | struct ieee80211_radiotap_header *rtheader; 370 | int max_length; 371 | int this_arg_index; 372 | uint8 *this_arg; 373 | 374 | int arg_index; 375 | uint8 *arg; 376 | uint32 *next_bitmap; 377 | uint32 bitmap_shifter; 378 | }; 379 | 380 | extern int ieee80211_radiotap_iterator_init(struct ieee80211_radiotap_iterator *iterator, struct ieee80211_radiotap_header *radiotap_header, int max_length); 381 | extern int ieee80211_radiotap_iterator_next(struct ieee80211_radiotap_iterator *iterator); 382 | 383 | #endif /* IEEE80211_RADIOTAP_H */ 384 | -------------------------------------------------------------------------------- /patches/include/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef DEBUG_H 2 | #define DEBUG_H 3 | 4 | struct trace { 5 | unsigned int exception_id; 6 | unsigned int PC; 7 | unsigned int CPSR; 8 | unsigned int SPSR; 9 | unsigned int r0; 10 | unsigned int r1; 11 | unsigned int r2; 12 | unsigned int r3; 13 | unsigned int r4; 14 | unsigned int r5; 15 | unsigned int r6; 16 | unsigned int r7; 17 | unsigned int r8; 18 | unsigned int r9; 19 | unsigned int r10; 20 | unsigned int r11; 21 | unsigned int r12; 22 | unsigned int sp; 23 | unsigned int lr; 24 | unsigned int pc; 25 | } __attribute__((packed)); 26 | 27 | /* the number of available watch- and breakpoints */ 28 | #define DBG_NUMBER_OF_WATCHPOINTS 4 29 | #define DBG_NUMBER_OF_BREAKPOINTS 4 30 | 31 | #define SET_DBG_VALUE(name, value) (((value) & name ## _MASK) << name ## _SHIFT) 32 | #define GET_DBG_VALUE(name, reg) (((reg) >> name ## _SHIFT) & name ## _MASK) 33 | #define GET_DBG_MASK(name) (name ## _MASK << name ## _SHIFT) 34 | #define GET_DBG_INV_MASK(name) ~GET_DBG_MASK(name) 35 | #define UPDATE_DBG_REG(reg, mask, value) (((reg) & ~(mask)) | (value)) 36 | 37 | /* The address where the memory mapped debug registers are located */ 38 | #define DBGBASE (0x18007000) 39 | 40 | /* C11.11.20 DBGDSCR - Debug Status and Control Register */ 41 | #define DBGDSCR (*(volatile int *) (DBGBASE + 0x88)) 42 | 43 | // MASK masks the bits before shifting left or after shifting right 44 | /* DBGDTRRX register full (read only) */ 45 | #define DBGDSCR_RXfull_SHIFT 30 46 | #define DBGDSCR_RXfull_MASK 1 47 | #define DBGDSCR_RXfull_EMPTY 0 48 | #define DBGDSCR_RXfull_FULL 1 49 | 50 | /* DBGDTRTX register full (read only) */ 51 | #define DBGDSCR_TXfull_SHIFT 29 52 | #define DBGDSCR_TXfull_MASK 1 53 | #define DBGDSCR_TXfull_EMPTY 0 54 | #define DBGDSCR_TXfull_FULL 1 55 | 56 | /* Latched RXfull (read only) */ 57 | #define DBGDSCR_RXfull_I_SHIFT 27 58 | #define DBGDSCR_RXfull_I_MASK 1 59 | 60 | /* Latched TXfull (read only) */ 61 | #define DBGDSCR_TXfull_I_SHIFT 26 62 | #define DBGDSCR_TXfull_I_MASK 1 63 | 64 | /* Sticky Pipeline Advance bit (read only) */ 65 | #define DBGDSCR_PipeAdv_SHIFT 25 66 | #define DBGDSCR_PipeAdv_MASK 1 67 | 68 | /* Latched Instruction Complete (read only) */ 69 | #define DBGDSCR_InstrCompl_I_SHIFT 24 70 | #define DBGDSCR_InstrCompl_I_MASK 1 71 | #define DBGDSCR_InstrCompl_I_NOT_COMPLETED 0 72 | #define DBGDSCR_InstrCompl_I_COMPLETED 1 73 | 74 | /* External DCC access mode */ 75 | #define DBGDSCR_ExtDCCmode_SHIFT 20 76 | #define DBGDSCR_ExtDCCmode_MASK 3 77 | #define DBGDSCR_ExtDCCmode_NON_BLOCKING_MODE 0x0 78 | #define DBGDSCR_ExtDCCmode_STALL_MODE 0x1 79 | #define DBGDSCR_ExtDCCmode_FAST_MODE 0x2 80 | 81 | /* Asynchronous Aborts Discarded */ 82 | #define DBGDSCR_ADAdiscard_SHIFT 19 83 | #define DBGDSCR_ADAdiscard_MASK 1 84 | 85 | /* Non-secure state status */ 86 | #define DBGDSCR_NS_SHIFT 18 87 | #define DBGDSCR_NS_MASK 1 88 | 89 | /* Secure PL1 Non_invasive Debug Disabled */ 90 | #define DBGDSCR_SPNIDdis_SHIFT 17 91 | #define DBGDSCR_SPNIDdis_MASK 1 92 | #define DBGDSCR_SPNIDdis_PERMITTED 0 93 | #define DBGDSCR_SPNIDdis_NOT_PERMITTED 1 94 | 95 | /* Secure PL1 Invasive Debug Disabled bit */ 96 | #define DBGDSCR_SPIDdis_SHIFT 16 97 | #define DBGDSCR_SPIDdis_MASK 1 98 | #define DBGDSCR_SPIDdis_PERMITTED 0 99 | #define DBGDSCR_SPIDdis_NOT_PERMITTED 1 100 | 101 | /* Monitor debug-mode enable */ 102 | #define DBGDSCR_MDBGen_SHIFT 15 103 | #define DBGDSCR_MDBGen_MASK 1 104 | #define DBGDSCR_MDBGen_DISABLED 0 105 | #define DBGDSCR_MDBGen_ENABLED 1 106 | 107 | /* Halting debug-mode enable */ 108 | #define DBGDSCR_HDBGen_SHIFT 14 109 | #define DBGDSCR_HDBGen_MASK 1 110 | #define DBGDSCR_HDBGen_DISABLED 0 111 | #define DBGDSCR_HDBGen_ENABLED 1 112 | 113 | /* Execute ARM instruction enable */ 114 | #define DBGDSCR_ITRen_SHIFT 13 115 | #define DBGDSCR_ITRen_MASK 1 116 | #define DBGDSCR_ITRen_DISABLED 0 117 | #define DBGDSCR_ITRen_ENABLED 1 118 | 119 | /* User mode access to Debug Communications Channel (DCC) disabled */ 120 | #define DBGDSCR_UDCCdis_SHIFT 12 121 | #define DBGDSCR_UDCCdis_MASK 1 122 | #define DBGDSCR_UDCCdis_ENABLED 0 123 | #define DBGDSCR_UDCCdis_DISABLED 1 124 | 125 | /* Interrumpts Disable */ 126 | #define DBGDSCR_INTdis_SHIFT 11 127 | #define DBGDSCR_INTdis_MASK 1 128 | #define DBGDSCR_INTdis_ENABLED 0 129 | #define DBGDSCR_INTdis_DISABLED 1 130 | 131 | /* Force Debug Acknowledge */ 132 | #define DBGDSCR_DBGack_SHIFT 10 133 | #define DBGDSCR_DBGack_MASK 1 134 | 135 | /* Fault status */ 136 | #define DBGDSCR_FS_SHIFT 9 137 | #define DBGDSCR_FS_MASK 1 138 | 139 | /* Sticky Undefined Instruction */ 140 | #define DBGDSCR_UND_I_SHIFT 8 141 | #define DBGDSCR_UND_I_MASK 1 142 | 143 | /* Sticky Asynchronous Abort */ 144 | #define DBGDSCR_ADABORT_I_SHIFT 7 145 | #define DBGDSCR_ADABORT_I_MASK 1 146 | 147 | /* Sticky Synchronous Data Abort */ 148 | #define DBGDSCR_SDABORT_I_SHIFT 6 149 | #define DBGDSCR_SDABORT_I_MASK 1 150 | 151 | /* Method of Debug entry */ 152 | #define DBGDSCR_MOE_SHIFT 2 153 | #define DBGDSCR_MOE_MASK 0xF 154 | 155 | /* Processor Restarted */ 156 | #define DBGDSCR_RESTARTED_SHIFT 1 157 | #define DBGDSCR_RESTARTED_MASK 1 158 | 159 | /* Processor Halted */ 160 | #define DBGDSCR_HALTED_SHIFT 0 161 | #define DBGDSCR_HALTED_MASK 1 162 | #define DBGDSCR_HALTED_NON_DEBUG_STATE 0 163 | #define DBGDSCR_HALTED_DEBUG_STATE 1 164 | 165 | /* C11.11.3 DBGBVR - Breakpoint Value Registers */ 166 | #define DBGBVR0 (*(volatile int *) (DBGBASE + 0x100)) 167 | #define DBGBVR1 (*(volatile int *) (DBGBASE + 0x104)) 168 | #define DBGBVR2 (*(volatile int *) (DBGBASE + 0x108)) 169 | #define DBGBVR3 (*(volatile int *) (DBGBASE + 0x10C)) 170 | #define DBGBVR4 (*(volatile int *) (DBGBASE + 0x110)) 171 | #define DBGBVR5 (*(volatile int *) (DBGBASE + 0x114)) 172 | #define DBGBVR6 (*(volatile int *) (DBGBASE + 0x118)) 173 | #define DBGBVR7 (*(volatile int *) (DBGBASE + 0x11C)) 174 | 175 | /* The last two bits of an instruction address needs to be set to 0 */ 176 | #define DBGBVR_ADDRMASK (0xFFFFFFFC) 177 | 178 | /* C11.11.2 DBGBCR - Breakpoint Control Registers */ 179 | #define DBGBCR0 (*(volatile int *) (DBGBASE + 0x140)) 180 | #define DBGBCR1 (*(volatile int *) (DBGBASE + 0x144)) 181 | #define DBGBCR2 (*(volatile int *) (DBGBASE + 0x148)) 182 | #define DBGBCR3 (*(volatile int *) (DBGBASE + 0x14C)) 183 | #define DBGBCR4 (*(volatile int *) (DBGBASE + 0x150)) 184 | #define DBGBCR5 (*(volatile int *) (DBGBASE + 0x154)) 185 | #define DBGBCR6 (*(volatile int *) (DBGBASE + 0x158)) 186 | #define DBGBCR7 (*(volatile int *) (DBGBASE + 0x15C)) 187 | 188 | /* Address range mask */ 189 | #define DBGBCR_MASK_SHIFT 24 190 | #define DBGBCR_MASK_MASK 0x1F 191 | #define DBGBCR_MASK_NO_MASK 0 192 | #define DBGBCR_MASK_00000007 3 193 | #define DBGBCR_MASK_0000000F 4 194 | #define DBGBCR_MASK_0000001F 5 195 | #define DBGBCR_MASK_0000003F 6 196 | #define DBGBCR_MASK_0000007F 7 197 | #define DBGBCR_MASK_000000FF 8 198 | #define DBGBCR_MASK_000001FF 9 199 | #define DBGBCR_MASK_000003FF 10 200 | #define DBGBCR_MASK_000007FF 11 201 | #define DBGBCR_MASK_00000FFF 12 202 | #define DBGBCR_MASK_00001FFF 13 203 | #define DBGBCR_MASK_00003FFF 14 204 | #define DBGBCR_MASK_00007FFF 15 205 | #define DBGBCR_MASK_0000FFFF 16 206 | #define DBGBCR_MASK_0001FFFF 17 207 | #define DBGBCR_MASK_0003FFFF 18 208 | #define DBGBCR_MASK_0007FFFF 19 209 | #define DBGBCR_MASK_000FFFFF 20 210 | #define DBGBCR_MASK_001FFFFF 21 211 | #define DBGBCR_MASK_003FFFFF 22 212 | #define DBGBCR_MASK_007FFFFF 23 213 | #define DBGBCR_MASK_00FFFFFF 24 214 | #define DBGBCR_MASK_01FFFFFF 25 215 | #define DBGBCR_MASK_03FFFFFF 26 216 | #define DBGBCR_MASK_07FFFFFF 27 217 | #define DBGBCR_MASK_0FFFFFFF 28 218 | #define DBGBCR_MASK_1FFFFFFF 29 219 | #define DBGBCR_MASK_3FFFFFFF 30 220 | #define DBGBCR_MASK_7FFFFFFF 31 221 | 222 | /* Breakpoint type */ 223 | #define DBGBCR_BT_SHIFT 20 224 | #define DBGBCR_BT_MASK 0xF 225 | #define DBGBCR_BT_UNLINKED_INSTR_ADDR_MATCH 0 226 | #define DBGBCR_BT_LINKED_INSTR_ADDR_MATCH 1 227 | #define DBGBCR_BT_UNLINKED_CONTEXT_ID_MATCH 2 228 | #define DBGBCR_BT_LINKED_CONTEXT_ID_MATCH 3 229 | #define DBGBCR_BT_UNLINKED_INSTR_ADDR_MISMATCH 4 230 | #define DBGBCR_BT_LINKED_INSTR_ADDR_MISMATCH 5 231 | 232 | /* Linked breakpoint number */ 233 | #define DBGBCR_LBN_SHIFT 16 234 | #define DBGBCR_LBN_MASK 0xF 235 | 236 | /* Security state control */ 237 | #define DBGBCR_SSC_SHIFT 14 238 | #define DBGBCR_SSC_MASK 3 239 | 240 | /* Hyp mode control bit */ 241 | #define DBGBCR_HMC_SHIFT 13 242 | #define DBGBCR_HMC_MASK 1 243 | 244 | /* Byte address select */ 245 | #define DBGBCR_BAS_SHIFT 5 246 | #define DBGBCR_BAS_MASK 0xF 247 | 248 | #define GET_BAS_FOR_THUMB_ADDR(addr) (3 << (addr & 2)) 249 | 250 | /* Privileged mode control */ 251 | #define DBGBCR_PMC_SHIFT 1 252 | #define DBGBCR_PMC_MASK 3 253 | 254 | /* combined options for SSC, HMC and PMC */ 255 | /* secure and non secure modes */ 256 | #define DBGBCR_SSC_HMC_PMC__PL0_SUP_SYS (SET_DBG_VALUE(DBGBCR_SSC, 0) | SET_DBG_VALUE(DBGBCR_HMC, 0) | SET_DBG_VALUE(DBGBCR_PMC, 0)) 257 | #define DBGBCR_SSC_HMC_PMC__PL1 (SET_DBG_VALUE(DBGBCR_SSC, 0) | SET_DBG_VALUE(DBGBCR_HMC, 0) | SET_DBG_VALUE(DBGBCR_PMC, 1)) 258 | #define DBGBCR_SSC_HMC_PMC__PL0 (SET_DBG_VALUE(DBGBCR_SSC, 0) | SET_DBG_VALUE(DBGBCR_HMC, 0) | SET_DBG_VALUE(DBGBCR_PMC, 2)) 259 | #define DBGBCR_SSC_HMC_PMC__SEC_ALL__NON_SEC_PL1_PL0 (SET_DBG_VALUE(DBGBCR_SSC, 0) | SET_DBG_VALUE(DBGBCR_HMC, 0) | SET_DBG_VALUE(DBGBCR_PMC, 3)) 260 | #define DBGBCR_SSC_HMC_PMC__SEC_PL1__NON_SEC_PL2_PL1 (SET_DBG_VALUE(DBGBCR_SSC, 0) | SET_DBG_VALUE(DBGBCR_HMC, 1) | SET_DBG_VALUE(DBGBCR_PMC, 1)) 261 | #define DBGBCR_SSC_HMC_PMC__ALL (SET_DBG_VALUE(DBGBCR_SSC, 0) | SET_DBG_VALUE(DBGBCR_HMC, 1) | SET_DBG_VALUE(DBGBCR_PMC, 3)) 262 | /* only non-secure modes */ 263 | #define DBGBCR_SSC_HMC_PMC__NON_SEC_PL0_SUP_SYS (SET_DBG_VALUE(DBGBCR_SSC, 1) | SET_DBG_VALUE(DBGBCR_HMC, 0) | SET_DBG_VALUE(DBGBCR_PMC, 0)) 264 | #define DBGBCR_SSC_HMC_PMC__NON_SEC_PL2 (SET_DBG_VALUE(DBGBCR_SSC, 3) | SET_DBG_VALUE(DBGBCR_HMC, 1) | SET_DBG_VALUE(DBGBCR_PMC, 0)) 265 | #define DBGBCR_SSC_HMC_PMC__NON_SEC_PL1 (SET_DBG_VALUE(DBGBCR_SSC, 1) | SET_DBG_VALUE(DBGBCR_HMC, 0) | SET_DBG_VALUE(DBGBCR_PMC, 1)) 266 | #define DBGBCR_SSC_HMC_PMC__NON_SEC_PL0 (SET_DBG_VALUE(DBGBCR_SSC, 1) | SET_DBG_VALUE(DBGBCR_HMC, 0) | SET_DBG_VALUE(DBGBCR_PMC, 2)) 267 | #define DBGBCR_SSC_HMC_PMC__NON_SEC_PL1_PL0 (SET_DBG_VALUE(DBGBCR_SSC, 1) | SET_DBG_VALUE(DBGBCR_HMC, 0) | SET_DBG_VALUE(DBGBCR_PMC, 3)) 268 | #define DBGBCR_SSC_HMC_PMC__NON_SEC_PL2_PL1 (SET_DBG_VALUE(DBGBCR_SSC, 1) | SET_DBG_VALUE(DBGBCR_HMC, 1) | SET_DBG_VALUE(DBGBCR_PMC, 1)) 269 | #define DBGBCR_SSC_HMC_PMC__NON_SEC_ALL (SET_DBG_VALUE(DBGBCR_SSC, 1) | SET_DBG_VALUE(DBGBCR_HMC, 1) | SET_DBG_VALUE(DBGBCR_PMC, 3)) 270 | /* only secure modes */ 271 | #define DBGBCR_SSC_HMC_PMC__SEC_PL0_SUP_SYS (SET_DBG_VALUE(DBGBCR_SSC, 2) | SET_DBG_VALUE(DBGBCR_HMC, 0) | SET_DBG_VALUE(DBGBCR_PMC, 0)) 272 | #define DBGBCR_SSC_HMC_PMC__SEC_PL1 (SET_DBG_VALUE(DBGBCR_SSC, 2) | SET_DBG_VALUE(DBGBCR_HMC, 0) | SET_DBG_VALUE(DBGBCR_PMC, 1)) 273 | #define DBGBCR_SSC_HMC_PMC__SEC_PL0 (SET_DBG_VALUE(DBGBCR_SSC, 2) | SET_DBG_VALUE(DBGBCR_HMC, 0) | SET_DBG_VALUE(DBGBCR_PMC, 2)) 274 | #define DBGBCR_SSC_HMC_PMC__SEC_ALL (SET_DBG_VALUE(DBGBCR_SSC, 2) | SET_DBG_VALUE(DBGBCR_HMC, 0) | SET_DBG_VALUE(DBGBCR_PMC, 3)) 275 | 276 | #define DBGBCR_SSC_HMC_PMC_SHIFT 0 277 | #define DBGBCR_SSC_HMC_PMC_MASK (GET_DBG_MASK(DBGBCR_SSC) | GET_DBG_MASK(DBGBCR_HMC) | GET_DBG_MASK(DBGBCR_PMC)) 278 | 279 | /* Breakpoint enable */ 280 | #define DBGBCR_E_SHIFT 0 281 | #define DBGBCR_E_MASK 1 282 | #define DBGBCR_E_DISABLED 0 283 | #define DBGBCR_E_ENABLED 1 284 | 285 | /* DBGLAR - Lock Access Register */ 286 | #define DBGLAR (*(volatile int *) (DBGBASE + 0xFB0)) 287 | #define DBGLAR_UNLOCK_CODE (0xC5ACCE55) 288 | 289 | /* Breakpoint numbers one-hot encoded */ 290 | #define DBGBP0 (1 << 0) 291 | #define DBGBP1 (1 << 1) 292 | #define DBGBP2 (1 << 2) 293 | #define DBGBP3 (1 << 3) 294 | 295 | /* Watch numbers one-hot encoded */ 296 | #define DBGWP0 (1 << 0) 297 | #define DBGWP1 (1 << 1) 298 | #define DBGWP2 (1 << 2) 299 | #define DBGWP3 (1 << 3) 300 | 301 | /* C11.11.46 DBGWVR - Watchpoint Value Registers */ 302 | #define DBGWVR0 (*(volatile int *) (DBGBASE + 0x180)) 303 | #define DBGWVR1 (*(volatile int *) (DBGBASE + 0x184)) 304 | #define DBGWVR2 (*(volatile int *) (DBGBASE + 0x188)) 305 | #define DBGWVR3 (*(volatile int *) (DBGBASE + 0x18C)) 306 | #define DBGWVR4 (*(volatile int *) (DBGBASE + 0x190)) 307 | #define DBGWVR5 (*(volatile int *) (DBGBASE + 0x194)) 308 | #define DBGWVR6 (*(volatile int *) (DBGBASE + 0x198)) 309 | #define DBGWVR7 (*(volatile int *) (DBGBASE + 0x19C)) 310 | 311 | /* The last two bits of an address needs to be set to 0 */ 312 | #define DBGWVR_ADDRMASK (0xFFFFFFFC) 313 | 314 | /* C11.11.44 DBGWCR - Watchpoint Control Registers */ 315 | #define DBGWCR0 (*(volatile int *) (DBGBASE + 0x1C0)) 316 | #define DBGWCR1 (*(volatile int *) (DBGBASE + 0x1C4)) 317 | #define DBGWCR2 (*(volatile int *) (DBGBASE + 0x1C8)) 318 | #define DBGWCR3 (*(volatile int *) (DBGBASE + 0x1CC)) 319 | #define DBGWCR4 (*(volatile int *) (DBGBASE + 0x1D0)) 320 | #define DBGWCR5 (*(volatile int *) (DBGBASE + 0x1D4)) 321 | #define DBGWCR6 (*(volatile int *) (DBGBASE + 0x1D8)) 322 | #define DBGWCR7 (*(volatile int *) (DBGBASE + 0x1DC)) 323 | 324 | /* Address range mask */ 325 | #define DBGWCR_MASK_SHIFT 24 326 | #define DBGWCR_MASK_MASK 0x1F 327 | #define DBGWCR_MASK_NO_MASK 0 328 | #define DBGWCR_MASK_00000007 3 329 | #define DBGWCR_MASK_0000000F 4 330 | #define DBGWCR_MASK_0000001F 5 331 | #define DBGWCR_MASK_0000003F 6 332 | #define DBGWCR_MASK_0000007F 7 333 | #define DBGWCR_MASK_000000FF 8 334 | #define DBGWCR_MASK_000001FF 9 335 | #define DBGWCR_MASK_000003FF 10 336 | #define DBGWCR_MASK_000007FF 11 337 | #define DBGWCR_MASK_00000FFF 12 338 | #define DBGWCR_MASK_00001FFF 13 339 | #define DBGWCR_MASK_00003FFF 14 340 | #define DBGWCR_MASK_00007FFF 15 341 | #define DBGWCR_MASK_0000FFFF 16 342 | #define DBGWCR_MASK_0001FFFF 17 343 | #define DBGWCR_MASK_0003FFFF 18 344 | #define DBGWCR_MASK_0007FFFF 19 345 | #define DBGWCR_MASK_000FFFFF 20 346 | #define DBGWCR_MASK_001FFFFF 21 347 | #define DBGWCR_MASK_003FFFFF 22 348 | #define DBGWCR_MASK_007FFFFF 23 349 | #define DBGWCR_MASK_00FFFFFF 24 350 | #define DBGWCR_MASK_01FFFFFF 25 351 | #define DBGWCR_MASK_03FFFFFF 26 352 | #define DBGWCR_MASK_07FFFFFF 27 353 | #define DBGWCR_MASK_0FFFFFFF 28 354 | #define DBGWCR_MASK_1FFFFFFF 29 355 | #define DBGWCR_MASK_3FFFFFFF 30 356 | #define DBGWCR_MASK_7FFFFFFF 31 357 | 358 | /* Watchpoint type */ 359 | #define DBGWCR_WT_SHIFT 20 360 | #define DBGWCR_WT_MASK 1 361 | #define DBGWCR_WT_UNLINKED_DATA_ADDR_MATCH 0 362 | #define DBGWCR_WT_LINKED_DATA_ADDR_MATCH 1 363 | 364 | /* Linked watchpoint number */ 365 | #define DBGWCR_LBN_SHIFT 16 366 | #define DBGWCR_LBN_MASK 0xF 367 | 368 | /* Security state control */ 369 | #define DBGWCR_SSC_SHIFT 14 370 | #define DBGWCR_SSC_MASK 3 371 | 372 | /* Hyp mode control bit */ 373 | #define DBGWCR_HMC_SHIFT 13 374 | #define DBGWCR_HMC_MASK 1 375 | 376 | /* Byte address select */ 377 | #define DBGWCR_BAS_4BIT_SHIFT 5 378 | #define DBGWCR_BAS_4BIT_MASK 0xF 379 | #define DBGWCR_BAS_8BIT_SHIFT 5 380 | #define DBGWCR_BAS_8BIT_MASK 0xFF 381 | 382 | /* Load/store access control */ 383 | #define DBGWCR_LSC_SHIFT 3 384 | #define DBGWCR_LSC_MASK 3 385 | #define DBGWCR_LSC_MATCH_LOAD 1 386 | #define DBGWCR_LSC_MATCH_STORE 2 387 | #define DBGWCR_LSC_MATCH_ALL 3 388 | 389 | /* Privileged access control */ 390 | #define DBGWCR_PAC_SHIFT 1 391 | #define DBGWCR_PAC_MASK 3 392 | 393 | /* combined options for SSC, HMC and PAC */ 394 | /* secure and non secure modes */ 395 | #define DBGWCR_SSC_HMC_PAC__PL1 (SET_DBG_VALUE(DBGWCR_SSC, 0) | SET_DBG_VALUE(DBGWCR_HMC, 0) | SET_DBG_VALUE(DBGWCR_PAC, 1)) 396 | #define DBGWCR_SSC_HMC_PAC__PL0 (SET_DBG_VALUE(DBGWCR_SSC, 0) | SET_DBG_VALUE(DBGWCR_HMC, 0) | SET_DBG_VALUE(DBGWCR_PAC, 2)) 397 | #define DBGWCR_SSC_HMC_PAC__PL1_PL0 (SET_DBG_VALUE(DBGWCR_SSC, 0) | SET_DBG_VALUE(DBGWCR_HMC, 0) | SET_DBG_VALUE(DBGWCR_PAC, 3)) 398 | #define DBGWCR_SSC_HMC_PAC__SEC_PL1__NON_SEC_PL2_PL1 (SET_DBG_VALUE(DBGWCR_SSC, 0) | SET_DBG_VALUE(DBGWCR_HMC, 1) | SET_DBG_VALUE(DBGWCR_PAC, 1)) 399 | #define DBGWCR_SSC_HMC_PAC__ALL (SET_DBG_VALUE(DBGWCR_SSC, 0) | SET_DBG_VALUE(DBGWCR_HMC, 1) | SET_DBG_VALUE(DBGWCR_PAC, 3)) 400 | /* only non-secure modes */ 401 | #define DBGWCR_SSC_HMC_PAC__NON_SEC_PL2 (SET_DBG_VALUE(DBGWCR_SSC, 3) | SET_DBG_VALUE(DBGWCR_HMC, 1) | SET_DBG_VALUE(DBGWCR_PAC, 0)) 402 | #define DBGWCR_SSC_HMC_PAC__NON_SEC_PL1 (SET_DBG_VALUE(DBGWCR_SSC, 1) | SET_DBG_VALUE(DBGWCR_HMC, 0) | SET_DBG_VALUE(DBGWCR_PAC, 1)) 403 | #define DBGWCR_SSC_HMC_PAC__NON_SEC_PL0 (SET_DBG_VALUE(DBGWCR_SSC, 1) | SET_DBG_VALUE(DBGWCR_HMC, 0) | SET_DBG_VALUE(DBGWCR_PAC, 2)) 404 | #define DBGWCR_SSC_HMC_PAC__NON_SEC_PL1_PL0 (SET_DBG_VALUE(DBGWCR_SSC, 1) | SET_DBG_VALUE(DBGWCR_HMC, 0) | SET_DBG_VALUE(DBGWCR_PAC, 3)) 405 | #define DBGWCR_SSC_HMC_PAC__NON_SEC_PL2_PL1 (SET_DBG_VALUE(DBGWCR_SSC, 1) | SET_DBG_VALUE(DBGWCR_HMC, 1) | SET_DBG_VALUE(DBGWCR_PAC, 1)) 406 | #define DBGWCR_SSC_HMC_PAC__NON_SEC_PL2_PL1_PL0 (SET_DBG_VALUE(DBGWCR_SSC, 1) | SET_DBG_VALUE(DBGWCR_HMC, 1) | SET_DBG_VALUE(DBGWCR_PAC, 3)) 407 | /* only secure modes */ 408 | #define DBGWCR_SSC_HMC_PAC__SEC_PL1 (SET_DBG_VALUE(DBGWCR_SSC, 2) | SET_DBG_VALUE(DBGWCR_HMC, 0) | SET_DBG_VALUE(DBGWCR_PAC, 1)) 409 | #define DBGWCR_SSC_HMC_PAC__SEC_PL0 (SET_DBG_VALUE(DBGWCR_SSC, 2) | SET_DBG_VALUE(DBGWCR_HMC, 0) | SET_DBG_VALUE(DBGWCR_PAC, 2)) 410 | #define DBGWCR_SSC_HMC_PAC__SEC_PL1_PL0 (SET_DBG_VALUE(DBGWCR_SSC, 2) | SET_DBG_VALUE(DBGWCR_HMC, 0) | SET_DBG_VALUE(DBGWCR_PAC, 3)) 411 | 412 | #define DBGWCR_SSC_HMC_PAC_SHIFT 0 413 | #define DBGWCR_SSC_HMC_PAC_MASK (GET_DBG_MASK(DBGWCR_SSC) | GET_DBG_MASK(DBGWCR_HMC) | GET_DBG_MASK(DBGWCR_PAC)) 414 | 415 | /* Watchpoint enable */ 416 | #define DBGWCR_E_SHIFT 0 417 | #define DBGWCR_E_MASK 1 418 | #define DBGWCR_E_DISABLED 0 419 | #define DBGWCR_E_ENABLED 1 420 | 421 | /* Processor modes */ 422 | #define DBG_PROCESSOR_MODE_USR 0x10 423 | #define DBG_PROCESSOR_MODE_FIQ 0x11 424 | #define DBG_PROCESSOR_MODE_IRQ 0x12 425 | #define DBG_PROCESSOR_MODE_SVC 0x13 426 | #define DBG_PROCESSOR_MODE_ABT 0x17 427 | #define DBG_PROCESSOR_MODE_UND 0x1B 428 | #define DBG_PROCESSOR_MODE_SYS 0x1F 429 | 430 | /* debug helper macros */ 431 | #define dbg_expand1(x) #x 432 | #define dbg_expand(x) dbg_expand1(x) 433 | 434 | #define dbg_change_processor_mode(mode) do { \ 435 | asm("cps #" dbg_expand(mode) "\n"); \ 436 | } while (0) 437 | 438 | #define dbg_unlock_debug_registers() do { \ 439 | DBGLAR = DBGLAR_UNLOCK_CODE; \ 440 | } while (0) 441 | 442 | #define dbg_enable_monitor_mode_debugging() do { \ 443 | DBGDSCR = UPDATE_DBG_REG(DBGDSCR, GET_DBG_MASK(DBGDSCR_MDBGen), SET_DBG_VALUE(DBGDSCR_MDBGen, DBGDSCR_MDBGen_ENABLED)); \ 444 | } while (0) 445 | 446 | #define dbg_disable_monitor_mode_debugging() do { \ 447 | DBGDSCR = UPDATE_DBG_REG(DBGDSCR, GET_DBG_MASK(DBGDSCR_MDBGen), SET_DBG_VALUE(DBGDSCR_MDBGen, DBGDSCR_MDBGen_DISABLED)); \ 448 | } while (0) 449 | 450 | #define dbg_enable_breakpoint(number) do { \ 451 | DBGBCR ## number = UPDATE_DBG_REG(DBGBCR ## number, GET_DBG_MASK(DBGBCR_E), SET_DBG_VALUE(DBGBCR_E, DBGBCR_E_ENABLED)); \ 452 | } while (0) 453 | 454 | #define dbg_disable_breakpoint(number) do { \ 455 | DBGBCR ## number = UPDATE_DBG_REG(DBGBCR ## number, GET_DBG_MASK(DBGBCR_E), SET_DBG_VALUE(DBGBCR_E, DBGBCR_E_DISABLED)); \ 456 | } while (0) 457 | 458 | #define dbg_set_breakpoint_type_to_instr_addr_match(number) do { \ 459 | DBGBCR ## number = UPDATE_DBG_REG(DBGBCR ## number, GET_DBG_MASK(DBGBCR_BT), SET_DBG_VALUE(DBGBCR_BT, DBGBCR_BT_UNLINKED_INSTR_ADDR_MATCH)); \ 460 | } while (0) 461 | 462 | #define dbg_set_breakpoint_type_to_instr_addr_mismatch(number) do { \ 463 | DBGBCR ## number = UPDATE_DBG_REG(DBGBCR ## number, GET_DBG_MASK(DBGBCR_BT), SET_DBG_VALUE(DBGBCR_BT, DBGBCR_BT_UNLINKED_INSTR_ADDR_MISMATCH)); \ 464 | } while (0) 465 | 466 | #define dbg_is_breakpoint_enabled(number) (GET_DBG_VALUE(DBGBCR_E, DBGBCR ## number)) 467 | 468 | #define dbg_is_breakpoint_type_instr_addr_match(number) (GET_DBG_VALUE(DBGBCR_BT, DBGBCR ## number) == DBGBCR_BT_UNLINKED_INSTR_ADDR_MATCH) 469 | 470 | #define dbg_is_breakpoint_type_instr_addr_mismatch(number) (GET_DBG_VALUE(DBGBCR_BT, DBGBCR ## number) == DBGBCR_BT_UNLINKED_INSTR_ADDR_MISMATCH) 471 | 472 | #define dbg_triggers_on_breakpoint_address(number, address) ((DBGBVR ## number == (address & DBGBVR_ADDRMASK)) && (GET_DBG_VALUE(DBGBCR_BAS, DBGBCR ## number) == GET_BAS_FOR_THUMB_ADDR(address))) 473 | 474 | #define dbg_set_breakpoint_for_addr_match(number, address) do { \ 475 | DBGBCR ## number = 0x0; \ 476 | DBGBVR ## number = (address) & DBGBVR_ADDRMASK; \ 477 | DBGBCR ## number = \ 478 | SET_DBG_VALUE(DBGBCR_BT, DBGBCR_BT_UNLINKED_INSTR_ADDR_MATCH) | \ 479 | SET_DBG_VALUE(DBGBCR_MASK, DBGBCR_MASK_NO_MASK) | \ 480 | SET_DBG_VALUE(DBGBCR_E, DBGBCR_E_ENABLED) | \ 481 | SET_DBG_VALUE(DBGBCR_SSC_HMC_PMC, DBGBCR_SSC_HMC_PMC__PL0_SUP_SYS) | \ 482 | SET_DBG_VALUE(DBGBCR_BAS, GET_BAS_FOR_THUMB_ADDR(address)); \ 483 | } while (0) 484 | 485 | #define dbg_set_breakpoint_for_addr_mismatch(number, address) do { \ 486 | DBGBCR ## number = 0x0; \ 487 | DBGBVR ## number = (address) & DBGBVR_ADDRMASK; \ 488 | DBGBCR ## number = \ 489 | SET_DBG_VALUE(DBGBCR_BT, DBGBCR_BT_UNLINKED_INSTR_ADDR_MISMATCH) | \ 490 | SET_DBG_VALUE(DBGBCR_MASK, DBGBCR_MASK_NO_MASK) | \ 491 | SET_DBG_VALUE(DBGBCR_E, DBGBCR_E_ENABLED) | \ 492 | SET_DBG_VALUE(DBGBCR_SSC_HMC_PMC, DBGBCR_SSC_HMC_PMC__PL0_SUP_SYS) | \ 493 | SET_DBG_VALUE(DBGBCR_BAS, GET_BAS_FOR_THUMB_ADDR(address)); \ 494 | } while (0) 495 | 496 | 497 | #define dbg_enable_watchpoint(number) do { \ 498 | DBGWCR ## number = UPDATE_DBG_REG(DBGWCR ## number, GET_DBG_MASK(DBGWCR_E), SET_DBG_VALUE(DBGWCR_E, DBGWCR_E_ENABLED)); \ 499 | } while (0) 500 | 501 | #define dbg_disable_watchpoint(number) do { \ 502 | DBGWCR ## number = UPDATE_DBG_REG(DBGWCR ## number, GET_DBG_MASK(DBGWCR_E), SET_DBG_VALUE(DBGWCR_E, DBGWCR_E_DISABLED)); \ 503 | } while (0) 504 | 505 | #define dbg_set_watchpoint_for_addr_match(number, address) do { \ 506 | DBGWCR ## number = 0x0; \ 507 | DBGWVR ## number = (address) & DBGWVR_ADDRMASK; \ 508 | DBGWCR ## number = \ 509 | SET_DBG_VALUE(DBGWCR_WT, DBGWCR_WT_UNLINKED_DATA_ADDR_MATCH) | \ 510 | SET_DBG_VALUE(DBGWCR_MASK, DBGWCR_MASK_NO_MASK) | \ 511 | SET_DBG_VALUE(DBGWCR_E, DBGWCR_E_ENABLED) | \ 512 | SET_DBG_VALUE(DBGWCR_SSC_HMC_PAC, DBGWCR_SSC_HMC_PAC__ALL) | \ 513 | SET_DBG_VALUE(DBGWCR_LSC, DBGWCR_LSC_MATCH_ALL) | \ 514 | SET_DBG_VALUE(DBGWCR_BAS_4BIT, 0xF); \ 515 | } while (0) 516 | 517 | #define dbg_set_watchpoint_for_addr_match_with_mask(number, address, mask) do { \ 518 | DBGWCR ## number = 0x0; \ 519 | DBGWVR ## number = (address) & DBGWVR_ADDRMASK; \ 520 | DBGWCR ## number = \ 521 | SET_DBG_VALUE(DBGWCR_WT, DBGWCR_WT_UNLINKED_DATA_ADDR_MATCH) | \ 522 | SET_DBG_VALUE(DBGWCR_MASK, mask) | \ 523 | SET_DBG_VALUE(DBGWCR_E, DBGWCR_E_ENABLED) | \ 524 | SET_DBG_VALUE(DBGWCR_SSC_HMC_PAC, DBGWCR_SSC_HMC_PAC__ALL) | \ 525 | SET_DBG_VALUE(DBGWCR_LSC, DBGWCR_LSC_MATCH_ALL) | \ 526 | SET_DBG_VALUE(DBGWCR_BAS_4BIT, 0xF); \ 527 | } while (0) 528 | 529 | 530 | #endif /* DEBUG_H */ -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------