Ignore:
Timestamp:
Mar 18, 2021, 8:57:36 PM (4 years ago)
Author:
David Azarewicz
Message:

Merge changes from Paul's uniaud32next branch.

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/drv32/startup.asm

    r577 r679  
    3737DATA16 segment
    3838                extrn DOS32FLATDS : abs                ; ring 0 FLAT kernel data selector
    39                 public __OffFinalDS16
    40                 public help_header
    41                 public uniaud_header
    42                 public _MSG_TABLE16
    43                 public DevHelpInit
    44                 public fOpen   
    45                 public InitPktSeg
    46                 public InitPktOff
    47                 public _MESSAGE_STR
    48                 public pddname16
    49                 public FileName
    50                 public _RM_Help0
    51                 public _RM_Help1
    52                 public _RM_Help3
    53                 public _RMFlags
    54 IFDEF DEBUG
    55                 public DbgU32TimerCnt
    56                 public DbgU32IntCnt
    57 ENDIF
    58 
    5939;*********************************************************************************************
    6040;************************* Device Driver Header **********************************************
    6141;*********************************************************************************************
     42                public help_header
    6243help_header     dw OFFSET DATA16:uniaud_header         ; Pointer to next driver
    6344                dw SEG DATA16:uniaud_header
     
    9273                dw 0000000000000000b
    9374
    94 uniaud_header    dd -1
     75                public uniaud_header
     76uniaud_header   dd -1
    9577                dw 1101100110000000b            ; Device attributes
    9678;                  ||||| +-+   ||||
     
    123105                dw 0000000000000000b
    124106
     107
     108                public DevHelpInit
    125109DevHelpInit     dd 0
     110
     111                public fOpen   
    126112fOpen           dd 0
     113
     114                public InitPktSeg
     115                public InitPktOff
    127116InitPktSeg      dw 0
    128117InitPktOff      dw 0
     118
    129119IFDEF DEBUG
    130 DbgU32TimerCnt dd 0
    131 DbgU32IntCnt dd 0
     120                public DbgU32TimerCnt
     121                public DbgU32IntCnt
     122DbgU32TimerCnt  dd 0
     123DbgU32IntCnt    dd 0
    132124ENDIF
     125
    133126;needed for rmcalls.lib
     127                public _RM_Help0
     128                public _RM_Help1
     129                public _RM_Help3
     130                public _RMFlags
    134131_RM_Help0       dd 0
    135132_RM_Help1       dd 0
    136133_RM_Help3       dd 0
    137134_RMFlags        dd 0
     135
     136                public _MESSAGE_STR
     137                public _MSG_TABLE16
    138138_MESSAGE_STR    db 1024 dup (0)
    139139_MSG_TABLE16    dw 0    ;message length
     
    141141                dw SEG    _MESSAGE_STR
    142142
    143 pddname16       db 'ALSA32$'
    144 FileName        db "ALSAHLP$", 0
    145 ResMgr          DB  52H,45H,53H,4dH,47H,52H,24H,20H
    146                 DB  00H
     143FileName        db 'ALSAHLP$', 0
     144ResMgr          db 'RESMGR$ ',0
     145
    147146_RMIDCTable     DB  00H,00H,00H,00H,00H,00H,00H,00H
    148147                DB  00H,00H,00H,00H
    149148
    150149;last byte in 16 bits data segment
    151 __OffFinalDS16 label byte
     150                public __OffFinalDS16
     151__OffFinalDS16  label byte
    152152
    153153DATA16 ends
    154 
     154; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
    155155CODE16 segment
    156156        assume cs:CODE16, ds:DATA16
    157157
    158         public __OffFinalCS16
    159 
    160         public help_stub_strategy
    161         public uniaud_stub_strategy
    162         public uniaud_stub_idc
    163         public uniaud_stub_timer
    164         public thunk3216_devhelp
    165         public thunk3216_devhelp_modified_ds
    166158        extrn DOSOPEN       : far
    167         extrn DOSWRITE      : far
     159        extrn _DOSWRITE     : far
    168160        extrn DOSCLOSE      : far
    169161
     
    394386        lea     dx, [bp - 2]
    395387        push    dx
    396         call    DOSWRITE
     388        call    _DOSWRITE
    397389
    398390        pop     eax
     
    413405        ALIGN   2
    414406;use devhlp pointer stored in 16 bits code segment
     407        public thunk3216_devhelp
    415408thunk3216_devhelp:
    416409        push    ds
     
    419412        call    dword ptr DevHelpInit
    420413        pop     ds
    421 
    422414        jmp     far ptr FLAT:thunk1632_devhelp
    423415
    424416        ALIGN   2
     417        public thunk3216_devhelp_modified_ds
    425418thunk3216_devhelp_modified_ds:
    426419        push    gs
     
    10201013
    10211014;end of 16 bits code segment
     1015               public __OffFinalCS16
    10221016__OffFinalCS16 label byte
    10231017
    10241018CODE16 ends
    1025 
     1019; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
     1020;Label to mark start of 32 bits code section
     1021FIRSTCODE32 segment
     1022               public __OffBeginCS32
     1023__OffBeginCS32 label byte
     1024FIRSTCODE32 ends
     1025; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
    10261026CODE32 segment
    10271027ASSUME CS:FLAT, DS:FLAT, ES:FLAT
    10281028
    1029         public __GETDS
    1030         public thunk1632_devhelp
    1031         public thunk1632_devhelp_modified_ds   
    1032         public DevHlp
    1033         public DevHlp_ModifiedDS
    1034         public STRATEGY_
    1035         public IDC_
    1036         public TIMER_
    10371029        extrn  ALSA_STRATEGY  : near
    10381030        extrn  ALSA_IDC : near
    10391031        extrn  ALSA_TIMER_ : near
    10401032        extrn  ALSA_Interrupt : near
    1041         extrn  GetTKSSBase : near
    10421033        extrn  _rdOffset: dword
    1043 
    1044 IFDEF KEE
    10451034        extrn  KernThunkStackTo16 : near
    10461035        extrn  KernThunkStackTo32 : near
    1047 ELSE
    1048         extrn  StackAlloc : near
    1049         extrn  StackFree  : near
    1050 ENDIF
    10511036
    10521037;Called by Watcom to set the DS
     
    10671052DevHelpDebug  endp
    10681053
    1069         ALIGN   4
    1070 
    1071         ALIGN 4
     1054        ALIGN 4
     1055        public DevHlp
    10721056DevHlp proc near
    1073 IFDEF FLATSTACK
    10741057        DevThunkStackTo16_Int
    1075 ENDIF
    1076 
    10771058        jmp     far ptr CODE16:thunk3216_devhelp
    10781059        ALIGN 4
    10791060thunk1632_devhelp:
    1080 IFDEF FLATSTACK
    10811061        DevThunkStackTo32_Int
    1082 ENDIF
    10831062        ret
    10841063DevHlp endp
     
    10861065        ALIGN   4
    10871066DevHlp_ModifiedDS proc near
    1088 IFDEF FLATSTACK
    10891067        DevThunkStackTo16_Int
    1090 ENDIF
    10911068        jmp     far ptr CODE16:thunk3216_devhelp_modified_ds
    10921069        ALIGN 4
    10931070thunk1632_devhelp_modified_ds:
    1094 IFDEF FLATSTACK
    10951071        DevThunkStackTo32_Int
    1096 ENDIF
    10971072        ret
    10981073DevHlp_ModifiedDS endp
    1099 
    1100 
    1101 IFNDEF KEE
    1102 ;;******************************************************************************
    1103 ;FixSelDPL:
    1104 ;
    1105 ; Set DPL of DOS32FLATDS selector to 0 or else we'll get a trap D when loading
    1106 ; it into the SS register (DPL must equal CPL when loading a selector into SS)
    1107 ;;******************************************************************************
    1108         PUBLIC FixSelDPL
    1109         ALIGN  4
    1110 FixSelDPL proc near
    1111         cmp     fWrongDPL, 1
    1112         jne     short @@fixdpl_end
    1113         cmp     SelRef, 0
    1114         jne     short @@fixdpl_endfix
    1115         push    eax
    1116         push    ebx
    1117         push    edx
    1118         sgdt    fword ptr [gdtsave]             ; access the GDT ptr
    1119         mov     ebx, dword ptr [gdtsave+2]      ; get lin addr of GDT
    1120         mov     eax, ds                         ; build offset into table
    1121         and     eax, 0fffffff8h                 ; mask away DPL
    1122         add     ebx, eax                        ; build address
    1123 
    1124         mov     eax, dword ptr [ebx+4]
    1125         mov     edx, eax
    1126         shr     edx, 13
    1127         and     edx, 3
    1128 
    1129         ;has the OS/2 kernel finally changed the DPL to 0?
    1130         cmp     edx, 0
    1131         jne     @@changedpl
    1132         mov     fWrongDPL, 0            ;don't bother anymore
    1133         mov     SelRef, 0
    1134         jmp     short @@endchange
    1135 
    1136 @@changedpl:
    1137         mov     oldDPL, eax
    1138         and     eax, NOT 6000h          ;clear bits 5 & 6 in the high word (DPL)
    1139         mov     dword ptr [ebx+4], eax
    1140 @@endchange:
    1141         pop     edx
    1142         pop     ebx
    1143         pop     eax
    1144 @@fixdpl_endfix:
    1145         inc     SelRef
    1146 @@fixdpl_end:
    1147         ret
    1148 FixSelDPL endp
    1149 ;;******************************************************************************
    1150 ; RestoreSelDPL:
    1151 ;
    1152 ;  Restore DPL of DOS32FLATDS selector or else OS/2 kernel code running in ring 3
    1153 ;  will trap (during booting only; this sel has a DPL of 0 when PM starts up)
    1154 ;;******************************************************************************
    1155         PUBLIC RestoreSelDPL
    1156         ALIGN  4
    1157 RestoreSelDPL proc near
    1158         cmp     fWrongDPL, 1
    1159         jne     short @@restdpl_end
    1160 
    1161         cmp     SelRef, 1
    1162         jne     short @@restdpl_endrest
    1163         push    eax
    1164         push    ebx
    1165         sgdt    fword ptr [gdtsave]             ; access the GDT ptr
    1166         mov     ebx, dword ptr [gdtsave+2]      ; get lin addr of GDT
    1167         mov     eax, ds                         ; build offset into table
    1168         and     eax, 0fffffff8h                 ; mask away DPL
    1169         add     ebx, eax                        ; build address
    1170 
    1171         mov     eax, oldDPL
    1172         mov     dword ptr [ebx+4], eax
    1173         pop     ebx
    1174         pop     eax
    1175 @@restdpl_endrest:
    1176         dec     SelRef
    1177 @@restdpl_end:
    1178         ret
    1179 RestoreSelDPL endp
    1180 ENDIF
    11811074
    11821075;*******************************************************************************
     
    11941087        mov  ebp, esp
    11951088        push ebx
    1196 
    11971089        lea  ebx, [ebp+8]
    11981090        DevThunkStackTo16_Int
    1199 
    12001091        push dword ptr [ebx+16]    ;param2
    12011092        push dword ptr [ebx+12]    ;param1
     
    12031094        call fword ptr [ebx]
    12041095        add  sp, 12
    1205 
    12061096        DevThunkStackTo32_Int
    1207 
    12081097        pop  ebx
    12091098        pop  ebp
     
    12221111        push    fs
    12231112        push    gs
    1224 
    12251113        mov     eax, DOS32FLATDS
    12261114        mov     ds, eax
    12271115        mov     es, eax
    1228 
    1229 IFDEF FLATSTACK
    1230 
    1231 IFNDEF KEE
    1232         ;done in init.cpp for the KEE version
    1233         cmp     dword ptr [intSwitchStack], 0
    1234         jne     stratcontinue
    1235 
    1236         ;get TKSSBase & intSwitchStack pointers
    1237         call    GetTKSSBase
    1238 stratcontinue:
    1239 ENDIF
    1240 
    12411116        DevThunkStackTo32
    1242         cmp     eax, 0
    1243         jne     @@stackswitchfail_strat
    1244 
    12451117        call    ALSA_STRATEGY
    1246 
    12471118        DevThunkStackTo16
    1248 
    1249 @@stackswitchfail_strat:
    1250 ELSE
    1251         int     3
    1252         call    ALSA_STRATEGY
    1253 ENDIF
    1254 
    12551119        pop     gs
    12561120        pop     fs
     
    12731137        push    fs
    12741138        push    gs
    1275 
    12761139        mov     eax, DOS32FLATDS
    12771140        mov     ds, eax
    12781141        mov     es, eax
    1279 
    1280 IFDEF FLATSTACK
    12811142        DevThunkStackTo32
    1282         cmp     eax, 0
    1283         jne     @@stackswitchfail_idc
    1284 
    12851143        call    ALSA_IDC
    1286 
    12871144        DevThunkStackTo16
    1288 
    1289 @@stackswitchfail_idc:
    1290 
    1291 ELSE
    1292         int     3
    1293         call    ALSA_IDC
    1294 ENDIF
    1295 
    12961145        pop     gs
    12971146        pop     fs
     
    13101159        push    fs
    13111160        push    gs
    1312 
    13131161        mov     eax, DOS32FLATDS
    13141162        mov     ds, eax
    13151163        mov     es, eax
    1316 
    13171164IFDEF DEBUG
    13181165        add     DbgU32TimerCnt, 1
    13191166ENDIF
    1320 
    1321 IFDEF FLATSTACK
    13221167        DevThunkStackTo32
    1323         cmp     eax, 0
    1324         jne     @@stackswitchfail_timer
    1325 
    13261168        call    ALSA_TIMER_
    1327 
    13281169        DevThunkStackTo16
    1329 
    1330 @@stackswitchfail_timer:
    1331 
    1332 ELSE
    1333         int     3
    1334         call    ALSA_TIMER_
    1335 ENDIF
    13361170IFDEF DEBUG
    13371171        add     DbgU32TimerCnt, -1
    13381172ENDIF
    1339 
    13401173        pop     gs
    13411174        pop     fs
     
    13551188        enter   0, 0
    13561189        and     sp, 0fffch                      ; align stack
    1357 
    13581190        pushad
    13591191        push    ds
     
    13611193        push    fs
    13621194        push    gs
    1363 
    13641195        mov     eax, DOS32FLATDS
    13651196        mov     ds, eax
    13661197        mov     es, eax
    1367 
    13681198        pushfd
    1369 
    13701199IFDEF DEBUG
    13711200                add         DbgU32IntCnt, 1
    13721201ENDIF
    1373 
    13741202        ; At this point a cli is redundant
    13751203        ; we enter the interrupt handler with interrupts disabled.
    13761204        ;cli
    1377 
    1378 IFDEF FLATSTACK
    13791205        DevThunkStackTo32
    1380         cmp     eax, 0
    1381         jne     @@stackswitchfail_irq
    1382 
    13831206        ;returns irq status in eax (1=handled; 0=unhandled)
    13841207        call    ALSA_Interrupt
    1385 
    13861208        DevThunkStackTo16
    1387 
    1388 @@stackswitchfail_irq:
    1389 ELSE
    1390         int     3
    1391         call    ALSA_Interrupt
    1392 ENDIF
    1393 
    13941209IFDEF DEBUG
    13951210                add         DbgU32IntCnt, -1
    13961211ENDIF
    1397 
    13981212        ;restore flags
    13991213        popfd
    1400 
    14011214        cmp     eax, 1
    14021215        je      irqhandled
    14031216        stc                     ;tell OS/2 kernel we didn't handle this interrupt
    14041217        jmp     short endofirq
    1405 
    14061218irqhandled:
    14071219        clc                     ;tell OS/2 kernel this interrupt was ours
    1408 
    14091220endofirq:
    1410 
    14111221        pop     gs
    14121222        pop     fs
     
    14141224        pop     ds
    14151225        popad
    1416 
    14171226        leave
    14181227        retf
     
    15721381_RMHandleToResourceHandleList endp
    15731382
     1383; shifted from devhlp.asm
     1384        extrn  DOSIODELAYCNT : ABS
     1385        ALIGN 4
     1386        public iodelay32_
     1387iodelay32_ proc near
     1388        mov   eax, DOSIODELAYCNT
     1389        align 4
     1390@@:     dec   eax
     1391        jnz   @b
     1392        loop  iodelay32_
     1393        ret
     1394iodelay32_ endp
    15741395
    15751396CODE32 ends
    1576 
     1397; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
     1398;Label to mark end of 32 bits code section
     1399LASTCODE32 segment
     1400       public __OffFinalCS32
     1401__OffFinalCS32 label byte
     1402LASTCODE32 ends
     1403; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
     1404;Label to mark start of 32 bits data section
     1405BSS32 segment
     1406    public  __OffBeginDS32
     1407    __OffBeginDS32   dd 0
     1408BSS32 ends
     1409; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
    15771410DATA32  segment
     1411
     1412    public  stackbase
     1413    public  stacksel
     1414    stackbase dd 0
     1415    stacksel  dd 0
     1416
    15781417    public  __OffsetFinalCS16
    15791418    public  __OffsetFinalDS16
    1580     public  PDDName
     1419    __OffsetFinalCS16 dw OFFSET CODE16:__OffFinalCS16
     1420    __OffsetFinalDS16 dw OFFSET DATA16:__OffFinalDS16
     1421
    15811422    public  _MSG_TABLE32
     1423    _MSG_TABLE32     dw OFFSET  DATA16:_MSG_TABLE16
     1424                     dw SEG     DATA16:_MSG_TABLE16
     1425
     1426;16:32 addresses of resource manager functions in 16 bits code segment
    15821427    public  RMAllocResource1632
    15831428    public  RMModifyResources1632
     
    15901435    public  RMDevIDToHandleList1632
    15911436    public  RMHandleToResourceHandleList1632
    1592     public  _TimerHandler16
    1593     public  _ISR00
    1594     public  _ISR01
    1595     public  _ISR02
    1596     public  _ISR03
    1597     public  _ISR04
    1598     public  _ISR05
    1599     public  _ISR06
    1600     public  _ISR07
    1601 
    1602 IFDEF FLATSTACK
    1603     extrn   intSwitchStack : dword
    1604 ENDIF
    1605 
    1606 IFDEF KEE
    1607     public  stackbase
    1608     public  stacksel
    1609 
    1610     stackbase dd 0
    1611     stacksel  dd 0
    1612 ELSE
    1613 
    1614     public  gdtsave
    1615     public  fWrongDPL
    1616     public  oldDPL
    1617     public  SelRef
    1618 
    1619     tempeax          dd 0
    1620     tempedx          dd 0
    1621     tempesi          dd 0
    1622     cpuflags         dd 0
    1623 
    1624     gdtsave          dq 0
    1625     fWrongDPL        dd 1       ;DOS32FLATDS has the wrong DPL for SS
    1626     SelRef           dd 0
    1627     oldDPL           dd 0
    1628 
    1629     fInitStack       dd 0
    1630 ENDIF
    1631 
    1632     __OffsetFinalCS16 dw OFFSET CODE16:__OffFinalCS16
    1633     __OffsetFinalDS16 dw OFFSET DATA16:__OffFinalDS16
    1634 
    1635     _MSG_TABLE32     dw OFFSET  DATA16:_MSG_TABLE16
    1636                      dw SEG     DATA16:_MSG_TABLE16
    1637 
    1638 ;16:16 address of driver name
    1639     PDDName          dw OFFSET  DATA16:pddname16
    1640                      dw SEG     DATA16:pddname16
    1641 
    1642 ;16:32 addresses of resource manager functions in 16 bits code segment
    16431437    RMAllocResource1632  dd OFFSET CODE16:_RMAllocResource16
    16441438                         dw SEG CODE16:_RMAllocResource16
     
    16741468
    16751469;16:16 address of uniaud_stub_timer
     1470    public  _TimerHandler16
    16761471    _TimerHandler16      dd OFFSET CODE16:uniaud_stub_timer
    16771472                         dw OFFSET CODE16:uniaud_stub_timer
    16781473
    16791474;16:16 addresses of interrupt dispatchers
     1475    public  _ISR00
     1476    public  _ISR01
     1477    public  _ISR02
     1478    public  _ISR03
     1479    public  _ISR04
     1480    public  _ISR05
     1481    public  _ISR06
     1482    public  _ISR07
    16801483    _ISR00               dw OFFSET CODE16:ISR00_16
    16811484                         dw SEG CODE16:ISR00_16
     
    16941497    _ISR07               dw OFFSET CODE16:ISR07_16
    16951498                         dw SEG CODE16:ISR07_16
    1696 DATA32 ends
    1697 
    1698 end
    1699 
     1499DATA32     ends
     1500; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
     1501;Label to mark end of 32 bits data section
     1502LASTDATA32 segment
     1503    public __OffFinalDS32
     1504    __OffFinalDS32 dd 0
     1505LASTDATA32 ends
     1506
     1507           end
Note: See TracChangeset for help on using the changeset viewer.