void nvmpeek (void const * memory) { if (LE32TOH (*(uint32_t *)(memory)) == 0x60000000) { nvmpeek1 (memory); return; } nvmpeek2 (memory); return; }
static signed nvmchain2 (void const * memory, size_t extent, char const * filename, flag_t flags) { struct nvm_header2 * nvm_header; unsigned module = 0; uint32_t origin = ~0; uint32_t offset = 0; uint32_t length = 0; do { nvm_header = (struct nvm_header2 *)((char *)(memory) + offset); if (LE16TOH (nvm_header->MajorVersion) != 1) { if (_allclr (flags, NVM_SILENCE)) { error (0, errno, NVM_HDR_VERSION, filename, module); } return (-1); } if (LE16TOH (nvm_header->MinorVersion) != 1) { if (_allclr (flags, NVM_SILENCE)) { error (0, errno, NVM_HDR_VERSION, filename, module); } return (-1); } if (LE32TOH (nvm_header->PrevHeader) != origin) { if (_allclr (flags, NVM_SILENCE)) { error (0, errno, NVM_HDR_LINK, filename, module); } return (-1); } if (checksum32 (nvm_header, sizeof (* nvm_header), 0)) { if (_allclr (flags, NVM_SILENCE)) { error (0, 0, NVM_HDR_CHECKSUM, filename, module); } return (-1); } origin = offset; offset += sizeof (* nvm_header); extent -= sizeof (* nvm_header); length = LE32TOH (nvm_header->ImageLength); if (_anyset (flags, NVM_VERBOSE)) { printf ("------- %s (%d) -------\n", filename, module); nvmpeek2 (nvm_header); } if (LE32TOH (nvm_header->ImageType) == NVM_IMAGE_MANIFEST) { if (_anyset (flags, NVM_MANIFEST)) { printf ("------- %s (%d) -------\n", filename, module); manifest ((char *)(memory) + offset, length); return (0); } } if (checksum32 ((char *)(memory) + offset, length, nvm_header->ImageChecksum)) { if (_allclr (flags, NVM_SILENCE)) { error (0, errno, NVM_IMG_CHECKSUM, filename, module); } return (-1); } offset += length; extent -= length; module++; } while (~nvm_header->NextHeader); if (extent) { if (_allclr (flags, NVM_SILENCE)) { error (0, errno, NVM_HDR_LINK, filename, module); } } return (0); }