diff options
| author | Evan Lojewski <github@meklort.com> | 2020-10-04 19:57:54 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-04 19:57:54 -0600 |
| commit | 7971bb6dd945ee1155a58aa595d20f7bc49288ce (patch) | |
| tree | 7fbca2477d8be0dfe6034e61c25d841239b6bd1f /utils/bcmflash/nvm.cpp | |
| parent | 84ba838435e87e88570b633903a4091d392371d8 (diff) | |
| download | bcm5719-ortega-7971bb6dd945ee1155a58aa595d20f7bc49288ce.tar.gz bcm5719-ortega-7971bb6dd945ee1155a58aa595d20f7bc49288ce.zip | |
bcmflash: Refactor bcmflash to cleanup IO code. (#127)
Diffstat (limited to 'utils/bcmflash/nvm.cpp')
| -rw-r--r-- | utils/bcmflash/nvm.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/utils/bcmflash/nvm.cpp b/utils/bcmflash/nvm.cpp index af067d8..2f06e37 100644 --- a/utils/bcmflash/nvm.cpp +++ b/utils/bcmflash/nvm.cpp @@ -41,12 +41,27 @@ /// POSSIBILITY OF SUCH DAMAGE. /// @endcond //////////////////////////////////////////////////////////////////////////////// + +#include "HAL.hpp" #include "bcmflash.h" #include <../bcm5719_NVM.h> #include <NVRam.h> #include <bcm5719_eeprom.h> +bool bcmflash_nvram_init(const char *name) +{ + char *end_ptr; + int function = strtol(name, &end_ptr, 10); + if (end_ptr == name) + { + // Unable to detect, default to function 1. + function = 1; + } + + return initHAL(NULL, function); +} + size_t bcmflash_nvram_size(const char *name) { size_t size; @@ -62,8 +77,10 @@ size_t bcmflash_nvram_size(const char *name) return size; } -bool bcmflash_nvram_read(const char *name, uint32_t *words, uint32_t num_words) +bool bcmflash_nvram_read(const char *name, void *buffer, size_t len) { + uint32_t *words = (uint32_t *)buffer; + uint32_t num_words = len / 4; NVRam_acquireLock(); NVRam_enable(); |

