📄 clkmpc.asm
字号:
;**************************************************************************
;*
;* CLKMPC.ASM
;*
;* Copyright (c) 1999-2002 National Semiconductor Corporation.
;* All Rights Reserved.
;*
;* Function:
;* Set up SC1x00 configuration block and PLLs
;*
;* $Revision: 3 $
;*
;**************************************************************************
.486P
INCLUDE DEF.INC
INCLUDE MACROS.INC
INCLUDE PORT80.INC
INCLUDE MPC.INC
INCLUDE OPTIONS.INC
INCLUDE BDCFG.INC
_TEXT SEGMENT PUBLIC use16 'CODE'
ASSUME CS:SEGGROUP
EXTERN CpuMemRegWrite:NEAR
EXTERN unreal:NEAR
EXTERN CpuRegRead:NEAR
EXTERN CpuRegWrite:NEAR
EXTERN Delay_100_mSec:NEAR
;**************************************************************************
;*
;* clockInit
;*
;* Configuration block, PLLs, MUX initialization
;*
;* Entry:
;* BX = return address
;*
;* Exit:
;* None
;*
;* Modified:
;* EBX, EAX, EDX, GS
;*
;**************************************************************************
clockInit PROC NEAR PUBLIC
shl ebx, 16
PORT80 P80_CHIPSET_INIT+01h
; Check if configuration block is configured already
mov dx, GEODE_CONFIG_BASE + GEODE_CBA
in ax, dx
cmp ax, GEODE_CONFIG_BASE
jz @f
PORT80 P80_CHIPSET_INIT+02h
; Put configuration block on new address
mov ax, GEODE_CONFIG_BASE
mov gs, ax
mov dx, GEODE_INIT_BASE
out dx, ax
@@:
mov dx, GEODE_CONFIG_BASE
mov gs, dx
; no longer process chip revision as we don't support rev a chips
; ; What is the revision of the chip?
; mov dx, gs ; NSC_GEODE_CONFIG_BASE
; add dx, GEODE_REV
; in al, dx
; cmp al, GEODE_SCXXXX_REVB ; Rev B or later?
; jae do_sc1200_revB
; ; Parallel Port, IDE or TFT/CRT, AC97,
; ; Video Port, IOR/IOW, AB2, SP2, SP1,
; ; TRDE, GPIO20, SP3, GPIO17, GPIO19,
; ; PC_BEEP, LPC
; mov dx, gs
; add dx, GEODE_PMR
; mov eax, PMR_A_VALUE
; out dx, eax
;
; jmp do_sc1200_general
;
;do_sc1200_revB:
; ; AC97, IDE, Parallel Port, IOR/IOW,
; ; AB2, SP2, SP1, LPC, GPIO01, TRDE, INTC
; ; IR, GPIO20, PC_BEEP
mov dx, gs
add dx, GEODE_PMR
if (SCx2xx_PROCESSOR)
mov eax, PMR_B_VALUE
else
; SC1100 Tavor
mov eax, PMR_VALUE
endif
out dx, eax
do_sc1200_general:
; Set 8-bit wide ROM
mov dx, gs
add dx, GEODE_MCR
mov eax, USER_MCR
out dx, eax
; Set PLL Power Control
mov dx, gs
add dx, GEODE_PPCR
in al, dx
IF (SCx1xx_PROCESSOR eq 0)
and al, 0D1h ; Enable FMUL1, PLL2, PLL3,
; TV encoder, USB and SuperI/O
ELSE
and al, 0B1h ; Enable FMUL1, PLL2, PLL3,
; USB and SuperI/O
ENDIF
out dx, al
PORT80 P80_CHIPSET_INIT+03h
mov al, 056h ; Start TIMER 1
out 043h, al
mov al, 012h
out 041h, al
shr ebx, 16
jmp bx
clockInit ENDP
;**************************************************************************
;*
;* GetHRTimerSpeed
;* Calculates
;*
;* Entry: Nothing
;*
;* Exit: AX = Speed in Mhz
;*
;* Destroys: EAX, EBX, ECX, EDX
;*
;**************************************************************************
GetHRTimerSpeed proc near public
push ebx
push ecx
push edx
; Determine the state of the High Resolution Timer
mov dx, GEODE_CONFIG_BASE + GEODE_TMRCNFG
in al, dx
mov cx, ax ; Save the state for reset later
or al, 03H ; Select 25Mhz (bit1) and enabled (bit0)
and al, 0FBH ; Select 25Mhz input enabled (bit2) and preserve reset (bits3-7)
mov dx, GEODE_CONFIG_BASE + GEODE_TMRCNFG
out dx, al
mov al, 0C1H ; Turn off SMIs
NOSTACK bx, CpuRegRead
shl ecx, 16 ; Save CX
mov cl, al ; Save state in cl for later
and cl, 2
and al, 0FDH
mov dl, al
mov al, 0C1H
NOSTACK bx, CpuRegWrite
pushf ; Turn of interrupts
cli
; Get start count and save in edi
mov dx, GEODE_CONFIG_BASE + GEODE_TIMER
in eax, dx
mov ebx, eax
call Delay_100_mSec
; Get end count
mov dx, GEODE_CONFIG_BASE + GEODE_TIMER
in eax, dx
popf
; Calculate The Total Counts (Start - Final)
sub eax, ebx
push ax
mov al, 0C1H ; Restore SMI state
NOSTACK bx, CpuRegRead
or al, cl ; Use saved state in cl
mov dl, al
mov al, 0C1H
NOSTACK bx, CpuRegWrite
shr ecx, 16 ; Restore CX
pop ax
; Multiply By 10 The Old Fashioned Way
; To Get Counts/Second
mov ebx, eax
shl eax, 3
add eax, ebx
add eax, ebx
add eax, 500000 ; Round up
; Divide By A Million To Get MHz
xor edx, edx
mov ebx, 1000000
div ebx
; Reset the state of the timer
push ax
xor eax, eax ; Clear upper word of eax
mov dx, GEODE_CONFIG_BASE + GEODE_TMRCNFG
mov ax, cx
out dx, al
pop ax
pop edx
pop ecx
pop ebx
ret
GetHRTimerSpeed endp
_TEXT ENDS
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -