flash.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. /* Motenpoche
  2. *
  3. * (c) 2023 Daniele Lacamera <root@danielinux.net>
  4. *
  5. *
  6. * Motenpoche is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Motenpoche is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  19. *
  20. */
  21. #ifndef FLASH_H
  22. #define FLASH_H
  23. #include "hardware/spi.h"
  24. #include "cryptoengine.h"
  25. #define SPI_FLASH_SECTOR_SIZE 0x1000
  26. uint16_t flash_init(spi_inst_t *spi);
  27. int flash_sector_erase(uint32_t address);
  28. int flash_read(uint32_t address, void *data, int len);
  29. int flash_write(uint32_t address, const void *data, int len);
  30. int flash_write_svc(struct vault_service *svc, int idx);
  31. int flash_decrypt_read_sector(uint32_t sector, uint8_t *buf);
  32. int flash_encrypt_write_sector(uint32_t sector, uint8_t *buf);
  33. uint8_t flash_read_status(void);
  34. #endif