void bootstrap3() { char *p; char error_str[80]; if (getCF()) { /* * Write error on PC screen - assumes reset has positioned the * cursor for us. Note that we can call the video using a BOP since * the video code does not itself use interrupts. */ sprintf(error_str,"DOS boot error - cannot open hard disk file"); p = error_str; while (*p != '\0') { setAH(14); setAL(*p++); bop(BIOS_VIDEO_IO); } } /* * enable hardware interrupts before we jump to DOS */ setIF(1); }
uint64_t readLocation(const StackMap::Record::Location& loc) { assert(id.type == PythonFrameId::COMPILED); if (loc.type == StackMap::Record::Location::LocationType::Register) { // TODO: need to make sure we deal with patchpoints appropriately return getReg(loc.regnum); } else if (loc.type == StackMap::Record::Location::LocationType::Direct) { uint64_t reg_val = getReg(loc.regnum); return reg_val + loc.offset; } else if (loc.type == StackMap::Record::Location::LocationType::Indirect) { uint64_t reg_val = getReg(loc.regnum); uint64_t addr = reg_val + loc.offset; return *reinterpret_cast<uint64_t*>(addr); } else if (loc.type == StackMap::Record::Location::LocationType::Constant) { return loc.offset; } else if (loc.type == StackMap::Record::Location::LocationType::ConstIndex) { int const_idx = loc.offset; assert(const_idx >= 0); assert(const_idx < cf->location_map->constants.size()); return getCF()->location_map->constants[const_idx]; } else { printf("%d %d %d %d\n", loc.type, loc.flags, loc.regnum, loc.offset); abort(); } }
void bootstrap2() { /* * If the Carry Flag is set then the previous read failed and we go and * try the hard disk. */ if (getCF()) { /* * Load up the registers to call the disk routine that will load * the first sector of DOS into memory. This ALWAYS resides on the * first sector of the disk. */ setAH(2); /* Read sector */ setAL(1); /* 1 block */ setCH(0); /* Cylinder 0 */ setCL(1); /* Sector 1 */ setDH(0); /* Head 0 */ setDL(0x80); /* Hard disk */ setES(DOS_SEGMENT); /* Load address */ setBX(DOS_OFFSET); } }
int deserializeRM(buffer *b, rowMutation *rm) { char *key = NULL, *cfName = NULL, *keyspaceName = NULL; if(!rm) return -1; if(readBytes(b, &keyspaceName, NULL) < 0 || readBytes(b, &key, NULL) < 0 || readBytes(b, &cfName, NULL) < 0){ if(key) free(key); if(cfName) free(cfName); if(keyspaceName) free(keyspaceName); return -1; } rm->key = key; rm->cfName = cfName; rm->keyspaceName = keyspaceName; columnFamilyMetadata *cfm = findCFMetaData(keyspaceName, cfName); if(!cfm){ return -1; } columnFamily *cf = NULL; if(!(cf = getCF(cfm))) return -1; rm->cf = cf; if(deserializeCF(b, rm->cf) < 0){ return -1; } return 0; }
FrameInfo* getFrameInfo() { if (id.type == PythonFrameId::COMPILED) { CompiledFunction* cf = getCF(); assert(cf->location_map->frameInfoFound()); const auto& frame_info_loc = cf->location_map->frame_info_location; return *reinterpret_cast<FrameInfo**>(readLocation(frame_info_loc)); } else if (id.type == PythonFrameId::INTERPRETED) { return getFrameInfoForInterpretedFrame((void*)id.bp); } abort(); }
llvm::ArrayRef<StackMap::Record::Location> findLocations(llvm::StringRef name) { assert(id.type == PythonFrameId::COMPILED); CompiledFunction* cf = getCF(); uint64_t ip = getId().ip; assert(ip > cf->code_start); unsigned offset = ip - cf->code_start; assert(cf->location_map); const LocationMap::LocationTable& table = cf->location_map->names[name]; auto entry = table.findEntry(offset); if (!entry) return {}; assert(entry->locations.size()); return entry->locations; }
BOOL DemDispatch (ULONG iSvc) { #if DBG if(iSvc < SVC_DEMLASTSVC && (fShowSVCMsg & DEMSVCTRACE) && apfnSVC[iSvc] != demNotYetImplemented){ sprintf(demDebugBuffer,"DemDispatch: Entering %s\n\tAX=%.4x BX=%.4x CX=%.4x DX=%.4x DI=%.4x SI=%.4x\n", aSVCNames[iSvc],getAX(),getBX(),getCX(),getDX(),getDI(),getSI()); OutputDebugStringOem(demDebugBuffer); sprintf(demDebugBuffer,"\tCS=%.4x IP=%.4x DS=%.4x ES=%.4x SS=%.4x SP=%.4x BP=%.4x\n", getCS(),getIP(), getDS(),getES(),getSS(),getSP(),getBP()); OutputDebugStringOem(demDebugBuffer); } #endif if (iSvc >= SVC_DEMLASTSVC){ #if DBG sprintf(demDebugBuffer,"Unimplemented SVC index %x\n",iSvc); OutputDebugStringOem(demDebugBuffer); #endif setCF(1); return FALSE; } if (pHardErrPacket) { pHardErrPacket->vhe_fbInt24 = 0; } CurrentISVC = iSvc; (apfnSVC [iSvc])(); #if DBG if((fShowSVCMsg & DEMSVCTRACE)){ sprintf(demDebugBuffer,"DemDispatch:On Leaving %s\n\tAX=%.4x BX=%.4x CX=%.4x DX=%.4x DI=%.4x SI=%.4x\n", aSVCNames[iSvc],getAX(),getBX(),getCX(),getDX(),getDI(),getSI()); OutputDebugStringOem(demDebugBuffer); sprintf(demDebugBuffer,"\tCS=%.4x IP=%.4x DS=%.4x ES=%.4x SS=%.4x SP=%.4x BP=%.4x CF=%x\n", getCS(),getIP(), getDS(),getES(),getSS(),getSP(),getBP(),getCF()); OutputDebugStringOem(demDebugBuffer); } #endif return TRUE; }
// Keyboard IRQ 1 static VOID WINAPI BiosKeyboardIrq(LPWORD Stack) { BOOLEAN SkipScanCode; BYTE ScanCode, VirtualKey; WORD Character; /* * Get the scan code from the PS/2 port, then call the * INT 15h, AH=4Fh Keyboard Intercept function to try to * translate the scan code. CF must be set before the call. * In return, if CF is set we continue processing the scan code * stored in AL, and if not, we skip it. */ BYTE CF; WORD AX; CF = getCF(); AX = getAX(); setCF(1); setAL(IOReadB(PS2_DATA_PORT)); setAH(0x4F); Int32Call(&BiosContext, BIOS_MISC_INTERRUPT); /* Retrieve the modified scan code in AL */ SkipScanCode = (getCF() == 0); ScanCode = getAL(); setAX(AX); setCF(CF); /* Check whether CF is clear. If so, skip the scan code. */ if (SkipScanCode) goto Quit; /* Get the corresponding virtual key code */ VirtualKey = MapVirtualKey(ScanCode & 0x7F, MAPVK_VSC_TO_VK); /* Check if this is a key press or release */ if (!(ScanCode & (1 << 7))) { /* Key press */ if (VirtualKey == VK_NUMLOCK || VirtualKey == VK_CAPITAL || VirtualKey == VK_SCROLL || VirtualKey == VK_INSERT) { /* For toggle keys, toggle the lowest bit in the keyboard map */ BiosKeyboardMap[VirtualKey] ^= ~(1 << 0); } /* Set the highest bit */ BiosKeyboardMap[VirtualKey] |= (1 << 7); /* Find out which character this is */ Character = 0; if (ToAscii(VirtualKey, ScanCode, BiosKeyboardMap, &Character, 0) == 0) { /* Not ASCII */ Character = 0; } /* Push it onto the BIOS keyboard queue */ BiosKbdBufferPush(MAKEWORD(Character, ScanCode)); } else { /* Key release, unset the highest bit */ BiosKeyboardMap[VirtualKey] &= ~(1 << 7); } /* Clear the keyboard flags */ Bda->KeybdShiftFlags = 0; /* Set the appropriate flags based on the state */ if (BiosKeyboardMap[VK_RSHIFT] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_RSHIFT; if (BiosKeyboardMap[VK_LSHIFT] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_LSHIFT; if (BiosKeyboardMap[VK_CONTROL] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_CTRL; if (BiosKeyboardMap[VK_MENU] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_ALT; if (BiosKeyboardMap[VK_SCROLL] & (1 << 0)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_SCROLL_ON; if (BiosKeyboardMap[VK_NUMLOCK] & (1 << 0)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_NUMLOCK_ON; if (BiosKeyboardMap[VK_CAPITAL] & (1 << 0)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_CAPSLOCK_ON; if (BiosKeyboardMap[VK_INSERT] & (1 << 0)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_INSERT_ON; if (BiosKeyboardMap[VK_RMENU] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_RALT; if (BiosKeyboardMap[VK_LMENU] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_LALT; if (BiosKeyboardMap[VK_SNAPSHOT] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_SYSRQ; if (BiosKeyboardMap[VK_PAUSE] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_PAUSE; if (BiosKeyboardMap[VK_SCROLL] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_SCROLL; if (BiosKeyboardMap[VK_NUMLOCK] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_NUMLOCK; if (BiosKeyboardMap[VK_CAPITAL] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_CAPSLOCK; if (BiosKeyboardMap[VK_INSERT] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_INSERT; DPRINT("BiosKeyboardIrq - Character = 0x%X, ScanCode = 0x%X, KeybdShiftFlags = 0x%X\n", Character, ScanCode, Bda->KeybdShiftFlags); Quit: PicIRQComplete(Stack); }
int main() { rowMutation *rm = NULL; columnFamily *cf = NULL; column *x = NULL; queryPath qp = {"Test", "cf1", "key0", NULL, "name", 0}; // char path[1000] = "/home/ydx/test/commitlog/commitlog-1317532982.db"; if(loadConfig(config) < 0 ){ LOG_WRITE("cannot load configure "); return -1; } printTableMetadata(); if(initDM() < 0){ LOG_WRITE("INIT dataModel error\n"); } //here is the marked int i; for(i = 0; i < 100000; i++){ char keytmp[300]; sprintf(keytmp, "key%d", i); if(!(rm = (rowMutation *)calloc(sizeof(rowMutation), 1))){ return -1; } rm->keyspaceName = strdup("Test"); rm->key = strdup(keytmp); rm->cfName = strdup("cf1"); columnFamilyMetadata *cfmd = findCFMetaData(rm->keyspaceName, rm->cfName); if(!cfmd || !(cf = getCF(cfmd))){ return -1; } cf->localDelete = 2000; cf->markedForDelete= 2000; x = getColumn(); if(!x){ return -1; } x->name = strdup("name"); x->value = strdup("ydx"); x->timestamp = 20000; //return -1表明必须释放column的空间,这里为了节省空间 //不得不这样纠结的设计 if(addCFColumn(cf, x) < 0){ LOG_WRITE("cannot add column to cf\n"); decrColumnRef(x); x = NULL; } rm->cf = cf; if(insertDM(rm) < 0){ LOG_WRITE("insert error\n"); freeHeapRM(rm); continue; } // LOG_WRITE("insert succeed\n"); freeHeapRM(rm); } // forceFlushDM("Test", "cf1"); //printf("please input the path to test replay\n"); //scanf("%s", path); // auxilary_recover(path); // column *v = NULL; // printf("getColumnDM return %d\n", getColumnDM(&qp, &v)); // if(v) // printf("name :%s", v->value); // // return 0; // getchar(); }