        title "miscellaneous MP primitives for the Corollary MP machines"
;++
;
;Copyright (c) 1994  Corollary, Inc
;
;Module Name:
;
;    cbusmisc.asm
;
;Abstract:
;
;   This module contains miscellaneous MP primitives for the
;   Corollary MP machines.
;
;Author:
;
;   Landy Wang (landy@corollary.com) 11-Jan-1994
;
;Environment:
;    Kernel mode.
;
;--

        .386P

_TEXT   SEGMENT  DWORD USE32 PUBLIC 'CODE'
_TEXT   ENDS

PUBLIC  _i486cacheon
PUBLIC  _inb
PUBLIC  _outb

        ASSUME   CS: FLAT, DS: FLAT, SS: FLAT, ES: FLAT

_TEXT   SEGMENT

CRO_CD          equ     0bfffffffh      ; turn on internal cache fills
CRO_NW          equ     0dfffffffh      ; enable write-thrus and invalidates

;++
;
; VOID
; i486cacheon
;
; Routine Description:
;
;   This function enables the calling processor's internal cache.
;   Executed by each processor from ProcInit for the
;   Corollary Cbus1 and Cbus2 architectures.
;
;   Note: This must be run before HalpInitializeStallExecution().
;
; Return Value:
;   none.
;
;--

_i486cacheon    PROC NEAR
        pushfd
        cli

        ; Enable the 486 processor internal cache.
        ; Note that we'd need the WBINVD for the Pentium, but no
        ; need to do that here - for the Pentium product we will
        ; be able to do it in the ROM.

        mov     eax, cr0                        ; get real cr0

        ; hard code the "invd" instruction to flush internal cache.
        ; this would cause an opcode trap on 386, but we will ship
        ; only 486 (Cbus1) and Pentium (Cbus2).

        db      00fh
        db      008h

        and     eax, CRO_CD                     ; turn "off cache disable"
        and     eax, CRO_NW                     ; turn "off not write-through"
        jmp     @f                              ; flush queues
@@:
        mov     cr0, eax                        ; put cr0 back
        popfd

        ret
_i486cacheon    ENDP

_inb    PROC NEAR
        xor     eax, eax
        mov     edx, dword ptr [esp+4]
        in      al, dx
        ret
_inb    ENDP

_outb   PROC NEAR
        mov     edx, dword ptr [esp+4]
        mov     al, byte ptr [esp+8]
        out     dx, al
        ret
_outb   ENDP

_TEXT   ends                                        ; end 32 bit code

        end
