ewq

#include<bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n;
stack<int> s;
LL arr[maxn];
int left[maxn],right[maxn];
LL sum[maxn];
void solve1(){
    while(!s.empty()) s.pop();
    for(int i=1;i<=n;i++){
        LL e = arr[i];
        do{
            if(s.empty()){
                left[i]=0;
                s.push();
                break;
            }
            LL c = arr[s.top()];
            if(c < e){
                left[i]=s.top();
                s.push(i);
                break;
            }
            else s.pop();
        }while(true);
    }
}
void solve2(){
    while(!s.empty()) s.pop();
    for(int i=n;i>=1;i--){
        LL e = arr[i];
        do{
            if(s.empty()){
                right[i]=n+1;
                s.push(i);
                break;
            }
            LL c=arr[s.top()];
            if(c<e){
                right[i]=s.top();
                s.push(i);
                break;
            }
            else s.pop();
        }while(true);
    }
}
int main()
{
    int Case=0;
    while(scanf("%d",&n)!=EOF){
        sum[0]=0L;
        for(int i=1;i<=n;i++)
        {
            scanf("%lld",&arr[i]);
            sum[i]=sum[i-1]+arr[i];
        }
        solve1();
        solve2();
        LL ans=-1;
        int pos_x,pos_y;
        int l;
        for(int i=1;i<=n;i++){
            int a=left[i];
            int b=right[i];
            int ll
        }
    }
    
    return 0;
}
/* lcf file for MPC5634M processor */ /* */ /* 1.5 MB Flash, 94KB SRAM */ MEMORY { resetvector: org = 0x00000000, len = 0x00000008 APP_ENTRY: org = 0x00010000, len = 0x00000100 init: org = 0x00010100, len = 0x00000F00 exception_handlers: org = 0x00011000, len = 0x00001000 internal_flash: org = 0x00012000, len = 0x0006C800 /*434K*/ crc32_flash: org = 0x0007E800, len = 0x00001800 /*6K*/ ASW_flash_A: org = 0x00080000, len = 0x00060000 /*384K*/ cal_flash_A: org = 0x000E0000, len = 0x00020000 /*128K*/ ASW_flash_B: org = 0x00100000, len = 0x00060000 /*384K*/ cal_flash_B: org = 0x00160000, len = 0x00020000 /*128K*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ cal_ram: org = 0x40000000, len = 0x00008000 /*32K*/ internal_ram: org = 0x40008000, len = 0x0000A800 /*42K*/ crc32_ram: org = 0x40012800, len = 0x00001800 /*6K*/ heap : org = 0x40014000, len = 0x00002000 /*8K*/ stack : org = 0x40016000, len = 0x00001800 /*6K*/ } /* This will ensure the rchw and reset vector are not stripped by the linker */ FORCEACTIVE { "bam_rchw" "bam_resetvector" } SECTIONS { .__bam_bootarea LOAD (0x00000000): {} > resetvector .app_entry (VLECODE) LOAD(0x00010000) : {} > APP_ENTRY GROUP : { .init LOAD (0x10100) : {} .init_vle (VLECODE) LOAD (_e_init) : { *(.init) *(.init_vle) } } > init .__exception_handlers (VLECODE) LOAD (0x00011000) : {} > exception_handlers GROUP : { .text : {} .text_vle (VLECODE) ALIGN(0x08): { *(.text) *(.text_vle) } .rodata (CONST) : { *(.rdata) *(.rodata) } .ctors : {} .dtors : {} extab : {} extabindex : {} } > internal_flash /************将应用层代码和const数据放在ASW_flash************/ GROUP : { .ASW_text (VLECODE) ALIGN(0x08) LOAD (0x00080000): { KEEP(*(.ASW_function)) Sensor.o(.text) EEpromSaveVal.o(.text) CanSend.o(.text) CanReceive.o(.text) BKLrn.o(.text) ClTrqMapLrn.o(.text) TmPosCal.o(.text) EngMotCtrl.o(.text) ClCtrl.o(.text) SlopeEst_Single.o(.text) VehCtl.o(.text) SftMotPidCtrl.o(.text) ClMotPidCtrl.o(.text) TrgtGearSub.o(.text) SftCtrl.o(.text) SftCtrl_TrgtCurrSub.o(.text) TempEst.o(.text) AveCalculate_DBzCpi0h.o(.text) BINARYSEARCH_real32_T.o(.text) InValStdJdgSub_EJoZRQLM.o(.text) InValStdJdgSub_INONT01g.o(.text) look1_iflf_binlcapw.o(.text) look1_iflf_binlxpw.o(.text) look2_iflf_binlcapw.o(.text) look2_iflf_binlcpw.o(.text) look2_iflf_binlxpw.o(.text) LookUp_real32_T_real32_T.o(.text) Myfun_TimeChr2eWq0hbv.o(.text) rt_nonfinite.o(.text) rtGetInf.o(.text) rtGetNaN.o(.text) } .ASW_data (CONST) : { Sensor_data.o(.rodata) const_params.o(.rodata) ClCtrl.o(.rodata) VehCtl_data.o(.rodata) TempEst_data.o(.rodata) } } > ASW_flash_A GROUP : { .__uninitialized_intc_handlertable ALIGN(2048) : {} .data : {} .sdata : {} .sbss : {} .sdata2 : {} .sbss2 : {} .bss : {} } > internal_ram .crc32_section LOAD (0x0007E800): { KEEP(*(.crc32_section)) } > crc32_ram /************param_cal************/ .cal_section LOAD (0x000E0000) : { KEEP(*(.cal_section)) } > cal_ram } /* Freescale CodeWarrior compiler address designations */ _stack_addr = ADDR(stack)+SIZEOF(stack); _stack_end = ADDR(stack); _heap_addr = ADDR(heap); _heap_end = ADDR(heap)+SIZEOF(heap); /* Exceptions Handlers Location (used in Exceptions.c IVPR initialization)*/ EXCEPTION_HANDLERS = ADDR(exception_handlers); /* L2 SRAM Location (used for L2 SRAM initialization) */ L2SRAM_LOCATION = 0x40000000; ~~~~~~~~~~~ mpc5634链接文件flash分区, 应用层程序对应的flash区域为:ASW_flash_A/ASW_flash_B, 标定量对应的flash区域为:cal_flash_A/cal_flash_B, 都做了两个分区,即一个为激活分区,一个为备用分区,想实现对应的flash区域刷写失败后,可以切换到备用分区,我不太清楚具体怎么实现,在链接文件中,我只能指定代码或者标定参数放在ASW_flash_A,cal_flash_A中,没有办法同时放在两个段,A-B的数据刷写只能在刷写A之前写入到B中,那么在程序运行的时候,我怎么指定是运行A中或者B中的代码或者参数呢?标定参数上电是需要复制到ram中的,这个我可以处理,比较麻烦的是代码是直接在flash中运行的,怎么指定使用哪个区域的代码呢?
07-20
/* lcf file for MPC5634M processor */ /* */ /* 1.5 MB Flash, 94KB SRAM */ MEMORY { resetvector: org = 0x00000000, len = 0x00000008 APP_ENTRY: org = 0x00010000, len = 0x00000100 init: org = 0x00010100, len = 0x00000F00 exception_handlers: org = 0x00011000, len = 0x00001000 internal_flash: org = 0x00012000, len = 0x0006C800 /*434K*/ crc32_flash: org = 0x0007E800, len = 0x00001800 /*6K*/ ASW_flash: org = 0x00080000, len = 0x00080000 /*512K*/ cal_flash: org = 0x00100000, len = 0x00020000 /*128K*/ cal_ram: org = 0x40000000, len = 0x00008000 /*32K*/ internal_ram: org = 0x40008000, len = 0x0000A800 /*42K*/ crc32_ram: org = 0x40012800, len = 0x00001800 /*6K*/ heap : org = 0x40014000, len = 0x00002000 /*8K*/ stack : org = 0x40016000, len = 0x00001800 /*6K*/ } /* This will ensure the rchw and reset vector are not stripped by the linker */ FORCEACTIVE { "bam_rchw" "bam_resetvector" } SECTIONS { .__bam_bootarea LOAD (0x00000000): {} > resetvector .app_entry (VLECODE) LOAD(0x00010000) : {} > APP_ENTRY GROUP : { .init LOAD (0x10100) : {} .init_vle (VLECODE) LOAD (_e_init) : { *(.init) *(.init_vle) } } > init .__exception_handlers (VLECODE) LOAD (0x00011000) : {} > exception_handlers /************将应用层代码和const数据放在ASW_flash************/ .ASW_section (VLECODE) ALIGN(0x08) LOAD (0x00080000): { KEEP(*(.ASW_function)) Sensor.o(.text) EEpromSaveVal.o(.text) CanSend.o(.text) CanReceive.o(.text) BKLrn.o(.text) ClTrqMapLrn.o(.text) TmPosCal.o(.text) EngMotCtrl.o(.text) ClCtrl.o(.text) SlopeEst_Single.o(.text) VehCtl.o(.text) SftMotPidCtrl.o(.text) ClMotPidCtrl.o(.text) TrgtGearSub.o(.text) SftCtrl.o(.text) SftCtrl_TrgtCurrSub.o(.text) TempEst.o(.text) AveCalculate_DBzCpi0h.o(.text) BINARYSEARCH_real32_T.o(.text) InValStdJdgSub_EJoZRQLM.o(.text) InValStdJdgSub_INONT01g.o(.text) look1_iflf_binlcapw.o(.text) look1_iflf_binlxpw.o(.text) look2_iflf_binlcapw.o(.text) look2_iflf_binlcpw.o(.text) look2_iflf_binlxpw.o(.text) LookUp_real32_T_real32_T.o(.text) Myfun_TimeChr2eWq0hbv.o(.text) rt_nonfinite.o(.text) rtGetInf.o(.text) rtGetNaN.o(.text) Sensor_data.o(.rodata) const_params.o(.rodata) ClCtrl.o(.rodata) VehCtl_data.o(.rodata) TempEst_data.o(.rodata) } > ASW_flash GROUP : { .text : {} .text_vle (VLECODE) ALIGN(0x08): { *(.text) *(.text_vle) } .rodata (CONST) : { *(.rdata) *(.rodata) } .ctors : {} .dtors : {} extab : {} extabindex : {} } > internal_flash GROUP : { .__uninitialized_intc_handlertable ALIGN(2048) : {} .data : {} .sdata : {} .sbss : {} .sdata2 : {} .sbss2 : {} .bss : {} } > internal_ram .crc32_section LOAD (0x0007E800): { KEEP(*(.crc32_section)) } > crc32_ram /************param_cal************/ .cal_section LOAD (0x00100000) : { KEEP(*(.cal_section)) } > cal_ram } /* Freescale CodeWarrior compiler address designations */ _stack_addr = ADDR(stack)+SIZEOF(stack); _stack_end = ADDR(stack); _heap_addr = ADDR(heap); _heap_end = ADDR(heap)+SIZEOF(heap); /* Exceptions Handlers Location (used in Exceptions.c IVPR initialization)*/ EXCEPTION_HANDLERS = ADDR(exception_handlers); /* L2 SRAM Location (used for L2 SRAM initialization) */ L2SRAM_LOCATION = 0x40000000; ~~~~~~~~~~~~ 以上是mpc5634的链接文件,用codewarrior2.10编译生成的map文件中, .rodata section layout Starting Virtual File address Size address offset --------------------------------- 00000000 00000c 00027a58 0004f4e8 1 .rodata __ppc_eabi_init.o 00000000 00000c 00027a58 0004f4e8 4 @22 __ppc_eabi_init.o 0000000c 000004 00027a68 0004f4f8 8 *fill* 00000010 003800 00027a68 0004f4f8 1 .rodata Motor_MCU_Interface.o 00000010 003800 00027a68 0004f4f8 8 etpu_code Motor_MCU_Interface.o 00003810 00000c 0002b268 00052cf8 1 .rodata Sensor_data.o 00003810 00000c 0002b268 00052cf8 4 Sensor_ConstB Sensor_data.o 0000381c 000004 0002b278 00052d08 8 *fill* 00003820 00001c 0002b278 00052d08 1 .rodata ClCtrl.o 00003820 00001c 0002b278 00052d08 4 ClCtrl_rtZCl2TrqCtrlDataBus ClCtrl.o 0000383c 000004 0002b298 00052d28 8 *fill* 00003840 000030 0002b298 00052d28 1 .rodata VehCtl_data.o 00003840 000030 0002b298 00052d28 8 VehCtl_ConstB VehCtl_data.o 00003870 00005c 0002b2c8 00052d58 1 .rodata TempEst_data.o 00003870 00005c 0002b2c8 00052d58 4 TempEst_ConstP TempEst_data.o 000038cc 000004 0002b328 00052db8 8 *fill* 000038d0 000150 0002b328 00052db8 1 .rodata const_params.o 000038d0 00000c 0002b328 00052db8 4 rtCP_pooled_0JMyuAsMOwil const_params.o 000038e0 000010 0002b338 00052dc8 8 rtCP_pooled_1rHWNHyJ5jD5 const_params.o 000038f0 000009 0002b348 00052dd8 4 rtCP_pooled_2vQMKU01UH0A const_params.o 00003900 000018 0002b358 00052de8 8 rtCP_pooled_3j9sNwln33UW const_params.o 00003918 00000c 0002b370 00052e00 4 rtCP_pooled_435vSzr2B3ga const_params.o 00003924 000024 0002b37c 00052e0c 4 rtCP_pooled_4mXD8NQdYsPP const_params.o UNUSED 00000c ........ ........ rtCP_pooled_7aRblQ8ZikmU const_params.o 00003948 000009 0002b3a0 00052e30 4 rtCP_pooled_BDFUXfRy9FB9 const_params.o UNUSED 0113b8 ........ ........ rtCP_pooled_CxHMTLeDJqOm const_params.o 00003954 00000c 0002b3ac 00052e3c 4 rtCP_pooled_P3IFcUsZHL40 const_params.o 00003960 00001c 0002b3b8 00052e48 4 rtCP_pooled_QTf4115BsApr const_params.o UNUSED 000048 ........ ........ rtCP_pooled_T7LJKz0qDStL const_params.o 0000397c 000009 0002b3d4 00052e64 4 rtCP_pooled_TA1PDX4owOXO const_params.o 00003988 000010 0002b3e0 00052e70 8 rtCP_pooled_Z9xEYqlPuj1U const_params.o UNUSED 00000c ........ ........ rtCP_pooled_elNW18cpOeL9 const_params.o 00003998 000009 0002b3f0 00052e80 4 rtCP_pooled_klAghWKMJZcQ const_params.o 000039a8 000018 0002b400 00052e90 8 rtCP_pooled_mIyM6o03E9NC const_params.o UNUSED 000048 ........ ........ rtCP_pooled_sBIJJlXDbIPs const_params.o UNUSED 00000c ........ ........ rtCP_pooled_sjXc2szChSoS const_params.o 000039c0 000009 0002b418 00052ea8 4 rtCP_pooled_ssalKWy0HONi const_params.o 000039d0 000010 0002b428 00052eb8 8 rtCP_pooled_uRI6StAYhRva const_params.o 000039e0 00001c 0002b438 00052ec8 4 rtCP_pooled_vcTuGzxyBaTT const_params.o UNUSED 0113b8 ........ ........ rtCP_pooled_xdeCXgKaCR9b const_params.o 000039fc 000024 0002b454 00052ee4 4 rtCP_pooled_xgv7ryg6ZEnf const_params.o 00003a20 000010 0002b478 00052f08 1 .rodata MSL_C.PPCEABI.bare.VS.UC.a e_fmod.o 00003a20 000010 0002b478 00052f08 8 Zero MSL_C.PPCEABI.bare.VS.UC.a e_fmod.o 我想把Sensor_data.o 的.rodata数据放在.ASW_section段,应该怎么修改?
07-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值