home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / SCREENDD / SVGAROUT.ASM < prev   
Encoding:
Assembly Source File  |  1995-04-14  |  86.0 KB  |  2,187 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT (C) Microsoft Corporation, 1989
  4. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  5. ;
  6. ;    The following IBM OS/2 WARP source code is provided to you solely for
  7. ;    the purpose of assisting you in your development of OS/2 WARP device
  8. ;    drivers. You may use this code in accordance with the IBM License
  9. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  10. ;    Copyright statement may not be removed.;
  11. ;*****************************************************************************/
  12. ;       CCSID = @(#)svgarout.asm       6.1 90/11/17
  13.  
  14. ; ****************************************************************************
  15. ; *                                                                          *
  16. ; *                                                                          *
  17. ; *                                                                          *
  18. ; ****************************************************************************
  19.         PAGE    58,132
  20.         TITLE   Screen Device Driver - (svgarout.Asm)
  21.         .386p
  22.  
  23. ;/***********************************************************************/
  24. ;/*                                                                     */
  25. ;/* SOURCE FILE NAME: svgarout.Asm      STATUS: Version 1.1             */
  26. ;/*                                                                     */
  27. ;/* DESCRIPTIVE NAME:  Base Video Subsystem Screen Device Driver        */
  28. ;/*                                                                     */
  29. ;/* FUNCTION:   Provide SVGA routines, called by category 80H,          */
  30. ;/*             SVGA_IOCTL listed below                                 */
  31. ;/*               GetSVGABank                                           */
  32. ;/*               SetSVGABank                                           */
  33. ;/*               GetSVGATrapIOList                                     */
  34. ;/*               SetSVGATrapIOList                                     */
  35. ;/*               GetSVGALockUnlock                                     */
  36. ;/*               SetSVGALockUnlock                                     */
  37. ;/*               GetSVGACleanup                                        */
  38. ;/*               SetSVGACleanup                                        */
  39. ;/*               GetSVGAInfo                                           */
  40. ;/*                                                                     */
  41. ;/*                                                                     */
  42. ;/* NOTES:  Executes on Level 0                                         */
  43. ;/*                                                                     */
  44. ;/* ENTRY POINT:  Screen_Strategy                                       */
  45. ;/*   LINKAGE: Far Call                                                 */
  46. ;/*                                                                     */
  47. ;/* INPUT:  ES:BX = request packet address                              */
  48. ;/*       DS = BIODATA                                                  */
  49. ;/*                                                                     */
  50. ;/* EXIT-NORMAL:                                                        */
  51. ;/*       AX = Status to return to OS                                   */
  52. ;/*                                                                     */
  53. ;/*              Error Code             Cause                           */
  54. ;/*              ------------------------------------------             */
  55. ;/*              ERROR_I24_BAD_PARAMETER Invalid Parameter              */
  56. ;/*                                                                     */
  57. ;/* EFFECTS:  None                                                      */
  58. ;/*                                                                     */
  59. ;/*   ROUTINES:  Device_Help                                            */
  60. ;/*              Device_Help (DevHlp_PhysToUVirt)                       */
  61. ;/*                                                                     */
  62. ;/************************ END OF SPECIFICATIONS ************************/
  63.  
  64. .xlist
  65.         INCLUDE basemaca.inc            ;;;;;; 2.0 unique (dosmac replacement)
  66.         INCLUDE devhlp.inc              ; Define DevHlp functions
  67.         INCLUDE devsym.inc              ; Define DOS equates
  68.         INCLUDE error.inc               ; Define Error Messages
  69.         INCLUDE struc.inc               ; Define STRUC macros
  70.         include iodelay.inc
  71.         include bsedev.inc              ;@senja
  72.         include svgadefs.inc            ;              ;          
  73.         include pci.inc              ;@senja
  74. .list
  75.  
  76. ;
  77. ; Structure definitions
  78. ;
  79. FAR_POINTER     STRUC
  80.         _OFF    DW      (?)             ; OFFSET OF FAR POINTER
  81.         _SEG    DW      (?)             ; SEGMENT OF FAR POINTER
  82. FAR_POINTER     ENDS
  83.  
  84. ;VVID_IDC argument structure. Return address is 8 bytes and save bp takes 2 bytes
  85. ;Pascal calling convention function.
  86. ulFunc          EQU     [bp+18]
  87. ulParam1        EQU     [bp+14]
  88. ulParam2        EQU     [bp+10]
  89.  
  90. Flat_Pointer    struc
  91.         fp_offlo        DW      ?
  92.         fp_offhi        DW      ?
  93.         fp_sel          DW      ?
  94. Flat_Pointer    ends
  95. IDC_SUCCESS     EQU     1
  96.  
  97. IDC_CMD_REGISTER_STACK_PROC     EQU     0       ; stack based IDC VDD-PDD EP.
  98. IDC_CMD_REGISTER_EPREGISTER     EQU     1       ; register based IDC VDD-PDD EP.
  99. ;@senja defined in the bsedev.inc
  100. ;GetLinear_Packet        STRUC
  101. ;        PacketLength    DD     0H       ; total size of data packet
  102. ;        PhysicalAddress DD     0H       ; Physical address of aperture
  103. ;        ApertureSize    DD     0H       ; Size of aperture
  104. ;        LinearAddress   DD     0H       ; Linear address of aperture (returned)
  105. ;        LinearFlags     DD     0H       ; Linear address flags (optional)
  106. ;GetLinear_Packet        ENDS
  107.  
  108. GetLinear_Packet_Size   EQU     SIZE GETLINIOCTLDATA            ;//@senja
  109. GetGlobal_Packet_Size   EQU     SIZE GlobalPktLength            ;//@senja
  110.  
  111. BANK_PARAM_PACKET_SIZE  EQU     SIZE BANKINFO                   ;//@senja
  112. VIDEO_SIZE              EQU     SIZE OEMSVGAINFO                ;//@senja
  113. SVGA_OEM_PACKET_SIZE    EQU     SIZE OEMINFO                    ;//@senja
  114.  
  115. ;
  116. ; SVGA BANK ROUTINES
  117. ; SCREENDD knows how to set or get current bank for all supported chipsets
  118. ; Routine depends on the current video mode and direction.
  119. ;
  120. ;SCREENDD_GETCURRENTBANK           EQU   0h             define in bsedev.h
  121. ;SCREENDD_SETCURRENTBANK           EQU   1h
  122.  
  123. ; parameter packet format is of _BANKINFO.
  124. ; SCREENDD_GETCURRENTBANK returns current Bank in the param packet Bank field.
  125. ; Minimum length of the packet is 8. Functions fail if less.
  126.  
  127. ;
  128. ; SVGA TRAP_IO_REGISTERS ROUTINES
  129. ; SCREENDD doesn't understand the format of the list and serves as a
  130. ; communicator only. It can not perform any operation on the list.
  131. ;
  132. SVGA_GET_TRAPIO_LIST    EQU   2h                ; if passed size of data insufficient,
  133.                                                 ; error returned and ReturnDataPacketSize set!
  134. SVGA_SET_TRAPIO_LIST    EQU   3h
  135.  
  136. ; parameter packet format is SvgaGenericPacket
  137.  
  138. ; data packet format: pointer to array of bytes of DataPacketSize.
  139. ; Only first ReturnDataPacketSize valid
  140.  
  141. ;
  142. ; SVGA LOCK/UNLOCK COMMAND SECTION ROUTINES
  143. ; SCREENDD doesn't understand the format of the lock/unlock and serves as a
  144. ; communicator only. It can not perform any operation on the command list.
  145. ;
  146. SVGA_GET_LOCK_UNLOCK    EQU   4h                ; if passed size of data insufficient,
  147.                                                 ; error returned and ReturnDataPacketSize set!
  148.  
  149. SVGA_SET_LOCK_UNLOCK    EQU   5h
  150.  
  151. ; parameter packet format SvgaGenericPacket
  152.  
  153. ; data packet format: pointer to array of bytes of DataPacketSize.
  154. ; Only first ReturnDataPacketSize valid
  155.  
  156. LOCK_COMMANDS           EQU    0H
  157. UNLOCK_COMMANDS         EQU    1H
  158. ;
  159. ; SVGA CLEANUP COMMAND SECTION ROUTINES
  160. ; SCREENDD doesn't understand the format of the cleanup and serves as a
  161. ; communicator only. It can not perform any operation on the command list.
  162. ;
  163. SVGA_GET_CLEANUP_SECT   EQU   6h                ; if passed size of data insufficient,
  164.                                                 ; error returned and ReturnDataPacketSize set!
  165. SVGA_SET_CLEANUP_SECT   EQU   7h
  166.  
  167. ; parameter packet format SvgaGenericPacket
  168.  
  169. ; data packet format: pointer to array of bytes of DataPacketSize.
  170. ; Only first ReturnDataPacketSize valid
  171.  
  172. ;
  173. ; SVGA_GET_INFO
  174. ;
  175. SCREENDD_SVGA_ID           EQU   8h
  176.  
  177. ;
  178. ; SVGA_GET_MANUFACTURER
  179. ;
  180. SCREENDD_SVGA_OEM           EQU   9h   ;           
  181. ;no parameter packet
  182.  
  183. DELIMITER      EQU     '('
  184. PERIOD         EQU     '.'
  185.  
  186. ;
  187. ; SCREENDD_UPDATE_MEMORY
  188. ;
  189. SCREENDD_UPDATE_MEMORY      EQU    0Ah              ;           
  190. ;no data packet
  191. ;parameter packet is a pointer to ULONG containing new SVGAMemory.           
  192.  
  193. ;                       end of SVGA support
  194.  
  195.         EXTRN NOPSetBank   : WORD               ; all bank routines in SVGABANK.ASM
  196.         EXTRN ATISetBank   : WORD
  197.         EXTRN CirrusSetBank: WORD
  198.         EXTRN IBMSetBank   : WORD
  199.         EXTRN S3SetBank    : WORD               ;             ;          
  200.         EXTRN TridentSetBank:WORD
  201.         EXTRN TsengSetBank : WORD
  202.         EXTRN Video7SetBank: WORD
  203.         EXTRN WDSetBank    : WORD
  204.         EXTRN WeitekSetBank: WORD                              ;/*          */
  205.  
  206.         EXTRN NOPGetBank   : WORD
  207.         EXTRN ATIGetBank   : WORD
  208.         EXTRN CirrusGetBank: WORD
  209.         EXTRN IBMGetBank   : WORD
  210.         EXTRN S3GetBank    : WORD               ;             ;          
  211.         EXTRN TridentGetBank:WORD
  212.         EXTRN TsengGetBank : WORD
  213.         EXTRN Video7GetBank: WORD
  214.         EXTRN WDGetBank    : WORD
  215.         EXTRN WeitekGetBank: WORD                              ;/*          */
  216.  
  217.         EXTRN DevHelp: DWORD
  218.         IFDEF FAMILY2                           ;           
  219.         EXTRN LID    : WORD
  220.         ENDIF
  221.  
  222.  
  223. DGROUP  GROUP   BioData
  224.  
  225. BioData SEGMENT WORD PUBLIC 'DATA' USE16
  226.         ASSUME  DS:BioData
  227.  
  228.         PUBLIC  _sSVGA                  ;                       /*          */
  229.         PUBLIC  _XGAInstance            ;                       /*          */
  230.  
  231.         EXTRN SvgaOEMInfo  : WORD       ;                       /*          */
  232.         EXTRN SvgaBaseAddr : WORD       ;                       /*          */
  233.         EXTRN DATA_END     : WORD       ;                       /*          */
  234.  
  235. PUBLIC  SVGA_SET_BANK_TABLE
  236. PUBLIC  SVGA_GET_BANK_TABLE
  237. PUBLIC  PmiInfo
  238.  
  239. DiamondWDSig    DB      'SPEEDSTAR 24X'         ;           
  240. DiamondETSig    DB      'SPEEDSTAR 24'          ;           
  241. DiamondS324Sig  DB      'STEALTH 24'            ;              ;          
  242. DiamondS3PROSig DB      'STEALTH PRO'           ;           
  243. Number9S3Sig    DB      10111101b,00110011b     ;           
  244. ArtistS3Sig     DB      'WINSPRINT 900'         ;           
  245. MIROCRYSTALSig  DB      'MIROCRYSTAL'           ;           
  246.  
  247.         align 2
  248. SVGA_FUNCTION_TABLE LABEL WORD          ; SVGA category IOCTL functions
  249.     DW  GetSVGABank             ;00h return current bank
  250.     DW  SetSVGABank             ;01h set current bank
  251.     DW  FutureSVGAFunc          ;02h return TRAP IO list for current chipset
  252.     DW  FutureSVGAFunc          ;03h save TRAP IO list for current chipset
  253.     DW  FutureSVGAFunc          ;04h return (un)lock section for current chipset
  254.     DW  FutureSVGAFunc          ;05h save (un)lock section for current chipset
  255.     DW  FutureSVGAFunc          ;06h return cleanup section for current chipset
  256.     DW  FutureSVGAFunc          ;07h save cleanup section for current chipset
  257.     DW  GetSVGAInfo             ;08h return chipset and vram size information
  258.     DW  GetOEMInfo              ;09h return chipset and vram size information
  259.     DW  UpdateMemoryInfo        ;0Ah return chipset and vram size information           
  260.     DW  GetLinearAccess         ;0Bh return linear address mapped to given physical           
  261.     DW  GetGlobalAccess         ;0Ch return global address converted from current process           
  262.     DW  FreeGlobalAccess        ;0Dh free global addresses converted from current process           
  263.     DW  RegisterRing0Caller     ;0Eh                      
  264.     DW  WaitOnRing0Caller       ;0Fh                      
  265. SVGA_FUNCTION_TABLE_SIZE        EQU ($-OFFSET SVGA_FUNCTION_TABLE)/2
  266.  
  267. SVGA_SET_BANK_TABLE     LABEL   WORD
  268.         DW      NOPSetBank
  269.         DW      Video7SetBank
  270.         DW      TridentSetBank
  271.         DW      TsengSetBank
  272.         DW      WDSetBank
  273.         DW      ATISetBank
  274.         DW      IBMSetBank
  275.         DW      CirrusSetBank
  276.         DW      S3SetBank               ;             ;          
  277.         DW      NOPSetBank              ;For Chips & Tech       /*          */
  278.         DW      WeitekSetBank           ;For Weitek             /*          */
  279.  
  280. SVGA_GET_BANK_TABLE     LABEL   WORD
  281.         DW      NOPGetBank
  282.         DW      Video7GetBank
  283.         DW      TridentGetBank
  284.         DW      TsengGetBank
  285.         DW      WDGetBank
  286.         DW      ATIGetBank
  287.         DW      IBMGetBank
  288.         DW      CirrusGetBank
  289.         DW      S3GetBank               ;             ;          
  290.         DW      NOPGetBank              ;For Chips & Tech       /*          */
  291.         DW      WeitekGetBank           ;For Weitek             /*          */
  292.  
  293. ScreenDDName    DB      "SCREEN$",0             ; 
  294. OemName         DB      "OEMHLP$ ",0            ;            must be 8 chars.
  295. IDC_ENTRY       STRUC
  296.         RealEntry   DD  ?                       ; DD Real Mode Entry Pt (Seg:Offset)
  297.         RealDS      DW  ?                       ; DD Real Mode Data Segment
  298.         ProtEntry   DD  ?                       ; DD Protect Mode Entry Pt (Sel:Offset)
  299.         ProtDS      DW  ?                       ; DD Protect Mode Data Selector
  300. IDC_ENTRY       ENDS
  301. OemDDEntry      IDC_ENTRY       <>              ;           
  302. OemDDRequest    Packet          <>              ;           
  303. pciFindClassP PciFindClassCode_P <>             ;@senja
  304. pciFindClassD PciFindClassCode_D <>             ;@senja
  305. pciReadConfigP pciReadConfig_P  <>              ;@senja
  306. pciReadConfigD pciReadConfig_D  <>              ;@senja
  307. FlatPointer     DD      0                       ; Used for GetLinearAccess
  308. FlatPtrOffset   DD      0                       ; Used for GetLinearAccess
  309. PUBLIC PCI_DeviceTbl
  310. PUBLIC PCI_Num
  311. PCI_DeviceTbl   DD      8       dup (?)         ;upto 8 PCI adapters
  312. PCI_Num         DW      0                       ;number of PCI adapters found
  313. Class_Index     DB      0                       ;Index within the same class@TSU
  314. JUNK            DB      0                       ;@TSU
  315. ; This is the class list for video. Unfortunatelly, there is no PCI subc.
  316. ; guidance which class should SVGA devices use.
  317. ; The only possible video class I've excluded is the XGA controller.
  318. ; This list is not really built as a table, since the code will keep probing in
  319. ; a specific order, in order to avoid setting up indirect addressing to walk the table.
  320. currentClass    EQU     00000101h               ; class 0, vga compatible sub-class
  321. VGAClass        EQU     00000100h               ; class 0,           
  322. SVGAClass       EQU     00030000h               ; class 3, VGA compatible sub-class
  323. XGAClass        EQU     00030100h               ; class 3, XGA Controller @TSU
  324. lastClass       EQU     00038000h               ; class 3, other display
  325. PCI_SUCCESSFUL  EQU     0                       ;@senja
  326. _sSVGA          OEMSVGAINFO <0,0,0100000H>     ;               /*          */
  327. PUBLIC  _XGAInstance
  328. _XGAInstance    DW      0               ;Speedway XGA instance  /*          */
  329. ADAPTER_TYPE    DW      0               ; Adapters found        /*          */
  330. PmiInfo         DD      _sSVGA                  ;This location will be used as the block key
  331.  
  332. BioData ends
  333.  
  334. BiosSeg SEGMENT WORD Public 'CODE' USE16
  335.         ASSUME  CS:BiosSeg
  336.  
  337. PUBLIC  GetSVGABank
  338. PUBLIC  SetSVGABank
  339.  
  340. PUBLIC  SVGA_SET_BANK_TABLE             ;                       /*          */
  341. PUBLIC  SVGA_GET_BANK_TABLE             ;                       /*          */
  342.  
  343. IF      0
  344.   PUBLIC  GetSVGATrapIOList
  345.   PUBLIC  SetSVGATrapIOList
  346.   PUBLIC  GetSVGALockUnlock
  347.   PUBLIC  SetSVGALockUnlock
  348.   PUBLIC  GetSVGACleanup
  349.   PUBLIC  SetSVGACleanup
  350. ENDIF
  351. PUBLIC  GetSVGAInfo
  352. PUBLIC  GetOEMInfo
  353. PUBLIC  UpdateMemoryInfo
  354. PUBLIC  SVGA_IOCTL
  355. PUBLIC  GetLinearAccess
  356. PUBLIC  GetGlobalAccess
  357. PUBLIC  FreeGlobalAccess
  358. PUBLIC  RegisterRing0Caller
  359. PUBLIC  WaitOnRing0Caller
  360.  
  361. PUBLIC  AttachOEM                               ;           
  362.  
  363. ;--------------------------------------------------------------------------
  364. ; SUBROUTINE NAME:      SVGA_IOCTL
  365. ;
  366. ; DESCRIPTIVE NAME:     SVGA IOCTL Routine
  367. ;
  368. ; FUNCTION:     Performs SVGA specific function requests
  369. ;
  370. ; ENTRY POINT:  SVGA_IOCTL
  371. ;    LINKAGE:   Call Near
  372. ;
  373. ; INPUT:
  374. ;       ES:BX = request packet address
  375. ;       DS = BIODATA
  376. ;
  377. ; EXIT-NORMAL:
  378. ;       AX = Status to return to OS
  379. ;
  380. ; EXIT-ERROR:
  381. ;       None
  382. ;
  383. ; EFFECTS:
  384. ;       AX
  385. ;
  386. ;    USES ROUTINES:
  387. ;               GetSVGABank
  388. ;               SetSVGABank
  389. ;               GetSVGATrapIOList
  390. ;               SetSVGATrapIOList
  391. ;               GetSVGALockUnlock
  392. ;               SetSVGALockUnlock
  393. ;               GetSVGACleanup
  394. ;               SetSVGACleanup
  395. ;               GetSVGAInfo
  396. ;               GetOEMInfo
  397. ;               UpdateMemoryInfo
  398. ;
  399. ;
  400. ;
  401. ; CALLED BY ROUTINES:
  402. ;               SCREEN_STRATEGY
  403. ;
  404.  
  405. SVGA_IOCTL      PROC    NEAR
  406.  
  407. ASSUME  DS:BioData , ES:NOTHING, SS:NOTHING
  408.  
  409. ;
  410. ; Get packet function and use appropriate table
  411. ;
  412.         mov     al, es:[bx].giofunction ; command code
  413.         .if     <al ae <svga_function_table_size>> ; if command is supported
  414.                                         ; else
  415.             mov     ax,STERR + ERROR_I24_BAD_COMMAND; unknown cmd err + error bit
  416.         .else
  417. svga_function:
  418.             mov     si, offset SVGA_FUNCTION_TABLE ; use standard routines
  419.             cbw                         ; make command code a word
  420.             shl     ax, 1               ; make command code a table offset
  421.             add     si, ax              ; si = command table offset
  422.             call    [si]                ; go do request
  423.         .endif
  424. ;
  425. ; exit
  426. ;
  427. endif_svga:
  428.         ret                                     ; return to caller.
  429.  
  430. SVGA_IOCTL      ENDP
  431.  
  432. ;--------------------------------------------------------------------------
  433. ; SUBROUTINE NAME:      VerifyDataPacket
  434. ;
  435. ; DESCRIPTIVE NAME:     Verify data packet pointer.
  436. ;
  437. ; FUNCTION:     Verify data packet.
  438. ;
  439. ; ENTRY POINT:  VerifyDataPacket
  440. ;    LINKAGE:   Call Near
  441. ;
  442. ; INPUT:
  443. ;       ES:BX = request packet address
  444. ;       CX = length to verify
  445. ;
  446. ; OUTPUT:
  447. ;       AX = STERR + ERROR_I24_INVALID_PARAMETER                /*          */
  448. ;
  449. ; EXIT-NORMAL:
  450. ;       NC.
  451. ;
  452. ; EXIT-ERROR:
  453. ;       CY
  454. ;
  455. ; EFFECTS:
  456. ;       AX, DI, DL
  457. ;
  458. ;    USES ROUTINES:
  459. ;
  460. ; CALLED BY ROUTINES:
  461. ;               Various.
  462. ;
  463. VerifyDataPacket        PROC    NEAR
  464.  
  465.         mov     ax,es:[bx].GIODataPack._SEG     ; Make sure data packet
  466.         mov     di,es:[bx].GIODataPack._OFF     ; selector is valid.
  467. ;       Drop thru to:
  468.  
  469. ;*                                                              /*          */
  470. ;--------------------------------------------------------------------------
  471. ; SUBROUTINE NAME:      VerifyPacket
  472. ;
  473. ; DESCRIPTIVE NAME:     Verify data packet pointer.
  474. ;
  475. ; FUNCTION:     Verify data packet.
  476. ;
  477. ; ENTRY POINT:  VerifyPacket
  478. ;    LINKAGE:   Call Near
  479. ;
  480. ; INPUT:
  481. ;       AX:DI = request packet address
  482. ;       CX = length to verify
  483. ;
  484. ; OUTPUT:
  485. ;       AX = STERR + ERROR_I24_INVALID_PARAMETER                /*          */
  486. ;
  487. ; EXIT-NORMAL:
  488. ;       NC.
  489. ;
  490. ; EXIT-ERROR:
  491. ;       CY
  492. ;
  493. ; EFFECTS:
  494. ;       AX, DL
  495. ;
  496. ;    USES ROUTINES:
  497. ;*              VerifyPacket                                    /*          */
  498. ;
  499. ; CALLED BY ROUTINES:
  500. ;               Various.
  501. ;
  502. VerifyPacket    PROC    NEAR
  503.  
  504.         mov     dh, 1                   ;read/write access
  505.         mov     dl,DevHlp_VerifyAccess
  506.         call    DevHelp
  507.         mov     ax,STERR + ERROR_I24_INVALID_PARAMETER ;        /*          */
  508.         ret
  509.  
  510. VerifyPacket    ENDP
  511.  
  512. VerifyDataPacket        ENDP
  513.  
  514. ;--------------------------------------------------------------------------
  515. ; SUBROUTINE NAME:      VerifyParaPacket
  516. ;
  517. ; DESCRIPTIVE NAME:     Verify parameter packet pointer.
  518. ;
  519. ; FUNCTION:     Verify parameter packet.
  520. ;
  521. ; ENTRY POINT:  VerifyParaPacket
  522. ;    LINKAGE:   Call Near
  523. ;
  524. ; INPUT:
  525. ;       ES:BX = request packet address
  526. ;       CX = length to verify
  527. ;
  528. ; OUTPUT:
  529. ;       AX = STERR + ERROR_I24_INVALID_PARAMETER                /*          */
  530. ;
  531. ; EXIT-NORMAL:
  532. ;       NC
  533. ;
  534. ; EXIT-ERROR:
  535. ;       CY
  536. ;
  537. ; EFFECTS:
  538. ;       AX, DI, DL
  539. ;
  540. ;    USES ROUTINES:
  541. ;*              VerifyPacket                                    /*          */
  542. ;
  543. ; CALLED BY ROUTINES:
  544. ;               Various.
  545. ;
  546. VerifyParaPacket        PROC    NEAR
  547.  
  548.         mov     ax,es:[bx].GIOParaPack._SEG     ; Make sure parameter packet
  549.         mov     di,es:[bx].GIOParaPack._OFF     ; selector is valid.
  550.         call    VerifyPacket
  551.         ret
  552.  
  553. VerifyParaPacket        ENDP
  554.  
  555. ;*                                                              /*          */
  556. ;--------------------------------------------------------------------------
  557. ; SUBROUTINE NAME:      VerifyVariablePacket
  558. ;
  559. ; DESCRIPTIVE NAME:     Verify parameter packet pointer.
  560. ;
  561. ; FUNCTION:     Verify parameter packet.
  562. ;
  563. ; ENTRY POINT:  VerifyVariablePacket
  564. ;    LINKAGE:   Call Near
  565. ;
  566. ; INPUT:
  567. ;       ES:BX = request packet address
  568. ;       CX = minimum length to verify
  569. ;
  570. ; OUTPUT:
  571. ;       FS:SI = ES:[BX.GIOParaPack]
  572. ;
  573. ; EXIT-NORMAL:
  574. ;       NC
  575. ;
  576. ; EXIT-ERROR:
  577. ;       AX = STERR + ERROR_I24_INVALID_PARAMETER                /*          */
  578. ;       CY
  579. ;
  580. ; EFFECTS:
  581. ;       AX, DI, DL
  582. ;
  583. ;    USES ROUTINES:
  584. ;*              VerifyParaPacket                                /*          */
  585. ;
  586. ; CALLED BY ROUTINES:
  587. ;               Various.
  588. ;
  589. VerifyVariablePacket    PROC    NEAR
  590.  
  591.         call    VerifyParaPacket        ;           
  592.         .if     <nc>
  593.             lfs     si, es:[bx].GIOParaPack ; verify the whole packet.
  594.             mov     ax, word ptr fs:[si].ulBankLength    ;           
  595.             .if     <cx b ax>
  596.                 mov     cx, ax
  597.                 call    VerifyParaPacket;            function requires es:bx=req.p.
  598.                                         ; and ds local data segment
  599.             .endif
  600.         .endif
  601.         ret
  602.  
  603. VerifyVariablePacket        ENDP
  604.  
  605. ;*                                                              /*          */
  606. ;--------------------------------------------------------------------------
  607. ; SUBROUTINE NAME:      VerifyBank
  608. ;
  609. ; DESCRIPTIVE NAME:     Verify data packet bank info.
  610. ;
  611. ; FUNCTION:     Verify data packet bank info.
  612. ;
  613. ; ENTRY POINT:  VerifyBank
  614. ;    LINKAGE:   Call Near
  615. ;
  616. ; INPUT:
  617. ;       FS:SI = request packet GIOParaPack
  618. ;
  619. ; OUTPUT:
  620. ;       AX = STERR + ERROR_I24_INVALID_PARAMETER                /*          */
  621. ;       DX = Direction
  622. ;       DI = Mode
  623. ;
  624. ; EXIT-NORMAL:
  625. ;       BE (all within range)
  626. ;
  627. ; EXIT-ERROR:
  628. ;       A (something beyond range)
  629. ;
  630. ; EFFECTS:
  631. ;
  632. ;    USES ROUTINES:
  633. ;
  634. ; CALLED BY ROUTINES:
  635. ;               GetSVGABank
  636. ;               SetSVGABank
  637. ;
  638. VerifyBank    PROC    NEAR
  639.  
  640.         mov     bx, si                  ;fs:bx points to the BankPacket
  641.         mov     dx, fs:[bx].usReadWriteMode ;read/write
  642.         .if     <dx be WRITE_BANK>
  643.             mov     di, fs:[bx].usVideoModeType
  644.             cmp     di, MODE_LINEAR
  645.         .endif
  646.         mov     ax,STERR + ERROR_I24_INVALID_PARAMETER ;        /*          */
  647.         ret
  648.  
  649. VerifyBank    ENDP
  650.  
  651. ;--------------------------------------------------------------------------
  652. ; SUBROUTINE NAME:      GetLinearAccess
  653. ;
  654. ; DESCRIPTIVE NAME:     Return linear address mapped to given physical
  655. ;
  656. ; FUNCTION:     Returns a linear address to a physical region of memory
  657. ;               of given size.
  658. ;
  659. ; ENTRY POINT:  GetLinearAccess
  660. ;    LINKAGE:   Call Near
  661. ;
  662. ; INPUT:
  663. ;       ES:BX = request packet address
  664. ;       DS = BIODATA
  665. ;
  666. ; EXIT-NORMAL:
  667. ;       AX = Status to return to OS
  668. ;
  669. ; EXIT-ERROR:
  670. ;       None
  671. ;
  672. ; EFFECTS:
  673. ;       AX
  674. ;
  675. ;    USES ROUTINES:
  676. ;
  677. ; CALLED BY ROUTINES:
  678. ;               SVGA_IOCTL
  679.  
  680. GetLinearAccess PROC    NEAR
  681.  
  682.         mov     cx,offset LinearFlags   ;Get packet min size    /*          */
  683.         call    VerifyVariablePacket    ;Verify at least cx byte/*          */
  684.         .if     <nc>                    ; 
  685.             les     bx,es:[bx].GIOParaPack  ; 
  686.             mov     edi,es:[bx].PhysicalAddress ; 
  687.             or      edi,edi             ;                       /*          */
  688.             stc                         ;Error if edi is zero   /*          */
  689.             .if     <nz>                ;                       /*          */
  690.                 mov     FlatPointer,edi ; 
  691.                 mov     eax,FlatPtrOffset   ; 
  692.                 .if     <zero eax>      ; 
  693.                     mov     ax,ds       ;Convert selector:offset
  694.                     mov     esi,OFFSET FlatPointer  ; 
  695.                     mov     dl,DevHlp_VirtToLin     ; 
  696.                     call    DevHelp     ; 
  697.                 .endif
  698.             .endif
  699.         .endif                          ;Endif packet size OK   /*          */
  700.         .if    <nc>                     ;If linear addr OK:     /*          */
  701.             mov     FlatPtrOffset,eax   ; 
  702.             mov     edi,eax             ; 
  703.             mov     eax,00410h          ;Map phys to linear (shared) by def
  704.             .if     <es:[bx].PacketLength ae GetLinear_Packet_Size> ;If flags:
  705.                 mov     eax,es:[bx].LinearFlags     ;Get caller flags.
  706.             .endif                      ;                       /*          */
  707.             mov     ecx,es:[bx].ApertureSize; Size in bytes
  708.             test    eax,080000000h      ;Top bit set?           /*          */
  709.             .if     <z>                 ;If not:                /*          */
  710.                 mov     dl,DevHlp_VMAlloc ; 
  711.                 call    DevHelp         ; 
  712.             .else                       ;Else set! Attach       /*          */
  713.                 mov     di,bx           ;save pointer to packet /*          */
  714.                 mov     eax,010h        ;VDHGP_ATTACH to process/*          */
  715.                 mov     ebx,es:[di].LinearAddress   ;Existing linear address
  716.                 mov     ecx,es:[di].ApertureSize    ;Size in bytes
  717.                 mov     dl,DevHlp_VMGlobalToProcess ;       /*          */
  718.                 call    DevHelp         ;                       /*          */
  719.                 mov     bx,di           ;Restore ptr to packet  /*          */
  720.             .endif                      ;Endif attach           /*          */
  721.         .endif                          ;Endif linear addr OK   /*          */
  722.         .if    <nc>                     ;If linear addr OK:
  723.             mov     es:[bx].LinearAddress,eax       ; 
  724.             xor     eax,eax             ;return - no error
  725.         .else
  726. GetLinError:
  727.             mov     ax,STERR + ERROR_I24_INVALID_PARAMETER ;    /*          */
  728.         .endif                          ;return - error code set
  729.         ret
  730.  
  731. GetLinearAccess ENDP
  732.  
  733. ;--------------------------------------------------------------------------
  734. ; SUBROUTINE NAME:      GetGlobalAccess
  735. ;
  736. ; DESCRIPTIVE NAME:     Return linear global address for per-process address
  737. ;
  738. ; FUNCTION:
  739. ;
  740. ; ENTRY POINT:  GetGlobalAccess
  741. ;    LINKAGE:   Call Near
  742. ;
  743. ; INPUT:
  744. ;       ES:BX = request packet address
  745. ;       DS = BIODATA
  746. ;
  747. ; EXIT-NORMAL:
  748. ;       AX = Status to return to OS
  749. ;
  750. ; EXIT-ERROR:
  751. ;       None
  752. ;
  753. ; EFFECTS:
  754. ;       AX
  755. ;
  756. ;    USES ROUTINES:
  757. ;
  758. ; CALLED BY ROUTINES:
  759. ;               SVGA_IOCTL
  760.  
  761. GetGlobalAccess PROC    NEAR
  762.         mov     cx,GetGlobal_Packet_Size;Get packet min size    /*          */
  763.         call    VerifyVariablePacket    ;Verify at least cx byte/*          */
  764.         jc      short GetGlobalError    ; 
  765.  
  766.         les     di,es:[bx].GIOParaPack  ;ES:DI -> packet        /*          */
  767.         mov     esi,es:[di].GlobalPktLength     ;check how many entries
  768.         sub     esi,GetGlobal_Packet_Size       ; 
  769.         cmp     esi,SIZE GLOBALIOCTLDATA
  770.         jb      short GetGlobalError            ; 
  771.         mov     eax,esi                         ; 
  772.         mov     cl,SIZE GLOBALIOCTLDATA        ; 
  773.         idiv    cl                              ; 
  774.         or      ah,ah                           ; 
  775.         jnz     short GetGlobalError            ;must be exact size
  776.         movzx   esi,al                          ;no of addresses to go global
  777.         add     edi,GetGlobal_Packet_Size       ; 
  778.  
  779. GetGlobalNext:
  780.         mov     ebx,es:[di].ProcessAddress      ;EBX = Process linear address
  781.         or      ebx,ebx                         ; 
  782.         jz      short @F                        ; 
  783.         test    ebx,0FFFH                       ; 
  784.         jnz     GetGlobalError                  ;must be page aligned
  785.         mov     ecx,es:[di].AddressLength       ;ECX = Length in bytes
  786.         or      ecx,ecx                         ; 
  787.         jz      short @F                        ; 
  788.         shr     ecx,4                           ;round up to para boundary
  789.         inc     ecx                             ; 
  790.         shl     ecx,4                           ; 
  791.         mov     eax,1                           ;Create writable mapping
  792.         mov     dl,DevHlp_VMProcessToGlobal     ; 
  793.         call    DevHelp                         ; 
  794.         jc      short GetGlobalError            ; 
  795.         mov     es:[di].GlobalAddress,eax       ; 
  796.  
  797. @@:     add     di,SIZE GLOBALIOCTLDATA        ; 
  798.         dec     esi                             ; 
  799.         jnz     short GetGlobalNext             ; 
  800.  
  801.         xor     eax,eax                         ; 
  802.         ret                                     ; return - no error
  803.  
  804. GetGlobalError:
  805.         mov     ax,STERR + ERROR_I24_INVALID_PARAMETER
  806.         ret                                     ; return - error code set
  807. GetGlobalAccess ENDP
  808.  
  809. ;--------------------------------------------------------------------------
  810. ; SUBROUTINE NAME:      FreeGlobalAccess
  811. ;
  812. ; DESCRIPTIVE NAME:     Free linear global addresses
  813. ;
  814. ; FUNCTION:
  815. ;
  816. ; ENTRY POINT:  FreeGlobalAccess
  817. ;    LINKAGE:   Call Near
  818. ;
  819. ; INPUT:
  820. ;       ES:BX = request packet address
  821. ;       DS = BIODATA
  822. ;
  823. ; EXIT-NORMAL:
  824. ;       AX = Status to return to OS
  825. ;
  826. ; EXIT-ERROR:
  827. ;       None
  828. ;
  829. ; EFFECTS:
  830. ;       AX
  831. ;
  832. ;    USES ROUTINES:
  833. ;
  834. ; CALLED BY ROUTINES:
  835. ;               SVGA_IOCTL
  836.  
  837. FreeGlobalAccess PROC    NEAR
  838.         mov     cx,GetGlobal_Packet_Size;Get packet min size    /*          */
  839.         call    VerifyVariablePacket    ;Verify at least cx byte/*          */
  840.         jc      short FreeGlobalError   ; 
  841.  
  842.         les     di,es:[bx].GIOParaPack  ;ES:DI -> packet        /*          */
  843.         mov     esi,es:[di].GlobalPktLength     ;check how many entries
  844.         sub     esi,GetGlobal_Packet_Size      ;@senja
  845.         cmp     esi,SIZE GLOBALIOCTLDATA       ; 
  846.         jb      short FreeGlobalError           ; 
  847.         mov     eax,esi                         ; 
  848.         mov     cl,SIZE GLOBALIOCTLDATA        ; 
  849.         idiv    cl                              ; 
  850.         or      ah,ah                           ; 
  851.         jnz     short FreeGlobalError           ;must be exact size
  852.         movzx   esi,al                          ;no of addresses to go global
  853.         add     edi,GetGlobal_Packet_Size       ;@senja
  854.  
  855. FreeGlobalNext:
  856.         mov     eax,es:[di].GlobalAddress       ;EAX = Global address
  857.         or      eax,eax                         ; 
  858.         jz      short @F                        ; 
  859.         mov     dl,DevHlp_VMFree                ; 
  860.         call    DevHelp                         ; 
  861.         jc      short FreeGlobalError           ; 
  862.  
  863. @@:     add     di,SIZE GLOBALIOCTLDATA        ; 
  864.         dec     esi                             ; 
  865.         jnz     short FreeGlobalNext            ; 
  866.  
  867.         xor     eax,eax                         ; 
  868.         ret                                     ; return - no error
  869.  
  870. FreeGlobalError:
  871.         mov     ax,STERR + ERROR_I24_INVALID_PARAMETER
  872.         ret                                     ; return - error code set
  873. FreeGlobalAccess ENDP
  874.  
  875. ;--------------------------------------------------------------------------
  876. ; SUBROUTINE NAME:      GetSVGAInfo
  877. ;
  878. ; DESCRIPTIVE NAME:     Return SVGA chip and its VRAM size information.
  879. ;
  880. ; FUNCTION:     Fill data packet with SVGA chip information.
  881. ;
  882. ; ENTRY POINT:  GetSVGAInfo
  883. ;    LINKAGE:   Call Near
  884. ;
  885. ; INPUT:
  886. ;       ES:BX = request packet address
  887. ;       DS = BIODATA
  888. ;
  889. ; EXIT-NORMAL:
  890. ;       AX = Status to return to OS
  891. ;
  892. ; EXIT-ERROR:
  893. ;       None
  894. ;
  895. ; EFFECTS:
  896. ;       AX
  897. ;
  898. ;    USES ROUTINES:
  899. ;
  900. ; CALLED BY ROUTINES:
  901. ;               SVGA_IOCTL
  902. ;
  903. GetSVGAInfo      PROC    NEAR
  904.         ASSUME  DS:BioData
  905.  
  906. ;       cmp     es:[bx].GIOFunction, SCREENDD_SVGA_ID ;            /*          */
  907. ;       jne     short @F                ;                       /*          */
  908.         mov     cx, VIDEO_SIZE          ;                       //@senja
  909.         mov     si, offset _sSVGA       ;                       /*          */
  910. ;Drop thru to:
  911.  
  912. ;                                                               /*          */
  913. ;--------------------------------------------------------------------------
  914. ; SUBROUTINE NAME:      GetDataPacket
  915. ;
  916. ; DESCRIPTIVE NAME:     Return saved data packet
  917. ;
  918. ; FUNCTION:     Fill data packet with saved info.
  919. ;
  920. ; ENTRY POINT:  GetDataPacket
  921. ;    LINKAGE:   Call Near
  922. ;
  923. ; INPUT:
  924. ;       CX = data packet length
  925. ;       SI = offset saved info offset.
  926. ;       ES:BX = request packet address
  927. ;       DS = BIODATA
  928. ;
  929. ; EXIT-NORMAL:
  930. ;       AX = Status to return to OS
  931. ;
  932. ; EXIT-ERROR:
  933. ;       None
  934. ;
  935. ; EFFECTS:
  936. ;       AX
  937. ;
  938. ;    USES ROUTINES:
  939. ;
  940. ; CALLED BY ROUTINES:
  941. ;               GetSVGAInfo
  942. ;
  943. GetDataPacket   PROC    NEAR
  944.         ASSUME  DS:BioData
  945.  
  946.         call    VerifyDataPacket        ;           
  947. ;       mov     ax,STERR + ERROR_I24_INVALID_PARAMETER ;        /*          */
  948.         .if     <nc>                    ;If no exit with error:
  949. ;           mov     al,es:[bx].GIOFunction      ;               /*          */
  950.             les     di,es:[bx].GIODataPack
  951. ;           mov     si, offset _sSVGA   ;                       /*          */
  952.             rep     movsb               ;                       /*          */
  953. ;           movsw                       ; SVGAAdapterType       /*          */
  954. ;           movsw                       ; SVGAChipType          /*          */
  955. ;           movsw                       ; SVGAMemory (LSW)      /*          */
  956. ;           movsw                       ; SVGAMemory (MSW)      /*          */
  957.             xor     ax,ax               ; Indicate success      /*          */
  958. ;           jmp short END_SVGA          ;                       /*          */
  959. ;@@:        mov     ax,STERR + ERROR_I24_BAD_COMMAND            /*          */
  960.         .endif
  961. END_SVGA:
  962.         ret
  963.  
  964. GetDataPacket   ENDP
  965.  
  966. GetSVGAInfo     ENDP
  967.  
  968. ;--------------------------------------------------------------------------
  969. ; SUBROUTINE NAME:      GetOEMInfo
  970. ;
  971. ; DESCRIPTIVE NAME:     Return SVGA manufacturer and BIOS revision.
  972. ;
  973. ; FUNCTION:     Fill data packet with OEM information.
  974. ;
  975. ; ENTRY POINT:  GetSVGAInfo
  976. ;    LINKAGE:   Call Near
  977. ;
  978. ; INPUT:
  979. ;       ES:BX = request packet address
  980. ;       DS = BIODATA
  981. ;
  982. ; EXIT-NORMAL:
  983. ;       AX = Status to return to OS
  984. ;
  985. ; EXIT-ERROR:
  986. ;       None
  987. ;
  988. ; EFFECTS:
  989. ;       AX
  990. ;
  991. ;    USES ROUTINES:
  992. ;
  993. ; CALLED BY ROUTINES:
  994. ;               SVGA_IOCTL
  995. ;
  996. GetOEMInfo      PROC    NEAR
  997.         ASSUME  DS:BioData
  998.  
  999. ;       cmp     es:[bx].GIOFunction, SCREENDD_SVGA_OEM;/*          */
  1000. ;       jne     short @F                ;                       /*          */
  1001.         mov     cx, dword               ;verify length first.   /*          */
  1002.         call    VerifyDataPacket        ;          
  1003. ;       mov     ax,STERR + ERROR_I24_INVALID_PARAMETER          /*          */
  1004.         .if     <nc>                    ;If no exit with error:
  1005. ;!!             What about using FS:SI?
  1006.             push    es                  ;read first dword to get total length.
  1007.             les     di, es:[bx].GIODataPack
  1008.             mov     cx, word ptr es:[di];verify entire packet
  1009.             pop     es
  1010.             call    VerifyDataPacket    ;           
  1011. ;           mov     ax,STERR + ERROR_I24_INVALID_PARAMETER      /*          */
  1012.         .endif
  1013.         .if     <nc>                    ;If no exit with error:
  1014.             les     di, es:[bx].GIODataPack ;ptr to OEM info    /*          */
  1015.             mov     cx, word ptr es:[di];verify entire packet   /*          */
  1016.             mov     ax, word ptr [SvgaOEMInfo.OEMLength] ;      /*          */
  1017.                                         ;Get space needed       /*          */
  1018.             .if     <cx a ax>           ;More space than we need/*          */
  1019.                 mov     cx, ax          ;Use minimum size       /*          */
  1020.             .endif                                              /*@V2.1MNH13*/
  1021.             lea     si, [SvgaOEMInfo]   ;Point to premade info  /*          */
  1022.             rep     movsb               ;Copy predetermined info/*          */
  1023.             xor     ax,ax               ;Indicate success
  1024. ;           jmp short END_OEM                                   /*          */
  1025. ;@@:        mov     ax,STERR + ERROR    _I24_BAD_COMMAND        /*          */
  1026.         .endif
  1027. END_OEM:
  1028.         ret
  1029. GetOEMInfo     ENDP
  1030. ;*                                                              /*          */
  1031. ;*      Moved Process OEM to initialization section             /*          */
  1032. ;*                                                              /*          */
  1033. ;          
  1034. ;--------------------------------------------------------------------------
  1035. ; SUBROUTINE NAME:      UpdateMemoryInfo
  1036. ;
  1037. ; DESCRIPTIVE NAME:     Set SVGA memory to the value passed.
  1038. ;
  1039. ; FUNCTION:
  1040. ;
  1041. ; ENTRY POINT:  UpdateMemoryInfo
  1042. ;    LINKAGE:   Call Near
  1043. ;
  1044. ; INPUT:
  1045. ;       ES:BX = request packet address
  1046. ;       DS = BIODATA
  1047. ;
  1048. ; EXIT-NORMAL:
  1049. ;       AX = Status to return to OS
  1050. ;
  1051. ; EXIT-ERROR:
  1052. ;       None
  1053. ;
  1054. ; EFFECTS:
  1055. ;       AX
  1056. ;
  1057. ;    USES ROUTINES:
  1058. ;
  1059. ; CALLED BY ROUTINES:
  1060. ;               SVGA_IOCTL
  1061. ;
  1062. UpdateMemoryInfo      PROC    NEAR
  1063.         ASSUME  DS:BioData
  1064.  
  1065. ;       mov     ax,STERR + ERROR_I24_BAD_COMMAND;               /*          */
  1066. ;       cmp     es:[bx].GIOFunction, SCREENDD_UPDATE_MEMORY ;       /*          */
  1067. ;       jne     short @F                ;                       /*          */
  1068.         mov     cx, dword               ;                       /*          */
  1069.         call    VerifyParaPacket        ;           
  1070. ;       mov     ax,STERR + ERROR_I24_INVALID_PARAMETER ;        /*          */
  1071.         .if     <nc>                    ;If no exit with error:
  1072.             les     bx, es:[bx].GIOParaPack     ; 
  1073.             mov     eax, es:[bx]        ; 
  1074.             mov     [_sSVGA.Memory], eax ;                      /*          */
  1075.             xor     eax, eax            ; 
  1076.         .endif
  1077. @@:
  1078.         ret
  1079. UpdateMemoryInfo     ENDP
  1080.  
  1081. ;--------------------------------------------------------------------------
  1082. ; SUBROUTINE NAME:      GetSVGABank
  1083. ;
  1084. ; DESCRIPTIVE NAME:     Return current chipset bank.
  1085. ;
  1086. ; FUNCTION:     Parameter packet contains direction and video mode.
  1087. ;               Return bank thru data packet. All chipset routines expect
  1088. ;               current video mode in DI and direction in DX. Bank returned
  1089. ;               in AX. No error handling by the routines.
  1090. ;
  1091. ; ENTRY POINT:  GetSVGABank
  1092. ;    LINKAGE:   Call Near
  1093. ;
  1094. ; INPUT:
  1095. ;       ES:BX = request packet address
  1096. ;       DS = BIODATA
  1097. ;
  1098. ; EXIT-NORMAL:
  1099. ;       AX = Status to return to OS
  1100. ;
  1101. ; EXIT-ERROR:
  1102. ;       None
  1103. ;
  1104. ; EFFECTS:
  1105. ;       AX
  1106. ;
  1107. ;    USES ROUTINES:
  1108. ;
  1109. ; CALLED BY ROUTINES:
  1110. ;               SVGA_IOCTL
  1111. ;
  1112. GetSVGABank             PROC    NEAR
  1113.  
  1114.         mov     cx,BANK_PARAM_PACKET_SIZE ; minimum length which should be valid.
  1115.         call    VerifyVariablePacket    ;                       /*          */
  1116.         .if     <nc>                    ;                       /*          */
  1117.             call    VerifyBank          ;                       /*          */
  1118.             .if     <be>                ;                       /*          */
  1119.                 mov     si, [_sSVGA.AdapterType] ;              /*          */
  1120.                 shl     si, 1           ; Make adapter type a table offset
  1121.                 call    [SVGA_GET_BANK_TABLE][si] ; go do request
  1122.                                         ; AX = current bank
  1123.                 mov     word ptr fs:[bx].usBank, ax;           
  1124.                 xor     ax,ax                   ; Indicate success
  1125. ;               ret                     ;                       /*          */
  1126.             .endif
  1127.         .endif
  1128. ERROR_BANK_EXIT:
  1129. ;       mov     ax,STERR + ERROR_I24_INVALID_PARAMETER          /*          */
  1130.         ret
  1131. GetSVGABank             ENDP
  1132.  
  1133. ;--------------------------------------------------------------------------
  1134. ; SUBROUTINE NAME:      SetSVGABank
  1135. ;
  1136. ; DESCRIPTIVE NAME:     Return current chipset bank.
  1137. ;
  1138. ; FUNCTION:     Parameter packet contains length, bank, direction and video mode.
  1139. ;               All chipset routines expect current video mode in DI,
  1140. ;               direction in DX and bank in CX.
  1141. ;               No error handling by the called routines.
  1142. ;
  1143. ; ENTRY POINT:  SetSVGABank
  1144. ;    LINKAGE:   Call Near
  1145. ;
  1146. ; INPUT:
  1147. ;       ES:BX = request packet address
  1148. ;       DS = BIODATA
  1149. ;
  1150. ; EXIT-NORMAL:
  1151. ;       AX = Status to return to OS
  1152. ;
  1153. ; EXIT-ERROR:
  1154. ;       None
  1155. ;
  1156. ; EFFECTS:
  1157. ;       AX
  1158. ;
  1159. ;    USES ROUTINES:
  1160. ;
  1161. ; CALLED BY ROUTINES:
  1162. ;               SVGA_IOCTL
  1163. ;
  1164. SetSVGABank             PROC    NEAR
  1165.  
  1166.         mov     cx,BANK_PARAM_PACKET_SIZE       ; mimimum size which should be valid.
  1167.         call    VerifyVariablePacket    ;                       /*          */
  1168.         .if     <nc>                    ;                       /*          */
  1169.             call    VerifyBank          ;                       /*          */
  1170.             .if     <be>                ;                       /*          */
  1171.                 mov     cx, fs:[bx].usBank ; Bank
  1172.                 mov     si, [_sSVGA.AdapterType] ;              /*          */
  1173.                 shl     si, 1           ; Make adapter type a table offset
  1174.                 call    [SVGA_SET_BANK_TABLE][si]     ; go do request
  1175.                 xor     ax,ax           ; Indicate success
  1176. ;               ret                     ;                       /*          */
  1177.             .endif
  1178.         .endif
  1179. ERROR_BANK:
  1180. ;       mov     ax,STERR + ERROR_I24_INVALID_PARAMETER          /*          */
  1181.         ret
  1182.  
  1183. SetSVGABank             ENDP
  1184.  
  1185. ; Future SVGA functions 2-7. Still undefined.
  1186. ;GetSVGATrapIOList
  1187. ;SetSVGATrapIOList
  1188. ;GetSVGALockUnlock
  1189. ;SetSVGALockUnlock
  1190. ;GetSVGACleanup
  1191. ;SetSVGACleanup
  1192. FutureSVGAFunc       PROC    NEAR               ;           
  1193.         mov     ax,STERR + ERROR_I24_BAD_COMMAND
  1194.         ret
  1195. FutureSVGAFunc       ENDP
  1196.  
  1197. ;                                                               /*          */
  1198. ;--------------------------------------------------------------------------
  1199. ; SUBROUTINE NAME:      RegisterRing0Caller
  1200. ;
  1201. ; DESCRIPTIVE NAME:     Register the ring 0 caller.
  1202. ;
  1203. ; FUNCTION:             RegisterRing0Caller and WaitOnRing0Caller represent a
  1204. ;                       communication interface for the svgapmi/vvid. WaitOnRing0Caller
  1205. ;                       (svgapmi) will be blocked until ring0 caller (Vvid)
  1206. ;                       registers.
  1207. ;                       PMIInfo global data represents the block event key.
  1208. ;
  1209. ;
  1210. ; ENTRY POINT:  RegisterRing0Caller
  1211. ;    LINKAGE:   Call Near
  1212. ;
  1213. ; INPUT:
  1214. ;       ES:BX = request packet address
  1215. ;       DS = BIODATA
  1216. ;
  1217. ; EXIT-NORMAL:
  1218. ;       AX = Status to return to OS
  1219. ;
  1220. ; EXIT-ERROR:
  1221. ;       None
  1222. ;
  1223. ; EFFECTS:
  1224. ;       AX
  1225. ;
  1226. ;    USES ROUTINES:
  1227. ;
  1228. ; CALLED BY ROUTINES:
  1229. ;               SVGA_IOCTL
  1230. ;
  1231. RegisterRing0Caller PROC    NEAR
  1232.         ASSUME  DS:BioData
  1233.  
  1234.         ; release the WaitOnRing0 caller's thread.
  1235.         mov     ax, ds              ; setup event ID
  1236.         mov     bx, offset PmiInfo  ; 
  1237.         mov     dl,DevHlp_ProcRun   ; 
  1238.         call    DevHelp
  1239.         xor     ax,ax               ;Indicate success
  1240.         ret                         ; 
  1241. RegisterRing0Caller ENDP
  1242.  
  1243. ;                                                               /*          */
  1244. ;--------------------------------------------------------------------------
  1245. ; SUBROUTINE NAME:      WaitOnRing0Caller
  1246. ;
  1247. ; DESCRIPTIVE NAME:     Set Ring0 Pmi Info data structure
  1248. ;
  1249. ; FUNCTION:             RegisterRing0Caller and WaitOnRing0Caller represent a
  1250. ;                       communication interface for the svgapmi/vvid. WaitOnRing0Caller
  1251. ;                       (svgapmi) will be blocked until ring0 caller (Vvid)
  1252. ;                       registers.
  1253. ;                       PMIInfo global data represents the block event key.
  1254. ;
  1255. ; ENTRY POINT:  WaitOnRing0Caller
  1256. ;    LINKAGE:   Call Near
  1257. ;
  1258. ; INPUT:
  1259. ;       ES:BX = request packet address
  1260. ;       DS = BIODATA
  1261. ;
  1262. ; EXIT-NORMAL:
  1263. ;       AX = Status to return to OS
  1264. ;
  1265. ; EXIT-ERROR:
  1266. ;       None
  1267. ;
  1268. ; EFFECTS:
  1269. ;       AX
  1270. ;
  1271. ;    USES ROUTINES:
  1272. ;
  1273. ; CALLED BY ROUTINES:
  1274. ;               SVGA_IOCTL
  1275. ;
  1276. WaitOnRing0Caller PROC    NEAR
  1277.         ASSUME  DS:BioData
  1278.         ; block until ring0 caller registers. No time-out, noninterruptable
  1279.         mov     ax, ds              ; setup event ID
  1280.         mov     bx, offset PmiInfo
  1281.         mov     di, 0ffffh
  1282.         mov     cx, 0ffffh
  1283.         mov     dh, 1
  1284.         mov     dl,DevHlp_ProcBlock
  1285.         call    DevHelp
  1286.         ; run again here, ring0 caller registered.
  1287.         ; return.
  1288.         xor     ax,ax               ;Indicate success
  1289.         ret
  1290.  
  1291. WaitOnRing0Caller ENDP
  1292.  
  1293. PUBLIC  VVID_IDC
  1294. ;/****************************************************************************
  1295. ;*
  1296. ;* FUNCTION NAME = VVID_IDC
  1297. ;*
  1298. ;* DESCRIPTION   = IDC Interface to VVID. This function is
  1299. ;*                 registered at INIT time by calling DevHlp_RegisterPDD.
  1300. ;*                 It is using a stack parameter interface and it is used
  1301. ;*                 only to open and obtain the register entry point bank
  1302. ;*                 IDC interface function VVID_BANK_REGISTER_ENTRY, which is
  1303. ;*                 much faster/
  1304. ;*                 Parameters:
  1305. ;*                 [sp+8] = ulFunc DD   0 for open, 1 for obtain register entry point
  1306. ;*                 [sp+12] = ul1    DD  16:16 Pointer to input structure:
  1307. ;*                 [sp+16] = ul2    DD  16:16 Pointer to output structure: 16:16
  1308. ;*                                      area for the register entry point address to be returned.
  1309. ;*                 This function depends on parameter pointers
  1310. ;*                 being in the sel:offset format. VVID must convert its linear pointers
  1311. ;*                 prior to calling this entry point.
  1312. ;*
  1313. ;* INPUT         = see Parameters above.
  1314. ;* OUTPUT        = NONE
  1315. ;*
  1316. ;* RETURN-NORMAL = 1 as success
  1317. ;* RETURN-ERROR  = 0 as failure.
  1318. ;*
  1319. ;****************************************************************************/
  1320.  
  1321. VVID_IDC        PROC    FAR
  1322.         push    bp
  1323.         mov     bp,sp
  1324.         push    ds
  1325.         push    es
  1326.         push    bx
  1327.         push    di
  1328.         push    si
  1329.         mov     ax, BioData
  1330.         mov     ds, ax
  1331.         ASSUME  DS:BioData
  1332.  
  1333.         mov     cx, word ptr [ulFunc]           ; higher word ignored
  1334.         .if     <cx e IDC_CMD_REGISTER_STACK_PROC>
  1335.                 mov     ax, IDC_SUCCESS
  1336.         .else
  1337.         .if     <cx e IDC_CMD_REGISTER_EPREGISTER>
  1338.                 mov     es,[ulParam1]._SEG      ; get pointer 1 selector
  1339.                 mov     di,[ulParam1]._OFF      ; get pointer 1 offset
  1340.                 mov     es:[di].fp_sel,cs       ; set the far pointer selector
  1341.                 mov     es:[di].fp_offhi,0      ; set the far pointer high offset
  1342.                 lea     ax,cs:VVID_BANK_REGISTER_ENTRY      ; get the far pointer low offset
  1343.                 mov     es:[di].fp_offlo,ax     ; set the far pointer low offset
  1344.                 mov     ax, IDC_SUCCESS
  1345.         .else
  1346.                 xor     ax, ax
  1347.         .endif
  1348.         .endif
  1349.         pop    si
  1350.         pop    di
  1351.         pop    bx
  1352.         pop    es
  1353.         pop    ds
  1354.  
  1355.         mov     sp, bp
  1356.         pop     bp
  1357. ;    RETURN (32 bit)
  1358.         db      66h
  1359.         ret     12
  1360. VVID_IDC        ENDP
  1361.  
  1362. ;/****************************************************************************
  1363. ;*
  1364. ;* FUNCTION NAME = VVID_BANK_REGISTER_ENTRY
  1365. ;*
  1366. ;* DESCRIPTION   = Register based IDC Interface to VVID. This function
  1367. ;*                 called with parameters passed thru the stack:
  1368. ;*                 BX = Function
  1369. ;*                      SCREENDD_GETCURRENTBANK (0h),
  1370. ;*                      SCREENDD_SETCURRENTBANK (1h)
  1371. ;*                 For SetBank it calls appropriate routine with args:
  1372. ;*                      CX Bank, DX Direction and DI video mode
  1373. ;*                 For GetBank it calls appropriate routine with args:
  1374. ;*                      DX Direction and DI video mode.
  1375. ;*                      Bank returned in AX.
  1376. ;* INPUT         = see Parameters above.
  1377. ;* OUTPUT        = NONE
  1378. ;*
  1379. ;* LINKAGE:     Far 16:32
  1380. ;*
  1381. ;* RETURN-NORMAL = See above
  1382. ;* RETURN-ERROR  =
  1383. ;*
  1384. ;****************************************************************************/
  1385. VVID_BANK_REGISTER_ENTRY PROC    FAR
  1386.         push    ds
  1387.         push    es
  1388.         mov     ax, BioData
  1389.         mov     ds, ax
  1390.         ASSUME  DS:BioData
  1391.         mov     ax, [_sSVGA.AdapterType] ;                      /*          */
  1392.         .if <bx e SCREENDD_SETCURRENTBANK>
  1393.                 mov     si,offset SVGA_SET_BANK_TABLE  ; 
  1394.         .else
  1395.         .if <bx e SCREENDD_GETCURRENTBANK>
  1396.                 mov     si,offset SVGA_GET_BANK_TABLE  ; 
  1397.         .else                                          ; unsupported function.
  1398.                 pop     es
  1399.                 pop     ds
  1400.                 ret
  1401.         .endif
  1402.         .endif
  1403. ;       cbw                             ;Make adapter type a word/*          */
  1404.         shl     ax,1                    ;Make adapter type a table offset
  1405.         add     si,ax                   ;SI = get bank table offset
  1406.         call    [si]                    ;go do request
  1407.         pop     es
  1408.         pop     ds
  1409.         ret
  1410. VVID_BANK_REGISTER_ENTRY ENDP
  1411. ;
  1412. ; The following label defines the end of the Screen resident code.
  1413. ;
  1414. DEVICE_END LABEL BYTE
  1415.  
  1416. BiosSeg ends                            ;                       /*          */
  1417.  
  1418. BiosSeg SEGMENT WORD Public 'CODE' USE16;                       /*          */
  1419.         ASSUME  CS:BiosSeg              ;                       /*          */
  1420.         ASSUME  DS:BioData              ;                       /*          */
  1421.  
  1422.         EXTRN SVGAPhysToVirt      : NEAR ;                      /*          */
  1423.         EXTRN SVGAUnPhysToVirt    : NEAR ;                      /*          */
  1424.         EXTRN SVGAPhysToUVirt     : NEAR ;                      /*          */
  1425.         EXTRN SVGAUnPhysToUVirt   : NEAR ;                      /*          */
  1426.         EXTRN FindString          : NEAR ;                      /*          */
  1427.         EXTRN FindStringExpansion : NEAR ;                      /*          */
  1428.         EXTRN GetCrtcBase         : NEAR ;                      /*          */
  1429.  
  1430.         EXTRN _IdentifySVGA       : FAR  ;                      /*          */
  1431.  
  1432. ;*                                                              /*          */
  1433. ;*      Moved Process OEM to initialization section             /*          */
  1434. ;*                                                              /*          */
  1435.  
  1436. IFDEF   FAMILY2
  1437.  
  1438. ;--------------------------------------------------------------------------
  1439. ; SUBROUTINE NAME:      QueryMCSlot
  1440. ;
  1441. ; DESCRIPTIVE NAME:     If an adapter with a matching MC-ID found,
  1442. ;                       return the slot.
  1443. ;
  1444. ; FUNCTION:     Return adapter MC slot number in AX.
  1445. ;
  1446. ; ENTRY POINT:  QueryMCSlot
  1447. ;    LINKAGE:   Call Near
  1448. ;
  1449. ; INPUT:
  1450. ;       AX = MC ID
  1451. ;
  1452. ;* RETURN-NORMAL = ZR if found.
  1453. ;* RETURN-ERROR  = NZ if not found.
  1454. ;
  1455. ; EFFECTS:
  1456. ;       AX
  1457. ;
  1458. ;    USES ROUTINES:
  1459. ;
  1460. ; CALLED BY ROUTINES:
  1461. ;               ProcessMC_OEM
  1462. ;
  1463. ; OUTPUT:       AX = Adapter's slot number
  1464. ;
  1465.  
  1466. QueryMCSlot   PROC    Near
  1467.  
  1468.         push    di                              ; 
  1469.         mov     di, ax                          ; ID we are searching for
  1470.         in      al, 96h                         ; Read card slot setting
  1471.         mov     bl, al                          ; Save current card slot setting
  1472.         mov     cx, 08h                         ; Start with card slot 0 (bit 0-3)
  1473.         .repeat                                 ; Search up to 8 card slots
  1474.             mov     al, cl                      ; 
  1475.             out     96h, al                     ; Put card slot into setup mode
  1476.             mov     dx, 100h
  1477.             in      ax, dx                      ; Get POS ID from slot (IOdelay)
  1478.             in      ax, dx                      ; Get POS ID from slot
  1479.             cmp     ax, di                      ; found
  1480.             .if     <z>                         ; 
  1481.                 mov     ax, cx                  ; Set SLOT number
  1482.             .else
  1483.                 sub     ax, ax                  ; not found
  1484.             .endif                              ; 
  1485.         .until  <nonzero ax> or                 ; found
  1486.             inc     cx                          ; Next slot
  1487.         .until  <cx a 0Fh>                      ; Search all 8 slots?
  1488.         mov     cx, ax
  1489.         and     ax, 7h                          ; set the result slot to 0-7
  1490.         push    ax
  1491.         cmp     cx, 0                           ; set the result: z if not found, nz found.
  1492.         mov     al, bl                          ; 
  1493.         out     96h, al                         ; Restore card slot setting
  1494.         pop     ax
  1495.         pop     di
  1496.         ret
  1497.  
  1498. QueryMCSlot   ENDP
  1499.  
  1500. ;--------------------------------------------------------------------------
  1501. ; SUBROUTINE NAME:      ProcessMC_OEM
  1502. ;
  1503. ; DESCRIPTIVE NAME:     Identify MC SVGA manufacturer.
  1504. ;
  1505. ; FUNCTION:     Return manufacturer info in DATA packet.
  1506. ;
  1507. ; ENTRY POINT:  ProcessMC_OEM
  1508. ;    LINKAGE:   Call Near
  1509. ;
  1510. ; INPUT:
  1511. ;       DS = BIODATA
  1512. ; OUTPUT:       NONE
  1513. ;
  1514. ; EXIT-NORMAL:  NONE
  1515. ; EXIT-ERROR:   NONE
  1516. ;
  1517. ; EFFECTS:
  1518. ;       NONE
  1519. ;
  1520. ;    USES ROUTINES:
  1521. ;
  1522. ; CALLED BY ROUTINES:
  1523. ;               INIT
  1524. ;
  1525. ; OUTPUT:       Is in adapter specific format. For example:
  1526. ;               Orchid Pro MC: returns slot in Manufacturer Data.
  1527. ;
  1528.  
  1529. ProcessMC_OEM   PROC    Near
  1530.  
  1531.         pusha                           ;                       /*          */
  1532. ;                                       ;if not ET4000, exit without
  1533.         .if     <[_sSVGA.AdapterType] e TSENG_ADAPTER> ;3       /*          */
  1534. ;           push    es                  ;                       /*          */
  1535. ;           push    si                  ;Preserve target addr   /*          */
  1536.             mov     ax, ORCHID_MC_ID    ; load MC id for Orchid
  1537.             call    QueryMCSlot         ; if z failed, nz AX contains the slot
  1538. ;           pop     si                  ;                       /*          */
  1539. ;           pop     es                  ;                       /*          */
  1540.             .if     <nz>                                        /*@V2.1MNH13*/
  1541.                 mov     word ptr [SvgaOEMInfo.OEMLength], dword*2
  1542.                 mov     [SvgaOEMInfo.Manufacturer], ORCHID_MC_ADAPTER
  1543.                 mov     word ptr [SvgaOEMInfo.ManufacturerData], AX
  1544.             .endif
  1545.         .endif
  1546. ExitMC_OEM:
  1547.         popa                            ;                       /*          */
  1548.         ret
  1549. ProcessMC_OEM   ENDP
  1550.  
  1551. ELSE ;/* Not FAMILY2 */                                         /*          */
  1552.  
  1553. IsItaNumber     PROC    Near
  1554.  
  1555.         xor     ax, ax
  1556.         mov     al, byte ptr ds:[si]
  1557.         cmp     al,'9'
  1558.         jg      NotaNumber
  1559.         sub     al, '0'                 ;                       /*          */
  1560.         jl      NotaNumber
  1561.         cmp     ax, ax                  ;Always zero!           /*          */
  1562.         ret
  1563. NotaNumber:
  1564.         and     si, si                  ;Should never be zero!  /*          */
  1565.         ret
  1566.  
  1567. IsItaNumber     ENDP
  1568.  
  1569. FindNumber      PROC    Near
  1570.  
  1571. SearchForNumber:
  1572.         .repeat                         ;                       /*          */
  1573.             call    IsItANumber
  1574.         .leave  < z >                   ;Exit if number found.  /*          */
  1575.             inc     si                  ;Pass the character     /*          */
  1576.             dec     dx                  ;Decrement count left   /*          */
  1577.         .until  < z >                   ;Exit when no more      /*          */
  1578. ExitFound:
  1579.         mov     bx, ax                  ;Use first digit as value.
  1580.         ret
  1581.  
  1582. FindNumber      ENDP
  1583.  
  1584. CollectNumber   PROC    Near
  1585.  
  1586.         .repeat                         ;                       /*          */
  1587.             inc     si                  ;Pass the character     /*          */
  1588.             dec     dx                  ;Decrement count left   /*          */
  1589.         .leave  < z >                   ;Don't overdo the search/*          */
  1590.             call    IsItaNumber         ;z if a number, ax value/*          */
  1591.         .leave  < nz >                                          /*@V2.1MNH13*/
  1592. AddNumberAndSearchLoop:                 ;If a number keep collecting
  1593.             imul    bx, 10
  1594.             add     bx, ax
  1595.         .until                          ;Continue collecting    /*          */
  1596.         ret
  1597.  
  1598. CollectNumber   ENDP
  1599.  
  1600. ;          
  1601. ;***    GetBiosRev
  1602. ;
  1603. ;       Entry:  AX = ROM address (high)
  1604. ;               BX = ROM address (low)
  1605. ;               CX = length of the area to search
  1606. ;
  1607. ;       Look for Vers. string at BIOS location.
  1608. ;       Return major and minor.
  1609. ;
  1610. ;       NOTE:   This routine makes very few assumptions about the
  1611. ;       BIOS signature format. The assumption is that the BIOS
  1612. ;       revision must have at least 1 digit major, followed by a period
  1613. ;       and at least 1 digit in the minor. If the major and minor are out-
  1614. ;       side of the expected range, the caller can call us again with the ROM
  1615. ;       address in AX which is original plus the returned CX and we will
  1616. ;       search for another string of this format.
  1617. ;       There are no delimiters assumed, and the routine
  1618. ;       keeps the search within the bounds of what was converted into virtual.
  1619. ;       Returns NZ if the above format not found or
  1620. ;       AX= major, BX= minor, CX=how far into the area did we search.
  1621. ;
  1622. GetBiosRev      PROC    Near
  1623.         push    es                      ; 
  1624.         push    si                      ;                       /*          */
  1625.         push    dx                      ; used as a counter
  1626.         push    ds                      ;                       /*          */
  1627.         push    cx                      ; save our original length
  1628.         push    ds                      ; 
  1629.         pop     es                      ; 
  1630.         call    SVGAPhysToVirt          ; will load DS:SI with BIOS address
  1631.         mov     dx, cx                  ; load length of the string
  1632. FindBIOS:
  1633.         .repeat
  1634.             .repeat
  1635.                 call    FindNumber      ;bx contains value      /*          */
  1636. SearchLoop:
  1637.             .leave  <zero dx>           ;Don't overdo the search/*          */
  1638.                 call    CollectNumber   ;Get full value in bx   /*          */
  1639.             .leave  < z >               ;Don't overdo the search/*          */
  1640.             .until  <<byte ptr ds:[si]> e PERIOD> ;Period now?  /*          */
  1641.         .leave  <zero dx>               ;Don't overdo the search/*          */
  1642.             inc     si                  ;Pass the PERIOD        /*          */
  1643.             dec     dx                  ;Decrement count left   /*          */
  1644.         .leave  < z >                   ;Don't overdo the search/*          */
  1645. FoundMajor:                             ; have a major in bx
  1646.             mov     di, bx              ; preserve the major
  1647.             xor     bx, bx
  1648.             call    IsItaNumber         ;                       /*          */
  1649.         .until  < z >                   ;Until minor found!     /*          */
  1650.         .if     <nonzero dx>            ;If format found:       /*          */
  1651. CollectMinor:
  1652.             call    CollectNumber       ;Get full value in bx   /*          */
  1653. Processed:                              ; di has major, bx minor.
  1654.             mov     ax, di              ; set the major
  1655.             cmp     ax, ax              ;Always zero!           /*          */
  1656.         .else                           ;Format not OK:         /*          */
  1657. RevNotFound:
  1658.             or      ax, 0ffffh          ;Set major to non-zero! /*          */
  1659.             mov     bx, ax              ;Set minor to non-zero! /*          */
  1660.         .endif
  1661. GetBiosRevExit:
  1662.         pop     cx                      ; used as a counter
  1663.         pop     ds
  1664.         pushf
  1665.         sub     cx, dx                  ; return how far did we get.
  1666.         call    SVGAUnPhysToVirt
  1667.         popf
  1668.         pop     dx
  1669.         pop     si                      ;                       /*          */
  1670.         pop     es
  1671.         ret
  1672.  
  1673. GetBiosRev      ENDP
  1674.  
  1675. ;--------------------------------------------------------------------------
  1676. ; SUBROUTINE NAME:      ProcessOEM
  1677. ;
  1678. ; DESCRIPTIVE NAME:     Identify SVGA manufacturer.
  1679. ;
  1680. ; FUNCTION:     Return manufacturer info in DATA packet.
  1681. ;
  1682. ; ENTRY POINT:  ProcessOEM
  1683. ;    LINKAGE:   Call Near
  1684. ;
  1685. ; INPUT:
  1686. ;       DS = BIODATA
  1687. ; OUTPUT:       NONE
  1688. ;
  1689. ; EXIT-NORMAL:  NONE
  1690. ; EXIT-ERROR:   NONE
  1691. ;
  1692. ; EFFECTS:
  1693. ;       NONE
  1694. ;
  1695. ;    USES ROUTINES:
  1696. ;
  1697. ; CALLED BY ROUTINES:
  1698. ;               INIT
  1699. ;
  1700. ; OUTPUT:       Is in adapter specific format. For example:
  1701. ;               Diamond Speedstar: returns SvgaOEMPacket structure
  1702. ;
  1703. ProcessOEM      PROC    Near
  1704.  
  1705.         pusha                           ;                       /*          */
  1706. ;       push    es                      ;                       /*          */
  1707. ;       push    si                      ;Save target addr       /*          */
  1708. ;       mov     ax, 0000ch              ;BIOS address           /*          */
  1709. ;                                       ;is it WD?              /*          */
  1710.         .if     <[_sSVGA.AdapterType] e WESTERNDIG_ADAPTER> ;4  /*          */
  1711.             mov     di, OFFSET BioData:DiamondWDSig
  1712.             mov     bx, 02E4h           ; this is the offset where we expect it.
  1713.             mov     cx, 13              ; length of the string
  1714.             call    FindStringExpansion ;                     /*          */
  1715.             mov     bx, 02F1h           ; this is the offset where we should start looking.
  1716.         .endif                          ;                       /*          */
  1717.         .if     < nz >                  ;If not found yet:      /*          */
  1718. ET4000:
  1719. ;                                       ;if not ET4000, exit    /*          */
  1720.             .if     <[_sSVGA.AdapterType] e TSENG_ADAPTER> ;3   /*          */
  1721. ;                                       ;             ;          
  1722.                 mov     di, OFFSET BioData:DiamondETSig
  1723.                 mov     bx, 0A71h       ; this is the offset where we expect it.
  1724.                 mov     cx, 12          ; length of the string
  1725.                 call    FindStringExpansion ;                   /*          */
  1726.                 mov     bx, 0A85h       ; this is the offset where we should start looking.
  1727.             .endif                      ;                       /*          */
  1728.         .endif                          ;                       /*          */
  1729.         .if     < nz >                  ;If not found yet:      /*          */
  1730. S3:                                     ;           
  1731. ;                                       ;if not S3, exit        /*          */
  1732.             .if     <[_sSVGA.AdapterType] e S3_ADAPTER> ;8      /*          */
  1733.                 mov     di, OFFSET BioData:DiamondS324Sig
  1734.                 mov     bx, 046h        ; this is the offset where we expect it.
  1735.                 mov     cx, 0Ah         ; length of the string
  1736.                 call    FindStringExpansion ;                   /*          */
  1737.                 mov     bx, 056h        ; this is the offset where we should start looking.
  1738.                 .if     < nz >          ;If not found yet:      /*          */
  1739. S3PRO:                                  ;           
  1740.                     mov     di, OFFSET BioData:DiamondS3PROSig
  1741. ;                   mov     ax, 0000ch  ;BIOS address           /*          */
  1742.                     mov     bx, 046h    ; this is the offset where we expect it.
  1743.                     mov     cx, 0Bh     ; length of the string
  1744.                     call    FindStringExpansion ;               /*          */
  1745.                     mov     bx, 058h    ; this is the offset where we should start looking.
  1746.                 .endif                  ;                       /*          */
  1747.             .endif                      ;                       /*          */
  1748.         .endif                          ;                       /*          */
  1749.         .if     < z >                   ;If Diamond card found  /*          */
  1750.             mov     cx, DIAMOND_MANUFACTURER ;             ;          
  1751. DetermineBIOSRev:
  1752.             push    cx
  1753.             mov     ax, 0000ch          ;BIOS address           /*          */
  1754.             mov     cx, 00100h          ;Get a lot
  1755.             call    GetBiosRev          ;NZ fails or ax=major, bx=minor
  1756.             pop     cx
  1757.             .if     < z >               ;                       /*          */
  1758. ;               pop     si              ;                       /*          */
  1759. ;               pop     es              ;                       /*          */
  1760.                 mov     word ptr [SvgaOEMInfo.ManufacturerData][0*word], ax ;/*          */
  1761.                 mov     word ptr [SvgaOEMInfo.ManufacturerData][1*word], bx ;/*          */
  1762.             .endif                      ;                       /*          */
  1763.         .else                           ;Diamond card not found:/*          */
  1764. ;                                       ;if not S3, exit        /*          */
  1765.             .if     <[_sSVGA.AdapterType] e S3_ADAPTER> ;8      /*          */
  1766. Number9:                                        ;             ;          
  1767.                 mov     di, OFFSET BioData:Number9S3Sig
  1768. ;               mov     ax, 0000ch      ;BIOS address           /*          */
  1769.                 mov     bx, 160h        ;This is the offset where we expect it.
  1770.                 mov     cx, 02h         ;Length of the string
  1771.                 call    FindStringExpansion ;                   /*          */
  1772.                 mov     cx, NUMBER9_MANUFACTURER ;              /*          */
  1773.                 .if     < nz >          ;If not found yet:      /*          */
  1774.                     mov     di, OFFSET BioData:ArtistS3Sig
  1775. ;                   mov     ax, 0000ch  ;BIOS address           /*          */
  1776.                     mov     bx, 12Ch    ;This is the offset where we expect it.
  1777.                     mov     cx, 0dh     ;Length of the string
  1778.                     call    FindStringExpansion ;               /*          */
  1779.                     mov     cx, ARTIST_MANUFACTURER ;           /*          */
  1780.                 .endif                  ;                       /*          */
  1781.                 .if     < nz >          ;If not found yet:      /*          */
  1782.                     mov     di, OFFSET BioData:MIROCRYSTALSig  ;/*          */
  1783. ;                   mov     ax, 0000ch  ;BIOS address           /*          */
  1784.                     mov     bx, 0e6h    ;This is the offset where we expect it.
  1785.                     mov     cx, 0bh     ;Length of the string   /*          */
  1786.                     call    FindStringExpansion ;               /*          */
  1787.                     mov     cx, MIROCRYSTAL_MANUFACTURER ;      /*          */
  1788.                 .endif                  ;                       /*          */
  1789.             .else                                               /*@V3.0YEE01*/
  1790. ;             Looking for Thinkpad system                         @V3.0YEE01
  1791.               .if     <[_sSVGA.AdapterType] e WESTERNDIG_ADAPTER> ;4
  1792.                  cli                    ;don't let system interrupt test
  1793.                  mov     dx, 070h       ;query CMOS to see if
  1794.                  mov     al, 07ch       ;SMAPI installed.
  1795.                  out     dx, al         ;SMAPI unique to Thinkpads
  1796.                  inc     dx             ; 
  1797.                  in      al, dx         ; 
  1798.                  .if     <al e 'I'>     ; 
  1799.                      dec    dx          ; 
  1800.                      mov    al, 07dh    ; 
  1801.                      out    dx, al      ; 
  1802.                      inc    dx          ; 
  1803.                      in     al, dx      ; 
  1804.                      cmp    al, 'S'     ;Tbird Enhanced or later
  1805.                      je     @F          ; 
  1806.                      cmp    al, 06h     ;Tbird or Flamingo
  1807.                      jne    NotThinkPad ; 
  1808. @@:                  mov    cx, THINKPAD_MANUFACTURER  ;yep, found one!!
  1809. NotThinkPad:
  1810.                  .endif                 ;end Thinkpad search      @V3.0YEE01
  1811.                  sti                    ;re-enable interrupts     @V3.0YEE01
  1812.               .endif                    ;end WD search again    /*@V3.0YEE01*/
  1813.             .endif                      ;                       /*          */
  1814.         .endif                          ;                       /*          */
  1815.         .if     < z >                   ;If card found:         /*          */
  1816. ;           pop     si                  ;                       /*          */
  1817. ;           pop     es                  ;                       /*          */
  1818.             mov     [SvgaOEMInfo.Manufacturer], cx
  1819.         .endif                          ;                       /*          */
  1820. ;       ret                             ;                       /*          */
  1821. ExitOEM:
  1822. ;       pop     si                      ;                       /*          */
  1823. ;       pop     es                      ;                       /*          */
  1824.         popa                            ;                       /*          */
  1825.         ret
  1826.  
  1827. ProcessOEM      ENDP
  1828.  
  1829. ENDIF ;/* FAMILY2 */                                            /*          */
  1830.  
  1831. ;            start
  1832. ;--------------------------------------------------------------------------
  1833. ; SUBROUTINE NAME:      AttachOEM
  1834. ;
  1835. ; DESCRIPTIVE NAME:     Attach to OEMHLP PDD and retrieve ADAPTER TYPE.
  1836. ;
  1837. ; FUNCTION:     Call OEMHLP IOCTL 7 to obtain Adapter type.
  1838. ;
  1839. ; ENTRY POINT:  AttachOEM
  1840. ;    LINKAGE:   Call Near
  1841. ;
  1842. ; INPUT:
  1843. ;       ES:BX = request packet address
  1844. ;       DS = BIODATA
  1845. ;
  1846. ; EXIT-NORMAL:
  1847. ;       VOID function.
  1848. ;
  1849. ; EXIT-ERROR:
  1850. ;       VOID function.
  1851. ;
  1852. ; EFFECTS:
  1853. ;       All preserved.
  1854. ;
  1855. ;    USES ROUTINES:
  1856. ;
  1857. ; CALLED BY ROUTINES:
  1858. ;               INIT
  1859. ;
  1860. AttachOEM       PROC    NEAR
  1861.         push    es
  1862.         push    bx
  1863.         ; 
  1864.         ; Attach to OEMHLP and obtain the entry point into its IDC which
  1865.         ; represent the strategy routine entry point as well.
  1866.         ; 
  1867.         mov     bx, offset OemName
  1868.         mov     di, offset OemDDEntry
  1869.         mov     dl, DevHlp_AttachDD
  1870.         call    DevHelp
  1871.         jc      AttachExit
  1872.         ; Build a request packet suitable for function 7, category 80
  1873.         mov     OemDDRequest.PktLen, 25
  1874.         mov     OemDDRequest.PktCmd, CMDGenIOCtl
  1875.         mov     OemDDRequest.PktUnit, 0
  1876.         mov     OemDDRequest.PktStatus, 0
  1877.         mov     OemDDRequest.PktFlag, 0
  1878.         mov     OemDDRequest.GIOCategory, 80H
  1879.         mov     OemDDRequest.GIOFunction, 7
  1880.         mov     dword ptr OemDDRequest.GIOParaPack, 0
  1881.         mov     ax, offset ADAPTER_TYPE
  1882.         mov     word ptr OemDDRequest.GIODataPack, ax
  1883.         mov     ax, ds
  1884.         mov     word ptr OemDDRequest.GIODataPack + 2, ax
  1885.  
  1886.         ; Execute IOCTL which will fill out our local ADAPTER_TYPE.
  1887.         ; save our DS, load DS with OEMHLP and load es:bx with Packet
  1888.         mov     es, ax
  1889.         mov     bx, offset OemDDRequest                 ; es:bx request packet.
  1890.         push    ds
  1891.         mov     ax, es:OemDDEntry.ProtDS
  1892.         mov     ds, ax
  1893.         call    dword ptr es:OemDDEntry.ProtEntry
  1894.         pop     ds
  1895.         xor     cx, cx          ;index
  1896.         mov     byte ptr Class_Index, 0             ;@TSU
  1897. ;        int     3             ; ========================================
  1898.         mov     OEMDDEntry.ReqStat, 0
  1899.         mov     dword ptr pciFindClassP.pfcc_ulClassCode, currentClass ; there are multiple classes that could work
  1900.         align 2
  1901. QueryNextPCIConfiguration:                                  ;@senja start
  1902.         ; CAll OEMHLP to execute a PCI BIOS find (video) class and read configuration
  1903.         ; space. PCI_video structure (8 entries) will contain the Vendor ID and device ID
  1904.         ; for upto 8 video devices found.
  1905.         mov     OemDDRequest.PktLen, 25
  1906.         mov     OemDDRequest.PktCmd, CMDGenIOCtl
  1907.         mov     OemDDRequest.PktUnit, 0
  1908.         mov     OemDDRequest.PktStatus, 0
  1909.         mov     OemDDRequest.PktFlag, 0
  1910.         mov     OemDDRequest.GIOCategory, 00H
  1911.         mov     OemDDRequest.GIOFunction, 0bh          ;PCI_FUNC
  1912.         mov     pciFindClassP.pfcc_bPCIFunc, OEM_PCI_FIND_CLASS_CODE
  1913.  
  1914. ;        mov     pciFindClassP.pfcc_bIndex, cl              ; current index
  1915.         mov     al, Class_Index                        ; @TSU
  1916.         mov     pciFindClassP.pfcc_bIndex, al          ; current index @TSU
  1917.         inc     al                                     ; @TSU
  1918.         mov     byte ptr Class_Index, al               ; @TSU
  1919.         mov     word ptr OemDDRequest.GIOParaPack, offset pciFindClassP
  1920.         mov     ax, ds
  1921.         mov     word ptr OemDDRequest.GIOParaPack + 2, ax
  1922.         mov     ax, ds
  1923.         ; setup the data packet
  1924.         mov     word ptr OemDDRequest.GIODataPack, offset pciFindClassD
  1925.         mov     word ptr OemDDRequest.GIODataPack + 2, ax
  1926.         ; Execute IOCTL which will fill out our local pciFindClassD.
  1927.         ; save our DS, load DS with OEMHLP and load es:bx with Packet
  1928.         mov     es, ax
  1929.         mov     bx, offset OemDDRequest                 ; es:bx request packet.
  1930.         push    cx
  1931.         push    ds
  1932.         mov     ax, es:OemDDEntry.ProtDS
  1933.         mov     ds, ax
  1934.         call    dword ptr es:OemDDEntry.ProtEntry
  1935.         pop     ds
  1936.         pop     cx
  1937.         ; if the IOCTL returned success and a device of our class was found
  1938.         ; issue ReadConfiguration call to obtain the vendor ID
  1939.         cmp     OEMDDEntry.ReqStat, 0
  1940.         jnz     AttachExit
  1941. ;        cmp     pciFindClassD.pfcc_bReturn, PCI_SUCCESSFUL
  1942.         test    ax, 08000h                      ; bit 15 is the generic error
  1943.                                                 ; bit for IOCTL calls @TSU
  1944.         jz      short @F                        ; found the class, get the info
  1945.                                                 ; failed to find a device of current class
  1946.         cmp     dword ptr pciFindClassP.pfcc_ulClassCode, lastClass ; 
  1947.         jz      AttachExit                      ; failed to find any video class.
  1948.         cmp     dword ptr pciFindClassP.pfcc_ulClassCode, SVGAClass         ; see comment on the class list.
  1949.         jz      TryXGAClass                      ;@TSU
  1950. ;        jz      TryLastClass                   ;@TSU
  1951.         cmp     dword ptr pciFindClassP.pfcc_ulClassCode, XGAClass ;@TSU ; see comment on the class list.
  1952.         jz      TryLastClass                      ;@TSU
  1953.         cmp     dword ptr pciFindClassP.pfcc_ulClassCode, VGAClass ;          
  1954.         jz      TrySVGAClass                                       ;          
  1955.         mov     dword ptr pciFindClassP.pfcc_ulClassCode, VGAClass ;          
  1956.         mov     byte ptr Class_Index, 0                            ;          
  1957.         jmp     QueryNextPCIConfiguration                          ;          
  1958. TrySVGAClass:                                                      ;          
  1959.         mov     dword ptr pciFindClassP.pfcc_ulClassCode, SVGAClass
  1960.         mov     byte ptr Class_Index, 0             ;@TSU
  1961.         jmp     QueryNextPCIConfiguration
  1962. TryXGAClass:                                                        ;@TSU
  1963.         mov     dword ptr pciFindClassP.pfcc_ulClassCode, XGAClass  ;@TSU
  1964.         mov     byte ptr Class_Index, 0             ;@TSU
  1965.         jmp     QueryNextPCIConfiguration                           ;@TSU
  1966. TryLastClass:
  1967.         mov     dword ptr pciFindClassP.pfcc_ulClassCode, lastClass
  1968.         mov     byte ptr Class_Index, 0             ;@TSU
  1969.         jmp     QueryNextPCIConfiguration
  1970. @@:
  1971.         ; 
  1972.         ; Setup the request packet to issue the read configuration caal
  1973.         ; 
  1974.         mov     OEMDDEntry.ReqStat, 0
  1975.         mov     byte ptr PciReadConfigP.prc_bPCIFunc, OEM_PCI_READ_CONFIG
  1976.         mov     al, byte ptr pciFindClassD.pfcc_bDevFunc
  1977.         mov     ah, byte ptr pciFindClassD.pfcc_bBusNum
  1978.         mov     byte ptr PciReadConfigP.prc_bDevFunc,al
  1979.         mov     byte ptr PciReadConfigP.prc_bBusNum, ah
  1980.         mov     byte ptr PciReadConfigP.prc_bConfigReg, 0           ;get Vendor ID and Device ID
  1981.         mov     byte ptr PciReadConfigP.prc_bSize, 4
  1982.         ; for future:
  1983.         ; perform another IOCTl to get configuration data from byte offset 4,
  1984.         ; 2 bytes to read the command register. If bits 0,1 are non0, the
  1985.         ; device has been enabled.If multiple devices enabled, get base
  1986.         ; addresses for io and memory ports as well.
  1987.         ; Also, get subsystem ID which identifies the adapter maker.
  1988.         mov     word ptr OemDDRequest.GIOParaPack, offset pciReadConfigP
  1989.         mov     ax, ds
  1990.         mov     word ptr OemDDRequest.GIOParaPack + 2, ax
  1991.         mov     ax, ds
  1992.         ; setup the data packet
  1993.         mov     word ptr OemDDRequest.GIODataPack, offset pciReadConfigD
  1994.         mov     word ptr OemDDRequest.GIODataPack + 2, ax
  1995.         mov     OEMDDEntry.ReqStat, 0
  1996.         ; Execute IOCTL which will fill out our local pciReadConfigD.
  1997.         ; save our DS, load DS with OEMHLP and load es:bx with Packet
  1998.         mov     es, ax
  1999.         mov     bx, offset OemDDRequest                 ; es:bx request packet.
  2000.         push    cx
  2001.         push    ds
  2002.         mov     ax, es:OemDDEntry.ProtDS
  2003.         mov     ds, ax
  2004.         call    dword ptr es:OemDDEntry.ProtEntry
  2005.         pop     ds
  2006.         pop     cx
  2007.         ; if the IOCTL returned success and a PCI function returned success
  2008.         ; stash the ID.
  2009.         ; keep going until the FindClass function fails
  2010.         cmp     OEMDDEntry.ReqStat, 0
  2011.         jnz     @F
  2012.         cmp     pciReadConfigD.prc_bReturn, PCI_SUCCESSFUL
  2013.         jnz     @F
  2014.         mov     si, offset PCI_DeviceTbl           ;ulong hw: Vendor ID, lw Device ID
  2015.         mov     ax, cx
  2016.         shl     ax, 2
  2017.         add     si, ax
  2018.         mov     ax, word ptr pciReadConfigD.prc_ulData
  2019.         mov     word ptr ds:[si], ax; stash the value
  2020.         mov     ax, word ptr pciReadConfigD.prc_ulData[2]
  2021.         mov     word ptr ds:[si+2], ax; stash the value
  2022.         ; 
  2023.         ; 
  2024.         ;          
  2025.         ; Setup the request packet to issue the read configuration to
  2026.         ; read command register and status register
  2027.         ; 
  2028.         mov     OEMDDEntry.ReqStat, 0
  2029.         mov     byte ptr PciReadConfigP.prc_bPCIFunc, OEM_PCI_READ_CONFIG
  2030.         mov     al, byte ptr pciFindClassD.pfcc_bDevFunc
  2031.         mov     ah, byte ptr pciFindClassD.pfcc_bBusNum
  2032.         mov     byte ptr PciReadConfigP.prc_bDevFunc,al
  2033.         mov     byte ptr PciReadConfigP.prc_bBusNum, ah
  2034.         mov     byte ptr PciReadConfigP.prc_bConfigReg, 4 ; get command register and status register
  2035.         mov     byte ptr PciReadConfigP.prc_bSize, 4
  2036.         mov     word ptr OemDDRequest.GIOParaPack, offset pciReadConfigP
  2037.         mov     ax, ds
  2038.         mov     word ptr OemDDRequest.GIOParaPack + 2, ax
  2039.         mov     ax, ds
  2040.         ; setup the data packet
  2041.         mov     word ptr OemDDRequest.GIODataPack, offset pciReadConfigD
  2042.         mov     word ptr OemDDRequest.GIODataPack + 2, ax
  2043.         mov     OEMDDEntry.ReqStat, 0
  2044.         ; Execute IOCTL which will fill out our local pciReadConfigD.
  2045.         ; save our DS, load DS with OEMHLP and load es:bx with Packet
  2046.         mov     es, ax
  2047.         mov     bx, offset OemDDRequest                 ; es:bx request packet.
  2048.         push    cx
  2049.         push    ds
  2050.         mov     ax, es:OemDDEntry.ProtDS
  2051.         mov     ds, ax
  2052.         call    dword ptr es:OemDDEntry.ProtEntry
  2053.         pop     ds
  2054.         pop     cx
  2055.         ; if the IOCTL returned success and a PCI function returned success
  2056.         ; stash the ID.
  2057.         ; keep going until the FindClass function fails
  2058.         cmp     OEMDDEntry.ReqStat, 0
  2059.         jnz     @F
  2060.         cmp     pciReadConfigD.prc_bReturn, PCI_SUCCESSFUL
  2061.         jnz     @F
  2062.         ; Test command register
  2063.         mov     ax, word ptr pciReadConfigD.prc_ulData
  2064.         and     ax, 03h   ; I/O access and memory access enabled
  2065.         jz      @F        ;this video is disabled
  2066.         inc     cx        ; this video is enabled, add it to PCI_DeviceTbl
  2067. @@:
  2068.         cmp     cx, 8
  2069.         jae     AttachExit
  2070.         jmp     QueryNextPCIConfiguration
  2071. AttachExit:                             ;//@senja end
  2072.         mov     word ptr PCI_Num, cx    ;remeber how many PCI devices were found.
  2073.         pop     bx
  2074.         pop     es
  2075.         ret
  2076. AttachOEM       ENDP
  2077. ;            end
  2078.  
  2079. ;*****************************************************************************
  2080.  
  2081. ;**     INIT - Device Driver Initialization routine
  2082. ;
  2083. ;       ENTRY
  2084. ;               ES:BX = Request Packet
  2085. ;               DS    = ?
  2086. ;       EXIT
  2087. ;               Terminating Code Address Set
  2088. ;               Terminating Data Address Set
  2089. ;               BIOS palette save area initialized ;@@2
  2090. ;               Status = OK
  2091. ;               DevHelp Address Saved
  2092. ;
  2093.  
  2094. PUBLIC  Init
  2095. Init    PROC    NEAR
  2096.  
  2097. ; Save DevHelp Function Router Address
  2098.  
  2099.         mov     ax,word ptr ES:[bx.InitpEnd]
  2100.         mov     word ptr DevHelp,ax
  2101.         mov     ax,word ptr ES:[bx.InitpEnd+2]
  2102.         mov     word ptr DevHelp+2,ax
  2103.  
  2104.         ; 
  2105.         ; Attach to OEMHLP to determine adapter type
  2106.         ; 
  2107.         call    AttachOEM                       ;           
  2108.         ; 
  2109.         ; Determine Super VGA adapter type
  2110.         ; 
  2111.         test    [ADAPTER_TYPE], EGA_BIT ;                       /*          */
  2112.         jnz     @F                      ;                       /*          */
  2113.         call    _IdentifySVGA           ;                       /*          */
  2114. @@:                                     ;                       /*          */
  2115.  
  2116.         IFDEF   FAMILY2                 ;                       /*          */
  2117.         call    ProcessMC_OEM           ;           
  2118.         ELSE
  2119.         call    ProcessOEM
  2120.         ENDIF                           ;                       /*          */
  2121.  
  2122.         push    es
  2123.         ; 
  2124.         ; Register with VDM manager for communication with VVID.
  2125.         ; 
  2126.         mov     ax, SEG ScreenDDName
  2127.         mov     ds, ax
  2128.         ASSUME  DS:BioData
  2129.         lea     si, ScreenDDName
  2130.         mov     di, cs
  2131.         mov     es, di                          ; DS:SI = Pointer to name of PDD
  2132.         lea     di, VVID_IDC                    ; ES:DI = Pointer to IDC
  2133.         mov     dl,DevHlp_RegisterPDD
  2134.         call    DevHelp                         ; if the function fails, system halp occures.
  2135.         pop     es
  2136.         mov     word ptr es:[bx.InitpEnd],offset DEVICE_END-1 ;@@4
  2137.         mov     word ptr es:[bx.InitpEnd+2],offset DATA_END-1 ;@@4
  2138. IFDEF  FAMILY2
  2139.         mov     al,3                            ; Video Device Id ???
  2140.         mov     bl,0                            ; First available LID
  2141.         mov     dh,0                            ; Device State = 0 (Reserved)
  2142.         mov     dl,DevHlp_GetLIDEntry
  2143.         Call    DevHelp
  2144.         sti
  2145.         .if     nc
  2146.             mov     LID,ax                      ; Save the LID number
  2147.         .endif
  2148. ENDIF
  2149.         sub     ax,ax                           ; DCR0226
  2150.         ret
  2151. Init    ENDP
  2152.  
  2153. BiosSeg ends
  2154.  
  2155.         end
  2156. ;           12/28/92 Senja SVGA support. File created.
  2157. ;           01/20/93 Senja Enhanced WD detection.
  2158. ;           01/21/93 Senja XGA doesn't boot because Aperture Index gets trashed.
  2159. ;           02/10/93 Senja Manufacturer info IOCTL.
  2160. ;           02/18/93 Senja UpdateMemoryInfo IOCTL.
  2161. ;           03/05/93 Senja Do not identify XGA as Speedway.
  2162. ;           03/10/93 Senja Identification of MC Orchid.
  2163. ;           03/12/93 Senja Changed BANK packet interface to be more consistent.
  2164. ;           03/16/93 Senja Making SCREENDD more consistent.
  2165. ;           03/23/93 Senja Fixing bank packet validation.
  2166. ;           04/03/93 Senja Attach to OEMHLP.
  2167. ;           04/14/92 Senja If XGA detected, do not proceed with the detection.
  2168. ;           05/02/93       Improve Speedway checks, defect 68723.
  2169. ;           06/03/93       Lock the extended sequencer before exit, defect 69461
  2170. ;           06/03/93       ACER M3125 SVGA fix, defect 63910
  2171. ;           06/04/93 F69306 Add support for S3
  2172. ;           08/12/93  72760 Enhance S3 chip detection
  2173. ;           08/30/93  73465 Only need 1 manufacturer value for Diamond
  2174. ;           08/31/93        Recognize Cirrus Logic GD5428 chip
  2175. ;           10/06/93  72687 Support Number Nine adapters with S3
  2176. ;           10/13/93  74175 Fix SVGA conflict on Gateway VLB
  2177. ;           11/01/93 D75458 Merge r206v, r205, r206, r207 S3 code
  2178. ;           12/15/93  76685 Recognize Winsprint adapter by Artist Graphics
  2179. ;           03/01/94 D79562 Recognize additional WD chipsets
  2180. ;           03/15/94 D80921 Fix WD DOS started in background
  2181. ;           05/13/94 F74819 ATI Mach8/32 check in files
  2182. ;           09/21/94 D99280 PCI detection conflict
  2183. ;---NOT RELEASED:---
  2184. ;           02/22/94        PMIRing0 communication interface.
  2185. ;           09/12/94  97689 Recognize miroCRYSTAL adapter
  2186. ;@V3.0YEE01 02/24/95 113003 Recognize Thinkpad systems
  2187.