Changeset 154
- Timestamp:
- Apr 10, 2013, 6:47:05 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/Makefile
r153 r154 30 30 # Define default build version if not specified in environment 31 31 BLD_MAJOR=1 32 BLD_MINOR=2 6# must be 2 digits32 BLD_MINOR=27 # must be 2 digits 33 33 BLD_REV=0 # not used at this time 34 34 … … 149 149 @AddToFile $^@,$#define BLD_MONTH,DATEMONTH 150 150 @AddToFile $^@,$#define BLD_DAY,DATEDAY 151 @AddToFile $^@,$#define BLDLEVEL,BLDLEVEL2,$(VENDOR),$(BLD_MAJOR).$(BLD_MINOR),AHCI Driver (c) Mensys BV 2013 151 @AddToFile $^@,$#define BLDLEVEL,BLDLEVEL2,$(VENDOR),$(BLD_MAJOR).$(BLD_MINOR),AHCI Driver (c) Mensys BV 2013,$(FIXPACK) 152 152 153 153 .asm.obj: .autodepend … … 188 188 189 189 os2ahci.sym: os2ahci.map 190 191 192 190 wat2map.cmd $[@ $^*.ma1 191 $(MAPSYM) $^*.ma1 192 @%erase $^*.ma1 193 193 -
trunk/src/os2ahci/README
r153 r154 106 106 Option Description 107 107 ------------------------------------------------------------------------------ 108 /c:<addr> Set debug COM port base address in hex (default = 3f8);108 /c:<addr> Set debug COM port base address in hex (default = 0); 109 109 if used, this option should come before any /d options. 110 110 If <addr> is set to 0, the COM port is turned off and … … 113 113 command "type os2ahci$"; see the OS2AHCI project page 114 114 at http://svn.ecomstation.nl/ahci/wiki/AhciTrace 115 for more info. 115 for more info. COM0=3f8, COM1=2f8 116 116 /d Debug output on COM port/trace buffer; multiple "/d" 117 117 options will increase verbosity: -
trunk/src/os2ahci/ahci.c
r148 r154 144 144 ddprintf("ahci_save_bios_config: BIOS AHCI mode is %d\n", ai->bios_config[HOST_CTL / sizeof(u32)] & HOST_AHCI_EN); 145 145 146 #if 0 146 147 if ((ai->bios_config[HOST_CTL / sizeof(u32)] & HOST_AHCI_EN) == 0 && 147 148 ai->pci->vendor == PCI_VENDOR_ID_INTEL) { … … 151 152 init_reset = 1; 152 153 } 154 #endif 153 155 154 156 /* HOST_CAP2 only exists for AHCI V1.2 and later */ … … 676 678 if (ai->port_map & (1UL << p)) { 677 679 if (init_reset) { 678 d printf("ahci_complete_init: resetting port %d\n", p);680 ddprintf("ahci_complete_init: resetting port %d\n", p); 679 681 ahci_reset_port(ai, p, 1); 680 682 } else { 681 d printf("ahci_complete_init: restarting port #%d\n", p);683 ddprintf("ahci_complete_init: restarting port #%d\n", p); 682 684 ahci_stop_port(ai, p); 683 685 ahci_start_port(ai, p, 1); … … 718 720 int timeout; 719 721 720 d printf("ahci_reset_port: resetting port %d.%d\n", ad_no(ai), p);722 ddprintf("ahci_reset_port: resetting port %d.%d\n", ad_no(ai), p); 721 723 if (debug > 1) { 722 724 printf(" PORT_CMD = 0x%lx\n", readl(port_mmio + PORT_CMD)); … … 749 751 /* set link speed and power management options */ 750 752 ddprintf("ahci_reset_port: setting link speed and power management options\n"); 751 tmp = readl(port_mmio + PORT_SCR_CTL) & ~0x00000fffUL; //DAZ753 tmp = readl(port_mmio + PORT_SCR_CTL) & ~0x00000fffUL; 752 754 tmp |= ((u32) link_speed[ad_no(ai)][p] & 0x0f) << 4; 753 755 tmp |= ((u32) link_power[ad_no(ai)][p] & 0x0f) << 8; 754 //DAZwritel(port_mmio + PORT_SCR_CTL, tmp);756 writel(port_mmio + PORT_SCR_CTL, tmp); 755 757 756 758 /* issue COMRESET on the port */ 757 759 ddprintf("ahci_reset_port: issuing COMRESET on port %d\n", p); 758 //DAZ tmp = readl(port_mmio + PORT_SCR_CTL) & ~0x0000000fUL;759 760 writel(port_mmio + PORT_SCR_CTL, tmp | 1); 760 761 readl(port_mmio + PORT_SCR_CTL); /* flush */ … … 810 811 u8 _far *port_mmio = port_base(ai, p); 811 812 u32 status; 812 //int timeout; 813 814 dprintf("ahci_start_port %d.%d\n", ad_no(ai), p); 813 814 ddprintf("ahci_start_port %d.%d\n", ad_no(ai), p); 815 815 /* check whether device presence is detected and link established */ 816 817 #if 0818 /* wait for communication to be re-established after port reset */819 timeout = 5000;820 while (((status = readl(port_mmio + PORT_SCR_STAT)) & 3) != 3) {821 mdelay(10);822 timeout -= 10;823 if (timeout <= 0) {824 dprintf("ahci_start_port #%d (PORT_SCR_STAT = 0x%lx)\n", p, status);825 return(-1);826 }827 }828 #endif829 816 830 817 status = readl(port_mmio + PORT_SCR_STAT); … … 920 907 int rc; 921 908 922 d printf("ahci_stop_port %d.%d\n", ad_no(ai), p);909 ddprintf("ahci_stop_port %d.%d\n", ad_no(ai), p); 923 910 924 911 /* disable port interrupts */ … … 1195 1182 1196 1183 /* restart/reset port (includes the necessary port configuration) */ 1197 if ((ai->bios_config[HOST_CTL / sizeof(u32)] & HOST_AHCI_EN) == 0 && 1198 ai->pci->vendor == PCI_VENDOR_ID_INTEL) { 1184 if (init_reset) { 1199 1185 /* As outlined in ahci_restore_bios_config(), switching back and 1200 1186 * forth between SATA and AHCI mode requires a COMRESET to force … … 1803 1789 } 1804 1790 1805 -
trunk/src/os2ahci/ata.c
r153 r154 442 442 443 443 /****************************************************************************** 444 * Try to read LVM information from the disk. If found, use the LVM geometry. 445 * This function will only work at init time. A better strategy would be to 446 * calculate the geometry during ahci_scan_ports and save it away and then just 447 * return the saved values when ata_get_geometry() is called. 448 */ 449 int is_lvm_geometry(IORBH _far *iorb) 450 { 451 ADD_WORKSPACE _far *aws = add_workspace(iorb); 452 AD_INFO *ai = ad_infos + iorb_unit_adapter(iorb); 453 GEOMETRY _far *geometry = ((IORB_GEOMETRY _far *) iorb)->pGeometry; 454 PDLA_Table_Sector pDLA; 455 int p = iorb_unit_port(iorb); 456 int d = iorb_unit_device(iorb); 457 int rc; 458 ULONG sector; 459 460 if (init_complete) return 0; /* We cannot use ahci_exec_polled_cmd() after init_complete */ 461 462 if (use_lvm_info) { 463 ddprintf("is_lvm_geometry (%d.%d.%d)\n", ad_no(ai), p, d); 464 465 for (sector = 255; sector >= 63; sector >>= 1) { 466 rc = ahci_exec_polled_cmd(ai, p, 0, 500, ATA_CMD_READ, 467 AP_SECTOR_28, (u32) sector-1, 468 AP_COUNT, (u16) 1, 469 AP_VADDR, (void _far *) aws->buf, 512, 470 AP_DEVICE, 0x40, 471 AP_END); 472 if (rc) continue; 473 474 pDLA = (PDLA_Table_Sector)aws->buf; 475 ddphex(pDLA, sizeof(DLA_Table_Sector), "DLA sector %d:\n", sector-1); 476 477 if ((pDLA->DLA_Signature1 == DLA_TABLE_SIGNATURE1) && (pDLA->DLA_Signature2 == DLA_TABLE_SIGNATURE2)) { 478 ddprintf("is_lvm_geometry found at sector %d\n", sector); 479 geometry->TotalCylinders = pDLA->Cylinders; 480 geometry->NumHeads = pDLA->Heads_Per_Cylinder; 481 geometry->SectorsPerTrack = pDLA->Sectors_Per_Track; 482 return 1; 483 } 484 } 485 } 486 487 return 0; 488 } 489 490 /****************************************************************************** 444 491 * Post processing function for ata_get_geometry(): convert the ATA identify 445 492 * information to OS/2 IOCC_GEOMETRY information. … … 452 499 int a = iorb_unit_adapter(iorb); 453 500 int p = iorb_unit_port(iorb); 501 char *Method; 454 502 455 503 /* Fill-in geometry information; the ATA-8 spec declares the geometry … … 500 548 } 501 549 550 Method = "None"; 502 551 /* fabricate the remaining geometry fields */ 503 552 if (track_size[a][p] != 0) { … … 511 560 ((u32) geometry->NumHeads * 512 561 (u32) geometry->SectorsPerTrack); 513 562 Method = "Custom"; 514 563 } else if (CUR_HEADS(id_buf) > 0 && CUR_CYLS(id_buf) > 0 && 515 564 CUR_SECTORS(id_buf) > 0 && … … 521 570 geometry->SectorsPerTrack = CUR_SECTORS(id_buf); 522 571 geometry->TotalCylinders = CUR_CYLS(id_buf); 523 572 Method = "BIOS"; 524 573 } else if (ATA_HEADS(id_buf) > 0 && ATA_CYLS(id_buf) > 0 && 525 574 ATA_SECTORS(id_buf) > 0) { … … 528 577 geometry->SectorsPerTrack = ATA_SECTORS(id_buf); 529 578 geometry->TotalCylinders = ATA_CYLS(id_buf); 530 579 Method = "ATA"; 531 580 } else { 532 581 /* use typical SCSI geometry */ … … 536 585 ((u32) geometry->NumHeads * 537 586 (u32) geometry->SectorsPerTrack); 538 } 587 Method = "SCSI"; 588 } 589 590 if (is_lvm_geometry(iorb)) Method = "LVM"; 539 591 540 592 if (debug) { 541 printf("geometry information:\n"); 542 printf(" heads: %d\n", (u16) geometry->NumHeads); 543 printf(" sectors: %d\n", (u16) geometry->SectorsPerTrack); 544 printf(" cylinders: %d\n", (u16) geometry->TotalCylinders); 545 printf(" capacity: %ldMB\n", (u32) (geometry->TotalSectors / 2048)); 593 printf("Drive geometry: %d cylinders, %d heads, %d sectors per track (%ldMB) (%s)\n", 594 (u16) geometry->TotalCylinders, (u16) geometry->NumHeads, (u16) geometry->SectorsPerTrack, 595 (u32) (geometry->TotalSectors / 2048), Method); 546 596 } 547 597 -
trunk/src/os2ahci/libc.c
r153 r154 62 62 63 63 /* debug COM port base address */ 64 u16 com_base = 0 x03f8;64 u16 com_base = 0; 65 65 66 66 static char hex_digits[] = "0123456789abcdef"; … … 295 295 len += vsprintf(buf + len, fmt, va); 296 296 297 298 299 300 301 302 297 if (com_base == 0) { 298 /* write debug message to trace buffer, not COM port */ 299 trace_write(buf, len); 300 spin_unlock(com_lock); 301 return; 302 } 303 303 304 304 /* write debug message to serial port */ -
trunk/src/os2ahci/os2ahci.c
r153 r154 90 90 int verbosity = 1; /* == 1 -> show sign on banner 91 91 * > 1 -> show adapter info during boot */ 92 int use_lvm_info = 1; 92 93 93 94 PFN Device_Help = 0; /* pointer to device helper entry point */ … … 343 344 break; 344 345 346 case 'z': 347 use_lvm_info = !invert_option; 348 break; 349 345 350 case 'v': 346 351 /* be verbose during boot */ … … 377 382 if (TRACE_ACTIVE) { 378 383 /* debug is on, but COM port is off -> use our trace buffer */ 379 trace_init(); 380 } 381 dprintf("BldLevel: %s\n", BldLevel); 382 dprintf("CmdLine: %Fs\n", cmd_line); 384 trace_init(AHCI_TRACE_BUF_SIZE); 385 } else { 386 trace_init(AHCI_INFO_BUF_SIZE); 387 } 388 389 printf_nts("BldLevel: %s\n", BldLevel); 390 printf_nts("CmdLine: %Fs\n", cmd_line); 383 391 384 392 /* scan PCI bus for supported devices */ … … 390 398 mdelay_cal(); 391 399 392 if (DevHelp_RegisterDeviceClass(drv_name, (PFN) add_entry, 0, 1, 393 &add_handle)) { 400 if (DevHelp_RegisterDeviceClass(drv_name, (PFN) add_entry, 0, 1, &add_handle)) { 394 401 cprintf("%s: couldn't register device class\n", drv_name); 395 402 goto init_fail; … … 466 473 case OS2AHCI_IDC_BIOSMODE: 467 474 /* reconfigure adapters in BIOS/int13 mode; needed for generating 468 * trap dumps on some machines. This is called by ACPI.PSD. 475 * trap dumps on some machines. This was intended to be called by ACPI.PSD, 476 * but that is never done. This is obslete. The kernel exit accomplishes 477 * this instead. 469 478 * 470 479 * To enter BIOS mode, we flush all write caches, turn off interrupts … … 500 509 USHORT char_dev_input(RP_RWV _far *rwrb) 501 510 { 502 if (TRACE_ACTIVE) { 503 return(trace_char_dev(rwrb)); 504 } 505 return(STDON | STATUS_ERR_UNKCMD); 511 return(trace_char_dev(rwrb)); 506 512 } 507 513 … … 804 810 init_complete = 1; 805 811 806 /* DAZ turn off COM port output */812 /* DAZ turn off COM port output if on */ 807 813 com_base = 0; 808 814 … … 814 820 /* register APM hook */ 815 821 apm_init(); 822 823 if (!TRACE_ACTIVE) build_user_info(); 816 824 } 817 825 iorb_done(iorb); … … 1571 1579 dprintf("Registered kernel exit routine for INT13 mode\n"); 1572 1580 } 1581 -
trunk/src/os2ahci/os2ahci.h
r153 r154 119 119 120 120 /* TRACE macros (for our internal ring buffer trace) */ 121 #define AHCI_TRACE_BUF_SIZE 0x8000U /* 32k */ 122 #define AHCI_INFO_BUF_SIZE 0x1000U /* 4k */ 121 123 #define TRACE_ACTIVE (debug > 0 && com_base == 0) 122 124 … … 386 388 BUF_TO_SG /* copy from buffer to S/G list */ 387 389 } SG_MEMCPY_DIRECTION; 390 391 /* Define the size of a disk name. Disk Names are user defined names given to physical disk drives in the system. */ 392 #define DLA_TABLE_SIGNATURE1 0x424D5202L 393 #define DLA_TABLE_SIGNATURE2 0x44464D50L 394 #define DISK_NAME_SIZE 20 395 396 typedef struct _DLA_Table_Sector { /* DTS */ 397 ULONG DLA_Signature1; /* The magic signature (part 1) of a Drive Letter Assignment Table. */ 398 ULONG DLA_Signature2; /* The magic signature (part 2) of a Drive Letter Assignment Table. */ 399 ULONG DLA_CRC; /* The 32 bit CRC for this sector. Calculated assuming that this field and all unused space in the sector is 0. */ 400 ULONG Disk_Serial_Number; /* The serial number assigned to this disk. */ 401 ULONG Boot_Disk_Serial_Number;/* The serial number of the disk used to boot the system. This is for conflict resolution when multiple volumes 402 want the same drive letter. Since LVM.EXE will not let this situation happen, the only way to get this situation 403 is for the disk to have been altered by something other than LVM.EXE, or if a disk drive has been moved from one 404 machine to another. If the drive has been moved, then it should have a different Boot_Disk_Serial_Number. Thus, 405 we can tell which disk drive is the "foreign" drive and therefore reject its claim for the drive letter in question. 406 If we find that all of the claimaints have the same Boot_Disk_Serial_Number, then we must assign drive letters on 407 a first come, first serve basis. */ 408 ULONG Install_Flags; /* Used by the Install program. */ 409 ULONG Cylinders; 410 ULONG Heads_Per_Cylinder; 411 ULONG Sectors_Per_Track; 412 char Disk_Name[DISK_NAME_SIZE]; /* The name assigned to the disk containing this sector. */ 413 UCHAR Reboot; /* For use by Install. Used to keep track of reboots initiated by install. */ 414 BYTE Reserved[3]; /* Alignment. */ 415 /* These are the four entries which correspond to the entries in the partition table. */ 416 } DLA_Table_Sector, *PDLA_Table_Sector; 388 417 389 418 /* -------------------------- function prototypes -------------------------- */ … … 498 527 499 528 /* trace.c */ 500 extern void trace_init ( void);529 extern void trace_init (u16); 501 530 extern void trace_exit (void); 502 531 extern void trace_write (u8 _far *s, int len); 503 532 extern u16 trace_read (u8 _far *buf, u16 cb_buf); 504 //NOT_USED extern u16 trace_bytes_avail(void);505 533 extern u16 trace_char_dev(RP_RWV _far *rwrb); 534 extern void build_user_info(void); 506 535 507 536 /* pci.c */ … … 544 573 extern int force_write_cache; /* if != 0, force write cache */ 545 574 extern int verbosity; /* if != 0, show some info during boot */ 575 extern int use_lvm_info; 546 576 547 577 extern HDRIVER rm_drvh; /* resource manager driver handle */ -
trunk/src/os2ahci/trace.c
r153 r154 28 28 29 29 /* -------------------------- macros and constants ------------------------- */ 30 31 #define AHCI_TRACE_BUF_SIZE 0x8000U /* 32k */32 30 33 31 /* ------------------------ typedefs and structures ------------------------ */ … … 53 51 * a GDT selector for the trace ring buffer 54 52 */ 55 void trace_init( void)53 void trace_init(u16 usBufSize) 56 54 { 57 55 SEL sel = 0; 56 57 if (ahci_trace_buf.phys_addr) return; 58 58 59 59 /* initialize ring buffer logic */ 60 60 ahci_trace_buf.writep = 0; 61 61 ahci_trace_buf.readp = 0; 62 ahci_trace_buf.mask = AHCI_TRACE_BUF_SIZE- 1;62 ahci_trace_buf.mask = usBufSize - 1; 63 63 64 64 if (ahci_trace_buf.phys_addr == 0) { 65 65 /* allocate buffer */ 66 if (DevHelp_AllocPhys((ULONG) AHCI_TRACE_BUF_SIZE, MEMTYPE_ABOVE_1M,66 if (DevHelp_AllocPhys((ULONG) usBufSize, MEMTYPE_ABOVE_1M, 67 67 &(ahci_trace_buf.phys_addr))) { 68 68 /* failed above 1MB, try below */ 69 if (DevHelp_AllocPhys((ULONG) AHCI_TRACE_BUF_SIZE, MEMTYPE_BELOW_1M,69 if (DevHelp_AllocPhys((ULONG) usBufSize, MEMTYPE_BELOW_1M, 70 70 &(ahci_trace_buf.phys_addr))) { 71 71 /* failed, too. Give up */ 72 72 ahci_trace_buf.phys_addr = 0; 73 73 cprintf("%s warning: failed to allocate %dk trace buffer\n", 74 drv_name, AHCI_TRACE_BUF_SIZE/ 1024);74 drv_name, usBufSize / 1024); 75 75 return; 76 76 } … … 80 80 if (DevHelp_AllocGDTSelector(&sel, 1) || 81 81 DevHelp_PhysToGDTSelector(ahci_trace_buf.phys_addr, 82 AHCI_TRACE_BUF_SIZE, sel)) {82 usBufSize, sel)) { 83 83 /* failed; free GDT selector and physical memory we allocated before */ 84 84 if (sel) { … … 95 95 96 96 } 97 98 99 97 } 100 98 … … 182 180 return cb_read; 183 181 } 184 185 #ifdef NOT_USED186 /******************************************************************************187 * return number of bytes we can read from the trace buffer188 */189 u16 trace_bytes_avail(void)190 {191 192 if (ahci_trace_buf.writep == ahci_trace_buf.readp ) return 0; /* buffer is empty */193 194 if (ahci_trace_buf.readp <= ahci_trace_buf.writep) {195 /* read pointer is smaller than write pointer; no wrap in between */196 if (ahci_trace_buf.writep == ahci_trace_buf.readp) {197 /* full buffer available */198 return AHCI_TRACE_BUF_SIZE;199 }200 return ahci_trace_buf.writep - ahci_trace_buf.readp;201 }202 203 /* read pointer is larger than write pointer; buffer wrapped */204 return AHCI_TRACE_BUF_SIZE - ahci_trace_buf.readp + ahci_trace_buf.writep;205 }206 #endif207 182 208 183 /****************************************************************************** … … 251 226 return(STDON); 252 227 } 228 229 /****************************************************************************** 230 * Create adapter/port/device list for user output. 231 */ 232 void build_user_info(void) 233 { 234 int a; 235 int p; 236 int d; 237 238 for (a = 0; a < ad_info_cnt; a++) { 239 AD_INFO *ai = ad_infos + a; 240 241 printf_nts("Adapter %d: %d:%d:%d irq=%d addr=0x%lx\n", a, 242 ai->bus, ai->dev_func>>3, ai->dev_func&7, 243 ai->irq, ai->mmio_phys); 244 245 for (p = 0; p <= ai->port_max; p++) { 246 P_INFO *pi = &ai->ports[p]; 247 248 printf_nts(" Port %d:\n", p); 249 250 for (d = 0; d <= pi->dev_max; d++) { 251 if (!pi->devs[d].present) continue; 252 printf_nts(" Drive %d: atapi=%d, removable=%d\n", d, pi->devs[d].atapi, pi->devs[d].removable); 253 } 254 } 255 } 256 } 257 -
trunk/tools/AddToFile.cmd
r149 r154 46 46 47 47 when (What='DATEYEAR') then do 48 rc=lineout(OutFile, String||' '|| SUBSTR(DATE('S'), 1, 4));48 rc=lineout(OutFile, String||' '||FORMAT(SUBSTR(DATE('S'), 1, 4))); 49 49 rc=lineout(OutFile); 50 50 end 51 51 52 52 when (What='DATEMONTH') then do 53 rc=lineout(OutFile, String||' '|| SUBSTR(DATE('S'), 5, 2));53 rc=lineout(OutFile, String||' '||FORMAT(SUBSTR(DATE('S'), 5, 2))); 54 54 rc=lineout(OutFile); 55 55 end 56 56 57 57 when (What='DATEDAY') then do 58 rc=lineout(OutFile, String||' '|| SUBSTR(DATE('S'), 7, 2));58 rc=lineout(OutFile, String||' '||FORMAT(SUBSTR(DATE('S'), 7, 2))); 59 59 rc=lineout(OutFile); 60 60 end
Note:
See TracChangeset
for help on using the changeset viewer.