Files
STM32F4-Base/App/cfg/prot_set_store.h
T
wandering1 1fe163ba7b feat(protect): B7 定值持久化 + 全局软压板 + L5-1 竞态收口(W1 代码腿完成)
- prot_set:新增 PS_GLOBAL_EN(枚举尾追加);值区双缓冲 + 单字交换,
  prot_set_set_sealed 原子写+封存;selfcheck 改 seqlock 式复核
  (提交撞见 = 本轮跳过)→ 收口 B5 登记的 µs 级误锁窗口
- 持久化:新增 App/cfg/prot_set_store.c/h,/prot_set.bin blob
  (magic+版本+计数+值区+sum32 正/反码对,144 B)走 cfg_store_write_atomic;
  uvprojx 注册 + 模拟器豁免点名(check_registration 同步)
- 写路径:C_SE/YK12 执行段置脏 → iec104Task 投递 SYS_EVT_PROT_SET_SAVE
  (事件位 bit7)→ defaultTask(配置引擎属主)落盘,写失败脏回置 = 天然
  重试;装载 = STORAGE_READY 屏障前整表原子 parse(损坏保出厂默认 +
  自检留痕 prot set corrupt;文件缺失 = 首启静默)
- YK12 转真:两段式(选择段校验 DPC / 执行段 set_sealed),protectTask
  下一拍读退出态 → 复位元件 + 停判据(global plate OUT/IN 边沿日志);
  本地定值项 comm_addr=0 显式不可寻址(防 IOA=0 误命中首个本地项)
- 单测:prot_set 63 断言(+33:软压板/原子写/脏握手/blob 往返/损坏拒绝/
  伪造自洽越界对抗样本)、iec104 94 断言(+7:YK12 两段转真/置脏/本地项
  C_RD EVI)
- 文档:IEC104 设计说明 §3.3/§3.4/§7、保护规划 §3.5 L5-1/§7 P4/变更记录、
  App/algo 与 App/cfg README、W1 任务卡 B7→🟦(台架腿 🔴 待窗口,随 B6 同窗)
- 验证:@build 0 错 0 警(Code=205500,ZI +280 = 双缓冲+blob 缓冲);
  ci_local 全绿(L0 27 钩子 + L0.5 13 套件 826 断言);ram_baseline 台账
  受管区与内存快照已同步;19 个改动文件无 BOM / LF / 零乱码
2026-10-12 15:01:49 +08:00

32 lines
1.5 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* 模块名称:prot_set_store
* 模块功能:保护定值持久化胶水(B7)——把 prot_set 的纯逻辑 blob
* (prot_set_store_serialize/parse)落到 cfg 存储后端的
* "/prot_set.bin"(MCU = NAND/FatFs 原子写,模拟器 = 宿主文件系统)。
* 装载在 defaultTask 存储 bring-up(STORAGE_READY 前);
* 落盘在 defaultTask(配置引擎属主,iec104Task 经
* SYS_EVT_PROT_SET_SAVE 投递请求,本模块只被属主调用)。
* 适用平台:双端接口(MCU 与模拟器共用 cfg_file_store 抽象)
* 创建日期:2026-10-12(B7)
*/
#ifndef PROT_SET_STORE_H
#define PROT_SET_STORE_H
/*
* 函数功能:开机装载定值 blob(整表原子,all-or-nothing)
* 返回值:0 - 已装载;1 - 文件缺失(首启正常,保持出厂默认);
* -1 - blob 损坏/越界被拒(保持出厂默认,调用方留痕)
* 限定条件:仅 defaultTask、卷已挂载(storage_bring_up 内调用)
*/
int prot_set_store_load(void);
/*
* 函数功能:落盘当前定值(内部先消费脏标志;无改动 = 空操作返回 0)
* 返回值:0 - 无待写或写成功;-1 - 写失败(脏标志已回置,等下轮重试)
* 限定条件:仅 defaultTask 调用(配置引擎属主;原子写 = 临时文件 + rename,
* 与 /config.ini 共用同目录 config.TMP——两者都在本任务串行执行,无并发)
*/
int prot_set_store_save(void);
#endif /* PROT_SET_STORE_H */