Home |
RTTarget-32 Programming Manual Function RTPCSetConfigRegister Function RTPCMapATA System Management BIOS (SMBIOS) Advanced Programmable Interrupt Controller (APIC) |
Function RTPCMapATAThis function is deprecated. Please use RTPCMapATAContiguous instead. This function maps and enables all required resources to use an ATA disk card in standard I/O mode: void RTPCMapATA(int Socket, int DriveNumber, int IRQ); This function is deprecated since it may not work on all PCMCIA controllers. Use RTPCMapATAContiguous instead. This function should be called after an application has verified that an ATA disk card has been inserted. ParametersSocketSpecifies the socket of the card to map. DriveNumberSpecifies the RTFiles-32 drive number for the drive. Values 0 .. 7 are supported. (DriveNumber / 2) specifies the IDE channel/controller and (DriveNumber % 2) specifies whether the drive should be a master (0) or slave (1). For example, DriveNumber 3 would configure an ATA card to be a slave drive of the second IDE channel. IRQThe interrupt on which the disk should signal events. The default values are 14, 15, 11, and 10 for up to four IDE controllers. If the default IRQ is not available (either in use by some other peripheral or not supported by the PCMCIA controller), a custom value must be selected. The application must ensure that the requested resources are free. For example, a PCMCIA disk can only be configured to be on the primary IDE channel if no IDE host adapter is in the system (e.g., on the motherboard). In addition, it must be observed that not all PCMCIA ATA disks support being configured as a slave drive. Thus, it is recommended to use DriveNumbers 0 and 2 for embedded targets without IDE controller or DriveNumbers 2 and 4 for targets with a single IDE controller. Important: If a custom IRQ value is used, you must also inform RTFiles-32's IDE driver of the IRQ used! The IDE driver must not operate in RTF_CONTIGUOUS_IO mode! The following example shows how to configure a PCMCIA ATA disk as the master on the third IDE channel with a custom IRQ value. The PCMCIA ATA disk has drive number 2 and can coexist with up to two IDE disks on the primary IDE channel installed on the target's motherboard. #include <rttarget.h> #include <rtpcmcia.h> #include <rtfiles.h> #define PCMCIA_ATA_IDX 2 // entry #2 in device list #define PCMCIA_ATA_IRQ 10 static RTFDrvIDEData IDEDrive0Data = {0}; // master disk on moboard static RTFDrvIDEData IDEDrive1Data = {0}; // slave disk on moboard static RTFDrvIDEData IDEDrive2Data = {0, 0, 0, 0, 0, 0, PCMCIA_ATA_IRQ}; RTFDevice RTFDeviceList[] = { { RTF_DEVICE_FDISK, 0, 0, &RTFDrvIDE, &IDEDrive0Data }, { RTF_DEVICE_FDISK, 1, 0, &RTFDrvIDE, &IDEDrive1Data }, { RTF_DEVICE_FDISK, 4, RTF_DEVICE_REMOVABLE | RTF_DEVICE_NO_MEDIA | RTF_DEVICE_NEW_LOCK, &RTFDrvIDE, &IDEDrive2Data }, { 0 } }; void ConfigureDisk(int Socket) { if (RTPCIsATA(Socket)) { RTPCMapATA(Socket, RTFDeviceList[PCMCIA_ATA_IDX].DeviceNumber, PCMCIA_ATA_IRQ); // tell RTFiles-32 that this disk is now available RTFRawSetMedia(PCMCIA_ATA_IDX, 1); } } Function RTPCMapATA's source code is: void RTPCMapATA(int Socket, int DriveNumber, int IRQ) { static WORD DefaultPortBases[] = { 0x1F0, 0x170, 0x0F0, 0x070 }; static BYTE DefaultIRQs[] = { 14, 15, 11, 10 }; int Controller = DriveNumber / 2; int MasterSlave = DriveNumber % 2; // Set Socket_Copy Register (3) // Set to Socket_Copy register to Copy << 4 | Socket RTPCSetConfigRegister(Socket, RTPC_CFGREG_SOCKET_COPY, (MasterSlave << 4) | Socket); // Set Option Config Register (0) RTPCSetConfigRegister(Socket, RTPC_CFGREG_OPTION, 0x40 | 2); // config 2 RTPCUnmapCIS(Socket); RTPCMapIOWindow(Socket, 0, DefaultPortBases[Controller], DefaultPortBases[0], 8, RTPC_IO_WINDOW_AUTO); RTPCMapIOWindow(Socket, 1, DefaultPortBases[Controller] + 0x206, DefaultPortBases[0] + 0x206, 2, RTPC_IO_WINDOW_8BIT); if ((IRQ == -1) || (IRQ == 0)) RTPCEnableIRQ(Socket, DefaultIRQs[Controller]); else RTPCEnableIRQ(Socket, IRQ); }
|