Changeset 148
- Timestamp:
- Mar 27, 2013, 5:55:26 AM (12 years ago)
- Location:
- trunk/src/os2ahci
- Files:
-
- 1 added
- 2 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/Makefile
r144 r148 1 1 ############################################################################### 2 # Makefile - makefile for os2ahci driver , c600 tool chain2 # Makefile - makefile for os2ahci driver using WATCOM compiler 3 3 # 4 # Copyright (c) 2011 thi.guten Software Development 5 # Copyright (c) 2011 Mensys B.V. 6 # 7 # Authors: Christian Mueller, Markus Thielen 4 # Copyright (c) 2010 Christian Mueller, Markus Thielen. 5 # Parts copied from/inspired by the Linux AHCI driver; 6 # those parts are (c) Linux AHCI/ATA maintainers 8 7 # 9 8 # This program is free software; you can redistribute it and/or modify … … 20 19 # along with this program; if not, write to the Free Software 21 20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 # 21 22 23 ############################################################################### 24 # Environment 25 26 .ERASE 27 .SUFFIXES 28 .SUFFIXES: .lst .obj .c .asm .lib .def 29 30 # Define default build version if not specified in environment 31 BLD_MAJOR=1 32 BLD_MINOR=26 # must be 2 digits 33 BLD_REV=0 # not used at this time 34 35 !ifndef %WATCOM # if not defined in the environment 36 !error WATCOM must be set in the environment. 37 !endif 38 WATCOM=$(%WATCOM) 39 40 !ifndef %DDK # if not defined in the environment 41 !error DDK must be set in the environment. 42 !endif 43 DDK=$(%DDK) 44 45 !ifdef %VENDOR 46 VENDOR=$(%VENDOR) 47 !else 48 VENDOR=Mensys BV 49 !endif 50 51 !ifdef %BLD_MAJOR 52 BLD_MAJOR=$(%BLD_MAJOR) 53 !endif 54 55 !ifdef %BLD_MINOR 56 BLD_MINOR=$(%BLD_MINOR) 57 !endif 58 59 CC_INCLUDE = -I..\include & 60 -I$(DDK)\base\h & 61 -I$(DDK)\base\ibmh & 62 -I$(DDK)\base\src\dev\dasd\diskh & 63 -I$(DDK)\base\src\dev\thinkpad\dockii\apmcalls & 64 65 AS_INCLUDE = -I=$(DDK)\base\inc & 66 -I=$(DDK)\base\src\dev\dasd\diskinc 67 68 LIB_DIRS = $(DDK)\base\lib\ & 69 $(DDK)\base\src\dev\dasd\devhlp\ & 70 $(DDK)\base\src\dev\thinkpad\dockii\apmcalls\ 23 71 24 72 ############################################################################### 25 73 # Tool Chain 26 74 # 75 # This makefile uses the Watcom 16-bit compiler, Watcom Assembler and Linker. 76 # The updated DDK devhelp.h is required and a copy is in the include directory 77 # of this project. 78 # 27 79 28 AS = $(DDK)\tools\alp.exe 29 CC = cl 30 LD = $(DDK)\base\tools\link.exe 80 %PATH=..\..\tools;$(WATCOM)\BINP;$(WATCOM)\BINW; 81 AS = wasm 82 CC = wcc 31 83 MAPSYM = $(DDK)\base\tools\mapsym.exe 32 BLDLEVEL = cmd.exe /c ..\..\tools\bldlvl.cmd33 BLDDATE = cmd.exe /c ..\..\tools\blddate.cmd34 84 35 AFLAGS = -Mb 36 CFLAGS = -c -nologo -Asnw -W2 -G2ms -Zlpd -Fc -Zi -DECS_BUILD 37 LFLAGS = /noe /nod /packd /a:16 /batch /map /line 38 39 ############################################################################### 40 # Environment 41 42 # main path to OS/2 DDK; this needs to be set before this makefile will work 43 !ifndef DDK 44 DDK = i:\ddk 85 !ifdef __LOADDLL__ 86 !loaddll wcc $(WATCOM)\BINP\DLL\wccd.dll 87 !loaddll wlink $(WATCOM)\BINP\DLL\wlinkd.dll 45 88 !endif 46 89 47 # main path to 16 bit C compiler 48 !ifndef CC16 49 CC16 = i:\c600 50 !endif 51 52 CC_INCLUDE = -I..\include \ 53 -I$(DDK)\base\h \ 54 -I$(DDK)\base\ibmh \ 55 -I$(DDK)\base\src\dev\dasd\diskh \ 56 -I$(DDK)\base\src\dev\thinkpad\dockii\apmcalls \ 57 # -I$(CC16)\include 58 59 AS_INCLUDE = -I:$(DDK)\base\inc \ 60 -I:$(DDK)\base\src\dev\dasd\diskinc 61 62 LIB_DIRS = $(DDK)\base\lib\ \ 63 $(DDK)\base\src\dev\dasd\devhlp\ \ 64 $(DDK)\base\src\dev\thinkpad\dockii\apmcalls\ \ 65 # $(CC16)\lib\ \ 66 90 AFLAGS = -q 91 #CFLAGS = -ei -5 -d3 -hc -bt=os2 -ms -zu -w3 -wcd=138 -wcd=300 -ecc -zp1 -q -s -zgp -zfp -oi 92 # In order to build the SMP safe version you must have the updated devhelp.h and define OS2AHCI_SMP. 93 CFLAGS = -ei -5 -d0 -bt=os2 -ms -zu -w=0 -ecc -zp=1 -q -s -zgp -zfp -oi -DOS2AHCI_SMP 94 CFLAGS_DEBUG = -ei -5 -d3 -hc -bt=os2 -ms -zu -ecc -zp=1 -q -s -zgp -zfp -od 67 95 68 96 ############################################################################### 69 97 # Main dependencies 70 98 71 TARGET = os2ahci.add 99 LIBS = addcalls doscalls rmcalls apmcalls 72 100 73 LIBS = addcalls dhcalls doscalls slibcep rmcalls apmcalls 101 SRCS = init.asm math.asm libc.c os2ahci.c pci.c ahci.c ata.c atapi.c & 102 ctxhook.c trace.c ioctl.c apm.c 74 103 75 SRCS = init.asm libc.c os2ahci.c pci.c ahci.c ata.c atapi.c ctxhook.c \ 76 apm.c ioctl.c trace.c104 OBJS = init.obj libc.obj os2ahci.obj pci.obj ahci.obj ata.obj atapi.obj & 105 ctxhook.obj trace.obj ioctl.obj apm.obj 77 106 78 OBJS = init.obj libc.obj os2ahci.obj pci.obj ahci.obj ata.obj atapi.obj \ 79 ctxhook.obj apm.obj ioctl.obj trace.obj 107 INCS = os2ahci.h ahci.h 80 108 81 INCS = os2ahci.h ahci.h version.h ioctl.h ..\include\ahci-idc.h 109 all: os2ahci.add os2ahci.sym 82 110 83 84 all: $(TARGET) 85 86 clean: 87 rm -f $(OBJS) $(TARGET) *.cod *.lst *.def *.map *.sym *.err *.lnk \ 88 bldday.h 89 111 clean: .symbolic 112 rm -f $(OBJS) os2ahci.add *.cod *.lst *.def *.map *.sym *.err *.lnk version.h 90 113 91 114 ############################################################################### 92 115 # Object/source dependencies 93 116 94 init.obj: init.asm Makefile 117 libc.obj: libc.c Makefile $(INCS) 95 118 96 libc.obj: libc.c Makefile $(INCS) 119 os2ahci.obj: os2ahci.c Makefile $(INCS) version.h ioctl.h 97 120 98 os2ahci.obj: os2ahci.c Makefile $(INCS) bldday.h ioctl.h 121 pci.obj: pci.c Makefile $(INCS) 99 122 100 pci.obj: pci.c Makefile $(INCS) 123 ahci.obj: ahci.c Makefile $(INCS) ata.h atapi.h 101 124 102 a hci.obj: ahci.c Makefile $(INCS) ata.h atapi.h125 ata.obj: ata.c Makefile $(INCS) ata.h 103 126 104 ata .obj: ata.c Makefile $(INCS)ata.h127 atapi.obj: atapi.c Makefile $(INCS) atapi.h ata.h 105 128 106 atapi.obj: atapi.cMakefile $(INCS) ata.h atapi.h129 ctxhook.obj: ctxhook.c Makefile $(INCS) ata.h atapi.h 107 130 108 ctxhook.obj: ctxhook.c Makefile $(INCS) ata.h atapi.h 131 apm.obj: apm.c Makefile $(INCS) 109 132 110 apm.obj: apm.c Makefile $(INCS) 133 ioctl.obj: ioctl.c Makefile $(INCS) ioctl.h atapi.h 111 134 112 ioctl.obj: ioctl.c Makefile $(INCS) ata.h atapi.h ioctl.h 113 114 trace.obj: trace.c Makefile $(INCS) 115 116 os2ahci.def: version.h os2ahci.def.template 135 trace.obj: trace.c Makefile $(INCS) 117 136 118 137 ############################################################################### … … 121 140 # emacs TAGS file creation 122 141 # NOTE: OS/2 emacs etags.exe expects an empty file named c:\dev\null... 123 tags: $(SRCS) $(INCS) Makefile 124 etags.exe $(SRCS) $(INCS) $(DDK)\base\src\dev\dasd\diskh\dhcalls.h \ 125 $(DDK)\base\src\dev\dasd\diskh\iorb.h \ 126 $(DDK)\base\h\bsedos16.h \ 127 $(DDK)\base\h\devcmd.h \ 128 $(DDK)\base\h\reqpkt.h 142 tags: $(SRCS) $(INCS) 143 etags.exe $(SRCS) $(INCS) 129 144 130 bldday.h: 131 $(BLDDATE) > bldday.h 145 version.h: Makefile .always 146 @%create $^@ 147 @%append $^@ /* Autogenerated by Makefile */ 148 @%append $^@ $#define VERSION $(BLD_MAJOR)$(BLD_MINOR) /* driver version (2 implied decimals) */ 149 @AddToFile $^@,$#define BLD_YEAR,DATEYEAR 150 @AddToFile $^@,$#define BLD_MONTH,DATEMONTH 151 @AddToFile $^@,$#define BLD_DAY,DATEDAY 132 152 133 .asm.obj: 134 $(AS) $(AFLAGS) $(AS_INCLUDE) $*.asm 135 wdis -l $*.obj 153 .asm.obj: .autodepend 154 $(AS) $(AFLAGS) $(AS_INCLUDE) $[@ 155 #wdis -l $^@ 136 156 137 .c.obj: 138 $(CC) $(CFLAGS) $(CC_INCLUDE) $*.c 139 wdis -l $*.obj 157 .c.obj: .autodepend 158 $(CC) $(CFLAGS) $(CC_INCLUDE) $[@ 159 #wdis -l $^@ 140 160 141 os2ahci.def: 142 $(BLDLEVEL) os2ahci.def.template os2ahci.def version.h 161 os2ahci.add: $(OBJS) Makefile 162 # Target name, system and type 163 @%create $*.lnk 164 @%append $*.lnk name $*.add 165 @%append $*.lnk sys os2 dll 166 # Merge BLDLEVEL information 167 @AddToFile.cmd $*.lnk,option description,BLDLEVEL,$(VENDOR),$(BLD_MAJOR).$(BLD_MINOR),AHCI Driver (c) Mensys BV 2013 168 # Set various options 169 @%append $*.lnk option protmode 170 @%append $*.lnk option map 171 @%append $*.lnk option quiet 172 @%append $*.lnk option nocase 173 @%append $*.lnk option stack=0 174 # Generate directives for objects, libraries and library search-paths 175 @for %f in ($(OBJS)) do @%append $*.lnk file %f 176 @for %f in ($(LIBS)) do @%append $*.lnk lib %f 177 @for %f in ($(LIB_DIRS)) do @%append $*.lnk libpath %f 178 # Attributes for the DATA and CODE segments 179 @%append $*.lnk segment type DATA SHARED 180 @%append $*.lnk segment type CODE IOPL 181 # Order segments by class 182 @%append $*.lnk order 183 @%append $*.lnk clname 'DATA' 184 @%append $*.lnk clname 'CONST' 185 @%append $*.lnk clname 'BSS' 186 @%append $*.lnk clname 'CODE' 187 # Link the stuff together and build the target 188 wlink @$*.lnk 189 @%erase $*.lnk 143 190 191 os2ahci.sym: os2ahci.map 192 wat2map.cmd $[@ $^*.ma1 193 $(MAPSYM) $^*.ma1 194 @%erase $^*.ma1 144 195 145 $(TARGET): $(OBJS) os2ahci.def Makefile146 $(LD) $(LFLAGS) $(OBJS),$(TARGET),$*.map,$(LIB_DIRS) $(LIBS),$*.def147 $(MAPSYM) os2ahci -
trunk/src/os2ahci/README
r147 r148 16 16 17 17 Copyright (c) 2011 thi.guten Software Development 18 Copyright (c) 2011 Mensys B.V.18 Copyright (c) 2011-2013 Mensys B.V. 19 19 20 20 Authors: Christian Mueller, Markus Thielen … … 51 51 as modifications will also be published as outlined in the GNU GPL2. 52 52 53 Please note that builds other than the official binary delivered as 54 part of eComStation releases or downloaded from ecomstation.nl are 55 not officially supported by Mensys. 56 57 58 Building The Driver 59 ------------------- 60 61 The toolchain required for compilation consists of: 62 63 - IBM OS/2 DDK version 9.23 or later (see ddk\base\h\version.mak) 64 (Used for include files and qgrep) 65 - Open Watcom C/C++ package 66 (available from: http://www.openwatcom.org/index.php/Downloads) 67 - WCC 16-bit C Compiler (part of the Open Watcom package) 68 - WASM Assembler (part of the Open Watcom package) 69 - WLINK Linker (part of the Open Watcom package) 70 - MAPSYM (part of the DDK) 71 72 Simply use "wmake" or "wmake -a" to build the driver. 73 74 The driver can also be built using the DDK tools, but this build 75 is depreciated and is not kept up-to-date. 76 53 77 The toolchain required for compilation consists of: 54 78 … … 57 81 - ALP Assembler (part of DDK) 58 82 - link.exe (part of DDK) 59 60 Please note that builds other than the official binary delivered as 61 part of eComStation releases or downloaded from ecomstation.nl are 62 not officially supported by Mensys. 63 64 65 Open Watcom Build 66 ----------------- 67 68 The Open Watcom Build is fixed and now produces a working driver. 69 70 The toolchain required for compilation with Open Watcom consists of: 71 72 - IBM OS/2 DDK version 9.23 or later (see ddk\base\h\version.mak) 73 (Used for include files and qgrep) 74 - Open Watcom C/C++ package 75 (available from: http://www.openwatcom.org/index.php/Downloads) 76 - WCC 16-bits C Compiler (part of the Open Watcom package) 77 - WASM Assembler (part of the Open Watcom package) 78 - WLINK Linker (part of the Open Watcom package) 79 - QGREP (part of DDK) 80 81 Please note that the Open Watcom Build is not as extensively tested as the 82 normal DDK Build so don't use it on production systems yet. 83 84 Use the _wbuild.cmd script or run wmake -ms -f wmakefile to build it. 85 When switching between building with the DDK and Open Watcom, 86 be sure to do a clean first. 87 83 - MAPSYM (part of the DDK) 84 85 Use "nmake -f Makefile.old" or "nmake -f Makefile.old -a" to build 86 the driver. 87 88 When switching between building with the DDK and Open Watcom, it is 89 recommended to do a clean first (wmake clean or nmake -f Makefile.old clean). 88 90 89 91 -
trunk/src/os2ahci/_ibuild.cmd
r144 r148 1 1 @echo off 2 nmake 2 nmake -f Makefile.old 3 3 -
trunk/src/os2ahci/_iclean.cmd
r144 r148 1 1 @echo off 2 nmake clean2 nmake -f Makefile.old clean -
trunk/src/os2ahci/_wbuild.cmd
r144 r148 1 1 @echo off 2 wmake -ms -f wmakefile 2 rem set VENDOR=Mensys BV 3 rem set BLD_MAJOR=1 4 rem set BLD_MINOR=26 5 rem set WATCOM=i:\Watcom 6 rem set DDK=i:\ddk 7 wmake -
trunk/src/os2ahci/_wclean.cmd
r144 r148 1 1 @echo off 2 wmake -ms -f wmakefileclean2 wmake clean -
trunk/src/os2ahci/ahci.c
r145 r148 142 142 } 143 143 144 ddprintf("ahci_save_bios_config: BIOS AHCI mode is %d\n", ai->bios_config[HOST_CTL / sizeof(u32)] & HOST_AHCI_EN); 145 144 146 if ((ai->bios_config[HOST_CTL / sizeof(u32)] & HOST_AHCI_EN) == 0 && 145 147 ai->pci->vendor == PCI_VENDOR_ID_INTEL) { … … 165 167 166 168 if (i == HOST_CAP) { 167 printf (" -");168 if (val & HOST_CAP_64) printf (" 64bit");169 if (val & HOST_CAP_NCQ) printf (" ncq");170 if (val & HOST_CAP_SNTF) printf (" sntf");171 if (val & HOST_CAP_MPS) printf (" mps");172 if (val & HOST_CAP_SSS) printf (" sss");173 if (val & HOST_CAP_ALPM) printf (" alpm");174 if (val & HOST_CAP_LED) printf (" led");175 if (val & HOST_CAP_CLO) printf (" clo");176 if (val & HOST_CAP_ONLY) printf (" ahci_only");177 if (val & HOST_CAP_PMP) printf (" pmp");178 if (val & HOST_CAP_FBS) printf (" fbs");179 if (val & HOST_CAP_PIO_MULTI) printf (" pio_multi");180 if (val & HOST_CAP_SSC) printf (" ssc");181 if (val & HOST_CAP_PART) printf (" part");182 if (val & HOST_CAP_CCC) printf (" ccc");183 if (val & HOST_CAP_EMS) printf (" ems");184 if (val & HOST_CAP_SXS) printf (" sxs");185 printf (" cmd_slots:%d", (u16) ((val >> 8) & 0x1f) + 1);186 printf (" ports:%d", (u16) (val & 0x1f) + 1);169 printf_nts(" -"); 170 if (val & HOST_CAP_64) printf_nts(" 64bit"); 171 if (val & HOST_CAP_NCQ) printf_nts(" ncq"); 172 if (val & HOST_CAP_SNTF) printf_nts(" sntf"); 173 if (val & HOST_CAP_MPS) printf_nts(" mps"); 174 if (val & HOST_CAP_SSS) printf_nts(" sss"); 175 if (val & HOST_CAP_ALPM) printf_nts(" alpm"); 176 if (val & HOST_CAP_LED) printf_nts(" led"); 177 if (val & HOST_CAP_CLO) printf_nts(" clo"); 178 if (val & HOST_CAP_ONLY) printf_nts(" ahci_only"); 179 if (val & HOST_CAP_PMP) printf_nts(" pmp"); 180 if (val & HOST_CAP_FBS) printf_nts(" fbs"); 181 if (val & HOST_CAP_PIO_MULTI) printf_nts(" pio_multi"); 182 if (val & HOST_CAP_SSC) printf_nts(" ssc"); 183 if (val & HOST_CAP_PART) printf_nts(" part"); 184 if (val & HOST_CAP_CCC) printf_nts(" ccc"); 185 if (val & HOST_CAP_EMS) printf_nts(" ems"); 186 if (val & HOST_CAP_SXS) printf_nts(" sxs"); 187 printf_nts(" cmd_slots:%d", (u16) ((val >> 8) & 0x1f) + 1); 188 printf_nts(" ports:%d", (u16) (val & 0x1f) + 1); 187 189 188 190 } else if (i == HOST_CTL) { 189 printf (" -");190 if (val & HOST_AHCI_EN) printf (" ahci_enabled");191 if (val & HOST_IRQ_EN) printf (" irq_enabled");192 if (val & HOST_RESET) printf (" resetting");191 printf_nts(" -"); 192 if (val & HOST_AHCI_EN) printf_nts(" ahci_enabled"); 193 if (val & HOST_IRQ_EN) printf_nts(" irq_enabled"); 194 if (val & HOST_RESET) printf_nts(" resetting"); 193 195 194 196 } else if (i == HOST_CAP2) { 195 printf (" -");196 if (val & HOST_CAP2_BOH) printf (" boh");197 if (val & HOST_CAP2_NVMHCI) printf (" nvmhci");198 if (val & HOST_CAP2_APST) printf (" apst");197 printf_nts(" -"); 198 if (val & HOST_CAP2_BOH) printf_nts(" boh"); 199 if (val & HOST_CAP2_NVMHCI) printf_nts(" nvmhci"); 200 if (val & HOST_CAP2_APST) printf_nts(" apst"); 199 201 } 200 printf ("\n");202 printf_nts("\n"); 201 203 } 202 204 } … … 287 289 int ahci_restore_bios_config(AD_INFO *ai) 288 290 { 289 ddprintf(" restoring AHCI BIOS configuration\n");291 ddprintf("ahci_restore_bios_config: restoring AHCI BIOS configuration on adapter %d\n", ad_no(ai)); 290 292 291 293 /* Restore saved BIOS configuration; please note that HOST_CTL is restored … … 349 351 int ahci_restore_initial_config(AD_INFO *ai) 350 352 { 351 ddprintf(" restoring initial configuration\n");353 ddprintf("ahci_restore_initial_config: restoring initial configuration on adapter %d\n", ad_no(ai)); 352 354 353 355 /* restore saved BIOS configuration */ … … 448 450 449 451 /* couldn't enable AHCI mode */ 450 dprintf("failed to enable AHCI mode on adapter #%d\n", ad_no(ai));452 dprintf("failed to enable AHCI mode on adapter %d\n", ad_no(ai)); 451 453 return(1); 454 } 455 456 int ahci_reset_controller(AD_INFO *ai) 457 { 458 u32 tmp; 459 int timeout = 1000; 460 461 dprintf("controller reset starting on adapter %d\n", ad_no(ai)); 462 /* we must be in AHCI mode, before using anything 463 * AHCI-specific, such as HOST_RESET. 464 */ 465 ahci_enable_ahci(ai); 466 467 /* global controller reset */ 468 tmp = readl(ai->mmio + HOST_CTL); 469 if ((tmp & HOST_RESET) == 0) { 470 writel(ai->mmio + HOST_CTL, tmp | HOST_RESET); 471 readl(ai->mmio + HOST_CTL); /* flush */ 472 } 473 474 /* 475 * to perform host reset, OS should set HOST_RESET 476 * and poll until this bit is read to be "0". 477 * reset must complete within 1 second, or 478 * the hardware should be considered fried. 479 */ 480 while (((tmp = readl(ai->mmio + HOST_CTL)) & HOST_RESET) == HOST_RESET) { 481 mdelay(10); 482 timeout -= 10; 483 if (timeout <= 0) { 484 dprintf("controller reset failed (0x%lx)\n", tmp); 485 return(-1); 486 } 487 } 488 489 /* turn on AHCI mode */ 490 ahci_enable_ahci(ai); 491 492 /* Some registers might be cleared on reset. Restore 493 * initial values. 494 */ 495 ahci_restore_initial_config(ai); 496 497 if (ai->pci->vendor == PCI_VENDOR_ID_INTEL) { 498 u32 tmp16 = 0; 499 500 ddprintf("ahci_reset_controller: intel detected\n"); 501 /* configure PCS */ 502 pci_read_conf(ai->bus, ai->dev_func, 0x92, sizeof(u16), &tmp16); 503 if ((tmp16 & ai->port_map) != ai->port_map) { 504 ddprintf("ahci_reset_controller: updating PCS %x/%x\n", (u16)tmp16, ai->port_map); 505 tmp16 |= ai->port_map; 506 pci_write_conf(ai->bus, ai->dev_func, 0x92, sizeof(u16), tmp16); 507 } 508 } 509 510 return 0; 452 511 } 453 512 … … 487 546 } 488 547 548 ahci_reset_controller(ai); 549 489 550 if (ahci_enable_ahci(ai)) { 490 551 goto exit_port_scan; … … 492 553 493 554 /* perform port scan */ 494 dprintf(" scanning ports on adapter #%d\n", ad_no(ai));555 dprintf("ahci_scan_ports: scanning ports on adapter %d\n", ad_no(ai)); 495 556 for (p = 0; p < AHCI_MAX_PORTS; p++) { 496 557 if (ai->port_map & (1UL << p)) { 558 559 dprintf("ahci_scan_ports: Wait till not busy on port %d\n", p); 560 /* wait until all active commands have completed on this port */ 561 while (ahci_port_busy(ai, p)) { 562 msleep(250); 563 } 497 564 498 565 if (!init_complete) { … … 506 573 rc = ahci_reset_port(ai, p, 0); 507 574 } else { 508 ddprintf(" (re)starting port #%d\n", p);575 ddprintf("ahci_scan_ports: (re)starting port %d\n", p); 509 576 ahci_stop_port(ai, p); 510 577 rc = ahci_start_port(ai, p, 0); … … 517 584 518 585 /* this port seems to have a device attached and ready for commands */ 519 ddprintf(" port #%d seems to be attached to a device; probing...\n", p);586 ddprintf("ahci_scan_ports: port %d seems to be attached to a device; probing...\n", p); 520 587 521 588 /* Get ATA(PI) identity. The so-called signature gives us a hint whether … … 575 642 int i; 576 643 577 dprintf(" completing initialization of adapter #%d\n", ad_no(ai));644 dprintf("ahci_complete_init: completing initialization of adapter #%d\n", ad_no(ai)); 578 645 579 646 /* register IRQ handlers; each IRQ level is registered only once */ … … 609 676 if (ai->port_map & (1UL << p)) { 610 677 if (init_reset) { 678 dprintf("ahci_complete_init: resetting port %d\n", p); 611 679 ahci_reset_port(ai, p, 1); 612 680 } else { 613 dprintf(" restarting port #%d\n", p);681 dprintf("ahci_complete_init: restarting port #%d\n", p); 614 682 ahci_stop_port(ai, p); 615 683 ahci_start_port(ai, p, 1); … … 648 716 u8 _far *port_mmio = port_base(ai, p); 649 717 u32 tmp; 650 int timeout = 5000;651 652 dprintf(" resetting port %d.%d\n", ad_no(ai), p);718 int timeout; 719 720 dprintf("ahci_reset_port: resetting port %d.%d\n", ad_no(ai), p); 653 721 if (debug > 1) { 654 printf("command engine status:\n"); 722 printf(" PORT_CMD = 0x%lx\n", readl(port_mmio + PORT_CMD)); 723 printf("ahci_reset_port: command engine status:\n"); 655 724 printf(" PORT_SCR_ACT = 0x%lx\n", readl(port_mmio + PORT_SCR_ACT)); 656 725 printf(" PORT_CMD_ISSUE = 0x%lx\n", readl(port_mmio + PORT_CMD_ISSUE)); … … 673 742 writel(port_mmio + PORT_SCR_ERR, tmp); 674 743 744 /* power up and spin up the drive if necessary */ 745 if (((tmp = readl(port_mmio + PORT_CMD)) & (PORT_CMD_SPIN_UP|PORT_CMD_POWER_ON)) != (PORT_CMD_SPIN_UP|PORT_CMD_POWER_ON)) { 746 writel(port_mmio + PORT_CMD, tmp | PORT_CMD_SPIN_UP | PORT_CMD_POWER_ON); 747 } 748 675 749 /* set link speed and power management options */ 676 ddprintf(" setting link speed and power management options\n");677 tmp = readl(port_mmio + PORT_SCR_CTL) & ~0x00000ff 0UL;750 ddprintf("ahci_reset_port: setting link speed and power management options\n"); 751 tmp = readl(port_mmio + PORT_SCR_CTL) & ~0x00000fffUL; //DAZ 678 752 tmp |= ((u32) link_speed[ad_no(ai)][p] & 0x0f) << 4; 679 753 tmp |= ((u32) link_power[ad_no(ai)][p] & 0x0f) << 8; 680 writel(port_mmio + PORT_SCR_CTL, tmp);754 //DAZ writel(port_mmio + PORT_SCR_CTL, tmp); 681 755 682 756 /* issue COMRESET on the port */ 683 ddprintf(" issuing COMRESET on port\n");684 tmp = readl(port_mmio + PORT_SCR_CTL) & ~0x0000000fUL;757 ddprintf("ahci_reset_port: issuing COMRESET on port %d\n", p); 758 //DAZ tmp = readl(port_mmio + PORT_SCR_CTL) & ~0x0000000fUL; 685 759 writel(port_mmio + PORT_SCR_CTL, tmp | 1); 686 760 readl(port_mmio + PORT_SCR_CTL); /* flush */ … … 693 767 694 768 /* wait for communication to be re-established after port reset */ 769 timeout = 5000; 695 770 while (((tmp = readl(port_mmio + PORT_SCR_STAT)) & 3) != 3) { 696 771 mdelay(10); … … 708 783 709 784 /* start port so we can receive the COMRESET FIS */ 710 ddprintf(" starting port again\n");785 ddprintf("ahci_reset_port: starting port %d again\n", p); 711 786 ahci_start_port(ai, p, ei); 712 787 713 788 /* wait for device to be ready ((PxTFD & (BSY | DRQ | ERR)) == 0) */ 789 timeout = 5000; 714 790 while (((tmp = readl(port_mmio + PORT_TFDATA)) & 0x89) != 0) { 715 791 mdelay(10); … … 722 798 } 723 799 } 724 ddprintf(" PORT_TFDATA = 0x%lx\n", readl(port_mmio + PORT_TFDATA));800 ddprintf("ahci_reset_port: PORT_TFDATA = 0x%lx\n", readl(port_mmio + PORT_TFDATA)); 725 801 726 802 return(0); … … 734 810 u8 _far *port_mmio = port_base(ai, p); 735 811 u32 status; 736 812 //int timeout; 813 814 dprintf("ahci_start_port %d.%d\n", ad_no(ai), p); 737 815 /* check whether device presence is detected and link established */ 816 817 #if 0 818 /* 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 #endif 829 738 830 status = readl(port_mmio + PORT_SCR_STAT); 739 ddprintf(" PORT_SCR_STAT = 0x%lx\n", status);831 ddprintf("ahci_start_port: PORT_SCR_STAT = 0x%lx\n", status); 740 832 if ((status & 0xf) != 3) { 741 833 return(-1); … … 744 836 /* clear SError, if any */ 745 837 status = readl(port_mmio + PORT_SCR_ERR); 746 ddprintf(" PORT_SCR_ERR = 0x%lx\n", status);838 ddprintf("ahci_start_port: PORT_SCR_ERR = 0x%lx\n", status); 747 839 writel(port_mmio + PORT_SCR_ERR, status); 748 840 … … 827 919 u32 tmp; 828 920 int rc; 921 922 dprintf("ahci_stop_port %d.%d\n", ad_no(ai), p); 829 923 830 924 /* disable port interrupts */ -
trunk/src/os2ahci/libc.c
r118 r148 58 58 ULONG parm2); 59 59 static int mdelay_cal_end (void); 60 static void printf_nts (const char *fmt, ...);61 60 62 61 /* ------------------------ global/static variables ------------------------ */ … … 284 283 285 284 spin_lock(com_lock); 286 285 287 286 if (ts) { 288 287 /* include timestamp */ … … 351 350 * Print messages to COM port with no time stamp 352 351 */ 353 staticvoid printf_nts(const char *fmt, ...)352 void printf_nts(const char *fmt, ...) 354 353 { 355 354 va_list va; … … 509 508 len -= l; 510 509 } 511 510 512 511 pos += sg_list[i].XferBufLen; 513 512 } -
trunk/src/os2ahci/os2ahci.c
r147 r148 26 26 27 27 #include "os2ahci.h" 28 #include "bldday.h"29 30 28 #include "ioctl.h" 31 29 … … 357 355 ciprintf(init_msg, drv_name, VERSION / 100, VERSION % 100); 358 356 359 #ifdef ECS_BUILD360 ciprintf("This driver is licensed for use only in conjunction with eComStation.\n");361 #else362 ciprintf("This is the Open Watcom build.\n");363 #endif357 //#ifdef ECS_BUILD 358 // ciprintf("This driver is licensed for use only in conjunction with eComStation.\n"); 359 //#else 360 // ciprintf("This is the Open Watcom build.\n"); 361 //#endif 364 362 365 363 if (debug) { 366 364 /* initialize com port for debug output */ 367 init_com();365 //DAZ init_com(); 368 366 } 369 367 … … 781 779 } 782 780 init_complete = 1; 781 782 /* DAZ turn off COM port output */ 783 com_base = 0; 783 784 784 785 /* release all adapters */ -
trunk/src/os2ahci/os2ahci.def.template
r144 r148 1 1 library os2ahci 2 Description '$@#Mensys:0.0.0#@##1## 2011/05/02 11:41:00 ECSDEVEL::::00::@@AHCI Driver. (c) Mensys BV 2011'3 2 protmode 4 3 -
trunk/src/os2ahci/os2ahci.h
r145 r148 157 157 #define DevHelp_FreeSpinLock(sph) 0 158 158 159 #define DevHelp_A quireSpinLock(sph) if ((sph) != 0) \159 #define DevHelp_AcquireSpinLock(sph) if ((sph) != 0) \ 160 160 panic("recursive spinlock"); \ 161 161 (sph) = disable() … … 168 168 169 169 /* shortcut macros */ 170 #define spin_lock(sl) DevHelp_A quireSpinLock(sl)170 #define spin_lock(sl) DevHelp_AcquireSpinLock(sl) 171 171 #define spin_unlock(sl) DevHelp_ReleaseSpinLock(sl) 172 172 … … 476 476 extern void vfprintf (const char *fmt, va_list va); 477 477 extern void _cdecl printf (const char *fmt, ...); 478 extern void _cdecl printf_nts (const char *fmt, ...); 478 479 extern void cprintf (const char *fmt, ...); 479 480 extern void phex (const void _far *p, int len, const char *fmt, ...); … … 500 501 extern void trace_exit (void); 501 502 extern void trace_write (u8 _far *s, int len); 502 extern u16 trace_read ( void_far *buf, u16 cb_buf);503 extern u16 trace_bytes_avail(void);503 extern u16 trace_read (u8 _far *buf, u16 cb_buf); 504 //NOT_USED extern u16 trace_bytes_avail(void); 504 505 extern u16 trace_char_dev(RP_RWV _far *rwrb); 505 506 … … 511 512 extern char *vendor_from_id (u16 vendor); 512 513 extern char *device_from_id (u16 device); 514 UCHAR pci_read_conf (UCHAR bus, UCHAR dev_func, UCHAR indx, 515 UCHAR size, ULONG _far *val); 516 UCHAR pci_write_conf (UCHAR bus, UCHAR dev_func, UCHAR indx, UCHAR size, 517 ULONG val); 513 518 514 519 /* ctxhook.c */ -
trunk/src/os2ahci/pci.c
r123 r148 147 147 148 148 static void add_pci_device (PCI_ID *pci_id, OH_DATA _far *data); 149 static UCHAR pci_read_conf (UCHAR bus, UCHAR dev_func, UCHAR indx,150 UCHAR size, ULONG _far *val);151 static UCHAR pci_write_conf (UCHAR bus, UCHAR dev_func, UCHAR indx, UCHAR size,152 ULONG val);153 149 static int oemhlp_call (UCHAR subfunction, OH_PARM _far *parm, 154 150 OH_DATA _far *data); … … 698 694 ret = RMAllocResource(rm_drvh, ad_info->rm_bars + i, &resource); 699 695 if (ret != RMRC_SUCCESS) { 700 cprintf("%s: couldn't register [MM]IO region (rc = %s)\n", 696 cprintf("%s: couldn't register [MM]IO region (rc = %s)\n", 701 697 drv_name, rmerr(ret)); 702 698 goto add_pci_fail; … … 813 809 * Read PCI configuration space register 814 810 */ 815 staticUCHAR pci_read_conf(UCHAR bus, UCHAR dev_func, UCHAR indx, UCHAR size,811 UCHAR pci_read_conf(UCHAR bus, UCHAR dev_func, UCHAR indx, UCHAR size, 816 812 ULONG _far *val) 817 813 { … … 838 834 * Write PCI configuration space register 839 835 */ 840 staticUCHAR pci_write_conf(UCHAR bus, UCHAR dev_func, UCHAR indx, UCHAR size,836 UCHAR pci_write_conf(UCHAR bus, UCHAR dev_func, UCHAR indx, UCHAR size, 841 837 ULONG val) 842 838 { -
trunk/src/os2ahci/trace.c
r122 r148 42 42 u16 writep; /* current write offset in buffer */ 43 43 u16 readp; /* current read offset in buffer */ 44 int empty; /* != 0 if buffer is empty*/44 u16 mask; /* The mask for wrapping the buffer pointers */ 45 45 } ahci_trace_buf; 46 46 … … 49 49 /****************************************************************************** 50 50 * initialize AHCI circular trace buffer 51 * 51 * 52 52 * NOTE: this func must be called during INIT time since it allocates 53 53 * a GDT selector for the trace ring buffer … … 60 60 ahci_trace_buf.writep = 0; 61 61 ahci_trace_buf.readp = 0; 62 ahci_trace_buf. empty =1;62 ahci_trace_buf.mask = AHCI_TRACE_BUF_SIZE - 1; 63 63 64 64 if (ahci_trace_buf.phys_addr == 0) { … … 95 95 96 96 } 97 98 97 98 99 99 } 100 100 … … 126 126 * Note: This func wraps the buffer if necessary, so the caller does not 127 127 * need to call repeatedly until everything is written. 128 * 128 * 129 129 */ 130 130 void trace_write(u8 _far *s, int len) 131 131 { 132 u16 cbw; /* bytes we can store before buffer wrap occurrs */ 133 u16 cb; 134 USHORT awake_cnt; 135 132 //NOT USED USHORT awake_cnt; 133 136 134 if (ahci_trace_buf.phys_addr == 0) { 137 135 /* tracing not active */ 138 136 return; 139 137 } 140 141 cbw = AHCI_TRACE_BUF_SIZE - ahci_trace_buf.writep; 142 143 while (len > 0) { 144 cb = cbw < len ? cbw : len; 145 if (cb && ahci_trace_buf.empty) { 146 ahci_trace_buf.empty = 0; 147 } 148 memcpy(ahci_trace_buf.tbuf + ahci_trace_buf.writep, s, cb); 149 s += cb; 150 ahci_trace_buf.writep += cb; 151 len -= cb; 152 153 /* wrap? */ 154 if (ahci_trace_buf.writep >= AHCI_TRACE_BUF_SIZE) { 155 ahci_trace_buf.writep = 0; 156 cbw = AHCI_TRACE_BUF_SIZE; 157 } 158 } 159 138 139 while (len) { 140 /* The following line causes filling the trace buffer to stop when full. 141 * Comment the following line to keep filling and see the last buffer of data. 142 * Uncomment the following line to stop filling / see the first buffer of data. 143 */ 144 if ( ((ahci_trace_buf.writep+1) & ahci_trace_buf.mask) == ahci_trace_buf.readp ) break; /* buffer is full */ 145 146 ahci_trace_buf.tbuf[ahci_trace_buf.writep] = *s++; 147 ahci_trace_buf.writep++; 148 ahci_trace_buf.writep &= ahci_trace_buf.mask; 149 150 /* keep the latest full buffer of information */ 151 if (ahci_trace_buf.writep == ahci_trace_buf.readp) 152 ahci_trace_buf.readp = (ahci_trace_buf.readp+1) & ahci_trace_buf.mask; 153 154 len--; 155 } 156 160 157 /* wake up processes waiting for data from trace buffer */ 161 DevHelp_ProcRun(ahci_trace_buf.phys_addr, &awake_cnt);158 //NOT_USED DevHelp_ProcRun(ahci_trace_buf.phys_addr, &awake_cnt); 162 159 163 160 } … … 167 164 * returns the number of bytes written to the caller's buffer 168 165 * 169 * NOTE: the caller is expected to call this func repeatedly 166 * NOTE: the caller is expected to call this func repeatedly 170 167 * (up to two times) until it returns 0 171 168 */ 172 u16 trace_read( void_far *buf, u16 cb_buf)169 u16 trace_read(u8 _far *buf, u16 cb_buf) 173 170 { 174 171 u16 cb_avail; 175 172 u16 cb_read; 176 173 177 if (ahci_trace_buf.phys_addr == NULL || ahci_trace_buf.empty) { 178 return 0; 179 } 180 181 /* get number of bytes in buffer */ 182 if (ahci_trace_buf.readp < ahci_trace_buf.writep) { 183 /* read pointer is smaller than write pointer; no wrap in between */ 184 cb_avail = ahci_trace_buf.writep - ahci_trace_buf.readp; 185 } else { 186 /* read pointer is larger than (or same as) write pointer; 187 * read up to buffer end and let caller come again (if necessary) 188 */ 189 cb_avail = AHCI_TRACE_BUF_SIZE - ahci_trace_buf.readp; 190 } 191 192 /* determine number of bytes we actually can return */ 193 cb_read = cb_buf > cb_avail ? cb_avail : cb_buf; 194 195 memcpy(buf, ahci_trace_buf.tbuf + ahci_trace_buf.readp, cb_read); 196 197 /* update read pointer */ 198 ahci_trace_buf.readp += cb_read; 199 if (ahci_trace_buf.readp >= AHCI_TRACE_BUF_SIZE) { 200 ahci_trace_buf.readp = 0; 201 } 202 203 /* check if buffer is empty now */ 204 if (ahci_trace_buf.readp == ahci_trace_buf.writep) { 205 ahci_trace_buf.empty = 1; 206 } 207 174 if (ahci_trace_buf.phys_addr == NULL) return 0; 175 176 for (cb_read = 0; cb_read < cb_buf && ( ahci_trace_buf.readp != ahci_trace_buf.writep ); cb_read++) 177 { 178 *buf++ = ahci_trace_buf.tbuf[ahci_trace_buf.readp]; 179 ahci_trace_buf.readp++; 180 ahci_trace_buf.readp &= ahci_trace_buf.mask; 181 } 182 208 183 return cb_read; 209 184 } 210 185 186 #ifdef NOT_USED 211 187 /****************************************************************************** 212 188 * return number of bytes we can read from the trace buffer … … 214 190 u16 trace_bytes_avail(void) 215 191 { 216 217 if (ahci_trace_buf.empty) { 218 return 0; 219 } 192 193 if (ahci_trace_buf.writep == ahci_trace_buf.readp ) return 0; /* buffer is empty */ 220 194 221 195 if (ahci_trace_buf.readp <= ahci_trace_buf.writep) { … … 231 205 return AHCI_TRACE_BUF_SIZE - ahci_trace_buf.readp + ahci_trace_buf.writep; 232 206 } 233 207 #endif 234 208 235 209 /****************************************************************************** … … 243 217 USHORT mode = 0; 244 218 245 /* block process until data is available in the trace buffer; 246 * see also comment in ioctl.c next to DevHelp_ProcBlock 247 * concerning spin_lock and ProcBlock interaction 248 */ 249 while (ahci_trace_buf.empty) { 219 spin_lock(com_lock); 220 #ifdef NOT_USED 221 /* block process until data is available in the trace buffer. */ 222 while (ahci_trace_buf.writep == ahci_trace_buf.readp ) { /* buffer is empty */ 250 223 spin_lock(com_lock); 251 #ifndef OS2AHCI_SMP224 #ifndef OS2AHCI_SMP 252 225 com_lock = 0; 253 #endif254 if (DevHelp_ProcBlock((ULONG) ahci_trace_buf.phys_addr, 226 #endif 227 if (DevHelp_ProcBlock((ULONG) ahci_trace_buf.phys_addr, 255 228 (ULONG) -1, 0) == WAIT_INTERRUPTED) { 256 229 /* user pressed Ctrl+C or whatever */ … … 260 233 spin_lock(com_lock); 261 234 } 235 #endif 262 236 263 237 /* get pointer to caller's buffer */
Note:
See TracChangeset
for help on using the changeset viewer.