int main() { //---------- start nm program ------------ int fromHost=ncl_hostSync(0xC0DE6406); // send handshake to host if (fromHost!=0xC0DE0086){ // get handshake from host return -1; } // Get image parameters from host int width = ncl_hostSync(0); int height= ncl_hostSync(1); int size = width*height; int* intSrc=(int*)malloc32(size/4,HEAP_3); int* intDst=intSrc; free32(intSrc); CSobel sobel(width, height); // Check memory allocation if (sobel.isReady==false || intSrc ==0 ){ ncl_hostSync(0xDEADB00F); // send error to host return -1; } else ncl_hostSync(0x600DB00F); // send ok to host ncl_hostSync((int)extSrc); // Send source buffer address to host ncl_hostSync((int)extDst); // Send result buffer address to host clock_t t0,t1; int counter=0; // frame counter while(1){ // Start sobel in loop ncl_hostSync(counter); // Wait source buffer till is ready nmppsCopy_8u((nm8u*)extSrc,(nm8u*)intSrc,size); t0=clock(); sobel.filter((unsigned char*)intSrc,(unsigned char*)intDst); t1=clock(); nmppsCopy_8u((nm8u*)intDst,(nm8u*)extDst,size); ncl_hostSync(t1-t0); // Send elapsed time counter++; } ncl_hostSync(0xDEADB00F); free32(extSrc); free32(extDst); return 1; }
void RegisterAllocator::free(const OperandREF &ref) { for(int i = 0; i < 8; i++) { if(i == Encoding::ESP || i == Encoding::EBP) continue; if(GPR[i].reference == ref) { free32(i); } } for(int i = 0; i < 8; i++) { if(MMX[i].reference == ref) { free64(i); } } for(int i = 0; i < 8; i++) { if(XMM[i].reference == ref) { free128(i); } } }
static void freeelfobj(struct ElfObject *elfobj) /* free all memory connected to an ElfObject */ { if (elfobj) { if (elfobj->handle) clstream(elfobj); free32(elfobj); } }
static void freeprogram(struct ElfObject *eo) { struct ELFSection *s; unsigned int i; for (i=0; i<eo->nsects; i++) { if( (s = eo->sections[i]) != NULL ) { if (s->address) { free32(s->address); s->address = NULL; } } } }
void RegisterAllocator::freeAll() { for(int i = 0; i < 8; i++) { if(i == Encoding::ESP || i == Encoding::EBP) continue; free32(i); } for(int i = 0; i < 8; i++) { free64(i); } for(int i = 0; i < 8; i++) { free128(i); } }
void RegisterAllocator::free(const OperandREG32 &r32) { free32(r32.reg); }
void* ELFLoadObject( const char* objname ) { struct ElfObject *elfobj = NULL; /* allocate ElfObject structure */ elfobj = alloc32( sizeof( struct ElfObject ) ); if( elfobj != NULL ) { memset(elfobj,0,sizeof(struct ElfObject)); elfobj->header = alloc32( sizeof( struct Elf32_Ehdr ) ); if( elfobj->header != NULL ) { /* open ELF stream for reading */ elfobj->handle = opstream( elfobj, objname ); if( elfobj->handle != NULL ) { /* read and identify ELF 32bit PowerPC BigEndian header */ if( rdstream( elfobj, elfobj->header, sizeof(struct Elf32_Ehdr) ) ) { struct Elf32_Ehdr *hdr = elfobj->header; if (!strncmp(hdr->e_ident,ELFid,4) && hdr->e_ident[EI_CLASS]==ELFCLASS32 && hdr->e_ident[EI_DATA]==ELFDATA2MSB && hdr->e_ident[EI_VERSION]==1 && hdr->e_version==1 && (hdr->e_machine==EM_PPC || hdr->e_machine==EM_PPC_OLD || hdr->e_machine==EM_CYGNUS_POWERPC) && hdr->e_type==ET_REL) { struct Elf32_Shdr *shdrs; ULONG shdrsize = (ULONG) hdr->e_shnum * (ULONG) hdr->e_shentsize; // kprintf("elf32ppcbe format recognized\n"); shdrs = alloc32( shdrsize ); if( shdrs != NULL ) { /* read section header table and parse rest of object */ if( prstream( elfobj, hdr->e_shoff, shdrs, shdrsize ) ) { if( loadelf32( elfobj, shdrs ) ) { void* start; // kprintf("ELF object loaded (0x%08lx)\n", elfobj ); start = loadprogram( elfobj ); // kprintf("Start of PPC code: 0x%08lx\n", start ); free32( shdrs ); return (elfobj); } } free32( shdrs ); } } else kprintf( "Not an ELF32-PPC-BE\nrelocatable object."); } } freeelfobj(elfobj); } } return (NULL); }