Changeset 4622 in vbox
- Timestamp:
- Sep 8, 2007 6:28:46 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevPCNet.cpp
r4565 r4622 47 47 */ 48 48 49 /** To enable the PDMThread based send thread code. 50 * This is just a emergency switch in case changes doesn't quite work and 49 /** To enable the PDMThread based send thread code. 50 * This is just a emergency switch in case changes doesn't quite work and 51 51 * we want to get 1.5 out. 52 52 * @todo cleanup after 1.5. */ … … 204 204 /** If set the link is temporarily down because of a saved state load. */ 205 205 bool fLinkTempDown; 206 /** This flag is set on SavePrep to prevent altering of memory after pgmR3Save() was called 207 * @todo r=bird: This is inadequate, we are not supposed to do anything at all while the VM 206 /** This flag is set on SavePrep to prevent altering of memory after pgmR3Save() was called 207 * @todo r=bird: This is inadequate, we are not supposed to do anything at all while the VM 208 208 * isn't running. Naturally, the problem really lies with the driver and not 209 209 * the pcnet code. We will have to address this properly at some time. */ … … 229 229 #else 230 230 RTTHREAD hSendThread; 231 #endif 231 #endif 232 232 233 233 /** Access critical section. */ … … 317 317 #define BCR_INTCON 21 /* Reserved */ 318 318 #define BCR_PLAT 22 319 #define BCR_PCIS ID23320 #define BCR_PCIS VID24319 #define BCR_PCISVID 23 320 #define BCR_PCISID 24 321 321 #define BCR_SRAMSIZ 25 322 322 #define BCR_SRAMB 26 … … 2063 2063 if (VBOX_FAILURE(rc)) 2064 2064 return rc; /* can happen during termination */ 2065 #endif 2065 #endif 2066 2066 } 2067 2067 } … … 2174 2174 if (VBOX_FAILURE(rc)) 2175 2175 return rc; /* can happen during termination */ 2176 #endif 2176 #endif 2177 2177 } 2178 2178 else if (CSR_LOOP(pData) && !fDropFrame) … … 2238 2238 2239 2239 #ifdef USE_PDMTHREAD 2240 /** 2240 /** 2241 2241 * Async I/O thread for delayed sending of packets. 2242 * 2242 * 2243 2243 * @returns VBox status code. Returning failure will naturally terminate the thread. 2244 2244 * @param pDevIns The pcnet device instance. … … 2252 2252 * We can enter this function in two states, initializing or resuming. 2253 2253 * 2254 * The idea about the initializing bit is that we can do per-thread 2254 * The idea about the initializing bit is that we can do per-thread 2255 2255 * initialization while the creator thread can still pick up errors. 2256 2256 * At present, there is nothing to init, or at least nothing that … … 2261 2261 2262 2262 /* 2263 * Stay in the run-loop until we're supposed to leave the 2263 * Stay in the run-loop until we're supposed to leave the 2264 2264 * running state. If something really bad happens, we'll 2265 2265 * quit the loop while in the running state and return … … 2278 2278 2279 2279 /* 2280 * Perform async send. Mind that we might be requested to 2280 * Perform async send. Mind that we might be requested to 2281 2281 * suspended while waiting for the critical section. 2282 2282 */ … … 2300 2300 /** 2301 2301 * Unblock the send thread so it can respond to a state change. 2302 * 2302 * 2303 2303 * @returns VBox status code. 2304 2304 * @param pDevIns The pcnet device instance. … … 2478 2478 case 22: /* NRBAL */ 2479 2479 case 23: /* NRBAU */ 2480 case 24: /* BADRL */2481 case 25: /* BADRU */2482 2480 case 26: /* NRDAL */ 2483 2481 case 27: /* NRDAU */ 2484 2482 case 28: /* CRDAL */ 2485 2483 case 29: /* CRDAU */ 2486 case 30: /* BADXL */2487 case 31: /* BADXU */2488 2484 case 32: /* NXDAL */ 2489 2485 case 33: /* NXDAU */ … … 2504 2500 case 72: /* RCVRC */ 2505 2501 case 74: /* XMTRC */ 2506 case 76: /* RCVRL */ /** @todo call pcnetUpdateRingHandlers */2507 /** @todo receive ring length is stored in two's complement! */2508 case 78: /* XMTRL */ /** @todo call pcnetUpdateRingHandlers */2509 /** @todo transmit ring length is stored in two's complement! */2510 2502 case 112: /* MISSC */ 2511 2503 if (CSR_STOP(pData) || CSR_SPND(pData)) … … 2549 2541 case 17: /* IADRH */ 2550 2542 return pcnetCSRWriteU16(pData, 2, val); 2543 2544 /* 2545 * 24 and 25 are the Base Address of Receive Descriptor. 2546 * We combine and mirror these in GCRDRA. 2547 */ 2548 case 24: /* BADRL */ 2549 case 25: /* BADRU */ 2550 if (!CSR_STOP(pData) && !CSR_SPND(pData)) 2551 { 2552 Log(("PCNet#%d: WRITE CSR%d, %#06x !!\n", PCNETSTATE_2_DEVINS(pData)->iInstance, u32RAP, val)); 2553 return rc; 2554 } 2555 if (u32RAP == 24) 2556 pData->GCRDRA = (pData->GCRDRA & 0xffff0000) | (val & 0x0000ffff); 2557 else 2558 pData->GCRDRA = (pData->GCRDRA & 0x0000ffff) | ((val & 0x0000ffff) << 16); 2559 Log(("PCNet#%d: WRITE CSR%d, %#06x => GCRDRA=%08x (alt init)\n", PCNETSTATE_2_DEVINS(pData)->iInstance, 2560 u32RAP, val, pData->GCRDRA)); 2561 break; 2562 2563 /* 2564 * 30 & 31 are the Base Address of Transmit Descriptor. 2565 * We combine and mirrorthese in GCTDRA. 2566 */ 2567 case 30: /* BADXL */ 2568 case 31: /* BADXU */ 2569 if (!CSR_STOP(pData) && !CSR_SPND(pData)) 2570 { 2571 Log(("PCNet#%d: WRITE CSR%d, %#06x !!\n", PCNETSTATE_2_DEVINS(pData)->iInstance, u32RAP, val)); 2572 return rc; 2573 } 2574 if (u32RAP == 30) 2575 pData->GCTDRA = (pData->GCTDRA & 0xffff0000) | (val & 0x0000ffff); 2576 else 2577 pData->GCTDRA = (pData->GCTDRA & 0x0000ffff) | ((val & 0x0000ffff) << 16); 2578 Log(("PCNet#%d: WRITE CSR%d, %#06x => GCTDRA=%08x (alt init)\n", PCNETSTATE_2_DEVINS(pData)->iInstance, 2579 u32RAP, val, pData->GCTDRA)); 2580 break; 2581 2551 2582 case 58: /* Software Style */ 2552 2583 LOG_REGISTER(("PCNet#%d: WRITE SW_STYLE, %#06x\n", … … 2554 2585 rc = pcnetBCRWriteU16(pData, BCR_SWS, val); 2555 2586 break; 2587 2588 /* 2589 * Registers 76 and 78 aren't stored correctly (see todos), but I'm don't dare 2590 * try fix that right now. So, as a quick hack for 'alt init' I'll just correct them here. 2591 */ 2592 case 76: /* RCVRL */ /** @todo call pcnetUpdateRingHandlers */ 2593 /** @todo receive ring length is stored in two's complement! */ 2594 case 78: /* XMTRL */ /** @todo call pcnetUpdateRingHandlers */ 2595 /** @todo transmit ring length is stored in two's complement! */ 2596 if (!CSR_STOP(pData) && !CSR_SPND(pData)) 2597 { 2598 Log(("PCNet#%d: WRITE CSR%d, %#06x !!\n", PCNETSTATE_2_DEVINS(pData)->iInstance, u32RAP, val)); 2599 return rc; 2600 } 2601 Log(("PCNet#%d: WRITE CSR%d, %#06x (hacked %#06x) (alt init)\n", PCNETSTATE_2_DEVINS(pData)->iInstance, 2602 u32RAP, val, 1 + ~(uint16_t)val)); 2603 val = 1 + ~(uint16_t)val; 2604 2605 /* 2606 * HACK ALERT! Set the counter registers too. 2607 */ 2608 pData->aCSR[u32RAP - 4] = val; 2609 break; 2610 2556 2611 default: 2557 2612 return rc; … … 2821 2876 pData->iLog2DescSize = 3; 2822 2877 pData->aBCR[BCR_PLAT ] = 0xff06; 2878 pData->aBCR[BCR_PCIVID] = PCIDevGetVendorId(&pData->PciDev); 2879 pData->aBCR[BCR_PCISID] = PCIDevGetSubSystemId(&pData->PciDev); 2880 pData->aBCR[BCR_PCISVID] = PCIDevGetSubSystemVendorId(&pData->PciDev); 2823 2881 2824 2882 pcnetSoftReset(pData); … … 2870 2928 } 2871 2929 } 2930 else 2931 Log(("#%d pcnetIoportWriteU16: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNETSTATE_2_DEVINS(pData)->iInstance, addr, val)); 2872 2932 2873 2933 return rc; … … 2906 2966 } 2907 2967 } 2968 else 2969 Log(("#%d pcnetIoportReadU16: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNETSTATE_2_DEVINS(pData)->iInstance, addr, val & 0xffff)); 2970 2908 2971 pcnetUpdateIrq(pData); 2909 2972 … … 2941 3004 } 2942 3005 } 2943 else if ( addr== 0)3006 else if ((addr & 0x0f) == 0) 2944 3007 { 2945 3008 /* switch device to dword I/O mode */ … … 2949 3012 #endif 2950 3013 } 3014 else 3015 Log(("#%d pcnetIoportWriteU32: addr=%#010x val=%#010x !BCR_DWIO !!\n", PCNETSTATE_2_DEVINS(pData)->iInstance, addr, val)); 2951 3016 2952 3017 return rc; … … 2985 3050 } 2986 3051 } 3052 else 3053 Log(("#%d pcnetIoportReadU32: addr=%#010x val=%#010x !BCR_DWIO !!\n", PCNETSTATE_2_DEVINS(pData)->iInstance, addr, val)); 2987 3054 pcnetUpdateIrq(pData); 2988 3055 … … 3110 3177 PCNetState *pData = PDMINS2DATA(pDevIns, PCNetState *); 3111 3178 int rc; 3112 if (cb == 1) 3113 { 3114 STAM_PROFILE_ADV_START(&pData->StatAPROMRead, a); 3115 rc = PDMCritSectEnter(&pData->CritSect, VINF_IOM_HC_IOPORT_WRITE); 3116 if (rc == VINF_SUCCESS) 3179 3180 STAM_PROFILE_ADV_START(&pData->StatAPROMRead, a); 3181 rc = PDMCritSectEnter(&pData->CritSect, VINF_IOM_HC_IOPORT_WRITE); 3182 if (rc == VINF_SUCCESS) 3183 { 3184 3185 /* FreeBSD is accessing in dwords. */ 3186 if (cb == 1) 3187 *pu32 = pcnetAPROMReadU8(pData, Port); 3188 else if (cb == 2 && !BCR_DWIO(pData)) 3189 *pu32 = pcnetAPROMReadU8(pData, Port) 3190 | (pcnetAPROMReadU8(pData, Port + 1) << 8); 3191 else if (cb == 4 && BCR_DWIO(pData)) 3192 *pu32 = pcnetAPROMReadU8(pData, Port) 3193 | (pcnetAPROMReadU8(pData, Port + 1) << 8) 3194 | (pcnetAPROMReadU8(pData, Port + 2) << 16) 3195 | (pcnetAPROMReadU8(pData, Port + 3) << 24); 3196 else 3117 3197 { 3118 *pu32 = pcnetAPROMReadU8(pData, Port);3119 PDMCritSectLeave(&pData->CritSect);3198 Log(("#%d pcnetIOPortAPromRead: Port=%RTiop cb=%d BCR_DWIO !!\n", PCNETSTATE_2_DEVINS(pData)->iInstance, Port, cb)); 3199 rc = VERR_IOM_IOPORT_UNUSED; 3120 3200 } 3121 STAM_PROFILE_ADV_STOP(&pData->StatAPROMRead, a); 3122 } 3123 else 3124 rc = VERR_IOM_IOPORT_UNUSED; 3201 PDMCritSectLeave(&pData->CritSect); 3202 } 3203 STAM_PROFILE_ADV_STOP(&pData->StatAPROMRead, a); 3125 3204 LogFlow(("#%d pcnetIOPortAPromRead: Port=%RTiop *pu32=%#RX32 cb=%d rc=%Vrc\n", 3126 3205 PCNETSTATE_2_DEVINS(pData)->iInstance, Port, *pu32, cb, rc)); … … 3809 3888 SSMR3GetU64(pSSMHandle, &pData->u64LastPoll); 3810 3889 SSMR3GetMem(pSSMHandle, &Mac, sizeof(Mac)); 3811 Assert( !memcmp(&Mac, &pData->MacConfigured, sizeof(Mac)) 3890 Assert( !memcmp(&Mac, &pData->MacConfigured, sizeof(Mac)) 3812 3891 || SSMR3HandleGetAfter(pSSMHandle) == SSMAFTER_DEBUG_IT); 3813 3892 SSMR3GetBool(pSSMHandle, &pData->fAm79C973); … … 3922 4001 if (cb > 70) /* unqualified guess */ 3923 4002 pData->Led.Asserted.s.fReading = pData->Led.Actual.s.fReading = 1; 3924 pcnetReceiveNoSync(pData, (const uint8_t *)pvBuf, cb);4003 pcnetReceiveNoSync(pData, (const uint8_t *)pvBuf, cb); 3925 4004 pData->Led.Actual.s.fReading = 0; 3926 4005 } … … 4089 4168 { 4090 4169 #ifdef USE_PDMTHREAD 4091 /* 4170 /* 4092 4171 * At this point the send thread is suspended and will not enter 4093 * this module again. So, no coordination is needed here and PDM 4172 * this module again. So, no coordination is needed here and PDM 4094 4173 * will take care of terminating and cleaning up the thread. 4095 4174 */ … … 4105 4184 PDMCritSectLeave(&pData->CritSect); 4106 4185 PDMR3CritSectDelete(&pData->CritSect); 4107 #endif 4186 #endif 4108 4187 } 4109 4188 return VINF_SUCCESS; … … 4382 4461 rc = RTThreadCreate(&pData->hSendThread, pcnetAsyncSend, (void *)pData, 128*1024, RTTHREADTYPE_IO, 0, "PCNET_SEND"); 4383 4462 AssertRC(rc); 4384 #endif 4463 #endif 4385 4464 4386 4465 #ifdef VBOX_WITH_STATISTICS
Note:
See TracChangeset
for help on using the changeset viewer.