Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int write_bootdata(unsigned char* buf, int len,unsigned int boot_volume)
- {
- (void) boot_volume;
- struct boot_data_t *boot_data = NULL;
- int ret = 0;
- unsigned int i;
- unsigned int magic[2] = {BOOT_DATA_MAGIC0, BOOT_DATA_MAGIC1};
- if (len < BOOT_DATA_SEARCH_SIZE)
- ret = EKEY_NOT_FOUND;
- if (ret == 0)
- {
- /* search for boot data header prior to this offset */
- for(i = 0;i <= (BOOT_DATA_SEARCH_SIZE - sizeof(struct boot_data_t));i++)
- {
- if ( memcmp ( &buf[i], &magic[0], sizeof(magic) ) == 0)
- {
- boot_data = (struct boot_data_t*) &buf[i];
- boot_data->boot_volume = 0x52622300 | boot_volume;
- boot_data->crc = magic[0] ^ magic[1] ^ boot_data->boot_volume ^ len;
- break;
- }
- }
- if (boot_data == NULL)
- ret = EKEY_NOT_FOUND;
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement