- Timestamp:
- Dec 13, 2016, 10:30:24 PM (9 years ago)
- Location:
- trunk/src/os2ahci
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/ahci.c
r181 r182 207 207 #endif 208 208 209 int AllocPortData(AD_INFO *ai, int p) 210 { 211 if (ai->ports[p]) return 0; 212 ai->ports[p] = MemAlloc(sizeof(P_INFO)); 213 if (ai->ports[p] == NULL) return 1; 214 memset(ai->ports[p], 0, sizeof(P_INFO)); 215 return 0; 216 } 217 218 FreePortData(AD_INFO *ai, int p) 219 { 220 } 221 222 /****************************************************************************** 223 * Save BIOS configuration of AHCI adapter. As a side effect, this also saves 224 * generic configuration information which we may have to restore after an 225 * adapter reset. 226 * 227 * NOTE: This function also saves working copies of the CAP and CAP2 registers 228 * as well as the initial port map in the AD_INFO structure after 229 * removing features which are known to cause trouble on this specific 230 * piece of hardware. 231 */ 232 int ahci_save_bios_config(AD_INFO *ai) 209 /****************************************************************************** 210 * setup the CAPS and other adapter information for this adapter. 211 * 212 * This function saves working copies of the CAP and CAP2 registers 213 * as well as the initial port map in the AD_INFO structure after 214 * removing features which are known to cause trouble on this specific 215 * piece of hardware. 216 */ 217 int ahci_config_caps(AD_INFO *ai) 233 218 { 234 219 int ports; 235 220 int i; 236 221 237 /* save BIOS configuration */ 238 for (i = 0; i < HOST_CAP2; i += sizeof(u32)) 239 { 240 ai->bios_config[i / sizeof(u32)] = readl(ai->mmio + i); 241 } 242 243 DPRINTF(3,"ahci_save_bios_config: BIOS AHCI mode is %d\n", ai->bios_config[HOST_CTL / sizeof(u32)] & HOST_AHCI_EN); 222 ai->cap = readl(ai->mmio + HOST_CAP); 223 ai->port_map = readl(ai->mmio + HOST_PORTS_IMPL); 244 224 245 225 /* HOST_CAP2 only exists for AHCI V1.2 and later */ 246 if (ai->bios_config[HOST_VERSION / sizeof(u32)] >= 0x00010200L) 247 { 248 ai->bios_config[HOST_CAP2 / sizeof(u32)] = readl(ai->mmio + HOST_CAP2); 249 } 250 else 251 { 252 ai->bios_config[HOST_CAP2 / sizeof(u32)] = 0; 253 } 254 255 if ((ai->bios_config[HOST_CTL / sizeof(u32)] & HOST_AHCI_EN) == 0 && 256 ai->pci_vendor == PCI_VENDOR_ID_INTEL) 257 { 258 /* Adapter is not in AHCI mode and the spec says a COMRESET is 259 * required when switching from SATA to AHCI mode and vice versa. 260 */ 261 init_reset = 1; 262 } 263 264 DUMP_HOST_REGS(2,ai,1); 265 266 /* Save working copies of CAP, CAP2 and port_map and remove broken feature 267 * bits. This is largely copied from the Linux AHCI driver -- the wisdom 268 * around quirks and faulty hardware is hard to come by... 269 */ 270 ai->cap = ai->bios_config[HOST_CAP / sizeof(u32)]; 271 ai->cap2 = ai->bios_config[HOST_CAP2 / sizeof(u32)]; 272 ai->port_map = ai->bios_config[HOST_PORTS_IMPL / sizeof(u32)]; 226 if (readl(ai->mmio + HOST_VERSION) >= 0x00010200L) ai->cap2 = readl(ai->mmio + HOST_CAP2); 273 227 274 228 if (ai->pci->board >= sizeof(initial_flags) / sizeof(*initial_flags)) … … 289 243 } 290 244 245 /* Remove broken feature bits. This is largely copied from the Linux AHCI driver -- the wisdom 246 * around quirks and faulty hardware is hard to come by... 247 */ 291 248 if ((ai->cap & HOST_CAP_NCQ) && (ai->flags & AHCI_HFLAG_NO_NCQ)) 292 249 { … … 332 289 for (i = 0; i < AHCI_MAX_PORTS; i++) 333 290 { 334 if (ai->port_map & (1UL << i)) 335 { 336 ports--; 337 } 291 if (ai->port_map & (1UL << i)) ports--; 338 292 } 339 293 if (ports < 0) … … 347 301 /* set maximum command slot number */ 348 302 ai->cmd_max = ((ai->cap >> 8) & 0x1f); 303 304 return(0); 305 } 306 307 /****************************************************************************** 308 * Save BIOS configuration of AHCI adapter. As a side effect, this also saves 309 * generic configuration information which we may have to restore after an 310 * adapter reset. 311 */ 312 int ahci_save_bios_config(AD_INFO *ai) 313 { 314 int i; 315 316 /* save BIOS configuration */ 317 for (i = 0; i < HOST_CAP2; i += sizeof(u32)) 318 { 319 ai->bios_config[i / sizeof(u32)] = readl(ai->mmio + i); 320 } 321 322 DPRINTF(3,"ahci_save_bios_config: BIOS AHCI mode is %d\n", ai->bios_config[HOST_CTL / sizeof(u32)] & HOST_AHCI_EN); 323 324 if ((ai->bios_config[HOST_CTL / sizeof(u32)] & HOST_AHCI_EN) == 0 && ai->pci_vendor == PCI_VENDOR_ID_INTEL) 325 { 326 /* Adapter is not in AHCI mode and the spec says a COMRESET is 327 * required when switching from SATA to AHCI mode and vice versa. 328 */ 329 init_reset = 1; 330 } 331 332 DUMP_HOST_REGS(2,ai,1); 349 333 350 334 return(0); … … 649 633 /* this port seems to have a device attached and ready for commands */ 650 634 DPRINTF(1,"ahci_scan_ports: port %d seems to be attached to a device; probing...\n", p); 635 636 #ifdef DAZ_NEW_CODE 637 ai->dma_buf[p] = MemAllocAlign(AHCI_PORT_PRIV_DMA_SZ, 1024); 638 ai->dma_buf_phys[p] = MemPhysAdr(ai->dma_buf[p]); 639 #endif 651 640 652 641 /* Get ATA(PI) identity. The so-called signature gives us a hint whether … … 681 670 /* no device attached to this port */ 682 671 ai->port_map &= ~(1UL << p); 683 // DAZ free port structure here 672 #ifdef DAZ_NEW_CODE 673 if (ai->dma_buf[p]) MemFree(ai->dma_buf[p]); 674 ai->dma_buf[p] = NULL; 675 #endif 684 676 } 685 677 -
trunk/src/os2ahci/ata.c
r181 r182 263 263 do 264 264 { 265 u32 chunk = (sg_size > AHCI_MAX_SG_ELEMENT_LEN) ? AHCI_MAX_SG_ELEMENT_LEN 266 : sg_size; 265 u32 chunk = (sg_size > AHCI_MAX_SG_ELEMENT_LEN) ? AHCI_MAX_SG_ELEMENT_LEN : sg_size; 267 266 if (n >= AHCI_MAX_SG) 268 267 { -
trunk/src/os2ahci/os2ahci.h
r181 r182 42 42 #define DEBUG 43 43 //#define LEGACY_APM 44 //#define DAZ_NEW_CODE 44 45 45 46 #include "Dev32lib.h" … … 401 402 402 403 /* ahci.c */ 404 extern int ahci_config_caps(AD_INFO *ai); 403 405 extern int ahci_save_bios_config(AD_INFO *ai); 404 406 extern int ahci_restore_bios_config(AD_INFO *ai); -
trunk/src/os2ahci/pci.c
r178 r182 602 602 if (!ad_info->mmio) goto add_pci_fail; 603 603 604 /* fill in DMA scratch buffer addresses in adapter info */605 for (i = 0; i < AHCI_MAX_PORTS; i++)606 {607 ad_info->dma_buf[i] = MemAlloc(AHCI_PORT_PRIV_DMA_SZ);608 ad_info->dma_buf_phys[i] = MemPhysAdr(ad_info->dma_buf[i]);609 }610 611 604 /* register adapter with resource manager */ 612 605 memset(&adj, 0x00, sizeof(adj)); … … 634 627 } 635 628 629 if (ahci_config_caps(ad_info)) goto add_pci_fail; 630 631 #ifndef DAZ_NEW_CODE 632 /* fill in DMA scratch buffer addresses in adapter info */ 633 for (i = 0; i < ad_info->hw_ports; i++) 634 { 635 ad_info->dma_buf[i] = MemAlloc(AHCI_PORT_PRIV_DMA_SZ); 636 ad_info->dma_buf_phys[i] = MemPhysAdr(ad_info->dma_buf[i]); 637 } 638 #endif 639 636 640 /* Successfully added the adapter and reserved its resources; the adapter 637 641 * is still under BIOS control so we're not going to do anything else at 638 642 * this point. 639 643 */ 644 640 645 ad_info_cnt++; 641 646 return;
Note:
See TracChangeset
for help on using the changeset viewer.