Ignore:
Timestamp:
Jan 3, 2013, 1:22:56 PM (13 years ago)
Author:
rousseau
Message:

Fixed the Open Watcom build

Building with Open Watcom produced a non working driver.

Causes & Fixes

o Enum types were 8 bits when using WCC

This caused the functions with variable arguments to fail.
Adding the -ei compiler-flag to WCC solved this issue.

o Incorrect inline assembler syntax to call DeviceHelp in os2ahci.c

DeviceHelp is a 16:16 far pointer residing in memory.
MASM interprets 'call DeviceHelp' differently than WASM.
The correct syntax is: 'call dword ptr [DeviceHelp]'.

o Missing segments from TGROUP in init.asm

WLINK then generates the AUTO class, most probably causing incorrect
relocation fixups.

Enhancements

o WASM (or JWASM) can now be used instead of ALP
o WCC can now be used instead of CL
o The Open Watcom linker (WLINK) can now be used instead of LINK
o Streamlined both makefiles a notch so it's easy to use both tool-chains

To investigate

o CL barks about a missing prototype for DevHelp_Yield() in lib.c

The prototype is actually defined in dhcalls.h but CL still barks.

o Using WCC with ALP and WLINK produces an oversized image

Probaly due to misplaced BSS segments. WCC with ALP and LINK produces
a normal sized image however.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/os2ahci/wmakefile

    r112 r144  
    2929#
    3030
    31 #
    32 # THE WATCOM BUILD IS BROKEN!
    33 #
    34 # It might run through but produces a non-working driver
    35 #
    36 
    3731###############################################################################
    3832# wmake directives
     
    4337###############################################################################
    4438# Environment
     39
    4540
    4641# main path to OS/2 DDK; this needs to be set before this makefile will work
     
    5752               -I$(DDK)\base\h \
    5853               -I$(DDK)\base\ibmh \
    59                -I$(DDK)\base\src\dev\dasd\diskh \
     54               -I$(DDK)\base\src\dev\dasd\diskh \
    6055               -I$(DDK)\base\src\dev\thinkpad\dockii\apmcalls \
    61                -I$(CC16)\include
    62 
    63 AS_INCLUDE   = -I:$(DDK)\base\inc \
    64                -I:$(DDK)\base\src\dev\dasd\diskinc
     56#               -I$(CC16)\include
     57
     58AS_INCLUDE   = -I=$(DDK)\base\inc \
     59               -I=$(DDK)\base\src\dev\dasd\diskinc
    6560
    6661LIB_DIRS     = $(DDK)\base\lib\ \
    67                $(DDK)\base\src\dev\dasd\devhlp\ \
     62               $(DDK)\base\src\dev\dasd\devhlp\ \
    6863               $(DDK)\base\src\dev\thinkpad\dockii\apmcalls\ \
    6964
     65
     66
     67
    7068###############################################################################
    7169# Tool Chain
    7270#
    73 # This makefile uses the Watcom 16bit compiler.
    74 # Linker and assembler are link.exe and alp.exe that ship with the OS/2 DDK
    75 #
    76 
    77 AS         = $(DDK)\tools\alp.exe
     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#LINKER=ibm
     77LINKER=watcom
     78
     79
     80#AS         = $(DDK)\tools\alp.exe
     81#AS         = jwasm -Cp
     82AS         = wasm
    7883CC         = wcc
    7984LD         = $(DDK)\base\tools\link.exe
     
    8287MAPSYM     = $(DDK)\base\tools\mapsym.exe
    8388
    84 AFLAGS        = -Mb
    85 CFLAGS        = -d3 -hc -bt=os2 -ms -zu -5 -w3 -wcd=138 -wcd=300 -ecc -zp1 -q -s -zgp -zfp -oi
    86 CFLAGS_DEBUG  = -d3 -hc
     89#AFLAGS        = -Mb
     90#CFLAGS        = -ei -5 -d3 -hc -bt=os2 -ms -zu -w3 -wcd=138 -wcd=300 -ecc -zp1 -q -s -zgp -zfp -oi
     91CFLAGS        = -ei -5 -d0 -bt=os2 -ms -zu -w=0 -ecc -zp=1 -q -s -zgp -zfp -oi
     92CFLAGS_DEBUG  = -ei -5 -d3 -hc -bt=os2 -ms -zu -ecc -zp=1 -q -s -zgp -zfp -od
     93
    8794LFLAGS        = /noe /nod /packd /a:16 /batch /map /line
    8895
     
    9299TARGET   = os2ahci.add
    93100
    94 LIBS     = addcalls doscalls rmcalls apmcalls # dhcalls not needed, see local devhelp.h
     101#LIBS     = addcalls doscalls rmcalls apmcalls # dhcalls not needed, see local devhelp.h
     102LIBS     = addcalls doscalls rmcalls apmcalls dhcalls
    95103
    96104SRCS     = init.asm math.asm libc.c os2ahci.c pci.c ahci.c ata.c atapi.c \
    97            ctxhook.c trace.c ioctl.c apm.c
     105           ctxhook.c trace.c ioctl.c apm.c
    98106
    99107OBJS     = init.obj libc.obj os2ahci.obj pci.obj ahci.obj ata.obj atapi.obj \
     
    106114
    107115clean:
    108         rm -f $(OBJS) $(TARGET) *.lst *.cod
     116        rm -f $(OBJS) $(TARGET) *.cod *.lst *.def *.map *.sym *.err *.lnk \
     117                bldday.h
    109118
    110119###############################################################################
    111120# Object/source dependencies
    112121
    113 init.obj:     init.asm   Makefile
    114 
    115 libc.obj:     libc.c     Makefile $(INCS)
    116 
    117 os2ahci.obj:  os2ahci.c  Makefile $(INCS) bldday.h ioctl.h
    118 
    119 pci.obj:      pci.c      Makefile $(INCS)
    120 
    121 ahci.obj:     ahci.c     Makefile $(INCS) ata.h atapi.h
    122 
    123 ata.obj:      ata.c      Makefile $(INCS) ata.h
    124 
    125 atapi.obj:    atapi.c    Makefile $(INCS) ata.h atapi.h
    126 
    127 ctxhook.obj:  ctxhook.c  Makefile $(INCS) ata.h atapi.h
    128 
    129 apm.obj:      apm.c      Makefile $(INCS)
    130 
    131 ioctl.obj:    ioctl.c    Makefile $(INCS) atapi.h ioctl.h
    132 
    133 trace.obj:    trace.c    Makefile $(INCS)
    134 
    135 os2ahci.def:  version.h  os2ahci.def.template
     122init.obj:       $*.asm  wmakefile
     123
     124libc.obj:       $*.c    wmakefile $(INCS)
     125
     126os2ahci.obj:    $*.c    wmakefile $(INCS) bldday.h ioctl.h
     127
     128pci.obj:        $*.c    wmakefile $(INCS)
     129
     130ahci.obj:       $*.c    wmakefile $(INCS) ata.h atapi.h
     131
     132ata.obj:        $*.c    wmakefile $(INCS) $*.h
     133
     134atapi.obj:      $*.c    wmakefile $(INCS) $*.h ata.h
     135
     136ctxhook.obj:    $*.c    wmakefile $(INCS) ata.h atapi.h
     137
     138apm.obj:        $*.c    wmakefile $(INCS)
     139
     140ioctl.obj:      $*.c    wmakefile $(INCS) $*.h atapi.h
     141
     142trace.obj:      $*.c    wmakefile $(INCS)
     143
     144os2ahci.def:  version.h $*.def.template
    136145
    137146###############################################################################
     
    140149# emacs TAGS file creation
    141150# NOTE: OS/2 emacs etags.exe expects an empty file named c:\dev\null...
    142 tags:   $(SRCS) $(INCS)
    143         etags.exe $(SRCS) $(INCS)
     151tags:   $(SRCS) $(INCS)
     152        etags.exe $(SRCS) $(INCS)
    144153
    145154bldday.h:
    146         $(BLDDATE) > bldday.h
     155        $(BLDDATE) > bldday.h
    147156
    148157.asm.obj:
    149         $(AS) $(AFLAGS) $(AS_INCLUDE) $*.asm
     158        $(AS) $(AFLAGS) $(AS_INCLUDE) $*.asm
     159        wdis -l $*.obj
    150160
    151161.c.obj:
    152         $(CC) $(CFLAGS) $(CC_INCLUDE) $*.c
    153         wdis -l $*.obj
     162        $(CC) $(CFLAGS) $(CC_INCLUDE) $*.c
     163        wdis -l $*.obj
    154164
    155165os2ahci.def:
    156         $(BLDLEVEL) os2ahci.def.template os2ahci.def version.h
    157 
    158 $(TARGET): $(OBJS) os2ahci.def wmakefile
    159         $(LD) $(LFLAGS) $(OBJS),$(TARGET),$*.map,$(LIB_DIRS) $(LIBS),$*.def
    160         mapsym os2ahci
    161 
    162 
     166        $(BLDLEVEL) $*.def.template $*.def version.h
     167
     168$(TARGET): $(OBJS) $*.def wmakefile
     169
     170!if "$(LINKER)"=="watcom"
     171        # Target name, system and type
     172        @%create $*.lnk
     173        @%append $*.lnk name $*.add
     174        @%append $*.lnk sys os2 dll
     175        # Merge BLDLEVEL information
     176        @%append $*.lnk option
     177        @qgrep -y -e "description" $*.def >> $*.lnk
     178        # Set various options
     179        @%append $*.lnk option protmode
     180        @%append $*.lnk option map
     181        @%append $*.lnk option quiet
     182        @%append $*.lnk option nocase
     183        @%append $*.lnk option stack=0
     184        # Generate directives for objects, libraries and library search-paths
     185        @for %f in ($(OBJS)) do @%append $*.lnk file %f
     186        @for %f in ($(LIBS)) do @%append $*.lnk lib %f
     187        @for %f in ($(LIB_DIRS)) do @%append $*.lnk libpath %f
     188        # Attributes for the DATA and CODE segments
     189        @%append $*.lnk segment type DATA SHARED
     190        @%append $*.lnk segment type CODE IOPL
     191        # Order segments by class
     192        @%append $*.lnk order
     193        @%append $*.lnk clname 'DATA'
     194        @%append $*.lnk clname 'CONST'
     195        @%append $*.lnk clname 'BSS'
     196        @%append $*.lnk clname 'CODE'
     197        # Link the stuff together and build the target
     198        wlink  @$*.lnk
     199
     200!elseif "$(LINKER)"=="ibm"
     201        $(LD) $(LFLAGS) $(OBJS),$(TARGET),$*.map,$(LIB_DIRS) $(LIBS),$*.def
     202        mapsym $*
     203!else
     204        @echo "Error: No valid linker specified"
     205!endif
     206
Note: See TracChangeset for help on using the changeset viewer.