void memory_subinitialise(meminfo* mem) { fprintf(stderr, "Initialising RISCOSE memory subsystem\n"); /* let's have 16mb for our application */ mem->bank0 = jt_newarray(uint5, 16384/4); /* and 1 mb of ROM */ mem->rom0 = jt_newarray(uint5, 1024/4); }
/* returns 0 on success, 1 if error (not sym tab) */ uint5 readsymtab(FILE* ar, struct ar_hdr* header, archive_symtab* symtab) { uint5 numsym, i, strtabsize, stroffset; uint5* offsets, *strings; char* strtab; int rc; if (header->ar_name[0] != '/') { return 1; } numsym = readword(ar); offsets = jt_newarray(uint5, numsym); #ifdef DEBUG fprintf(stderr, "Reading %d symbols...\n", numsym); #endif sscanf(header->ar_size, "%d", &strtabsize); /* subtract number of things which are provably not strings */ strtabsize -= 4*(numsym+1); for (i=0; i<numsym; i++) { offsets[i] = readword(ar); /* fprintf(stderr, "Offset[%d]=%d\n", i, offsets[i]);*/ } strtab = jt_newarray(char, strtabsize); strings = jt_newarray(uint5, numsym); rc = fread(strtab, 1, strtabsize, ar); assert(rc==strtabsize); for (stroffset=0, i=0; i<numsym; i++) { strings[i] = stroffset; /* skip string and trailing \0 */ /* fprintf(stderr, "sym: %s\n", &strtab[stroffset]);*/ stroffset += strlen(&strtab[stroffset])+1; } symtab->count = numsym; symtab->loc = offsets; symtab->name = strtab; symtab->nameidx = strings; return 0; }