int loadTRD(Floppy* flp, const char* name) { std::ifstream file(name,std::ios::binary); if (!file.good()) return ERR_CANT_OPEN; file.seekg(0,std::ios::end); size_t len = file.tellg(); if (((len & 0xfff) != 0) || (len == 0) || (len > 0xa8000)) return ERR_TRD_LEN; // file.seekg(0x8e7,std::ios::beg); // if (file.peek() != 0x10) return ERR_TRD_SIGN; file.seekg(0); flpFormat(flp); int i=0; unsigned char* trackBuf = new unsigned char[0x1000]; do { file.read((char*)trackBuf,0x1000); flpFormTRDTrack(flp,i,trackBuf); i++; } while (!file.eof()); delete(trackBuf); flp->path = (char*)realloc(flp->path,sizeof(char) * (strlen(name) + 1)); strcpy(flp->path,name); flp->flag |= FLP_INSERT; loadBoot(flp); flp->flag &= ~FLP_CHANGED; return ERR_OK; }
void disk_boot(Computer* comp, int drv, int id) { int idx = 0; while (boot_ft[idx] && (boot_ft[idx] != id)) idx++; if (boot_ft[idx]) loadBoot(comp, conf.path.boot, drv); }
int loadFDI(Floppy* flp,const char* name) { std::ifstream file(name,std::ios::binary); if (!file.good()) return ERR_CANT_OPEN; unsigned char* buf = new unsigned char[14]; Sector sct; Sector trkimg[256]; int i,j,scnt; unsigned char fcnt,tmp; unsigned short tmpa,tmpb,slen; size_t tmpd,tmph,tmpt,tmps,cpos; file.read((char*)buf,14); if (strncmp((const char*)buf,"FDI",3) != 0) return ERR_FDI_SIGN; bool err = (buf[3] != 0); tmpa = buf[4] + (buf[5] << 8); // cylinders tmpb = buf[6] + (buf[7] << 8); // heads if ((tmpb != 1) && (tmpb != 2)) return ERR_FDI_HEAD; tmpd = buf[10] + (buf[11] << 8); // sectors data pos tmph = buf[12] + (buf[13] << 8) + 14; // track headers data pos file.seekg(tmph); // read tracks data for (i = 0; i < tmpa; i++) { for (j = 0; j < tmpb; j++) { // trkimg.clear(); tmpt = tmpd + getlen(&file,4); file.seekg(2,std::ios_base::cur); // skip 2 bytes tmp = file.get(); // sectors in disk; for (scnt=0; scnt < tmp; scnt++) { sct.cyl = file.get(); sct.side = file.get(); sct.sec = file.get(); sct.len = file.get(); fcnt = file.get(); // flag sct.type = (fcnt & 0x80) ? 0xf8 : 0xfb; tmps = tmpt + getlen(&file,2); cpos = file.tellg(); // remember current pos file.seekg(tmps); slen = (128 << sct.len); // sector len sct.data = new unsigned char[slen]; file.read((char*)sct.data,slen); // read sector data file.seekg(cpos); trkimg[scnt] = sct; //trkimg.push_back(sct); } flpFormTrack(flp, (i << 1) + j, trkimg, tmp); } } flp->flag &= ~FLP_PROTECT; if (err) flp->flag |= FLP_PROTECT; flp->flag |= FLP_INSERT; loadBoot(flp); flp->flag &= ~FLP_CHANGED; flp->path = (char*)realloc(flp->path,sizeof(char) * (strlen(name) + 1)); strcpy(flp->path,name); return ERR_OK; }
//========================================================================= // loadDDR: DDR initialization function //========================================================================= int loadDDR(char *name) { taskDelay(calcSysClkTicks(17)); /* taskDelay(1); */ if(!loadBoot()) return 0; taskDelay(calcSysClkTicks(17)); /* taskDelay(1); */ resetSDRAM(); // without this boot fails (mem errors) taskDelay(calcSysClkTicks(17)); /* taskDelay(1); */ #ifdef XXXXX #ifndef DSP_BIN_COMPILED_IN writeDDROS(name); // copy the DDR os to C6 memory #else loadDspDDRArray(); #endif #endif if( writeDDROS(name) == 1) { DPRINT1(-1,"'%s': copied into C6 memory",name); } else { DPRINT(-1,"Loading DSP DDR Array into C6 memory"); if ( loadDspDDRArray() == -1) { DPRINT(-1,"ERROR: could not load DSP DDR array into C6 memory"); return 0; } } strcpy(osname,name); taskDelay(calcSysClkTicks(17)); /* taskDelay(1); */ // send a signal to bootup program (causes a jump to adrs:0) total_ddr_msgs=total_host_msgs=0; return startDDR(); }