/******************************************************************************** * Loop through each node function to find usable EADs bridges. *********************************************************************************/ void iSeries_Scan_PHBs_Slots(struct pci_controller* Phb) { struct HvCallPci_DeviceInfo* DevInfo; HvBusNumber Bus = Phb->local_number; /* System Bus */ HvSubBusNumber SubBus = 0; /* EADs is always 0. */ int HvRc = 0; int IdSel = 1; int MaxAgents = 8; DevInfo = (struct HvCallPci_DeviceInfo*)kmalloc(sizeof(struct HvCallPci_DeviceInfo), GFP_KERNEL); if(DevInfo == NULL) return; /******************************************************************************** * Probe for EADs Bridges ********************************************************************************/ for (IdSel=1; IdSel < MaxAgents; ++IdSel) { HvRc = HvCallPci_getDeviceInfo(Bus, SubBus, IdSel,REALADDR(DevInfo), sizeof(struct HvCallPci_DeviceInfo)); if (HvRc == 0) { if(DevInfo->deviceType == HvCallPci_NodeDevice) { iSeries_Scan_EADs_Bridge(Bus, SubBus, IdSel); } else { printk("PCI: Invalid System Configuration(0x%02X).\n",DevInfo->deviceType); PCIFR( "Invalid System Configuration(0x%02X).", DevInfo->deviceType); } } else pci_Log_Error("getDeviceInfo",Bus, SubBus, IdSel,HvRc); } kfree(DevInfo); }
void iSeries_Scan_EADs_Bridge(HvBusNumber Bus, HvSubBusNumber SubBus, int IdSel) { struct HvCallPci_BridgeInfo* BridgeInfo; HvAgentId AgentId; int Function; int HvRc; BridgeInfo = (struct HvCallPci_BridgeInfo*)kmalloc(sizeof(struct HvCallPci_BridgeInfo), GFP_KERNEL); if(BridgeInfo == NULL) return; /********************************************************************* * Note: hvSubBus and irq is always be 0 at this level! *********************************************************************/ for (Function=0; Function < 8; ++Function) { AgentId = ISERIES_PCI_AGENTID(IdSel, Function); HvRc = HvCallXm_connectBusUnit(Bus, SubBus, AgentId, 0); if (HvRc == 0) { /* Connect EADs: 0x18.00.12 = 0x00 */ PPCDBG(PPCDBG_BUSWALK,"PCI:Connect EADs: 0x%02X.%02X.%02X\n",Bus, SubBus, AgentId); PCIFR( "Connect EADs: 0x%02X.%02X.%02X", Bus, SubBus, AgentId); HvRc = HvCallPci_getBusUnitInfo(Bus, SubBus, AgentId, REALADDR(BridgeInfo), sizeof(struct HvCallPci_BridgeInfo)); if (HvRc == 0) { PPCDBG(PPCDBG_BUSWALK,"PCI: BridgeInfo, Type:0x%02X, SubBus:0x%02X, MaxAgents:0x%02X, MaxSubBus: 0x%02X, LSlot: 0x%02X\n", BridgeInfo->busUnitInfo.deviceType, BridgeInfo->subBusNumber, BridgeInfo->maxAgents, BridgeInfo->maxSubBusNumber, BridgeInfo->logicalSlotNumber); PCIFR( "BridgeInfo, Type:0x%02X, SubBus:0x%02X, MaxAgents:0x%02X, MaxSubBus: 0x%02X, LSlot: 0x%02X", BridgeInfo->busUnitInfo.deviceType, BridgeInfo->subBusNumber, BridgeInfo->maxAgents, BridgeInfo->maxSubBusNumber, BridgeInfo->logicalSlotNumber); if (BridgeInfo->busUnitInfo.deviceType == HvCallPci_BridgeDevice) { /* Scan_Bridge_Slot...: 0x18.00.12 */ iSeries_Scan_Bridge_Slot(Bus,BridgeInfo); } else printk("PCI: Invalid Bridge Configuration(0x%02X)",BridgeInfo->busUnitInfo.deviceType); } } else if(HvRc != 0x000B) pci_Log_Error("EADs Connect",Bus,SubBus,AgentId,HvRc); } kfree(BridgeInfo); }
realcode_t expandcode(bytecode_t byteprog, int code_size, void * jumptable[]) { #ifdef THREADED bytecode_t pc = byteprog; int *realaddress = (int*)(malloc(code_size * sizeof(int))); int realsize = buildrealmap(byteprog, code_size, realaddress); realcode_t realprog = (realcode_t)malloc(realsize * sizeof(void*)); int codeptr = 0; while (pc - byteprog < code_size) { // printf("%d:%d\t\n", pc-byteprog, *pc); switch (*pc) { /* No arguments: */ Instruct(SWAP): Instruct(PUSH): Instruct(PUSHACC0): Instruct(ACC0): Instruct(PUSHACC1): Instruct(ACC1): Instruct(PUSHACC2): Instruct(ACC2): Instruct(PUSHACC3): Instruct(ACC3): Instruct(PUSHACC4): Instruct(ACC4): Instruct(PUSHACC5): Instruct(ACC5): Instruct(PUSHACC6): Instruct(ACC6): Instruct(PUSHACC7): Instruct(ACC7): Instruct(PUSHENV1): Instruct(ENV1): Instruct(PUSHENV2): Instruct(ENV2): Instruct(PUSHENV3): Instruct(ENV3): Instruct(PUSHENV4): Instruct(ENV4): Instruct(PUSHENV5): Instruct(ENV5): Instruct(PUSHENV6): Instruct(ENV6): Instruct(PUSHENV7): Instruct(ENV7): Instruct(PUSH_ENV1_APPLY1): Instruct(PUSH_ENV1_APPLY2): Instruct(PUSH_ENV1_APPLY3): Instruct(PUSH_ENV1_APPLY4): Instruct(APPLY1): Instruct(APPLY2): Instruct(APPLY3): Instruct(APPLY4): Instruct(RETURN1): Instruct(RETURN2): Instruct(RESTART): Instruct(UPDATE): Instruct(CHECK_SIGNALS): Instruct(PUSHATOM0): Instruct(ATOM0): Instruct(ATOM1): Instruct(ATOM2): Instruct(ATOM3): Instruct(ATOM4): Instruct(ATOM5): Instruct(ATOM6): Instruct(ATOM7): Instruct(ATOM8): Instruct(ATOM9): Instruct(GETFIELD0): Instruct(GETFIELD1): Instruct(GETFIELD2): Instruct(GETFIELD3): Instruct(GETFIELD0_0): Instruct(GETFIELD0_1): Instruct(GETFIELD1_0): Instruct(GETFIELD1_1): Instruct(SETFIELD0): Instruct(SETFIELD1): Instruct(SETFIELD2): Instruct(SETFIELD3): Instruct(VECTLENGTH): Instruct(GETVECTITEM): Instruct(SETVECTITEM): Instruct(GETSTRINGCHAR): Instruct(SETSTRINGCHAR): Instruct(BOOLNOT): Instruct(POPTRAP): Instruct(RAISE): Instruct(PUSHCONST0): Instruct(CONST0): Instruct(PUSHCONST1): Instruct(CONST1): Instruct(PUSHCONST2): Instruct(CONST2): Instruct(PUSHCONST3): Instruct(CONST3): Instruct(ADDINT): Instruct(SUBINT): Instruct(MULINT): Instruct(DIVINT): Instruct(MODINT): Instruct(ANDINT): Instruct(ORINT): Instruct(XORINT): Instruct(SHIFTLEFTINT): Instruct(SHIFTRIGHTINTSIGNED): Instruct(SHIFTRIGHTINTUNSIGNED): Instruct(TAGOF): Instruct(EQ): Instruct(NEQ): Instruct(LTINT): Instruct(GTINT): Instruct(LEINT): Instruct(GEINT): Instruct(EQUNSIGN): Instruct(NEQUNSIGN): Instruct(LTUNSIGN): Instruct(GTUNSIGN): Instruct(LEUNSIGN): Instruct(GEUNSIGN): Instruct(FLOATOFINT): Instruct(SMLNEGFLOAT): Instruct(SMLADDFLOAT): Instruct(SMLSUBFLOAT): Instruct(SMLMULFLOAT): Instruct(SMLDIVFLOAT): Instruct(INTOFFLOAT): Instruct(EQFLOAT): Instruct(NEQFLOAT): Instruct(LTFLOAT): Instruct(GTFLOAT): Instruct(LEFLOAT): Instruct(GEFLOAT): Instruct(STRINGLENGTH): Instruct(EQSTRING): Instruct(NEQSTRING): Instruct(LTSTRING): Instruct(GTSTRING): Instruct(LESTRING): Instruct(GESTRING): Instruct(MAKEVECTOR): Instruct(SMLNEGINT): Instruct(SMLSUCCINT): Instruct(SMLPREDINT): Instruct(SMLADDINT): Instruct(SMLSUBINT): Instruct(SMLMULINT): Instruct(SMLDIVINT): Instruct(SMLMODINT): Instruct(MAKEREFVECTOR): Instruct(SMLQUOTINT): Instruct(SMLREMINT): Instruct(STOP): realprog[codeptr++] = jumptable[*pc++]; break; /* A one-byte argument: */ Instruct(APPLY): Instruct(GRAB): Instruct(PUSHATOM): Instruct(ATOM): Instruct(MAKEBLOCK1): Instruct(MAKEBLOCK2): Instruct(MAKEBLOCK3): Instruct(MAKEBLOCK4): Instruct(CONSTBYTE): realprog[codeptr++] = jumptable[*pc++]; realprog[codeptr++] = (void*)(long)(*pc++); break; /* A four-byte label argument. The label is translated to an index into the realprog[] array. */ Instruct(PUSH_RETADDR): Instruct(PUSHTRAP): Instruct(BRANCH): Instruct(BRANCHIF): Instruct(BRANCHIFNOT): Instruct(POPBRANCHIFNOT): Instruct(BRANCHIFEQ): Instruct(BRANCHIFNEQ): Instruct(BRANCHIFLT): Instruct(BRANCHIFGT): Instruct(BRANCHIFLE): Instruct(BRANCHIFGE): realprog[codeptr++] = jumptable[*pc++]; realprog[codeptr++] = REALADDR(pc, s32pc); pc += LONG; break; /* Two four-byte label arguments. The labels should be translated to an address in the realprog[] array. This requires an auxiliary table. */ Instruct(BRANCHINTERVAL): realprog[codeptr++] = jumptable[*pc++]; realprog[codeptr++] = REALADDR(pc, s32pc); pc += LONG; realprog[codeptr++] = REALADDR(pc, s32pc); pc += LONG; break; /* A two-byte signed argument. */ Instruct(CONSTSHORT): realprog[codeptr++] = jumptable[*pc++]; realprog[codeptr++] = (void*)(long)s16pc; pc += SHORT; break; /* A two-byte unsigned argument. */ Instruct(PUSHACC): Instruct(ACCESS): Instruct(POP): Instruct(ASSIGN): Instruct(PUSHENVACC): Instruct(ENVACC): Instruct(DUMMY): Instruct(RETURN): Instruct(APPTERM1): Instruct(APPTERM2): Instruct(APPTERM3): Instruct(APPTERM4): Instruct(PUSH_ENV1_APPTERM1): Instruct(PUSH_ENV1_APPTERM2): Instruct(PUSH_ENV1_APPTERM3): Instruct(PUSH_ENV1_APPTERM4): Instruct(GETFIELD): Instruct(SETFIELD): Instruct(C_CALL1): Instruct(C_CALL2): Instruct(C_CALL3): Instruct(C_CALL4): Instruct(C_CALL5): realprog[codeptr++] = jumptable[*pc++]; realprog[codeptr++] = (void*)(unsigned long)u16pc; pc += SHORT; break; /* A four-byte unsigned argument. */ Instruct(MAKEBLOCK): Instruct(SETGLOBAL): Instruct(GETGLOBAL): Instruct(PUSH_GETGLOBAL): Instruct(PUSH_GETGLOBAL_APPLY1): Instruct(PUSH_GETGLOBAL_APPLY2): Instruct(PUSH_GETGLOBAL_APPLY3): Instruct(PUSH_GETGLOBAL_APPLY4): realprog[codeptr++] = jumptable[*pc++]; realprog[codeptr++] = (void*)(unsigned long)u32pc; pc += LONG; break; /* A four-byte signed argument. */ Instruct(PUSHCONSTINT): Instruct(CONSTINT): realprog[codeptr++] = jumptable[*pc++]; realprog[codeptr++] = (void*)(long)s32pc; pc += LONG; break; /* A one-byte argument and a four-byte signed (label) argument. */ Instruct(CLOSURE): Instruct(CLOSREC): Instruct(BRANCHIFNEQTAG): realprog[codeptr++] = jumptable[*pc++]; realprog[codeptr++] = (void*)(unsigned long)*pc++; realprog[codeptr++] = REALADDR(pc, s32pc); pc += LONG; break; /* A one-byte argument and a two-byte unsigned argument. */ Instruct(APPTERM): Instruct(C_CALLN): realprog[codeptr++] = jumptable[*pc++]; realprog[codeptr++] = (void*)(long)*pc++; realprog[codeptr++] = (void*)(unsigned long)u16pc; pc += SHORT; break; /* One two-byte and one four-byte unsigned argument. */ Instruct(PUSH_GETGLOBAL_APPTERM1): Instruct(PUSH_GETGLOBAL_APPTERM2): Instruct(PUSH_GETGLOBAL_APPTERM3): Instruct(PUSH_GETGLOBAL_APPTERM4): realprog[codeptr++] = jumptable[*pc++]; realprog[codeptr++] = (void*)(unsigned long)u16pc; pc += SHORT; realprog[codeptr++] = (void*)(unsigned long)u32pc; pc += LONG; break; /* A one-byte argument and a table of four-byte signed (label) arguments. */ /* We keep the byte argument for consistency. */ Instruct(SWITCH): { unsigned long i, n; bytecode_t pc1; realprog[codeptr++] = jumptable[*pc++]; n = (unsigned long)*pc++; realprog[codeptr++] = (void*)n; pc1 = pc; for (i=0; i<n; i++) { realprog[codeptr++] = REALADDR(pc1, s32pc); pc += LONG; } } break; default: printf("expandcode: opcode = %d at %d\n", *pc, pc-byteprog); fatal_error("bad opcode"); } } // printf("expandcode finished\n"); free(realaddress); // printf("freed realaddress\n"); return realprog; #else return NULL; #endif } // expandcode