ot_u8 sub_isf_mirror(ot_u8 direction) { vaddr header; vaddr header_base; vaddr header_alloc; vaddr header_mirror; //vaddr header_end; ot_int i; ot_u16* mirror_ptr; // Go through ISF Header array header = ISF_Header_START; for (i=0; i<ISF_NUM_STOCK_FILES; i++, header+=sizeof(vl_header)) { //get header data header_alloc = vworm_read(header+2); header_base = vworm_read(header+6); header_mirror = vworm_read(header+8); // Copy vworm to mirror if there is a mirror // 0. Skip unmirrored or uninitialized, or unallocated files // 1. Resolve Mirror Length (in vsram it is right ahead of the data) // 2. Load/Save Mirror Data (header_alloc is repurposed) if ((header_mirror != NULL_vaddr) && (header_alloc != 0)) { mirror_ptr = (ot_u16*)vsram_get(header_mirror); if (direction == MIRROR_TO_SRAM) { // LOAD *mirror_ptr = vworm_read(header+0); } if (header_base == NULL_vaddr) { // EXIT if file is mirror-only continue; } if (direction != MIRROR_TO_SRAM) { // SAVE vworm_write((header+0), *mirror_ptr); } header_alloc = header_base + *mirror_ptr; mirror_ptr++; for ( ; header_base<header_alloc; header_base+=2, mirror_ptr++) { if (direction == MIRROR_TO_SRAM) { *mirror_ptr = vworm_read(header_base); } else { vworm_write(header_base, *mirror_ptr); } } } } return 0; }
ot_u8 vworm_mark(vaddr addr, ot_u16 value) { #if (VWORM_SIZE <= 0) return ~0; #else return vworm_write(addr, value); #endif }
void sub_write_header(vaddr header, ot_u16* data, ot_uint length ) { ot_int i; for (i=0; i<length; i+=2, data++) { vworm_write( (header+i), *data); } }
ot_u8 vworm_wipeblock(vaddr addr, ot_uint wipe_span) { #if ((VWORM_SIZE > 0) && (OT_FEATURE_VLNVWRITE == ENABLED)) ot_u8 output = 0; wipe_span += addr; for (; ((addr < (vaddr)wipe_span) && (output == 0)); addr+=2) { output |= vworm_write(addr, NULL_vaddr); } return output; #else return 0; #endif }
ot_u8 vworm_wipeblock(vaddr addr, ot_uint wipe_span) { #if (VWORM_SIZE <= 0) return ~0; #else ot_u8 output = 0; wipe_span += addr; for (; ((addr < (vaddr)wipe_span) && (output == 0)); addr+=2) { output |= vworm_write(addr, NULL_vaddr); } return output; #endif }
ot_u8 vworm_mark(vaddr addr, ot_u16 value) { return vworm_write(addr, value); }