home *** CD-ROM | disk | FTP | other *** search
- small_m = 1
- mach386 = 1
- GOC = 1
- ;
- ; (C) Copyright 1987-1992; MetaWare Incorporated
- ;
- .287
-
- include init.inc
-
- _TEXT segment dword public 'CODE'
- _TEXT ends
-
- _DATA segment dword public 'DATA'
- extrn _mw1167:word
- extrn _mwemc87:word
- extrn _mwenv:byte
- extrn _mwoops:byte
- extrn _mwwind:byte
- extrn _mwprintnochipmsg:byte
-
- used dw 0 ; set if a '67 chip is used
-
- _DATA ends
- DGROUP group _DATA
- assume ds:DGROUP
-
- _TEXT segment dword public 'CODE'
- CGROUP group _TEXT
- assume cs:CGROUP
-
- ;-------------------------------------------------------------------------------
- ; _mwinit_67()
- ;-------------------------------------------------------------------------------
- _mwinit_67 proc
- public _mwinit_67
- jmp begin
-
- _mwinit_67u:
- public _mwinit_67u
- mov used,1
-
- begin:
- prolog
- cmp _mw1167,0
- jne endall ; nothing to do
-
- SG_ENV = 1
- PL_ENV = 2
- AI_ENV = 3
-
- ifndef NOWTK
- ifdef DOS
- ; Deal with Weitek 1167
- ; Pharlap uses fs:; IGC uses ffc0_0000.
- ; We don't know yet whether this is AI_ENV and what they do with
- ; the Weitek.
-
- ; Early versions of the emc87 will hang if given weitek code.
- extrnf _mwinit_87
- call _mwinit_87
- cmp byte ptr _mwemc87,1
- je Skip_all_weitek_processing
-
- ; For windows, we have to look for the chip, and set up fs if
- ; it is there. A selector value for fs is put at ss:0 by the
- ; windows startup code. We just move this selector into fs.
- cmp _mwwind,1
- jne start_test
- int 11h ; get bios equipment list
- and eax,01000000h ; bit 24 set if weitek exists
- jz Skip_all_weitek_processing
- mov fs,ss:0
-
- start_test:
-
- seg_ldctx macro
- ; pop fs:[0c000h]
- ; Until the assembler will allow address mode override, inline code a 1-byte-shorter move:
- db 67h,64h,8fh,06h,00,0c0h
- endm
- seg_stctx macro
- db 67h,64h,0a1h,00h,0c4h ; store context to eax.
- endm
- flat_ldctx macro
- pop ds:[0ffc0c000h]
- endm
- flat_stctx macro
- pop ds:[0ffc0c400h]
- endm
-
- push 03ff0000h ; truncate (1ff = round to nearest).
- push 30000000h ;
- push 0a0000000h ; 1165 accum timer
- push 64000000h ; 1164 accum timer
- push 16000000h ; 1164/1165 flowthrough timer, 16 mhz
- push 98000000h ; 20 mhz part init
- push 56000000h ; 20 mhz part
- push 0b8000000h ; test speed of chip.
-
- ; ldctx 1600_0000 1164/1165 flowthrough timer.
- ; ldctx 6400_0000 1164 accumulate timer.
- ; ldctx a000_0000 1165 accumulate timer.
- ; ldctx 3000_0000 reserved mode bits.
- ; ldctx 01ff_0000 rounding modes/exception mask.
- ifdef IGC_exists
- cmp _mwenv,SG_ENV
- je short SG_weitek
- endif
- ifdef PL_exists
- ; Check that fs <> ds. If so, Weitek installed at fs:.
- mov ax,fs
- mov bx,ds
- cmp ax,bx
- je No_weitek
- and ax,ax ; If fs = 0 (Lahey linker), can't have Weitek.
- je No_weitek
- mov _mw1167,1
- ; Until the assembler will allow address mode override, inline code a 1-byte-shorter move:
- seg_ldctx ; load ctx b8_000_000
- seg_stctx ; store context to eax.
- and ah,80h
- jnz short _20MHZ_part
- pop eax ; Delete 20 mhz init stuff.
- pop eax
- seg_ldctx
- jmp short common_1167
- _20MHZ_part:
- seg_ldctx
- seg_ldctx
- pop eax ; Kill the 16 mhz init.
- common_1167:
- seg_ldctx
- seg_ldctx
- seg_ldctx
- seg_ldctx
- jmp short Finish_weitek
- endif
- SG_weitek:
- ifdef IGC_exists
- cmp byte ptr _mw1167,1
- jne short No_weitek
- flat_ldctx ; for test.
- flat_stctx ; store context to eax.
- and ah,80h
- jnz short _20MHZ_part_flat
- pop eax ; Delete 20 mhz init stuff.
- pop eax
- flat_ldctx
- jmp short common_1167_flat
- _20MHZ_part_flat:
- flat_ldctx
- flat_ldctx
- pop eax ; Kill the 16 mhz init.
- common_1167_flat:
- flat_ldctx
- flat_ldctx
- flat_ldctx
- flat_ldctx
- flat_ldctx
- jmp short Finish_weitek
- endif
- No_weitek:
- add esp,8*4 ; Get rid of the junk.
- Skip_all_weitek_processing:
-
- cmp used,0
- je Finish_weitek
- cmp _mwwind,1
- jne doserr
- mov _mwprintnochipmsg,1
- jmp short Finish_weitek
-
- doserr:
- mov ah,9
- mov edx,offset ds:_mwoops
- call _mwint21
- extrnf exit
- call exit
-
- Finish_weitek:
-
-
- endif
- endif
-
- endall:
- epilog
- _mwinit_67 endp
-
- _TEXT ends
- end
-