2235{
2244
2245 UCHAR statusByte, statusByte2;
2247
2250
2251
2252
2254
2255
2256
2257
2258 static CONST ULONG InterruptLevels[5] = {14, 15, 11, 10, 0};
2259
2261
2262 if (!deviceExtension) {
2264 }
2266
2271
2273 goto exit_error;
2274 }
2275
2276 chan = &(deviceExtension->
chan[0]);
2278
2281 = ConfigInfo->AdapterInterfaceType;
2282
2283#ifndef UNIATA_CORE
2284
2285
2288
2289
2291 if (ArgumentString) {
2292
2295
2296
2298 if (!portBase) {
2299
2300
2302 }
2303 }
2304 }
2305
2306#endif
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2321
2322 if(portBase) {
2325 ConfigInfo->AdapterInterfaceType,
2326 ConfigInfo->SystemIoBusNumber,
2327 (*ConfigInfo->AccessRanges)[0].RangeStart,
2328 (*ConfigInfo->AccessRanges)[0].RangeLength,
2329 (
BOOLEAN) !((*ConfigInfo->AccessRanges)[0].RangeInMemory));
2330 } else {
2331
2332
2333 }
2335
2337 KdPrint2((
PRINT_PREFIX " preconfig, portBase=%x, len=%x\n", portBase, (*ConfigInfo->AccessRanges)[0].RangeLength));
2338 }
2339
2340
2341#ifndef UNIATA_CORE
2342 while (AdapterAddresses[*adapterCount] != 0) {
2343#else
2344 do {
2345#endif
2346
2347 retryCount = 4;
2348 deviceExtension->
DevIndex = (*adapterCount);
2350
2352
2353
2355 }
2356
2357
2358
2359
2360 if (preConfig ==
FALSE) {
2361
2362 ULONG portBase_reg = 0;
2364
2365 if (!portBase) {
2366 portBase = AdapterAddresses[*adapterCount];
2368 } else {
2370 }
2371
2374 if(portBase_reg && irq_reg) {
2376 portBase = portBase_reg;
2378 }
2379
2381 goto next_adapter;
2382 }
2384 ConfigInfo->AdapterInterfaceType,
2385 ConfigInfo->SystemIoBusNumber,
2389
2390 } else {
2392
2393
2394
2396 goto not_found;
2397 }
2398 }
2400next_adapter:
2401
2402 (*adapterCount)++;
2403
2404
2405 if (!ioSpace) {
2407 portBase = 0;
2408 continue;
2409 }
2410
2411
2412 if (BaseIoAddress1) {
2413 if(preConfig &&
2417 ConfigInfo->AdapterInterfaceType,
2418 ConfigInfo->SystemIoBusNumber,
2422 } else {
2424 ConfigInfo->AdapterInterfaceType,
2425 ConfigInfo->SystemIoBusNumber,
2429 }
2430 }
2436 }
2437
2440
2441#ifdef _DEBUG
2443#endif
2444
2445
2447
2451 KdPrint2((
PRINT_PREFIX "AtapiFindIsaController: Status %x vs AltStatus %x missmatch, abort init ?\n", statusByte, statusByte2));
2452
2453 if(BaseIoAddress2) {
2455 (
PCHAR)BaseIoAddress2);
2456 BaseIoAddress2 =
NULL;
2457 }
2461 ConfigInfo->AdapterInterfaceType,
2462 ConfigInfo->SystemIoBusNumber,
2466 if(!ioSpace) {
2467 BaseIoAddress2 =
NULL;
2469 goto not_found;
2470 }
2475 KdPrint2((
PRINT_PREFIX " abort: Status %x vs AltStatus %x missmatch\n", statusByte, statusByte2));
2476 goto not_found;
2477 }
2478 }
2479
2480retryIdentifier:
2481
2482
2484
2485
2488
2489
2492
2494 statusByte));
2495
2497
2499
2501
2502
2503
2504 do {
2508 "AtapiFindIsaController: First access to status %#x\n",
2509 statusByte));
2511
2513 goto retryIdentifier;
2514 }
2515 }
2516
2517
2520
2521
2523
2526
2528 "AtapiFindIsaController: Identifier read back from Slave (%#x)\n",
2529 statusByte));
2530 goto not_found;
2531 }
2532 }
2533
2534
2535 if (preConfig ==
FALSE) {
2536
2537
2539
2540 if (portBase) {
2542 } else {
2543 (*ConfigInfo->AccessRanges)[0].RangeStart =
2545 }
2546
2547 (*ConfigInfo->AccessRanges)[0].RangeLength =
ATA_IOSIZE;
2548 (*ConfigInfo->AccessRanges)[0].RangeInMemory =
FALSE;
2549
2550 if(BaseIoAddress2) {
2554 (*ConfigInfo->AccessRanges)[1].RangeInMemory =
FALSE;
2555 } else {
2556
2557
2558
2561 }
2564 (*ConfigInfo->AccessRanges)[1].RangeLength = 0;
2565 }
2566 }
2567
2568
2570 ConfigInfo->BusInterruptLevel =
irq;
2571 } else {
2572 ConfigInfo->BusInterruptLevel = InterruptLevels[*adapterCount - 1];
2573 }
2574
2575 if (ConfigInfo->AdapterInterfaceType ==
MicroChannel) {
2577 } else {
2578 ConfigInfo->InterruptMode =
Latched;
2579 }
2580 }
2581
2582 ConfigInfo->NumberOfBuses = 1;
2584
2585
2586 ConfigInfo->MaximumTransferLength = 0x10000;
2588
2590
2591
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2605
2607 "AtapiFindIsaController: Found IDE at %#x\n",
2608 BaseIoAddress1));
2609
2610
2611
2612 if (preConfig ==
FALSE) {
2613
2614 if (*adapterCount - 1 < 2) {
2615
2616
2617
2619#ifndef UNIATA_CORE
2621#endif
2622 } else {
2624 }
2625
2626 } else {
2627
2628 }
2629
2630 } else {
2631
2632
2634
2635 }
2636
2637
2641
2643 "AtapiFindIsaController: look for devices\n"));
2644
2646 0,
2647 0 )) {
2648
2650 "AtapiFindIsaController: detected\n"));
2651
2652 if (portBase) {
2653 switch (portBase) {
2655 ConfigInfo->AtdiskSecondaryClaimed =
TRUE;
2657 break;
2659 ConfigInfo->AtdiskPrimaryClaimed =
TRUE;
2661 break;
2662 default:
2663 break;
2664 }
2665 } else {
2666 if (*adapterCount == 1) {
2667 ConfigInfo->AtdiskPrimaryClaimed =
TRUE;
2669 } else if (*adapterCount == 2) {
2670 ConfigInfo->AtdiskSecondaryClaimed =
TRUE;
2672 }
2673 }
2674
2677 } else
2680 }
2681
2682 ConfigInfo->NumberOfBuses++;
2684 "AtapiFindIsaController: return SP_RETURN_FOUND\n"));
2686 } else {
2687not_found:
2688
2689 if(BaseIoAddress1) {
2691 (
PCHAR)BaseIoAddress1);
2692 BaseIoAddress1 =
NULL;
2693 }
2694 if(BaseIoAddress2) {
2696 (
PCHAR)BaseIoAddress2);
2697 BaseIoAddress2 =
NULL;
2698 }
2699 for(
i=0;
i<2;
i++) {
2701 "AtapiFindIsaController: cleanup AccessRanges %d\n",
i));
2703 (*ConfigInfo->AccessRanges)[
i].RangeLength = 0;
2704 (*ConfigInfo->AccessRanges)[
i].RangeInMemory =
FALSE;
2705 }
2707 portBase = 0;
2708 }
2709#ifndef UNIATA_CORE
2710 }
2711#else
2713#endif
2714
2715
2716
2717
2719 *(adapterCount) = 0;
2720
2722 "AtapiFindIsaController: return SP_RETURN_NOT_FOUND\n"));
2725
2726exit_error:
2729
2730}
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