void my_free(void * mem) { os_heap_free(0, mem); }
int read_from_device(void *outbuf, u32 size, u32 lba) { int r=-1; int l; r = __DI_CheckOffset(lba); if (r) return r; r=-1; lba += dip.base + dip.offset; if (dip.has_id) { /* Free memory */ if(fat_mode<=0) { if (table_lba) os_heap_free(0, table_lba); table_lba=NULL; ciso_lba=-1; } return read_from_device_out(outbuf, size, lba); } if(ciso_lba>=0 && ciso_lba!=0x7fffffff) { u32 lba_glob=0; if(table_lba==NULL) table_lba= (void *) os_heap_alloc_aligned(0, 2048*4, 32); // from global heap //ciso_lba=265; /* Allocate memory */ u8 * buff = dip_alloc_aligned(0x800, 32); if (!buff) ciso_lba=-1; if(ciso_lba>=0) { while(1) { lba_glob=(ciso_lba+16)<<9; r=read_from_device_out(buff, 2048, ciso_lba<<9); // read 16 cached sectors if(r<0) {ciso_lba=-1;break;} if((buff[0]=='C' && buff[1]=='I' && buff[2]=='S' && buff[3]=='O')) break; else { if(ciso_lba!=0) {ciso_lba=0;continue;} ciso_lba=-1; } break; } } // if(ciso_lba>=0 && table_lba && buff) ciso_lba=0x7fffffff; if(ciso_lba>=0 && table_lba) { ciso_size=(((u32)buff[4])+(((u32)buff[5])<<8)+(((u32)buff[6])<<16)+(((u32)buff[7])<<24))/4; dip_memset(mem_index,0,2048); for(l=0;l<16384;l++) { if(((l+8) & 2047)==0 && (l+8)>=2048) { r=read_from_device_out(buff, 2048, (ciso_lba+((l+8)>>11))<<9); // read 16 cached sectors if(r<0) {ciso_lba=-1;break;} } if((l & 7)==0) table_lba[l>>3]=lba_glob; if(buff[(8+l) & 2047]) { mem_index[l>>3]|=1<<(l & 7); lba_glob+=ciso_size; } }
void Mem_Free(void *ptr) { /* Free memory */ os_heap_free(hid, ptr); }
void USB_Free(void *ptr) { return os_heap_free(heap, ptr); }