Skip to content

Commit 7df0915

Browse files
committed
fwk: Update more intrusion switch info
- [x] SYSTEM_BBRAM_IDX_CHASSIS_WAS_OPEN - Implemented - [ ] SYSTEM_BBRAM_IDX_CHASSIS_MAGIC (RTC Battery ever removed) Never set. Is this useful on lotus/azalea without RTC? - [x] SYSTEM_BBRAM_IDX_CHASSIS_TOTAL - Implemented - [x] SYSTEM_BBRAM_IDX_CHASSIS_VTR_OPEN (Opened while system off) - Implemented in this commit. Tested on lotus. Works. Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 3d52748 commit 7df0915

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

zephyr/program/lotus/src/board_function.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ static uint8_t chassis_once_flag;
4242

4343
static uint64_t chassis_open_hibernate_time;
4444

45+
static uint8_t init = 1;
46+
4547
int bios_function_status(uint16_t type, uint16_t addr, uint8_t flag)
4648
{
4749
uint8_t status;
@@ -145,15 +147,25 @@ static void check_chassis_open(void)
145147
{
146148
if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_chassis_open_l)) == 0) {
147149
CPRINTS("Chassis was opened");
148-
chassis_once_flag = 1;
149-
150150
/* Record the chassis was open status in bbram */
151151
if (!chassis_once_flag)
152152
system_set_bbram(SYSTEM_BBRAM_IDX_CHASSIS_WAS_OPEN, 1);
153153

154-
if (chassis_open_count < 0xFF)
155-
chassis_open_count++;
156-
system_set_bbram(SYSTEM_BBRAM_IDX_CHASSIS_TOTAL, chassis_open_count);
154+
chassis_once_flag = 1;
155+
156+
if (init) {
157+
system_get_bbram(SYSTEM_BBRAM_IDX_CHASSIS_VTR_OPEN,
158+
&chassis_vtr_open_count);
159+
if (chassis_vtr_open_count < 0xFF)
160+
chassis_vtr_open_count++;
161+
system_set_bbram(SYSTEM_BBRAM_IDX_CHASSIS_VTR_OPEN, chassis_vtr_open_count);
162+
} else {
163+
system_get_bbram(SYSTEM_BBRAM_IDX_CHASSIS_TOTAL,
164+
&chassis_open_count);
165+
if (chassis_open_count < 0xFF)
166+
chassis_open_count++;
167+
system_set_bbram(SYSTEM_BBRAM_IDX_CHASSIS_TOTAL, chassis_open_count);
168+
}
157169

158170
/* Counter for chassis pin */
159171
if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
@@ -188,7 +200,10 @@ static void bios_function_init(void)
188200
set_detect_mode(flash_storage_get(FLASH_FLAGS_INPUT_MODULE_POWER));
189201
#endif
190202
gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_chassis_open));
203+
204+
init = 1;
191205
check_chassis_open();
206+
init = 0;
192207
}
193208
DECLARE_HOOK(HOOK_INIT, bios_function_init, HOOK_PRIO_DEFAULT + 1);
194209

0 commit comments

Comments
 (0)