2251{
2260
2261 UCHAR statusByte, statusByte2;
2263
2266
2267
2268
2270
2271
2272
2273
2274 static CONST ULONG InterruptLevels[5] = {14, 15, 11, 10, 0};
2275
2277
2278 if (!deviceExtension) {
2280 }
2282
2287
2289 goto exit_error;
2290 }
2291
2292 chan = &(deviceExtension->
chan[0]);
2294
2297 = ConfigInfo->AdapterInterfaceType;
2298
2299#ifndef UNIATA_CORE
2300
2301
2304
2305
2307 if (ArgumentString) {
2308
2311
2312
2314 if (!portBase) {
2315
2316
2318 }
2319 }
2320 }
2321
2322#endif
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2337
2338 if(portBase) {
2341 ConfigInfo->AdapterInterfaceType,
2342 ConfigInfo->SystemIoBusNumber,
2343 (*ConfigInfo->AccessRanges)[0].RangeStart,
2344 (*ConfigInfo->AccessRanges)[0].RangeLength,
2345 (
BOOLEAN) !((*ConfigInfo->AccessRanges)[0].RangeInMemory));
2346 } else {
2347
2348
2349 }
2351
2353 KdPrint2((
PRINT_PREFIX " preconfig, portBase=%x, len=%x\n", portBase, (*ConfigInfo->AccessRanges)[0].RangeLength));
2354 }
2355
2356
2357#ifndef UNIATA_CORE
2358 while (AdapterAddresses[*adapterCount] != 0) {
2359#else
2360 do {
2361#endif
2362
2363 retryCount = 4;
2364 deviceExtension->
DevIndex = (*adapterCount);
2366
2368
2369
2371 }
2372
2373
2374
2375
2376 if (preConfig ==
FALSE) {
2377
2378 ULONG portBase_reg = 0;
2380
2381 if (!portBase) {
2382 portBase = AdapterAddresses[*adapterCount];
2384 } else {
2386 }
2387
2390 if(portBase_reg && irq_reg) {
2392 portBase = portBase_reg;
2394 }
2395
2397 goto next_adapter;
2398 }
2400 ConfigInfo->AdapterInterfaceType,
2401 ConfigInfo->SystemIoBusNumber,
2405
2406 } else {
2408
2409
2410
2412 goto not_found;
2413 }
2414 }
2416next_adapter:
2417
2418 (*adapterCount)++;
2419
2420
2421 if (!ioSpace) {
2423 portBase = 0;
2424 continue;
2425 }
2426
2427
2428 if (BaseIoAddress1) {
2429 if(preConfig &&
2433 ConfigInfo->AdapterInterfaceType,
2434 ConfigInfo->SystemIoBusNumber,
2438 } else {
2440 ConfigInfo->AdapterInterfaceType,
2441 ConfigInfo->SystemIoBusNumber,
2445 }
2446 }
2452 }
2453
2456
2457#ifdef _DEBUG
2459#endif
2460
2461
2463
2467 KdPrint2((
PRINT_PREFIX "AtapiFindIsaController: Status %x vs AltStatus %x missmatch, abort init ?\n", statusByte, statusByte2));
2468
2469 if(BaseIoAddress2) {
2471 (
PCHAR)BaseIoAddress2);
2472 BaseIoAddress2 =
NULL;
2473 }
2477 ConfigInfo->AdapterInterfaceType,
2478 ConfigInfo->SystemIoBusNumber,
2482 if(!ioSpace) {
2483 BaseIoAddress2 =
NULL;
2485 goto not_found;
2486 }
2491 KdPrint2((
PRINT_PREFIX " abort: Status %x vs AltStatus %x missmatch\n", statusByte, statusByte2));
2492 goto not_found;
2493 }
2494 }
2495
2496retryIdentifier:
2497
2498
2500
2501
2504
2505
2508
2510 statusByte));
2511
2513
2515
2517
2518
2519
2520 do {
2524 "AtapiFindIsaController: First access to status %#x\n",
2525 statusByte));
2527
2529 goto retryIdentifier;
2530 }
2531 }
2532
2533
2536
2537
2539
2542
2544 "AtapiFindIsaController: Identifier read back from Slave (%#x)\n",
2545 statusByte));
2546 goto not_found;
2547 }
2548 }
2549
2550
2551 if (preConfig ==
FALSE) {
2552
2553
2555
2556 if (portBase) {
2558 } else {
2559 (*ConfigInfo->AccessRanges)[0].RangeStart =
2561 }
2562
2563 (*ConfigInfo->AccessRanges)[0].RangeLength =
ATA_IOSIZE;
2564 (*ConfigInfo->AccessRanges)[0].RangeInMemory =
FALSE;
2565
2566 if(BaseIoAddress2) {
2570 (*ConfigInfo->AccessRanges)[1].RangeInMemory =
FALSE;
2571 } else {
2572
2573
2574
2577 }
2580 (*ConfigInfo->AccessRanges)[1].RangeLength = 0;
2581 }
2582 }
2583
2584
2586 ConfigInfo->BusInterruptLevel =
irq;
2587 } else {
2588 ConfigInfo->BusInterruptLevel = InterruptLevels[*adapterCount - 1];
2589 }
2590
2591 if (ConfigInfo->AdapterInterfaceType ==
MicroChannel) {
2593 } else {
2594 ConfigInfo->InterruptMode =
Latched;
2595 }
2596 }
2597
2598 ConfigInfo->NumberOfBuses = 1;
2600
2601
2602 ConfigInfo->MaximumTransferLength = 0x10000;
2604
2606
2607
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2621
2623 "AtapiFindIsaController: Found IDE at %#x\n",
2624 BaseIoAddress1));
2625
2626
2627
2628 if (preConfig ==
FALSE) {
2629
2630 if (*adapterCount - 1 < 2) {
2631
2632
2633
2635#ifndef UNIATA_CORE
2637#endif
2638 } else {
2640 }
2641
2642 } else {
2643
2644 }
2645
2646 } else {
2647
2648
2650
2651 }
2652
2653
2657
2659 "AtapiFindIsaController: look for devices\n"));
2660
2662 0,
2663 0 )) {
2664
2666 "AtapiFindIsaController: detected\n"));
2667
2668 if (portBase) {
2669 switch (portBase) {
2671 ConfigInfo->AtdiskSecondaryClaimed =
TRUE;
2673 break;
2675 ConfigInfo->AtdiskPrimaryClaimed =
TRUE;
2677 break;
2678 default:
2679 break;
2680 }
2681 } else {
2682 if (*adapterCount == 1) {
2683 ConfigInfo->AtdiskPrimaryClaimed =
TRUE;
2685 } else if (*adapterCount == 2) {
2686 ConfigInfo->AtdiskSecondaryClaimed =
TRUE;
2688 }
2689 }
2690
2693 } else
2696 }
2697
2698 ConfigInfo->NumberOfBuses++;
2700 "AtapiFindIsaController: return SP_RETURN_FOUND\n"));
2702 } else {
2703not_found:
2704
2705 if(BaseIoAddress1) {
2707 (
PCHAR)BaseIoAddress1);
2708 BaseIoAddress1 =
NULL;
2709 }
2710 if(BaseIoAddress2) {
2712 (
PCHAR)BaseIoAddress2);
2713 BaseIoAddress2 =
NULL;
2714 }
2715 for(
i=0;
i<2;
i++) {
2717 "AtapiFindIsaController: cleanup AccessRanges %d\n",
i));
2719 (*ConfigInfo->AccessRanges)[
i].RangeLength = 0;
2720 (*ConfigInfo->AccessRanges)[
i].RangeInMemory =
FALSE;
2721 }
2723 portBase = 0;
2724 }
2725#ifndef UNIATA_CORE
2726 }
2727#else
2729#endif
2730
2731
2732
2733
2735 *(adapterCount) = 0;
2736
2738 "AtapiFindIsaController: return SP_RETURN_NOT_FOUND\n"));
2741
2742exit_error:
2745
2746}
struct _IDE_REGISTERS_2 * PIDE_REGISTERS_2
#define DFLAGS_TAPE_DEVICE
#define DFLAGS_DEVICE_PRESENT
struct _IDE_REGISTERS_1 * PIDE_REGISTERS_1
ULONG NTAPI AtapiParseArgumentString(IN PCHAR String, IN PCHAR KeyWord)
#define IDE_MAX_LUN_PER_CHAN
SCSI_PHYSICAL_ADDRESS NTAPI ScsiPortConvertUlongToPhysicalAddress(IN ULONG_PTR UlongAddress)
VOID NTAPI ScsiPortFreeDeviceBase(IN PVOID HwDeviceExtension, IN PVOID MappedAddress)
PVOID NTAPI ScsiPortGetDeviceBase(IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, IN ULONG SystemIoBusNumber, IN SCSI_PHYSICAL_ADDRESS IoAddress, IN ULONG NumberOfBytes, IN BOOLEAN InIoSpace)
BOOLEAN NTAPI UniataAllocateLunExt(PHW_DEVICE_EXTENSION deviceExtension, ULONG NewNumberChannels)
VOID NTAPI AtapiSetupLunPtrs(IN PHW_CHANNEL chan, IN PHW_DEVICE_EXTENSION deviceExtension, IN ULONG c)
#define UNIATA_ALLOCATE_NEW_LUNS
BOOLEAN NTAPI AtapiReadChipConfig(IN PVOID HwDeviceExtension, IN ULONG DeviceNumber, IN ULONG channel)
VOID NTAPI UniataFreeLunExt(PHW_DEVICE_EXTENSION deviceExtension)
BOOLEAN NTAPI AtapiChipInit(IN PVOID HwDeviceExtension, IN ULONG DeviceNumber, IN ULONG c)
#define ScsiPortConvertPhysicalAddressToUlong(Address)
#define SP_RETURN_NOT_FOUND
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define IDX_IO1_i_CylinderLow
#define IDX_ATAPI_IO1_i_Status
#define IDX_IO1_o_CylinderLow
BOOLEAN NTAPI AtapiCheckIOInterference(IN PPORT_CONFIGURATION_INFORMATION ConfigInfo, ULONG portBase)
INTERFACE_TYPE AdapterInterfaceType
ULONG MaximumDmaTransferLength
INTERFACE_TYPE OrigAdapterInterfaceType
#define RtlZeroMemory(Destination, Length)
ULONG NTAPI AtapiRegCheckDevValue(IN PVOID HwDeviceExtension, IN ULONG chan, IN ULONG dev, IN PCWSTR Name, IN ULONG Default)
VOID NTAPI UniataDumpATARegs(IN struct _HW_CHANNEL *chan)
#define IDX_IO2_AltStatus
VOID NTAPI UniataInitMapBase(IN struct _HW_CHANNEL *chan, IN PIDE_REGISTERS_1 BaseIoAddress1, IN PIDE_REGISTERS_2 BaseIoAddress2)
UCHAR DDKFASTAPI SelectDrive(IN struct _HW_CHANNEL *chan, IN ULONG DeviceNumber)
VOID NTAPI UniataInitMapBM(IN struct _HW_DEVICE_EXTENSION *deviceExtension, IN struct _IDE_BUSMASTER_REGISTERS *BaseIoAddressBM_0, IN BOOLEAN MemIo)
#define CHAN_NOT_SPECIFIED