Changeset 679 for GPL/trunk/drv32/startup.asm
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (4 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-linux-3.2.102 (added) merged: 611-614 /GPL/branches/uniaud32-next (added) merged: 615-678
- Property svn:mergeinfo changed
-
GPL/trunk/drv32/startup.asm
r577 r679 37 37 DATA16 segment 38 38 extrn DOS32FLATDS : abs ; ring 0 FLAT kernel data selector 39 public __OffFinalDS1640 public help_header41 public uniaud_header42 public _MSG_TABLE1643 public DevHelpInit44 public fOpen45 public InitPktSeg46 public InitPktOff47 public _MESSAGE_STR48 public pddname1649 public FileName50 public _RM_Help051 public _RM_Help152 public _RM_Help353 public _RMFlags54 IFDEF DEBUG55 public DbgU32TimerCnt56 public DbgU32IntCnt57 ENDIF58 59 39 ;********************************************************************************************* 60 40 ;************************* Device Driver Header ********************************************** 61 41 ;********************************************************************************************* 42 public help_header 62 43 help_header dw OFFSET DATA16:uniaud_header ; Pointer to next driver 63 44 dw SEG DATA16:uniaud_header … … 92 73 dw 0000000000000000b 93 74 94 uniaud_header dd -1 75 public uniaud_header 76 uniaud_header dd -1 95 77 dw 1101100110000000b ; Device attributes 96 78 ; ||||| +-+ |||| … … 123 105 dw 0000000000000000b 124 106 107 108 public DevHelpInit 125 109 DevHelpInit dd 0 110 111 public fOpen 126 112 fOpen dd 0 113 114 public InitPktSeg 115 public InitPktOff 127 116 InitPktSeg dw 0 128 117 InitPktOff dw 0 118 129 119 IFDEF DEBUG 130 DbgU32TimerCnt dd 0 131 DbgU32IntCnt dd 0 120 public DbgU32TimerCnt 121 public DbgU32IntCnt 122 DbgU32TimerCnt dd 0 123 DbgU32IntCnt dd 0 132 124 ENDIF 125 133 126 ;needed for rmcalls.lib 127 public _RM_Help0 128 public _RM_Help1 129 public _RM_Help3 130 public _RMFlags 134 131 _RM_Help0 dd 0 135 132 _RM_Help1 dd 0 136 133 _RM_Help3 dd 0 137 134 _RMFlags dd 0 135 136 public _MESSAGE_STR 137 public _MSG_TABLE16 138 138 _MESSAGE_STR db 1024 dup (0) 139 139 _MSG_TABLE16 dw 0 ;message length … … 141 141 dw SEG _MESSAGE_STR 142 142 143 pddname16 db 'ALSA32$' 144 FileName db "ALSAHLP$", 0 145 ResMgr DB 52H,45H,53H,4dH,47H,52H,24H,20H 146 DB 00H 143 FileName db 'ALSAHLP$', 0 144 ResMgr db 'RESMGR$ ',0 145 147 146 _RMIDCTable DB 00H,00H,00H,00H,00H,00H,00H,00H 148 147 DB 00H,00H,00H,00H 149 148 150 149 ;last byte in 16 bits data segment 151 __OffFinalDS16 label byte 150 public __OffFinalDS16 151 __OffFinalDS16 label byte 152 152 153 153 DATA16 ends 154 154 ; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ 155 155 CODE16 segment 156 156 assume cs:CODE16, ds:DATA16 157 157 158 public __OffFinalCS16159 160 public help_stub_strategy161 public uniaud_stub_strategy162 public uniaud_stub_idc163 public uniaud_stub_timer164 public thunk3216_devhelp165 public thunk3216_devhelp_modified_ds166 158 extrn DOSOPEN : far 167 extrn DOSWRITE: far159 extrn _DOSWRITE : far 168 160 extrn DOSCLOSE : far 169 161 … … 394 386 lea dx, [bp - 2] 395 387 push dx 396 call DOSWRITE388 call _DOSWRITE 397 389 398 390 pop eax … … 413 405 ALIGN 2 414 406 ;use devhlp pointer stored in 16 bits code segment 407 public thunk3216_devhelp 415 408 thunk3216_devhelp: 416 409 push ds … … 419 412 call dword ptr DevHelpInit 420 413 pop ds 421 422 414 jmp far ptr FLAT:thunk1632_devhelp 423 415 424 416 ALIGN 2 417 public thunk3216_devhelp_modified_ds 425 418 thunk3216_devhelp_modified_ds: 426 419 push gs … … 1020 1013 1021 1014 ;end of 16 bits code segment 1015 public __OffFinalCS16 1022 1016 __OffFinalCS16 label byte 1023 1017 1024 1018 CODE16 ends 1025 1019 ; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ 1020 ;Label to mark start of 32 bits code section 1021 FIRSTCODE32 segment 1022 public __OffBeginCS32 1023 __OffBeginCS32 label byte 1024 FIRSTCODE32 ends 1025 ; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ 1026 1026 CODE32 segment 1027 1027 ASSUME CS:FLAT, DS:FLAT, ES:FLAT 1028 1028 1029 public __GETDS1030 public thunk1632_devhelp1031 public thunk1632_devhelp_modified_ds1032 public DevHlp1033 public DevHlp_ModifiedDS1034 public STRATEGY_1035 public IDC_1036 public TIMER_1037 1029 extrn ALSA_STRATEGY : near 1038 1030 extrn ALSA_IDC : near 1039 1031 extrn ALSA_TIMER_ : near 1040 1032 extrn ALSA_Interrupt : near 1041 extrn GetTKSSBase : near1042 1033 extrn _rdOffset: dword 1043 1044 IFDEF KEE1045 1034 extrn KernThunkStackTo16 : near 1046 1035 extrn KernThunkStackTo32 : near 1047 ELSE1048 extrn StackAlloc : near1049 extrn StackFree : near1050 ENDIF1051 1036 1052 1037 ;Called by Watcom to set the DS … … 1067 1052 DevHelpDebug endp 1068 1053 1069 ALIGN 4 1070 1071 ALIGN 4 1054 ALIGN 4 1055 public DevHlp 1072 1056 DevHlp proc near 1073 IFDEF FLATSTACK1074 1057 DevThunkStackTo16_Int 1075 ENDIF1076 1077 1058 jmp far ptr CODE16:thunk3216_devhelp 1078 1059 ALIGN 4 1079 1060 thunk1632_devhelp: 1080 IFDEF FLATSTACK1081 1061 DevThunkStackTo32_Int 1082 ENDIF1083 1062 ret 1084 1063 DevHlp endp … … 1086 1065 ALIGN 4 1087 1066 DevHlp_ModifiedDS proc near 1088 IFDEF FLATSTACK1089 1067 DevThunkStackTo16_Int 1090 ENDIF1091 1068 jmp far ptr CODE16:thunk3216_devhelp_modified_ds 1092 1069 ALIGN 4 1093 1070 thunk1632_devhelp_modified_ds: 1094 IFDEF FLATSTACK1095 1071 DevThunkStackTo32_Int 1096 ENDIF1097 1072 ret 1098 1073 DevHlp_ModifiedDS endp 1099 1100 1101 IFNDEF KEE1102 ;;******************************************************************************1103 ;FixSelDPL:1104 ;1105 ; Set DPL of DOS32FLATDS selector to 0 or else we'll get a trap D when loading1106 ; it into the SS register (DPL must equal CPL when loading a selector into SS)1107 ;;******************************************************************************1108 PUBLIC FixSelDPL1109 ALIGN 41110 FixSelDPL proc near1111 cmp fWrongDPL, 11112 jne short @@fixdpl_end1113 cmp SelRef, 01114 jne short @@fixdpl_endfix1115 push eax1116 push ebx1117 push edx1118 sgdt fword ptr [gdtsave] ; access the GDT ptr1119 mov ebx, dword ptr [gdtsave+2] ; get lin addr of GDT1120 mov eax, ds ; build offset into table1121 and eax, 0fffffff8h ; mask away DPL1122 add ebx, eax ; build address1123 1124 mov eax, dword ptr [ebx+4]1125 mov edx, eax1126 shr edx, 131127 and edx, 31128 1129 ;has the OS/2 kernel finally changed the DPL to 0?1130 cmp edx, 01131 jne @@changedpl1132 mov fWrongDPL, 0 ;don't bother anymore1133 mov SelRef, 01134 jmp short @@endchange1135 1136 @@changedpl:1137 mov oldDPL, eax1138 and eax, NOT 6000h ;clear bits 5 & 6 in the high word (DPL)1139 mov dword ptr [ebx+4], eax1140 @@endchange:1141 pop edx1142 pop ebx1143 pop eax1144 @@fixdpl_endfix:1145 inc SelRef1146 @@fixdpl_end:1147 ret1148 FixSelDPL endp1149 ;;******************************************************************************1150 ; RestoreSelDPL:1151 ;1152 ; Restore DPL of DOS32FLATDS selector or else OS/2 kernel code running in ring 31153 ; will trap (during booting only; this sel has a DPL of 0 when PM starts up)1154 ;;******************************************************************************1155 PUBLIC RestoreSelDPL1156 ALIGN 41157 RestoreSelDPL proc near1158 cmp fWrongDPL, 11159 jne short @@restdpl_end1160 1161 cmp SelRef, 11162 jne short @@restdpl_endrest1163 push eax1164 push ebx1165 sgdt fword ptr [gdtsave] ; access the GDT ptr1166 mov ebx, dword ptr [gdtsave+2] ; get lin addr of GDT1167 mov eax, ds ; build offset into table1168 and eax, 0fffffff8h ; mask away DPL1169 add ebx, eax ; build address1170 1171 mov eax, oldDPL1172 mov dword ptr [ebx+4], eax1173 pop ebx1174 pop eax1175 @@restdpl_endrest:1176 dec SelRef1177 @@restdpl_end:1178 ret1179 RestoreSelDPL endp1180 ENDIF1181 1074 1182 1075 ;******************************************************************************* … … 1194 1087 mov ebp, esp 1195 1088 push ebx 1196 1197 1089 lea ebx, [ebp+8] 1198 1090 DevThunkStackTo16_Int 1199 1200 1091 push dword ptr [ebx+16] ;param2 1201 1092 push dword ptr [ebx+12] ;param1 … … 1203 1094 call fword ptr [ebx] 1204 1095 add sp, 12 1205 1206 1096 DevThunkStackTo32_Int 1207 1208 1097 pop ebx 1209 1098 pop ebp … … 1222 1111 push fs 1223 1112 push gs 1224 1225 1113 mov eax, DOS32FLATDS 1226 1114 mov ds, eax 1227 1115 mov es, eax 1228 1229 IFDEF FLATSTACK1230 1231 IFNDEF KEE1232 ;done in init.cpp for the KEE version1233 cmp dword ptr [intSwitchStack], 01234 jne stratcontinue1235 1236 ;get TKSSBase & intSwitchStack pointers1237 call GetTKSSBase1238 stratcontinue:1239 ENDIF1240 1241 1116 DevThunkStackTo32 1242 cmp eax, 01243 jne @@stackswitchfail_strat1244 1245 1117 call ALSA_STRATEGY 1246 1247 1118 DevThunkStackTo16 1248 1249 @@stackswitchfail_strat:1250 ELSE1251 int 31252 call ALSA_STRATEGY1253 ENDIF1254 1255 1119 pop gs 1256 1120 pop fs … … 1273 1137 push fs 1274 1138 push gs 1275 1276 1139 mov eax, DOS32FLATDS 1277 1140 mov ds, eax 1278 1141 mov es, eax 1279 1280 IFDEF FLATSTACK1281 1142 DevThunkStackTo32 1282 cmp eax, 01283 jne @@stackswitchfail_idc1284 1285 1143 call ALSA_IDC 1286 1287 1144 DevThunkStackTo16 1288 1289 @@stackswitchfail_idc:1290 1291 ELSE1292 int 31293 call ALSA_IDC1294 ENDIF1295 1296 1145 pop gs 1297 1146 pop fs … … 1310 1159 push fs 1311 1160 push gs 1312 1313 1161 mov eax, DOS32FLATDS 1314 1162 mov ds, eax 1315 1163 mov es, eax 1316 1317 1164 IFDEF DEBUG 1318 1165 add DbgU32TimerCnt, 1 1319 1166 ENDIF 1320 1321 IFDEF FLATSTACK1322 1167 DevThunkStackTo32 1323 cmp eax, 01324 jne @@stackswitchfail_timer1325 1326 1168 call ALSA_TIMER_ 1327 1328 1169 DevThunkStackTo16 1329 1330 @@stackswitchfail_timer:1331 1332 ELSE1333 int 31334 call ALSA_TIMER_1335 ENDIF1336 1170 IFDEF DEBUG 1337 1171 add DbgU32TimerCnt, -1 1338 1172 ENDIF 1339 1340 1173 pop gs 1341 1174 pop fs … … 1355 1188 enter 0, 0 1356 1189 and sp, 0fffch ; align stack 1357 1358 1190 pushad 1359 1191 push ds … … 1361 1193 push fs 1362 1194 push gs 1363 1364 1195 mov eax, DOS32FLATDS 1365 1196 mov ds, eax 1366 1197 mov es, eax 1367 1368 1198 pushfd 1369 1370 1199 IFDEF DEBUG 1371 1200 add DbgU32IntCnt, 1 1372 1201 ENDIF 1373 1374 1202 ; At this point a cli is redundant 1375 1203 ; we enter the interrupt handler with interrupts disabled. 1376 1204 ;cli 1377 1378 IFDEF FLATSTACK1379 1205 DevThunkStackTo32 1380 cmp eax, 01381 jne @@stackswitchfail_irq1382 1383 1206 ;returns irq status in eax (1=handled; 0=unhandled) 1384 1207 call ALSA_Interrupt 1385 1386 1208 DevThunkStackTo16 1387 1388 @@stackswitchfail_irq:1389 ELSE1390 int 31391 call ALSA_Interrupt1392 ENDIF1393 1394 1209 IFDEF DEBUG 1395 1210 add DbgU32IntCnt, -1 1396 1211 ENDIF 1397 1398 1212 ;restore flags 1399 1213 popfd 1400 1401 1214 cmp eax, 1 1402 1215 je irqhandled 1403 1216 stc ;tell OS/2 kernel we didn't handle this interrupt 1404 1217 jmp short endofirq 1405 1406 1218 irqhandled: 1407 1219 clc ;tell OS/2 kernel this interrupt was ours 1408 1409 1220 endofirq: 1410 1411 1221 pop gs 1412 1222 pop fs … … 1414 1224 pop ds 1415 1225 popad 1416 1417 1226 leave 1418 1227 retf … … 1572 1381 _RMHandleToResourceHandleList endp 1573 1382 1383 ; shifted from devhlp.asm 1384 extrn DOSIODELAYCNT : ABS 1385 ALIGN 4 1386 public iodelay32_ 1387 iodelay32_ proc near 1388 mov eax, DOSIODELAYCNT 1389 align 4 1390 @@: dec eax 1391 jnz @b 1392 loop iodelay32_ 1393 ret 1394 iodelay32_ endp 1574 1395 1575 1396 CODE32 ends 1576 1397 ; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ 1398 ;Label to mark end of 32 bits code section 1399 LASTCODE32 segment 1400 public __OffFinalCS32 1401 __OffFinalCS32 label byte 1402 LASTCODE32 ends 1403 ; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ 1404 ;Label to mark start of 32 bits data section 1405 BSS32 segment 1406 public __OffBeginDS32 1407 __OffBeginDS32 dd 0 1408 BSS32 ends 1409 ; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ 1577 1410 DATA32 segment 1411 1412 public stackbase 1413 public stacksel 1414 stackbase dd 0 1415 stacksel dd 0 1416 1578 1417 public __OffsetFinalCS16 1579 1418 public __OffsetFinalDS16 1580 public PDDName 1419 __OffsetFinalCS16 dw OFFSET CODE16:__OffFinalCS16 1420 __OffsetFinalDS16 dw OFFSET DATA16:__OffFinalDS16 1421 1581 1422 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 1582 1427 public RMAllocResource1632 1583 1428 public RMModifyResources1632 … … 1590 1435 public RMDevIDToHandleList1632 1591 1436 public RMHandleToResourceHandleList1632 1592 public _TimerHandler161593 public _ISR001594 public _ISR011595 public _ISR021596 public _ISR031597 public _ISR041598 public _ISR051599 public _ISR061600 public _ISR071601 1602 IFDEF FLATSTACK1603 extrn intSwitchStack : dword1604 ENDIF1605 1606 IFDEF KEE1607 public stackbase1608 public stacksel1609 1610 stackbase dd 01611 stacksel dd 01612 ELSE1613 1614 public gdtsave1615 public fWrongDPL1616 public oldDPL1617 public SelRef1618 1619 tempeax dd 01620 tempedx dd 01621 tempesi dd 01622 cpuflags dd 01623 1624 gdtsave dq 01625 fWrongDPL dd 1 ;DOS32FLATDS has the wrong DPL for SS1626 SelRef dd 01627 oldDPL dd 01628 1629 fInitStack dd 01630 ENDIF1631 1632 __OffsetFinalCS16 dw OFFSET CODE16:__OffFinalCS161633 __OffsetFinalDS16 dw OFFSET DATA16:__OffFinalDS161634 1635 _MSG_TABLE32 dw OFFSET DATA16:_MSG_TABLE161636 dw SEG DATA16:_MSG_TABLE161637 1638 ;16:16 address of driver name1639 PDDName dw OFFSET DATA16:pddname161640 dw SEG DATA16:pddname161641 1642 ;16:32 addresses of resource manager functions in 16 bits code segment1643 1437 RMAllocResource1632 dd OFFSET CODE16:_RMAllocResource16 1644 1438 dw SEG CODE16:_RMAllocResource16 … … 1674 1468 1675 1469 ;16:16 address of uniaud_stub_timer 1470 public _TimerHandler16 1676 1471 _TimerHandler16 dd OFFSET CODE16:uniaud_stub_timer 1677 1472 dw OFFSET CODE16:uniaud_stub_timer 1678 1473 1679 1474 ;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 1680 1483 _ISR00 dw OFFSET CODE16:ISR00_16 1681 1484 dw SEG CODE16:ISR00_16 … … 1694 1497 _ISR07 dw OFFSET CODE16:ISR07_16 1695 1498 dw SEG CODE16:ISR07_16 1696 DATA32 ends 1697 1698 end 1699 1499 DATA32 ends 1500 ; ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ 1501 ;Label to mark end of 32 bits data section 1502 LASTDATA32 segment 1503 public __OffFinalDS32 1504 __OffFinalDS32 dd 0 1505 LASTDATA32 ends 1506 1507 end
Note:
See TracChangeset
for help on using the changeset viewer.