Changeset 144 for trunk


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.

Location:
trunk/src/os2ahci
Files:
2 added
7 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/os2ahci/Makefile

    r143 r144  
    5555               -I$(DDK)\base\src\dev\dasd\diskh \
    5656               -I$(DDK)\base\src\dev\thinkpad\dockii\apmcalls \
    57                -I$(CC16)\include
     57#               -I$(CC16)\include
    5858
    5959AS_INCLUDE   = -I:$(DDK)\base\inc \
     
    6363               $(DDK)\base\src\dev\dasd\devhlp\ \
    6464               $(DDK)\base\src\dev\thinkpad\dockii\apmcalls\ \
    65                $(CC16)\lib\ \
     65#               $(CC16)\lib\ \
    6666
    6767
     
    8585
    8686clean:
    87         rm -f $(OBJS) $(TARGET) *.cod *.lst *.def *.map *.sym bldday.h
     87        rm -f $(OBJS) $(TARGET) *.cod *.lst *.def *.map *.sym *.err *.lnk \
     88                bldday.h
    8889
    8990
     
    132133.asm.obj:
    133134        $(AS) $(AFLAGS) $(AS_INCLUDE) $*.asm
     135        wdis -l $*.obj
    134136
    135137.c.obj:
    136138        $(CC) $(CFLAGS) $(CC_INCLUDE) $*.c
     139        wdis -l $*.obj
    137140
    138141os2ahci.def:
     
    143146        $(LD) $(LFLAGS) $(OBJS),$(TARGET),$*.map,$(LIB_DIRS) $(LIBS),$*.def
    144147        $(MAPSYM) os2ahci
    145 
    146 
  • trunk/src/os2ahci/_ibuild.cmd

    r143 r144  
    11@echo off
    22nmake
     3
  • trunk/src/os2ahci/ahci.c

    r121 r144  
    14671467  }
    14681468
    1469   dprintf("port #%d interrupt error status: 0x%08lx; restarting port\n", 
     1469  dprintf("port #%d interrupt error status: 0x%08lx; restarting port\n",
    14701470          p, irq_stat);
    14711471
  • trunk/src/os2ahci/init.asm

    r141 r144  
    88; Constants
    99                DEV_IDC  EQU    0400h        ;  IDC bit for ADD flags
    10        
     10
    1111; -----------------------------------------------------------------------------
    1212; Public symbols
    1313
    1414                PUBLIC  _asm_strat           ; low-level strategy routine
    15                 PUBLIC  _asm_idc_entry       ; low-level IDC entry point 
     15                PUBLIC  _asm_idc_entry       ; low-level IDC entry point
    1616                PUBLIC  _asm_krnl_exit       ; low-level kernel exit routine
    1717                PUBLIC  _readl               ; MMIO read (32 bits)
     
    2929                PUBLIC  _end_of_data         ; end of all data (label)
    3030                PUBLIC  _end_of_code         ; end of all code (label)
    31        
     31
    3232; ----------------------------------------------------------------------------
    3333; Device Driver Header
     
    6565; such as C.
    6666
     67; When using the Watcom Linker, the segment ordering can be overridden in
     68; the Watcom Makefile (wmakefile) where the Linker response-file is generated
     69; containing statements for segment ordering. First you can order by class and
     70; for each class you can specify the order of the segments within that class.
     71; See the ORDER directive in the wlink documentation.
    6772_DATA           SEGMENT WORD PUBLIC 'DATA'
    6873readl_dbg_fmt   db      "readl(%04x:%04x) = 0x%08lx"
     
    7277_DATA           ENDS
    7378
     79LIBDATA         SEGMENT WORD PUBLIC 'DATA'
     80LIBDATA         ENDS
     81
    7482CONST           SEGMENT WORD PUBLIC 'CONST'
    7583CONST           ENDS
     
    8391
    8492_z_data         SEGMENT WORD PUBLIC 'BSS'
    85 _end_of_data    db      0
     93_end_of_data    db      ?
    8694_z_data         ENDS
    8795
     
    98106CODE            ENDS
    99107
     108LIBCODE         SEGMENT WORD PUBLIC 'CODE'
     109LIBCODE         ENDS
     110
    100111RMCode          SEGMENT WORD PUBLIC 'CODE'
    101112RMCode          ENDS
    102 
    103 LIBCODE         SEGMENT WORD PUBLIC 'CODE'
    104 LIBCODE         ENDS
    105113
    106114_z_text         SEGMENT WORD PUBLIC 'CODE'
     
    108116_z_text         ENDS
    109117
    110 DGROUP          GROUP   DEVHDR, _DATA, CONST, _BSS, c_common, _z_data
    111 TGROUP          GROUP   _TEXT, CODE, _z_text
     118
     119; The Watcom Linker behaves differently than the IBM/MS Linkers when segments
     120; are defined but not added to the corresponding group. So when you define a
     121; a new (logical) segment and want it to be part of a physical segment (group)
     122; then don't forget to add it below or unresolvable or miscalculated
     123; relocations can be the result.
     124DGROUP          GROUP   DEVHDR, _DATA, LIBDATA, _BSS, c_common, _z_data
     125TGROUP          GROUP   _TEXT, CODE, LIBCODE, RMCode, _z_text
     126
    112127
    113128; ----------------------------------------------------------------------------
     
    140155; IDC entry point (Assembler stub)
    141156_asm_idc_entry  PROC    FAR
    142        
     157
    143158                ; push request packet address
    144159                PUSH    ES
     
    171186
    172187                RET
    173 _asm_krnl_exit  ENDP       
    174        
     188_asm_krnl_exit  ENDP
     189
    175190
    176191                .386
     
    293308
    294309
    295 ; Halfway-decent 32-bit implementation of memcpy(). 
     310; Halfway-decent 32-bit implementation of memcpy().
    296311;
    297312; C prototype: void *memcpy(void _far *d, void _far *s, size_t n);
     
    377392
    378393
    379 ; Unsigned long divide routine; 
     394; Unsigned long divide routine;
    380395; taken from OS/2 Uniaud project, original author: Timur Tabi
    381396__U4D           proc    near
     
    394409                ret
    395410__U4D           endp
    396        
    397 ; Long multiply routine; 
     411
     412; Long multiply routine;
    398413; taken from OS/2 Uniaud project, original author: Timur Tabi
    399414__U4M           proc    near
     
    412427
    413428
    414 ; Signed long divide routine; 
     429; Signed long divide routine;
    415430; taken from OS/2 Uniaud project, original author: Timur Tabi
    416431__I4D           proc    near
     
    429444                ret
    430445__I4D           endp
    431        
     446
    432447                .286
    433448
  • trunk/src/os2ahci/os2ahci.c

    r141 r144  
    164164    rc = char_dev_input((RP_RWV _far *) req);
    165165    break;
    166    
     166
    167167  default:
    168168    rc = STDON | STATUS_ERR_UNKCMD;
     
    358358
    359359#ifdef ECS_BUILD
    360   ciprintf("This driver is licensed for use only in conjunction with eComStation.");
     360  ciprintf("This driver is licensed for use only in conjunction with eComStation.\n");
     361#else
     362  ciprintf("This is the Open Watcom build.\n");
    361363#endif
    362364
     
    455457
    456458    case OS2AHCI_IDC_BIOSMODE:
    457       /* reconfigure adapters in BIOS/int13 mode; needed for generating 
     459      /* reconfigure adapters in BIOS/int13 mode; needed for generating
    458460       * trap dumps on some machines. This is called by ACPI.PSD.
    459461       *
    460462       * To enter BIOS mode, we flush all write caches, turn off interrupts
    461        * and restore the BIOS configuration. This is exactly what 
     463       * and restore the BIOS configuration. This is exactly what
    462464       * apm_suspend() does.
    463465       */
     
    474476  case DSKSP_CAT_GENERIC:
    475477    return(ioctl_gen_dsk(ioctl));
    476    
     478
    477479  case DSKSP_CAT_SMART:
    478480    return(ioctl_smart(ioctl));
     
    15211523{
    15221524  _asm {
    1523 
    15241525    push ds
    15251526    push es
     
    15331534    mov si, OFFSET asm_krnl_exit
    15341535    mov dl, DevHlp_RegisterKrnlExit
    1535     call Device_Help
     1536
     1537    call dword ptr [Device_Help]
    15361538
    15371539    pop  di
  • trunk/src/os2ahci/os2ahci.def.template

    r95 r144  
    44
    55segments
    6   DEVHDR        CLASS 'DATA'
    7   _DATA         CLASS 'DATA'
    8   CONST         CLASS 'CONST'
    9   _BSS          CLASS 'BSS'
    10   c_common      CLASS 'BSS'
    11   _z_data       CLASS 'BSS'
    12   _TEXT         CLASS 'CODE' IOPL
     6  'DEVHDR'      CLASS 'DATA'
     7  '_DATA'       CLASS 'DATA'
     8  'LIBDATA'     CLASS 'DATA'
     9  'CONST'       CLASS 'CONST'
     10  '_BSS'        CLASS 'BSS'
     11  'c_common'    CLASS 'BSS'
     12  '_z_data'     CLASS 'BSS'
     13  '_TEXT'       CLASS 'CODE' IOPL
    1314  'CODE'        CLASS 'CODE' IOPL
    14   RMCode        CLASS 'CODE' IOPL
    15   LIBCODE       CLASS 'CODE' IOPL
    16   _z_text       CLASS 'CODE' IOPL
    17 
     15  'LIBCODE'     CLASS 'CODE' IOPL
     16  'RMCode'      CLASS 'CODE' IOPL
     17  '_z_text'     CLASS 'CODE' IOPL
  • trunk/src/os2ahci/os2ahci.h

    r141 r144  
    2828
    2929/* IMPORTANT NOTE: The DDK headers require tight structure packing and this
    30  * is controlled via compiler parameters. Thus, all stuctures in os2ahci.sys
     30 * is controlled via compiler parameters. Thus, all stuctures in os2ahci.add
    3131 * are expected to be byte-aligned without the need of explicit pragma pack()
    3232 * directives. Where possible, the structures are layed out such that words
     
    4949#include <reqpkt.h>
    5050
     51/* NOTE: (Rousseau)
     52 * The regular dhcalls.h from $(DDK)\base\h also works.
     53 * The devhelp.h from $(DDK)\base\h produces inline assembler errors.
     54 * The modified devhelp.h from ..\include works OK and is used because it
     55 * generates a slightly smaller driver image.
     56 */
    5157#ifdef __WATCOMC__
    5258/* include WATCOM specific DEVHELP stubs */
     
    106112#define dddphex   if (debug > 2) phex
    107113
    108 /* verbosity console print macros 
     114/* verbosity console print macros
    109115 * (we use 'i' in ciprintf here to avoid name clash
    110116 * with vprintf-like funcs)
     
    380386  SG_TO_BUF,                           /* copy from S/G list to buffer */
    381387  BUF_TO_SG                            /* copy from buffer to S/G list */
    382 } SG_MEMCPY_DIRECTION; 
     388} SG_MEMCPY_DIRECTION;
    383389
    384390/* -------------------------- function prototypes -------------------------- */
  • 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.