Permalink
Browse files

bcm4361: added patch to save values overwritten during flashpatching.

  • Loading branch information...
matthiasseemoo committed Jan 3, 2019
1 parent 9e074cf commit d27089e43e949af5abac45a4dd49c17ce3aa3c8c

This file was deleted.

Oops, something went wrong.
@@ -46,7 +46,6 @@ FP_DATA_END_PTR=0x20B6D0
FP_CONFIG_BASE_PTR_1 = 0x201608
FP_CONFIG_END_PTR_1 = 0x20160C
FP_CONFIG_BASE_PTR_2 = 0x20179C
FP_CONFIG_BASE_PTR_2A = 0x201794
FP_CONFIG_END_PTR_2 = 0x201798
FP_CONFIG_SIZE=0x1000
FP_CONFIG_BASE=$$(($(PATCHSTART) - $(FP_CONFIG_SIZE)))
@@ -24,6 +24,8 @@ CFLAGS= \
-DTEMPLATERAMSTART1_PTR=$(TEMPLATERAMSTART1_PTR) \
-DTEMPLATERAMSTART2_PTR=$(TEMPLATERAMSTART2_PTR) \
-DVASIPSTART_PTR=$(VASIPSTART_PTR) \
-DFP_CONFIG_ORIGBASE=$(FP_CONFIG_ORIGBASE) \
-DFP_CONFIG_ORIGEND=$(FP_CONFIG_ORIGEND) \
-DPATCHSTART=$(PATCHSTART) \
-DUCODESIZE=$(UCODESIZE) \
-DGIT_VERSION=\"$(GIT_VERSION)\" \
@@ -91,7 +93,6 @@ gen/flashpatches.mk: gen/nexmon2.pre $(OBJS) $(FW_PATH)/definitions.mk
-v fp_config_base_ptr_1=$(FP_CONFIG_BASE_PTR_1) \
-v fp_config_end_ptr_1=$(FP_CONFIG_END_PTR_1) \
-v fp_config_base_ptr_2=$(FP_CONFIG_BASE_PTR_2) \
-v fp_config_base_ptr_2a=$(FP_CONFIG_BASE_PTR_2A) \
-v fp_config_end_ptr_2=$(FP_CONFIG_END_PTR_2) \
-v ramstart=$(RAMSTART) \
-v out_file=$(RAM_FILE) \
@@ -0,0 +1,40 @@
/***************************************************************************
* *
* ########### ########### ########## ########## *
* ############ ############ ############ ############ *
* ## ## ## ## ## ## ## *
* ## ## ## ## ## ## ## *
* ########### #### ###### ## ## ## ## ###### *
* ########### #### # ## ## ## ## # # *
* ## ## ###### ## ## ## ## # # *
* ## ## # ## ## ## ## # # *
* ############ ##### ###### ## ## ## ##### ###### *
* ########### ########### ## ## ## ########## *
* *
* S E C U R E M O B I L E N E T W O R K I N G *
* *
* This file is part of NexMon. *
* *
* Copyright (c) 2016 NexMon Team *
* *
* NexMon is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* NexMon is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with NexMon. If not, see <http://www.gnu.org/licenses/>. *
* *
**************************************************************************/

#ifndef LOCAL_WRAPPER_H
#define LOCAL_WRAPPER_H

#include "../src/local_wrapper.c" // wrapper definitions for functions that already exist in the firmware

#endif /*LOCAL_WRAPPER_H*/
@@ -0,0 +1,74 @@
/***************************************************************************
* *
* ########### ########### ########## ########## *
* ############ ############ ############ ############ *
* ## ## ## ## ## ## ## *
* ## ## ## ## ## ## ## *
* ########### #### ###### ## ## ## ## ###### *
* ########### #### # ## ## ## ## # # *
* ## ## ###### ## ## ## ## # # *
* ## ## # ## ## ## ## # # *
* ############ ##### ###### ## ## ## ##### ###### *
* ########### ########### ## ## ## ########## *
* *
* S E C U R E M O B I L E N E T W O R K I N G *
* *
* This file is part of NexMon. *
* *
* Copyright (c) 2016 NexMon Team *
* *
* NexMon is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* NexMon is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with NexMon. If not, see <http://www.gnu.org/licenses/>. *
* *
**************************************************************************/

#pragma NEXMON targetregion "patch"

#include <firmware_version.h> // definition of firmware version macros
#include <debug.h> // contains macros to access the debug hardware
#include <wrapper.h> // wrapper definitions for functions that already exist in the firmware
#include <structs.h> // structures that are used by the code in the firmware
#include <helper.h> // useful helper functions
#include <patcher.h> // macros used to craete patches such as BLPatch, BPatch, ...
#include <rates.h> // rates used to build the ratespec for frame injection
#include <local_wrapper.h>

struct fp_config {
unsigned int *target_addr;
unsigned int data_ptr;
};

unsigned int fp_orig_data[(FP_CONFIG_ORIGEND - FP_CONFIG_ORIGBASE) / sizeof(struct fp_config)][5] = { 0 };
unsigned int fp_orig_data_len = (FP_CONFIG_ORIGEND - FP_CONFIG_ORIGBASE) / sizeof(struct fp_config);

int
fp_apply_patches_hook(unsigned int rambase)
{
struct fp_config *fpc = (struct fp_config *) FP_CONFIG_ORIGBASE;
int i;

for (i = 0; i < fp_orig_data_len; i++) {
fp_orig_data[i][0] = (unsigned int) (fpc)->target_addr;
fp_orig_data[i][1] = ((fpc)->target_addr)[0];
fp_orig_data[i][2] = ((fpc)->target_addr)[1];
fp_orig_data[i][3] = ((fpc)->target_addr)[2];
fp_orig_data[i][4] = ((fpc)->target_addr)[3];
fpc++;
}

return fp_apply_patches(rambase);
}

// Hook call to fp_apply_patches in c_main
__attribute__((at(0x1A0E96, "", CHIP_VER_BCM4361b0, FW_VER_13_38_55_1_sta)))
BLPatch(fp_apply_patches, fp_apply_patches_hook);
@@ -49,6 +49,7 @@
#define CHIP_VER_BCM43455c0 101
#define CHIP_VER_BCM43909b0 102
#define CHIP_VER_BCM4366c 103
#define CHIP_VER_BCM4361b0 104

#define FW_VER_ALL 0

@@ -100,4 +101,7 @@
#define FW_VER_10_10_69_252 310
#define FW_VER_10_10_122_20 311

// for CHIP_VER_BCM4361b0
#define FW_VER_13_38_55_1_sta 410

#endif /*FIRMWARE_VERSION_H*/

0 comments on commit d27089e

Please sign in to comment.