📄 runtime.asm
字号:
jmp short $+2
jmp short $+2
;;=====================================================================;;
mov cx,4000h ; Delay
call fixed_delay
mov ah,63h
call read_sio_byte
or al,18h
call write_sio_byte
jmp $
;-----------------------------------------------------------------------;
; PREPARE_CHIPSET_FOR_FLASH_PROGRAMMING ; Moved from NRUNTIME.ASM
;-----------------------------------------------------------------------;
; This routine is called from extra INT-16 func E002h which prepares the;
; chipset for flash programming. This function is used by Flash program ;
; utility AMIFLASH. ;
; input : ;
; none ;
; stack available ;
; output: ;
; none ;
; register usage : Do not destroy any register ;
; Note: ;
; 1. Disable external cache and internal cache. ;
; 2. Disable power management. ;
; 3. Disable all shadow rams. ;
; 4. Enable E000 and F000 ROM and set BIOS size to 128K. ;
;-----------------------------------------------------------------------;
public prepare_chipset_for_flash_programming
extrn e000_read_rom_write_x:near
extrn f000_read_rom_write_x:near
extrn oem_prepare_chipset_for_flash_programming:near
prepare_chipset_for_flash_programming:
call disable_l1_cache
call disable_l2_cache
call e000_read_rom_write_x
call f000_read_rom_write_x
call oem_prepare_chipset_for_flash_programming
ret
COMMENT ~
;-----------------------------------------------------------------------;
; DISABLE_POWER_MANAGEMENT ;
;-----------------------------------------------------------------------;
; This routine is called from extra INT-16 func E002h which prepares the;
; chipset for flash programming. This function is used by Flash program ;
; utility AMIFLASH. ;
; input : ;
; none ;
; stack available ;
; output: ;
; none ;
; register usage : Do not destroy any register ;
; Note: ;
; 1. This routine should disable ALL power managent timers, disable all ;
; system events & break events, disable generation of SMI for all ;
; associated hardware events EXCEPT SMI generation for USB. ;
; PLEASE NOTE that if USB Keyboard is enabled, USB SMI generation MUST ;
; remain enabled, otherwise AMIFLASH utility will NOT get any keystrokes;
; from USB keyboard. ;
; 2. This routine should relocate the USB Bus Master data area from ;
; EE00:0000 to some other shadow RAM in C or D segment. Currently since ;
; BIOS is 128K size, the USB Bus Master data area can be relocated to ;
; DE00:0000 (note that this is not valid if BIOS size is more than 128K);
;-----------------------------------------------------------------------;
public disable_power_management
disable_power_management:
pushad
if MKF_USB_SUPPORT
; USB support is present
mov ax,2f02h ; Stop USB Host controller
CALL_RT_FUNCTION
mov al,Q_USB_LEGACY_ENABLE
extrn check_cmos_data:near
call check_cmos_data
jz dpm_00 ; USB Legacy disabled
; WRITE CODE HERE to Enable both Read and Write to some other SHADOW RAM
; area say (DE00:0000). This shadow RAM area will be used from nowon for
; USB Bus Mastering....................................................
; start USB Host at new Bust Master data area
; EBX = 32-bit absolute address for new Bus Master data area
mov ebx,000DE000h ; Bus Mastering address DE00:0000
mov cl,00h ; Enumerate, Beep
mov ax,2f01h ; Start USB Host
CALL_RT_FUNCTION
dpm_00:
; WRITE CODE HERE TO DISABLE ALL SMI GENERATION except USB SMI
; WRITE CODE HERE TO DISABLE ALL SYSTEM EVENTS and BREAK EVENTS
;---------------------------------------;
else
;---------------------------------------;
; USB support is NOT present
; WRITE CODE HERE TO DISABLE ALL SMI
;--------------- CHIPSET PORTING ---------------;
call get_pm_base_addr
mov si, offset cgroup:global_smi_disable_table
mov cx, (offset cgroup:global_smi_disable_table_end - offset cgroup:global_smi_disable_table) / 5
_01_dpm_prog_pmio_loop:
push cx ;Save Number of entries
lods word ptr cs:[si] ;Get bits to set
mov bx, ax ;BX = bits to set
lods word ptr cs:[si] ;Get bits to reset
mov cx, ax ;CX = bits to reset
lods byte ptr cs:[si] ;Get reg#.
push dx ;Save PM Base Address
movzx ax, al
add dx, ax ;DX = I/O register
in ax, dx ;AX = data
not cx ;CX = AND mask
and ax, cx ;Clear bits
or ax, bx ;Set bits
out dx, ax ;Write data
pop dx ;Restore PM Base Address
pop cx ;Restore Number of entries
loop short _01_dpm_prog_pmio_loop ;Process next entry
;------------- CHIPSET PORTING END -------------;
;---------------------------------------;
endif
popad
ret
~
;-----------------------------------------------------------------------;
; SET_INT_40_FLAG ; Moved from NRUNTIME.ASM
; CLEAR_INT_40_FLAG ; Moved from NRUNTIME.ASM
; SET_INT_13_FLAG ; Moved from NRUNTIME.ASM
; CLEAR_INT_13_FLAG ; Moved from NRUNTIME.ASM
;-----------------------------------------------------------------------;
extrn oem_set_int_40_flag:near
public set_int_40_flag
set_int_40_flag:
call oem_set_int_40_flag
ret
;-----------------------------------------------------------------------;
extrn oem_clear_int_40_flag:near
public clear_int_40_flag
clear_int_40_flag:
call oem_clear_int_40_flag
ret
;-----------------------------------------------------------------------;
extrn oem_set_int_13_flag:near
public set_int_13_flag
set_int_13_flag:
call oem_set_int_13_flag
ret
;-----------------------------------------------------------------------;
extrn oem_clear_int_13_flag:near
public clear_int_13_flag
clear_int_13_flag:
call oem_clear_int_13_flag
ret
;-----------------------------------------------------------------------;
; LPT SUPPORT ROUTINES ; Moved to OEMRUN.ASM
;-----------------------------------------------------------------------;
; GET_LPT_IRQ_INFO ; Moved to OEMRUN.ASM
; SET_LPT_IRQ ; Moved to OEMRUN.ASM
; GET_LPT_ECP_DMA_INFO ; Moved to OEMRUN.ASM
; SET_LPT_ECP_DMA_CHANNEL ; Moved to OEMRUN.ASM
;-----------------------------------------------------------------------;
;-----------------------------------------------------------------------;
; CHECK_100MHZ_CPU_BUS ;
;-----------------------------------------------------------------------;
; Input: None ;
; ;
; Output: ZR CPU BUS is 100 MHz ;
; NZ CPU BUS is 66 MHz ;
; ;
; Registers Destroyed: None ;
; Note: This route available after check point 24 ;
;-----------------------------------------------------------------------;
extrn cpu_freq:word
public check_100mhz_cpu_bus
check_100mhz_cpu_bus proc near
or sp,sp
ret
push eax
push ecx
push edx
mov ecx,02ah
.586p
rdmsr
.486p
shr eax,22
and ax,0fh
push bx
mov bx,offset cgroup:core_clock_freq_table
db 2eh
xlat
pop bx
mov cx,cpu_freq
xchg ax,cx
mov dx,10
mul dx
div cx
cmp al,100
pop edx
pop ecx
pop eax
ret
check_100mhz_cpu_bus endp
core_clock_freq_table label byte
db 20,30,40,50,25,35,45,55,60,70,80,00,65,75,00,20
;;============================================
;;Input:al = 0,1,2
;;outut:ax = ? M size
;;============================================
extrn read_pci_byte:near
public get_bank_size
get_bank_size:
push bx
push cx
push dx
push si
xor dx,dx
movzx cx,al
mov ah,63h
call read_pci_byte
bt ax,cx
jnc no_dram_installed
mov ah,60h
add ah,cl
call read_pci_byte
mov cl,al
mov ch,al ; CH for check DRAM side
and al,0fh ; it is DRAM Type
;;the bank is SDRAM
mov bx,offset cgroup:sdram_size_translate_table
get_size:
db 2eh ; CS:
xlat
movzx dx,al
shl dx,1
test ch,00100000b
jz no_dram_installed;jmp if single size
shl dx,1
no_dram_installed:
mov ax,dx ; output ax
pop si
pop dx
pop cx
pop bx
ret
sdram_size_translate_table label byte
db 4 ; no dram
db 16 ; 9*9
db 16 ; 10*10
db 32 ; 11*11
db 08 ; 12*12
db 32 ; 12*8
db 32 ; 12*9
db 64 ; 12*10
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -