From b10811e13e90f5eef1437bfefe01e81c5faf5d4f Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Tue, 28 Jun 2016 01:20:42 -0400 Subject: Only SO and wheel are allowed to upload. Also add bootloader upload. --- projects/hsm/mgmt-fpga.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'projects/hsm/mgmt-fpga.c') diff --git a/projects/hsm/mgmt-fpga.c b/projects/hsm/mgmt-fpga.c index b6eea3d..b74392e 100644 --- a/projects/hsm/mgmt-fpga.c +++ b/projects/hsm/mgmt-fpga.c @@ -32,6 +32,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* Rename both CMSIS HAL_OK and libhal HAL_OK to disambiguate */ +#define HAL_OK CMSIS_HAL_OK #include "stm-init.h" #include "stm-uart.h" #include "stm-fpgacfg.h" @@ -40,9 +42,16 @@ #include "mgmt-fpga.h" #include "mgmt-misc.h" +#undef HAL_OK +#define HAL_OK LIBHAL_OK +#include "hal.h" +#undef HAL_OK + #include +extern hal_user_t user; + static volatile uint32_t dfu_offset = 0; @@ -54,6 +63,11 @@ static int _flash_write_callback(uint8_t *buf, size_t len) { static int cmd_fpga_bitstream_upload(struct cli_def *cli, const char *command, char *argv[], int argc) { + if (user < HAL_USER_SO) { + cli_print(cli, "Permission denied."); + return CLI_ERROR; + } + uint8_t buf[BITSTREAM_UPLOAD_CHUNK_SIZE]; dfu_offset = 0; -- cgit v1.2.3