source: trunk/src/os2ahci/wmakefile@ 145

Last change on this file since 145 was 145, checked in by rousseau, 13 years ago

Possibly fixed VirtualBox trap #8/reset problem (TRAC ticket #15)

Depending on kernel (W4/SMP) and ACPI (enabled or not), massive copying of
files produced a trap #8 or reset when using OS2AHCI in VirtualBox.

Causes & Fixes

o Interrupts were not disabled before doing DevHelp_EOI().

Since the AHCI controller in VirtualBox is a software implementation,
it cannot process requests as fast as a true hardware controller.
This caused stacked interrupts to a level that exhausted the interrupt
stack, resulting in a trap #8 on W4 or a reset on SMP with ACPI.
Interrupts are now disabled before doing the EOI.
The "Physycal Device Driver Reference" mentions this in:
?:\IBMDDK\DOCS\PDDREF.INF->Device Helper (DevHlp) Services)->EOI
and cross-referencing with DANIS506 shows she does the same in:
s506m.c (state machine) around line 244.

To investigate

o SMP safety

The disable() function in lib.c (around line 793) mentions that SMP systems
should use spinlocks. Possibly because a CLI is only executed on the
current CPU and a new interrupt could come from another CPU where
interrupts are still enabled. However, doing the EOI before unlocking did
not solve the VBox issue, possibly because spin_unlock() enables
interrupts again. So, at least in the case of VBox, the interrupt handler
has to return with interrupts disabled.
This will only be an issue in VBox if it realy can receive interrupts from
multiple CPU's in it's software implementation.

o Real hardware

As far as I can tell this patch has no influence on performance when
using real hardware. Also, since real hardware can handle requests in a
much shorter timespan, the likeliness of stacked interrupts occuring is
much less.

Performance measurements in VirtualBox

VirtualBox is a virtual machine and therefore subjected to any system load
on the host OS. Even comparing DANIS506 with OS2AHCI makes no real sense
since with DANI the SATA-contoller will run in ATA-compatibility and with
OS2AHCI it will run in AHCI-mode. Also, I have experienced that when my CPU
get's hot, the duty-cycle throttling goes active, reducing performance and
thus impacting any benchmarks in VBox. (or real hardware)
The only way to compare DANIS506 with OS2AHCI is on real hardware, on the
same controller, with the same disks and doing the same tests.
And most importantly, with the same CPU core-temperature.

Note

Diff's may show changed lines that are actually the same.
That's because my editor is configured to strip trailing white space.

  • Property svn:executable set to *
File size: 7.0 KB
Line 
1###############################################################################
2# wmakefile - makefile for os2ahci driver using WATCOM compiler
3#
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
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22###############################################################################
23# Calling Syntax
24#
25# wmake -ms -f wmakefile
26#
27# NOTE: we use MS compatibility mode (-ms) so we can use a syntax similar
28# to the well known nmake syntax.
29#
30
31###############################################################################
32# wmake directives
33.HOLD # do not prompt for deletion of created files on error; leave them alone
34
35
36
37###############################################################################
38# Environment
39
40
41# main path to OS/2 DDK; this needs to be set before this makefile will work
42!ifndef DDK
43DDK = i:\ddk
44!endif
45
46# main path to WATCOM installation
47!ifndef WATCOM
48WATCOM = i:\watcom
49!endif
50
51CC_INCLUDE = -I..\include \
52 -I$(DDK)\base\h \
53 -I$(DDK)\base\ibmh \
54 -I$(DDK)\base\src\dev\dasd\diskh \
55 -I$(DDK)\base\src\dev\thinkpad\dockii\apmcalls \
56# -I$(CC16)\include
57
58AS_INCLUDE = -I=$(DDK)\base\inc \
59 -I=$(DDK)\base\src\dev\dasd\diskinc
60
61LIB_DIRS = $(DDK)\base\lib\ \
62 $(DDK)\base\src\dev\dasd\devhlp\ \
63 $(DDK)\base\src\dev\thinkpad\dockii\apmcalls\ \
64
65
66
67
68###############################################################################
69# Tool Chain
70#
71# This makefile uses the Watcom 16-bit compiler, Watcom Assembler and Linker.
72# You can change to the DDK Linker and Assembler by modifying the macros below.
73#
74
75
76
77
78#
79# Specify Linker
80# Note: Using ALP with Wlink produces an oversized image, possibly due to
81# the location of BSS segments. Putting the BSS segments after the CODE
82# segments in init.asm and/or segment ordering in the Wlink response file
83# seems not to work when using ALP.
84#
85
86#LINKER=ibm
87LINKER=watcom
88
89#
90# Specify Assembler
91# Note: This will only be of influence on assembling .asm files.
92# C inline _asm statements will use Wasm.
93#
94
95#AS = $(DDK)\tools\alp.exe
96#AS = jwasm -Cp
97AS = wasm
98
99
100CC = wcc
101LD = $(DDK)\base\tools\link.exe
102BLDLEVEL = cmd.exe /c ..\..\tools\bldlvl.cmd
103BLDDATE = cmd.exe /c ..\..\tools\blddate.cmd
104MAPSYM = $(DDK)\base\tools\mapsym.exe
105
106#AFLAGS = -Mb
107#CFLAGS = -ei -5 -d3 -hc -bt=os2 -ms -zu -w3 -wcd=138 -wcd=300 -ecc -zp1 -q -s -zgp -zfp -oi
108CFLAGS = -ei -5 -d0 -bt=os2 -ms -zu -w=0 -ecc -zp=1 -q -s -zgp -zfp -oi
109CFLAGS_DEBUG = -ei -5 -d3 -hc -bt=os2 -ms -zu -ecc -zp=1 -q -s -zgp -zfp -od
110
111LFLAGS = /noe /nod /packd /a:16 /batch /map /line
112
113###############################################################################
114# Main dependencies
115
116TARGET = os2ahci.add
117
118#LIBS = addcalls doscalls rmcalls apmcalls # dhcalls not needed, see local devhelp.h
119LIBS = addcalls doscalls rmcalls apmcalls dhcalls
120
121SRCS = init.asm math.asm libc.c os2ahci.c pci.c ahci.c ata.c atapi.c \
122 ctxhook.c trace.c ioctl.c apm.c
123
124OBJS = init.obj libc.obj os2ahci.obj pci.obj ahci.obj ata.obj atapi.obj \
125 ctxhook.obj trace.obj ioctl.obj apm.obj
126
127INCS = os2ahci.h ahci.h version.h
128
129
130all: $(TARGET)
131
132clean:
133 rm -f $(OBJS) $(TARGET) *.cod *.lst *.def *.map *.sym *.err *.lnk \
134 bldday.h
135
136###############################################################################
137# Object/source dependencies
138
139init.obj: $*.asm wmakefile
140
141libc.obj: $*.c wmakefile $(INCS)
142
143os2ahci.obj: $*.c wmakefile $(INCS) bldday.h ioctl.h
144
145pci.obj: $*.c wmakefile $(INCS)
146
147ahci.obj: $*.c wmakefile $(INCS) ata.h atapi.h
148
149ata.obj: $*.c wmakefile $(INCS) $*.h
150
151atapi.obj: $*.c wmakefile $(INCS) $*.h ata.h
152
153ctxhook.obj: $*.c wmakefile $(INCS) ata.h atapi.h
154
155apm.obj: $*.c wmakefile $(INCS)
156
157ioctl.obj: $*.c wmakefile $(INCS) $*.h atapi.h
158
159trace.obj: $*.c wmakefile $(INCS)
160
161os2ahci.def: version.h $*.def.template
162
163###############################################################################
164# Action definitions (compile/link commands)
165
166# emacs TAGS file creation
167# NOTE: OS/2 emacs etags.exe expects an empty file named c:\dev\null...
168tags: $(SRCS) $(INCS)
169 etags.exe $(SRCS) $(INCS)
170
171bldday.h:
172 $(BLDDATE) > bldday.h
173
174.asm.obj:
175 $(AS) $(AFLAGS) $(AS_INCLUDE) $*.asm
176 wdis -l $*.obj
177
178.c.obj:
179 $(CC) $(CFLAGS) $(CC_INCLUDE) $*.c
180 wdis -l $*.obj
181
182os2ahci.def:
183 $(BLDLEVEL) $*.def.template $*.def version.h
184
185$(TARGET): $(OBJS) $*.def wmakefile
186
187!if "$(LINKER)"=="watcom"
188 # Target name, system and type
189 @%create $*.lnk
190 @%append $*.lnk name $*.add
191 @%append $*.lnk sys os2 dll
192 # Merge BLDLEVEL information
193 @%append $*.lnk option
194 @qgrep -y -e "description" $*.def >> $*.lnk
195 # Set various options
196 @%append $*.lnk option protmode
197 @%append $*.lnk option map
198 @%append $*.lnk option quiet
199 @%append $*.lnk option nocase
200 @%append $*.lnk option stack=0
201 # Generate directives for objects, libraries and library search-paths
202 @for %f in ($(OBJS)) do @%append $*.lnk file %f
203 @for %f in ($(LIBS)) do @%append $*.lnk lib %f
204 @for %f in ($(LIB_DIRS)) do @%append $*.lnk libpath %f
205 # Attributes for the DATA and CODE segments
206 @%append $*.lnk segment type DATA SHARED
207 @%append $*.lnk segment type CODE IOPL
208 # Order segments by class
209 @%append $*.lnk order
210 @%append $*.lnk clname 'DATA'
211 @%append $*.lnk clname 'CONST'
212 @%append $*.lnk clname 'BSS'
213 @%append $*.lnk clname 'CODE'
214 # Link the stuff together and build the target
215 wlink @$*.lnk
216
217!elseif "$(LINKER)"=="ibm"
218 $(LD) $(LFLAGS) $(OBJS),$(TARGET),$*.map,$(LIB_DIRS) $(LIBS),$*.def
219 mapsym $*
220!else
221 @echo "Error: No valid linker specified"
222!endif
223
Note: See TracBrowser for help on using the repository browser.