home *** CD-ROM | disk | FTP | other *** search
- small_m = 1
- mach386 = 1
- GOC = 1
- include model
- .386p
- page 66,132
- title _67INIT - Point WTLSEG segment to ABACUS Physical Address
- name _67INIT
- public _67INIT, _mwWTLBASE
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; 67INIT -
- ; This routine modifies the Physical Page tables so that references
- ; into the WTLSEG segment will be translated into offsets from the
- ; ABACUS physical address C0000000h. It was written to facilitate mapped
- ; addressing under the Pharlap Protected mode environment.
- ;
- ; Returns: eax = 0 If mapping completed normally.
- ; eax = -1 If FS selector does not point to the ABACUS.
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Pharlap segment descriptors.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- THE_PSP equ 24h ; Pharlap PSP segment descriptor
- GDT_SEG equ 38h ; Maps the GDT
- LDT_SEG equ 30h ; Maps the LDT
- THE_LDT equ 28h ; The actual LDT descriptor
- MEM_SEG equ 40h ; Maps all of physical memory
-
- SEGSTR struc ; Structure of segment table entry.
- limlow dw ?
- baselow dw ?
- basemid db ?
- segtype db ?
- limhi db ?
- basehi db ?
- SEGSTR ends
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; The base of the ABACUS address space is defined by WTLBASE below. If linked
- ; as the first object module, WTLBASE should be at offset 0 from the DS
- ; selector. If WTLBASE is at 0, references to the ABACUS are directed to the
- ; very first 64K of the data segment. If the public symbol WTLBASE is used
- ; for all ABACUS instructions it is possible to locate the ABACUS base
- ; address on any 64K boundry within the program. However, it then becomes
- ; necessary to define WTLBASE as an external symbol in all object modules
- ; that reference the ABACUS.
- ;
- ; The trick is to map the actual physical address of the ABACUS, C0000000h,
- ; to the page table for the logical address WTLBASE. Ideally, the OS
- ; will be able to make this association through a system call. The FS
- ; selector should remain unchanged for backwards compatibility.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- WTLSEG segment page4k rw use32 public 'DATA'
- _mwWTLBASE db 10000h dup (1) ;Weitek address space.
- WTLSEG ends
-
- _DATA segment use32 para public 'DATA'
-
- align 4
- CONFIG label dword
- flag1 dd ?
- flag2 dd ?
- flag3 dd ?
- major dd ? ; pharlap major version
- minor dd ? ; pharlap minor version
- letter dd ? ; letter following minor version
- org CONFIG+512
-
- swapfile db 256 DUP (?)
-
- _DATA ends
-
- DGROUP group WTLSEG,_DATA
- assume ds:DGROUP
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;CODESEG segment use32 para public 'code'
- CODESEG segment
- assume CS:CODESEG
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- _67INIT proc near
- push ebp
- mov ebp, esp
- push edi
- push esi
- push ebx
- push edx
- push gs
- push es
-
- ; See if the ABACUS is even present.
- mov ax, ds
- mov bx, fs
- cmp ax, bx
- jz enderr
-
-
- ; Find Pharlap version. Note that this only works for
- ; Pharlap versions >= 2.2d.
- lea ebx,CONFIG
- lea ecx,swapfile
- mov eax,2526h
- int 21h
- cmp major,3
- jge ph30
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; for pharlap version >=2.2d and < 3.0 ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ; Set up to address the LDT and Physical Memory
- push MEM_SEG ;gs <- Physical memory address selector
- pop gs
- push LDT_SEG ;es <- LDT selector
- pop es
-
- ; Load the Base Linear address of DS
- mov dx, ds
- and edx, 0FFF8h ;edx <- DS Selector index.
- mov al, es:[edx].basehi
- shl eax, 8
- mov al, es:[edx].basemid
- shl eax, 16
- mov ax, es:[edx].baselow
- mov edi, offset _mwWTLBASE ;Add the ABACUS segment offset.
- add edi, eax ;edi <- DS Linear address
-
- ; Load the Base Linear address of ABACUS
- mov bx, fs
- and ebx, 0FFF8h ;ebx <- ABACUS (FS) Selector index.
- mov al, es:[ebx].basehi
- shl eax, 8
- mov al, es:[ebx].basemid
- shl eax, 16
- mov ax, es:[ebx].baselow
- mov esi, eax ;esi <- ABACUS Linear address
-
- ; eax <- Physical Page Directory-Directory from CR3.
- mov eax, cr3 ;Load eax with CR3
- and eax, 0FFFFF000h ; -clear off reserved portion.
- mov ecx, esi
- shr ecx, 22
- mov ebx, gs:[eax+ecx*4] ;ebx <- ABACUS Page Directory address
- and ebx, 0FFFFF000h ; -clear off attribute bytes
- and esi, 003FFFFFh ;
- shr esi, 10 ;esi <- ABACUS Page Table Index
- add esi, ebx ;esi <- Address of first ABACUS PTE
-
- mov ecx, edi
- shr ecx, 22
- mov edx, gs:[eax+ecx*4] ;edx <- DS Page Directory address
- and edx, 0FFFFF000h ; -clear off attribute bytes.
- and edi, 003FFFFFh
- shr edi, 10 ;edi <- DS Page Table Index
- add edi, edx ;edi <- Address of first DS PTE
-
-
- ;ebx = ABACUS Page Directory address
- ;edx = DS Page Directory address
- ;esi = ABACUS Linear Page
- ;edi = DS Linear Page
- mov ecx, 16 ;Do 16 page table entries.
- bloop:
- mov eax, gs:[esi]
- ; make it cachable
- ; and eax, 0ffffffefh
- ; make it non cachable
- or eax, 00000010h
- mov gs:[edi],eax
- add esi, 4
- add edi, 4
- loop bloop
- jmp endok
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; for pharlap version >=3.0 ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- PHYS_DEV_ADDR EQU 0C0000000H ; address of Weitek chip
- DEV_ADDR_SPAN EQU 10000H ; 64K address span of chip
-
- ph30:
- ; Memory address expected in ES:ECX for DOSX calls
- push ds
- pop es
- lea ecx, _mwWTLBASE
-
- ; Ensure pages are unmapped, free them if they are.
- mov bl, 1 ; address type
- mov edx, DEV_ADDR_SPAN
- mov bh, 0 ; Create Unmapped Pages (sub-function 0)
- mov eax, 252bh ; DOSX Page management Call
- int 21h
- jc short enderr ; CF true if error
-
- ; Map the Weitek to WTLBASE
- mov bl, 1 ; address type
- mov edx, DEV_ADDR_SPAN
- mov bh, 2 ; Create Physical Device Pages (sub-function 2)
- mov edi, PHYS_DEV_ADDR; Page aligned chip physical address
- mov eax, 252bh ; DOSX Page management Call
- int 21h
- jc short enderr ; CF true if error
- jmp short endok
-
- enderr:
- mov eax, -1 ; error exit
- jmp short endprog
- endok:
- mov eax, 0 ; successful exit
- endprog:
- pop es
- pop gs
- pop edx
- pop ebx
- pop esi
- pop edi
- pop ebp
- ret
-
- _67INIT endp
- CODESEG ends
-
-
- addinit _67INIT
-
- end
-