2022-12-02 22:48:00 +00:00
|
|
|
// Copyright 2022 QMK
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#include "quantum.h"
|
|
|
|
#include "xap.h"
|
|
|
|
#include "hardware_id.h"
|
|
|
|
|
2023-03-26 22:51:27 +00:00
|
|
|
bool xap_execute_get_config_blob_chunk(xap_token_t token, uint16_t offset) {
|
2022-12-02 22:48:00 +00:00
|
|
|
xap_route_qmk_config_blob_chunk_t ret = {0};
|
|
|
|
|
|
|
|
bool get_config_blob_chunk(uint16_t offset, uint8_t * data, uint8_t data_len);
|
|
|
|
if (!get_config_blob_chunk(offset, (uint8_t *)&ret, sizeof(ret))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return xap_respond_data(token, &ret, sizeof(ret));
|
|
|
|
}
|
|
|
|
|
2023-03-26 22:51:27 +00:00
|
|
|
bool xap_execute_secure_status(xap_token_t token) {
|
2022-12-02 22:48:00 +00:00
|
|
|
uint8_t ret = secure_get_status();
|
|
|
|
return xap_respond_data(token, &ret, sizeof(ret));
|
|
|
|
}
|
|
|
|
|
2023-03-26 22:51:27 +00:00
|
|
|
bool xap_execute_secure_unlock(xap_token_t token) {
|
2022-12-02 22:48:00 +00:00
|
|
|
secure_request_unlock();
|
|
|
|
return xap_respond_success(token);
|
|
|
|
}
|
|
|
|
|
2023-03-26 22:51:27 +00:00
|
|
|
bool xap_execute_secure_lock(xap_token_t token) {
|
2022-12-02 22:48:00 +00:00
|
|
|
secure_lock();
|
|
|
|
return xap_respond_success(token);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef BOOTLOADER_JUMP_SUPPORTED
|
2023-03-26 22:51:27 +00:00
|
|
|
bool xap_execute_request_bootloader(xap_token_t token) {
|
2022-12-02 22:48:00 +00:00
|
|
|
uint8_t ret = secure_is_unlocked();
|
|
|
|
|
|
|
|
// TODO: post to deferred queue so this request can return?
|
|
|
|
bool res = xap_respond_data(token, &ret, sizeof(ret));
|
|
|
|
reset_keyboard();
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef NO_RESET
|
2023-03-26 22:51:27 +00:00
|
|
|
bool xap_execute_request_eeprom_reset(xap_token_t token) {
|
2022-12-02 22:48:00 +00:00
|
|
|
uint8_t ret = secure_is_unlocked();
|
|
|
|
|
|
|
|
// TODO: post to deferred queue so this request can return?
|
|
|
|
bool res = xap_respond_data(token, &ret, sizeof(ret));
|
|
|
|
eeconfig_disable();
|
|
|
|
soft_reset_keyboard();
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-03-26 22:51:27 +00:00
|
|
|
bool xap_execute_get_hardware_id(xap_token_t token) {
|
2022-12-02 22:48:00 +00:00
|
|
|
hardware_id_t ret = get_hardware_id();
|
|
|
|
return xap_respond_data(token, &ret, sizeof(ret));
|
|
|
|
}
|