1) SouthBridge utilities;

2) reverted for the old (but stable) 62syscall for a while...

git-svn-id: svn://kolibrios.org@1599 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Artem Jerdev (art_zh) 2010-09-02 20:24:07 +00:00
parent e5c581d60d
commit e5b8886135
14 changed files with 3544 additions and 1496 deletions

View File

@ -7,13 +7,16 @@
;; ;; ;; ;;
;; AMD HyperTransport bus control ;; ;; AMD HyperTransport bus control ;;
;; ;; ;; ;;
;; art_zh <artem@jerdev.co.uk> ;; ;; art_zh <kolibri@jerdev.co.uk> ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 1554 $ $Revision: 1554 $
NB_MISC_INDEX equ 0xF0000060 ; NB Misc indirect access
NB_MISC_DATA equ 0xF0000064
PCIEIND_INDEX equ 0xF00000E0 ; PCIe Core indirect config space access
HTIU_NB_INDEX equ 0xF0000094 ; HyperTransport indirect config space access
;============================================================================= ;=============================================================================
; ;
@ -44,6 +47,10 @@ rs7xx_nbconfig_flush_pci:
align 4 align 4
;------------------------------------------
; params: al = nbconfig register#
; ebx = register content
;
rs7xx_nbconfig_write_pci: rs7xx_nbconfig_write_pci:
and eax, 0x0FC ; leave register# only and eax, 0x0FC ; leave register# only
or eax, 0x80000000 ; bdf = 0:0.0 or eax, 0x80000000 ; bdf = 0:0.0
@ -54,6 +61,138 @@ rs7xx_nbconfig_write_pci:
out dx, eax out dx, eax
ret ret
;***************************************************************************
; Function
; rs7xx_unlock_bar3: unlocks the BAR3 register of nbconfig that
; makes pcie config address space visible
; -----------------------
; in: nothing out: nothing destroys: eax ebx edx
;
;***************************************************************************
align 4
rs7xx_unlock_bar3:
mov eax, NB_MISC_INDEX
mov ebx, 0x080 ; reg#0; write-enable
call rs7xx_nbconfig_write_pci ; set index
mov eax, NB_MISC_DATA
call rs7xx_nbconfig_read_pci ; read data
mov ebx, eax
and ebx, 0xFFFFFFF7 ; clear bit3
mov eax, NB_MISC_DATA
call rs7xx_nbconfig_write_pci ; write it back
mov eax, NB_MISC_INDEX
xor ebx, ebx ; reg#0; write-locked
call rs7xx_nbconfig_write_pci ; set index
ret
;--------------------------------------------------------------
align 4
rs780_read_misc:
; in: eax(al) - reg# out: eax = NBMISCIND data
push edx
mov edx, NB_MISC_INDEX
and eax, 0x07F
mov [edx], eax
add dl, 4
mov eax, [edx]
pop edx
ret
;-------------------------------------------
align 4
rs780_write_misc:
; in: eax(al) - reg# ebx = NBMISCIND data
push edx
mov edx, NB_MISC_INDEX
and eax, 0x07F
or eax, 0x080 ; set WE
mov [edx], eax
add dl, 4
mov [edx], ebx
sub dl, 4
xor eax, eax
mov [edx], eax ; safety last
pop edx
ret
;-------------------------------------------------------------
align 4
rs780_read_pcieind:
; in: ah = bridge#, al = reg# out: eax = PCIEIND data
push edx
xor edx, edx
mov ah, dl ; bridge# : 0 = Core+GFX; 0x10 = Core+SB
and dl, 15 ; 0x20 = Core+GPP; 2..12 = a PortBridge
shl edx, 15 ; device#
add edx, PCIEIND_INDEX ; full bdf-address
and eax, 0x30FF
or al, al
jnz @f
shl eax, 4 ; set bits 17..16 for a Core bridge
@@:
mov [edx], eax
add dl, 4
mov eax, [edx]
pop edx
ret
;-------------------------------------------
align 4
rs780_write_pcieind:
; in: ah = bridge#, al = reg#, ebx = PCIEIND data
push edx
xor edx, edx
mov ah, dl ; bridge# : 0 = Core+GFX; 0x10 = Core+SB
and dl, 15 ; 0x20 = Core+GPP; 2..12 = a PortBridge
shl edx, 15 ; device#
add edx, PCIEIND_INDEX ; full bdf-address
and eax, 0x30FF
or al, al
jnz @f
shl eax, 4 ; set bits 17..16 for a Core bridge
@@:
mov [edx], eax
add dl, 4
mov [edx], ebx
sub dl, 4
xor eax, eax
mov [edx], eax ; safety last
pop edx
ret
;------------------------------------------------
align 4
rs780_read_htiu:
; in: al = reg# | out: eax = HTIU data
;------------------------------------------------
push edx
mov edx, HTIU_NB_INDEX
and eax, 0x07F
mov [edx], eax
add dl, 4
mov eax, [edx]
pop edx
ret
;------------------------------------------------
align 4
rs780_write_htiu:
; in: al = reg#; ebx = data
;------------------------------------------------
push edx
mov edx, HTIU_NB_INDEX
and eax, 0x07F
or eax, 0x100
mov [edx], eax
add dl, 4
mov [edx], ebx
sub dl, 4
xor eax, eax
mov [edx], eax
pop edx
ret
;*************************************************************************** ;***************************************************************************
; Function ; Function
; rs7xx_pcie_init: ; rs7xx_pcie_init:
@ -66,6 +205,7 @@ rs7xx_nbconfig_write_pci:
align 4 align 4
rs7xx_pcie_init: rs7xx_pcie_init:
call rs7xx_unlock_bar3
mov al, 0x7C ; NB_IOC_CFG_CNTL mov al, 0x7C ; NB_IOC_CFG_CNTL
call rs7xx_nbconfig_read_pci call rs7xx_nbconfig_read_pci
mov ebx, eax mov ebx, eax
@ -120,7 +260,6 @@ rs7xx_pcie_init:
xor dx, dx ; PDEs counter xor dx, dx ; PDEs counter
@@: @@:
mov dword[ebx], eax ; map 4 buses mov dword[ebx], eax ; map 4 buses
invlpg [ecx] ; next PgDir entry
add bx, 4 ; new PDE add bx, 4 ; new PDE
add eax, 0x400000 ; +4M phys. add eax, 0x400000 ; +4M phys.
add ecx, 0x400000 ; +4M lin. add ecx, 0x400000 ; +4M lin.
@ -128,6 +267,8 @@ rs7xx_pcie_init:
jnc .pcie_cfg_mapped jnc .pcie_cfg_mapped
inc dl inc dl
jmp @b jmp @b
mov eax, cr3
mov cr3, eax ; flush TLB
.pcie_cfg_mapped: .pcie_cfg_mapped:
mov esi, boot_pcie_ok mov esi, boot_pcie_ok
call boot_log call boot_log
@ -135,13 +276,11 @@ rs7xx_pcie_init:
.rs7xx_pcie_fail: .rs7xx_pcie_fail:
mov esi, boot_rs7xx_fail mov esi, boot_rs7xx_fail
call boot_log call boot_log
ret jmp $
.rs7xx_pcie_blocked: .rs7xx_pcie_blocked:
mov esi, boot_rs7xx_blkd mov esi, boot_rs7xx_blkd
call boot_log call boot_log
call pci_ext_config jmp $
jmp .addr_found
ret

View File

@ -0,0 +1,131 @@
$Revision: 1598 $
SMBUS_PCIE_ADDR equ 0xF00A0000 ; bdf0:20.0 = SB7xx SMBus PCI Config Registers
LPC_PCIE_ADDR equ 0xF00A3000 ; bdf0:20.3 = SB7xx LPC ISA bridge Config Registers
SB_SIO_INDEX equ 0x2e
;---------------------------------------------------------------------
align 4
smbus_read_pciconfig:
; in: dl = reg# | out: eax = data
mov ebx, SMBUS_PCIE_ADDR
and edx, 0x0FC
mov eax, dword [ebx+edx]
ret
;------------------------------------------------
align 4
smbus_write_pciconfig:
; in: dl = reg#; eax = data
mov ebx, SMBUS_PCIE_ADDR
and edx, 0x0FC
mov dword [ebx+edx], eax
ret
;--------------------------------------------------------------------
align 4
lpc_read_pciconfig:
; in: dl = reg# | out: eax = data
mov ebx, LPC_PCIE_ADDR
and edx, 0x0FC
mov eax, dword [ebx+edx]
ret
;------------------------------------------------
align 4
lpc_write_pciconfig:
; in: dl = reg#; eax = data
mov ebx, LPC_PCIE_ADDR
and edx, 0x0FC
mov dword [ebx+edx], eax
ret
;--------------------------------------------------------------------
align 4
read_sio_cfg:
; in: al = reg# | out: al = data
mov dx, SB_SIO_INDEX
out dx, al
inc dl
in al, dx
ret
;------------------------------------------------
align 4
write_sio_cfg:
; in: al = reg#; ah = data
;------------------------------------------------
mov dx, SB_SIO_INDEX
out dx, al
inc dl
xchg al, ah
out dx, al
xchg al, ah
ret
;------------------------------------------------
align 4
enter_sio_cfg_mode:
; the magic sequence to unlock the port
;------------------------------------------------
mov dx, SB_SIO_INDEX
mov eax, 0x55550187 ; low byte first
out dx, al
shr eax, 8
out dx, al
shr eax, 8
out dx, al
shr eax, 8
out dx, al
ret
;-----------------------------------------------------------------------
; ATTENTION: the functions assume that RESET# signals use pins 84 and 34
; of IT8712F SuperIO chip. These signals may be (and will be!) different
; for every particular motherboard and SIO. Please refer to your m/board
; documentation to define the correct pins and GPIO lines!
;
; Note this example DOES NOT PRETEND to be 100% correct implementation
; of PCIe hotplug techniques !!
;-----------------------------------------------------------------------
align 4
init_pcie_slot_control:
;------------------------------------------------
call enter_sio_cfg_mode
mov ax, 0x0707 ; LDN = 07
call write_sio_cfg
mov al, 0x25
call read_sio_cfg ; ah = reg25h (Multy-function pin selector)
or ah, 3 ; set bits 0, 1 (GPIO)
call write_sio_cfg
mov al, 0x2A
call read_sio_cfg ; ah = reg2Ah (Extended fn pin selector)
or ah, 3 ; set bits 0, 1 (GPIO)
call write_sio_cfg
mov al, 0xB8
call read_sio_cfg ; ah = regB8h (internal pull-up enable)
or ah, 3 ; set bits 0, 1
call write_sio_cfg
mov al, 0xC0
call read_sio_cfg ; ah = regC0h (simple IO enable)
or ah, 3 ; set bits 0, 1
call write_sio_cfg
mov ax, 0x0202 ; Lock SIO config ports
call write_sio_cfg
ret
align 4
reset_pcie_slot:
;------------------------------------------------
call enter_sio_cfg_mode
mov ax, 0x0707 ; LDN = 07
call write_sio_cfg
mov al, 0xB0
call read_sio_cfg ; ah = regB0h (Pin polarity)
and ah, 0xFC ; invert bits 0, 1
call write_sio_cfg
or ah, 3 ; restore bits 0, 1
call write_sio_cfg
mov ax, 0x0202 ; Lock SIO config ports
call write_sio_cfg
ret

View File

@ -94,3 +94,14 @@ pci_ext_config:
call boot_log call boot_log
ret ; <<<<<<<<< FAILURE >>>>>>>>> ret ; <<<<<<<<< FAILURE >>>>>>>>>
;--------------------------------------------------------------------------
; this routine is platform-specific and used to change some BIOS settengs
; pcie_init_gfx
; sets the GPP mode of GFX bus
; this option disables external graphics
pcie_init_gfx:
ret

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; ;; ;; ;;
@ -8,11 +8,13 @@
;; ;; ;; ;;
;; 32 bit PCI driver code ;; ;; 32 bit PCI driver code ;;
;; ;; ;; ;;
;; Version 0.4 February 2nd, 2010 ;;
;; Version 0.3 April 9, 2007 ;; ;; Version 0.3 April 9, 2007 ;;
;; Version 0.2 December 21st, 2002 ;; ;; Version 0.2 December 21st, 2002 ;;
;; ;; ;; ;;
;; Author: Victor Prodan, victorprodan@yahoo.com ;; ;; Author: Victor Prodan, victorprodan@yahoo.com ;;
;; Mihailov Ilia, ghost.nsk@gmail.com ;; ;; Mihailov Ilia, ghost.nsk@gmail.com ;;
;; Artem Jerdev, kolibri@jerdev.co.uk ;;
;; Credits: ;; ;; Credits: ;;
;; Ralf Brown ;; ;; Ralf Brown ;;
;; Mike Hibbett, mikeh@oceanfree.net ;; ;; Mike Hibbett, mikeh@oceanfree.net ;;
@ -30,116 +32,64 @@ $Revision$
; Description ; Description
; entry point for system PCI calls ; entry point for system PCI calls
;*************************************************************************** ;***************************************************************************
mmio_pci_addr equ 0x400 ; set actual PCI address here to activate user-MMIO mmio_pci_addr dw 0x400 ; default PCI device bdf-address
iglobal
align 4
f62call:
dd pci_api.0
dd pci_api.1
dd pci_api.2
dd pci_api.not_support ;3
dd pci_read_reg ;4 byte
dd pci_read_reg ;5 word
dd pci_read_reg ;6 dword
dd pci_api.not_support ;7
dd pci_write_reg ;8 byte
dd pci_write_reg ;9 word
dd pci_write_reg ;10 dword
if defined mmio_pci_addr
dd pci_mmio_init ;11
dd pci_mmio_map ;12
dd pci_mmio_unmap ;13
end if
f62_rcall:
dd pci_read_reg.0 ;4 byte
dd pci_read_reg.1 ;5 word
dd pci_read_reg.2 ;6 dword
f62_rcall2:
dd pci_read_reg_2.0 ;4 byte
dd pci_read_reg_2.1 ;5 word
dd pci_read_reg_2.2 ;6 dword
f62_wcall:
dd pci_write_reg.0 ;4 byte
dd pci_write_reg.1 ;5 word
dd pci_write_reg.2 ;6 dword
f62_wcall2:
dd pci_write_reg_2.0 ;4 byte
dd pci_write_reg_2.1 ;5 word
dd pci_write_reg_2.2 ;6 dword
endg
align 4 align 4
pci_api: pci_api:
movzx eax,bl
cmp [pci_access_enabled],1 cmp [pci_access_enabled],1
jne .no_pci_access_for_applications jne no_pci_access_for_applications
if defined mmio_pci_addr or al,al
cmp eax, 13 jnz pci_fn_1
jb .not_support
else
cmp eax, 10
jb .not_support
end if
call dword [f62call+eax*4]
mov dword [esp+32],eax
ret
; or al,al
; jnz pci_fn_1
; PCI function 0: get pci version (AH.AL) ; PCI function 0: get pci version (AH.AL)
.0: movzx eax,word [BOOT_VAR+0x9022]
movzx eax, word [BOOT_VAR+0x9022]
ret ret
;pci_fn_1: pci_fn_1:
; cmp al,1 cmp al,1
; jnz pci_fn_2 jnz pci_fn_2
; PCI function 1: get last bus in AL ; PCI function 1: get last bus in AL
.1: mov al,[BOOT_VAR+0x9021]
movzx eax, byte [BOOT_VAR+0x9021]
ret ret
;pci_fn_2: pci_fn_2:
; cmp al,2 cmp al,2
; jne pci_fn_3 jne pci_fn_3
; PCI function 2: get pci access mechanism ; PCI function 2: get pci access mechanism
.2: mov al,[BOOT_VAR+0x9020]
movzx eax, byte [BOOT_VAR+0x9020]
ret ret
;pci_fn_3: pci_fn_3:
; cmp al,4 cmp al,4
; jz pci_read_reg ;byte jz pci_read_reg ;byte
; cmp al,5 cmp al,5
; jz pci_read_reg ;word jz pci_read_reg ;word
; cmp al,6 cmp al,6
; jz pci_read_reg ;dword jz pci_read_reg ;dword
; cmp al,8 cmp al,8
; jz pci_write_reg ;byte jz pci_write_reg ;byte
; cmp al,9 cmp al,9
; jz pci_write_reg ;word jz pci_write_reg ;word
; cmp al,10 cmp al,10
; jz pci_write_reg ;dword jz pci_write_reg ;dword
;if defined mmio_pci_addr cmp al,11 ; user-level MMIO functions
; cmp al,11 ; user-level MMIO functions jz pci_mmio_init
; jz pci_mmio_init cmp al,12
; cmp al,12 jz pci_mmio_map
; jz pci_mmio_map cmp al,13
; cmp al,13 jz pci_mmio_unmap
; jz pci_mmio_unmap
;end if
no_pci_access_for_applications:
or eax,-1
.not_support:
.no_pci_access_for_applications:
or eax,-1
ret ret
;*************************************************************************** ;***************************************************************************
@ -148,20 +98,20 @@ end if
; ;
; Description ; Description
; creates a command dword for use with the PCI bus ; creates a command dword for use with the PCI bus
; bus # in bh;ah ; bus # in ah
; device+func in ch;bh (dddddfff) ; device+func in bh (dddddfff)
; register in cl;bl ; register in bl
; ;
; command dword returned in ebx;eax ( 10000000 bbbbbbbb dddddfff rrrrrr00 ) ; command dword returned in eax ( 10000000 bbbbbbbb dddddfff rrrrrr00 )
;*************************************************************************** ;***************************************************************************
align 4 align 4
pci_make_config_cmd: pci_make_config_cmd:
shl ebx,8;eax,8 ; move bus to bits 16-23 shl eax,8 ; move bus to bits 16-23
mov bx,cx;ax,bx ; combine all mov ax,bx ; combine all
and ebx,0xffffff;eax,0xffffff and eax,0xffffff
or ebx,0x80000000;eax,0x80000000 or eax,0x80000000
ret ret
;*************************************************************************** ;***************************************************************************
@ -178,16 +128,12 @@ pci_make_config_cmd:
align 4 align 4
pci_read_reg: pci_read_reg:
cmp byte [BOOT_VAR+0x9020],2 ;what mechanism will we use? push esi ; save register size into ESI
je pci_read_reg_2 mov esi,eax
; mechanism 1
; push esi ; save register size into ESI
mov esi,ebx;eax
and esi,3 and esi,3
call pci_make_config_cmd call pci_make_config_cmd
mov eax,ebx;ebx,eax mov ebx,eax
; get current state ; get current state
mov dx,0xcf8 mov dx,0xcf8
in eax, dx in eax, dx
@ -201,100 +147,37 @@ pci_read_reg:
and bl,3 and bl,3
or dl,bl ; add to port address first 2 bits of register address or dl,bl ; add to port address first 2 bits of register address
; or esi,esi or esi,esi
; jz pci_read_byte1 jz pci_read_byte1
; cmp esi,1 cmp esi,1
; jz pci_read_word1 jz pci_read_word1
; cmp esi,2 cmp esi,2
; jz pci_read_dword1 jz pci_read_dword1
; jmp pci_fin_read1 jmp pci_fin_read1
jmp dword [f62_rcall+esi*4]
.0: pci_read_byte1:
in al,dx in al,dx
jmp .pci_fin_read1 jmp pci_fin_read1
.1: pci_read_word1:
in ax,dx in ax,dx
jmp .pci_fin_read1 jmp pci_fin_read1
.2: pci_read_dword1:
in eax,dx in eax,dx
; jmp pci_fin_read1 jmp pci_fin_read1
.pci_fin_read1: pci_fin_read1:
; restore configuration control ; restore configuration control
xchg eax,[esp] xchg eax,[esp]
mov dx,0xcf8 mov dx,0xcf8
out dx,eax out dx,eax
pop eax pop eax
;pop esi pop esi
ret
pci_read_reg_2:
test ch,128;bh,128 ;mech#2 only supports 16 devices per bus
jnz pci_api.not_support
; push esi ; save register size into ESI
mov esi,ebx;eax
and esi,3
push ebx;eax
mov eax,ebx
;store current state of config space
mov dx,0xcf8
in al,dx
mov ah,al
mov dl,0xfa
in al,dx
xchg eax,[esp]
; out 0xcfa,bus
mov al,ah
out dx,al
; out 0xcf8,0x80
mov dl,0xf8
mov al,0x80
out dx,al
; compute addr
shr ch,3;bh,3 ; func is ignored in mechanism 2
or ch,0xc0;bh,0xc0
mov dx,cx;bx
; or esi,esi
; jz pci_read_byte2
; cmp esi,1
; jz pci_read_word2
; cmp esi,2
; jz pci_read_dword2
; jmp pci_fin_read2
jmp dword [f62_rcall2+esi*4]
.0:
in al,dx
jmp .pci_fin_read2
.1:
in ax,dx
jmp .pci_fin_read2
.2:
in eax,dx
; jmp pci_fin_read2
.pci_fin_read2:
; restore configuration space
xchg eax,[esp]
mov dx,0xcfa
out dx,al
mov dl,0xf8
mov al,ah
out dx,al
pop eax
; pop esi
ret ret
;pci_read_reg_err: pci_read_reg_err:
; or dword [esp+32],-1 xor eax,eax
; ret dec eax
ret
;*************************************************************************** ;***************************************************************************
@ -312,17 +195,12 @@ pci_read_reg_2:
align 4 align 4
pci_write_reg: pci_write_reg:
cmp byte [BOOT_VAR+0x9020],2 ;what mechanism will we use? push esi ; save register size into ESI
je pci_write_reg_2 mov esi,eax
and esi,3
; mechanism 1
; push esi ; save register size into ESI
mov esi,ebx;eax
and esi,3 ;not need
call pci_make_config_cmd call pci_make_config_cmd
mov eax,ebx;ebx,eax mov ebx,eax
mov ecx,edx ;cross registers
; get current state into ecx ; get current state into ecx
mov dx,0xcf8 mov dx,0xcf8
in eax, dx in eax, dx
@ -337,121 +215,56 @@ pci_write_reg:
or dl,bl or dl,bl
mov eax,ecx mov eax,ecx
; or esi,esi or esi,esi
; jz pci_write_byte1 jz pci_write_byte1
; cmp esi,1 cmp esi,1
; jz pci_write_word1 jz pci_write_word1
; cmp esi,2 cmp esi,2
; jz pci_write_dword1 jz pci_write_dword1
; jmp pci_fin_write1 jmp pci_fin_write1
jmp dword [f62_wcall+esi*4]
.0:
out dx,al
jmp .pci_fin_write1
.1:
out dx,ax
jmp .pci_fin_write1
.2:
out dx,eax
.pci_fin_write1:
pci_write_byte1:
out dx,al
jmp pci_fin_write1
pci_write_word1:
out dx,ax
jmp pci_fin_write1
pci_write_dword1:
out dx,eax
jmp pci_fin_write1
pci_fin_write1:
; restore configuration control ; restore configuration control
pop eax pop eax
mov dl,0xf8 mov dl,0xf8
out dx,eax out dx,eax
xor eax,eax xor eax,eax
;pop esi pop esi
ret ret
pci_write_reg_2:
test ch,128;bh,128 ;mech#2 only supports 16 devices per bus
jnz pci_api.not_support
; push esi ; save register size into ESI
mov esi,eax
and esi,3 ;not need
push eax
mov ecx,edx ;cross registers
;store current state of config space
mov dx,0xcf8
in al,dx
mov ah,al
mov dl,0xfa
in al,dx
xchg eax,[esp]
; out 0xcfa,bus
mov al,ah
out dx,al
; out 0xcf8,0x80
mov dl,0xf8
mov al,0x80
out dx,al
; compute addr
shr bh,3 ; func is ignored in mechanism 2
or bh,0xc0
mov dx,bx
; write register
mov eax,ecx
; or esi,esi
; jz pci_write_byte2
; cmp esi,1
; jz pci_write_word2
; cmp esi,2
; jz pci_write_dword2
; jmp pci_fin_write2
jmp dword [f62_wcall2+esi*4]
.0:
out dx,al
jmp .pci_fin_write2
.1:
out dx,ax
jmp .pci_fin_write2
.2:
out dx,eax
.pci_fin_write2:
; restore configuration space
pop eax
mov dx,0xcfa
out dx,al
mov dl,0xf8
mov al,ah
out dx,al
pci_write_reg_err:
xor eax,eax xor eax,eax
;pop esi dec eax
ret ret
;pci_write_reg_err:
; xor eax,eax
; dec eax
; ret
if defined mmio_pci_addr ; must be set above
;*************************************************************************** ;***************************************************************************
; Function ; Function
; pci_mmio_init ; pci_mmio_init
; ;
; Description ; Description
; IN: cx = device's PCI bus address (bbbbbbbbdddddfff) ; IN: bx = device's PCI bus address (bbbbbbbbdddddfff)
; Returns eax = user heap space available (bytes) ; Returns eax = phys. address of user-accessible DMA block
; Error codes ; Error codes
; eax = -1 : PCI user access blocked, ; eax = -1 : PCI user access blocked,
; eax = -2 : device not registered for uMMIO service
; eax = -3 : user heap initialization failure ; eax = -3 : user heap initialization failure
;*************************************************************************** ;***************************************************************************
pci_mmio_init: pci_mmio_init:
cmp cx, mmio_pci_addr mov [mmio_pci_addr],bx
jz @f
mov eax,-2
ret
@@:
call init_heap ; (if not initialized yet) call init_heap ; (if not initialized yet)
or eax,eax or eax,eax
jz @f jz @f
mov eax, [UserDMAaddr]
ret ret
@@: @@:
mov eax,-3 mov eax,-3
@ -460,15 +273,14 @@ pci_mmio_init:
;*************************************************************************** ;***************************************************************************
; Function ; Function
; pci_mmio_map ; pci_mmio_map
; ;
; Description ; Description
; maps a block of PCI memory to user-accessible linear address ; maps a block of PCI memory to user-accessible linear address
; ;
; WARNING! This VERY EXPERIMENTAL service is for one chosen PCI device only!
; The target device address should be set in kernel var mmio_pci_addr
; ;
; IN: ah = BAR#; ; IN: ah = BAR#; or
; IN: ah = 0xDA for DMA-mapping requests;
; IN: ebx = block size (bytes); ; IN: ebx = block size (bytes);
; IN: ecx = offset in MMIO block (in 4K-pages, to avoid misaligned pages); ; IN: ecx = offset in MMIO block (in 4K-pages, to avoid misaligned pages);
; ;
@ -484,17 +296,21 @@ pci_mmio_init:
;*************************************************************************** ;***************************************************************************
pci_mmio_map: pci_mmio_map:
;cross
mov eax,ebx
mov ebx,ecx
mov ecx,edx
;;;;;;;;;;;;;;;;;;;
and edx,0x0ffff and edx,0x0ffff
cmp ah, 0xDA
jz .dma_map
cmp ah,6 cmp ah,6
jc .bar_0_5 jb .bar_0_5
jz .bar_rom jz .bar_rom
mov eax,-2 mov eax,-2
ret ret
.dma_map:
push ecx
mov ecx,ebx
mov eax,[UserDMAaddr]
jmp .allocate_block
.bar_rom: .bar_rom:
mov ah, 8 ; bar6 = Expansion ROM base address mov ah, 8 ; bar6 = Expansion ROM base address
.bar_0_5: .bar_0_5:
@ -506,7 +322,7 @@ pci_mmio_map:
shl bl, 1 shl bl, 1
shl bl, 1 shl bl, 1
add bl, 0x10 ; now bl = BAR offset in PCI config. space add bl, 0x10 ; now bl = BAR offset in PCI config. space
mov ax, mmio_pci_addr mov ax, [mmio_pci_addr]
mov bh, al ; bh = dddddfff mov bh, al ; bh = dddddfff
mov al, 2 ; al : DW to read mov al, 2 ; al : DW to read
call pci_read_reg call pci_read_reg
@ -523,7 +339,9 @@ pci_mmio_map:
pop ecx ; ecx = block size, bytes (expanded to whole page) pop ecx ; ecx = block size, bytes (expanded to whole page)
mov ebx, ecx ; user_alloc destroys eax, ecx, edx, but saves ebx mov ebx, ecx ; user_alloc destroys eax, ecx, edx, but saves ebx
and eax, 0xFFFFFFF0 and eax, 0xFFFFFFF0
push eax ; store MMIO physical address + keep 2DWords in the stack
.allocate_block:
push eax ; store MMIO physical address + keep the stack 2x4b deep
stdcall user_alloc, ecx stdcall user_alloc, ecx
or eax, eax or eax, eax
jnz mmio_map_over jnz mmio_map_over
@ -542,9 +360,7 @@ mmio_map_over:
pop edx ; edx = MMIO shift (pages) pop edx ; edx = MMIO shift (pages)
shl edx, 12 ; edx = MMIO shift (bytes) shl edx, 12 ; edx = MMIO shift (bytes)
add eax, edx ; eax = uMMIO physical address add eax, edx ; eax = uMMIO physical address
or eax, PG_SHARED or eax, (PG_SHARED+PG_UW+PG_NOCACHE)
or eax, PG_UW
or eax, PG_NOCACHE
mov edi, ebx mov edi, ebx
call commit_pages call commit_pages
mov eax, edi mov eax, edi
@ -552,7 +368,7 @@ mmio_map_over:
;*************************************************************************** ;***************************************************************************
; Function ; Function
; pci_mmio_unmap_page ; pci_mmio_unmap_page
; ;
; Description ; Description
; unmaps the linear space previously tied to a PCI memory block ; unmaps the linear space previously tied to a PCI memory block
@ -566,11 +382,9 @@ mmio_map_over:
;*************************************************************************** ;***************************************************************************
pci_mmio_unmap: pci_mmio_unmap:
stdcall user_free, ecx;ebx stdcall user_free, ebx
ret ret
end if
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
uglobal uglobal
align 4 align 4

File diff suppressed because it is too large Load Diff

View File

@ -99,7 +99,7 @@ iglobal
dd 0 dd 0
dd 0 dd 0
dd 0 dd 0
dd 0;sys_pci ; 62-PCI functions dd sys_pci ; 62-PCI functions
dd sys_msg_board ; 63-System message board dd sys_msg_board ; 63-System message board
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -170,7 +170,7 @@ iglobal
dd undefined_syscall ; 59-reserved dd undefined_syscall ; 59-reserved
dd sys_IPC ; 60-Inter Process Communication dd sys_IPC ; 60-Inter Process Communication
dd sys_gs ; 61-Direct graphics access dd sys_gs ; 61-Direct graphics access
dd pci_api;cross_order ; 62-PCI functions dd cross_order ; 62-PCI functions
dd cross_order ; 63-System message board dd cross_order ; 63-System message board
dd sys_resize_app_memory ; 64-Resize application memory usage dd sys_resize_app_memory ; 64-Resize application memory usage
dd sys_putimage_palette ; 65-PutImagePalette dd sys_putimage_palette ; 65-PutImagePalette

View File

@ -47,33 +47,33 @@ keymap_alt:
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
boot_memdetect db 'Determining amount of memory',0 boot_memdetect db 'Determining amount of memory',0
boot_fonts db 'Fonts loaded',0 boot_fonts db 'Fonts loaded',0
boot_tss db 'Setting TSSs',0 boot_tss db 'Setting TSSs',0
boot_cpuid db 'Reading CPUIDs',0 boot_cpuid db 'Reading CPUIDs',0
boot_devices db 'Detecting devices',0 boot_devices db 'Detecting devices',0
boot_timer db 'Setting timer',0 boot_timer db 'Setting timer',0
boot_irqs db 'Reprogramming IRQs',0 boot_irqs db 'Reprogramming IRQs',0
boot_setmouse db 'Setting mouse',0 boot_setmouse db 'Setting mouse',0
boot_windefs db 'Setting window defaults',0 boot_windefs db 'Setting window defaults',0
boot_bgr db 'Calculating background',0 boot_bgr db 'Calculating background',0
boot_resirqports db 'Reserving IRQs & ports',0 boot_resirqports db 'Reserving IRQs & ports',0
; boot_setrports db 'Setting addresses for IRQs',0 ; boot_setrports db 'Setting addresses for IRQs',0
boot_setostask db 'Setting OS task',0 boot_setostask db 'Setting OS task',0
boot_allirqs db 'Unmasking all IRQs',0 boot_allirqs db 'Unmasking all IRQs',0
boot_tsc db 'Reading TSC',0 boot_tsc db 'Reading TSC',0
boot_cpufreq db 'CPU frequency is ',' ',' MHz',0 boot_cpufreq db 'CPU frequency is ',' ',' MHz',0
; boot_pal_ega db 'Setting EGA/CGA 320x200 palette',0 ; boot_pal_ega db 'Setting EGA/CGA 320x200 palette',0
; boot_pal_vga db 'Setting VGA 640x480 palette',0 ; boot_pal_vga db 'Setting VGA 640x480 palette',0
boot_failed db 'Failed to start first app',0 boot_failed db 'Failed to start first app',0
boot_mtrr db 'Setting MTRR',0 boot_mtrr db 'Setting MTRR',0
boot_uDMA_ok db 'Set user DMA OK',0 boot_uDMA_ok db 'Set user DMA OK',0
boot_pcie_ok db 'PCIe config set OK',0 boot_pcie_ok db 'PCIe config set OK',0
boot_pcie_fail db 'PCIe config XXX failed XXX',0 boot_pcie_fail db 'PCIe config XXX failed XXX',0
boot_rs7xx_fail db 'RS7xx config XXX failed XXX',0 boot_rs7xx_fail db 'RS7xx config XXX failed XXX',0
boot_rs7xx_blkd db 'RS7xx config ---------- FAILED -----------',0 boot_rs7xx_blkd db 'RS7xx config ---------- FAILED -----------',0
if preboot_blogesc if preboot_blogesc
boot_tasking db 'All set - press ESC to start',0 boot_tasking db 'All set - press ESC to start',0
end if end if
;new_process_loading db 'K : New Process - loading',13,10,0 ;new_process_loading db 'K : New Process - loading',13,10,0
@ -84,19 +84,19 @@ msg_unresolved db 'unresolved ',0
msg_module db 'in module ',0 msg_module db 'in module ',0
msg_version db 'incompatible driver version',13,10,0 msg_version db 'incompatible driver version',13,10,0
msg_www db 'please visit www.kolibrios.org',13,10,0 msg_www db 'please visit www.kolibrios.org',13,10,0
msg_CR db 13,10,0 msg_CR db 13,10,0
aSis db 'SIS',0 aSis db 'SIS',0
intel_str db "GenuineIntel",0 intel_str db "GenuineIntel",0
AMD_str db "AuthenticAMD",0 AMD_str db "AuthenticAMD",0
;szSound db 'SOUND',0 ;szSound db 'SOUND',0
;szInfinity db 'INFINITY',0 ;szInfinity db 'INFINITY',0
szHwMouse db 'ATI2D',0 szHwMouse db 'ATI2D',0
szPS2MDriver db 'PS2MOUSE',0 szPS2MDriver db 'PS2MOUSE',0
;szCOM_MDriver db 'COM_MOUSE',0 ;szCOM_MDriver db 'COM_MOUSE',0
szUSB db 'USB',0 szUSB db 'USB',0
szAtiHW db '/rd/1/drivers/ati2d.drv',0 szAtiHW db '/rd/1/drivers/ati2d.drv',0
szSTART db 'START',0 szSTART db 'START',0
szEXPORTS db 'EXPORTS',0 szEXPORTS db 'EXPORTS',0
@ -107,25 +107,25 @@ szIMPORTS db 'IMPORTS',0
read_firstapp db '/sys/' read_firstapp db '/sys/'
firstapp db 'LAUNCHER',0 firstapp db 'LAUNCHER',0
char db '/sys/FONTS/CHAR.MT',0 char db '/sys/FONTS/CHAR.MT',0
char2 db '/sys/FONTS/CHAR2.MT',0 char2 db '/sys/FONTS/CHAR2.MT',0
bootpath db '/KOLIBRI ' bootpath db '/KOLIBRI '
bootpath2 db 0 bootpath2 db 0
vmode db '/sys/drivers/VMODE.MDR',0 vmode db '/sys/drivers/VMODE.MDR',0
vrr_m db 'VRR_M',0 vrr_m db 'VRR_M',0
kernel_file db 'KERNEL MNT' kernel_file db 'KERNEL MNT'
align 4 align 4
shmem_list: shmem_list:
.bk dd shmem_list .bk dd shmem_list
.fd dd shmem_list .fd dd shmem_list
dll_list: dll_list:
.bk dd dll_list .bk dd dll_list
.fd dd dll_list .fd dd dll_list
MAX_DEFAULT_DLL_ADDR = 0x20000000 MAX_DEFAULT_DLL_ADDR = 0x20000000
MIN_DEFAULT_DLL_ADDR = 0x10000000 MIN_DEFAULT_DLL_ADDR = 0x10000000
@ -137,13 +137,13 @@ dll_cur_addr dd MIN_DEFAULT_DLL_ADDR
; mike.dld { ; mike.dld {
db 0 db 0
dd servetable-0x10000 dd servetable-0x10000
draw_line dd __sys_draw_line draw_line dd __sys_draw_line
draw_pointer dd __sys_draw_pointer draw_pointer dd __sys_draw_pointer
;//mike.dld, 2006-08-02 [ ;//mike.dld, 2006-08-02 [
;drawbar dd __sys_drawbar ;drawbar dd __sys_drawbar
drawbar dd __sys_drawbar.forced drawbar dd __sys_drawbar.forced
;//mike.dld, 2006-08-02 ] ;//mike.dld, 2006-08-02 ]
putpixel dd __sys_putpixel putpixel dd __sys_putpixel
; } mike.dld ; } mike.dld
@ -151,10 +151,10 @@ align 4
keyboard dd 1 keyboard dd 1
syslang dd 1 syslang dd 1
boot_y dd 10 boot_y dd 10
pci_bios_entry dd 0 pci_bios_entry dd 0
dw pci_code_sel dw pci_code_sel
if __DEBUG__ eq 1 if __DEBUG__ eq 1
include_debug_strings include_debug_strings
@ -165,292 +165,292 @@ IncludeIGlobals
align 16 align 16
gdts: gdts:
dw gdte-$-1 dw gdte-$-1
dd gdts dd gdts
dw 0 dw 0
; Attention! Do not change the order of the first four selectors. They are used in Fast System Call ; Attention! Do not change the order of the first four selectors. They are used in Fast System Call
; must be : os_code, os_data, app_code, app_data, .... ; must be : os_code, os_data, app_code, app_data, ....
int_code_l: int_code_l:
os_code_l: os_code_l:
dw 0xffff dw 0xffff
dw 0x0000 dw 0x0000
db 0x00 db 0x00
dw 11011111b *256 +10011010b dw 11011111b *256 +10011010b
db 0x00 db 0x00
int_data_l: int_data_l:
os_data_l: os_data_l:
dw 0xffff dw 0xffff
dw 0x0000 dw 0x0000
db 0x00 db 0x00
dw 11011111b *256 +10010010b dw 11011111b *256 +10010010b
db 0x00 db 0x00
app_code_l: app_code_l:
dw 0xFFFF dw 0xFFFF
dw 0 dw 0
db 0 db 0
db cpl3 db cpl3
dw G32+D32+0xF; dw G32+D32+0xF;
app_data_l: app_data_l:
dw 0xFFFF dw 0xFFFF
dw 0 dw 0
db 0 db 0
db drw3 db drw3
dw G32+D32+0xF; dw G32+D32+0xF;
; ------------- PCI BIOS ------------------ ; ------------- PCI BIOS ------------------
pci_code_32: pci_code_32:
dw 0 ;lim 0-15 dw 0 ;lim 0-15
dw 0 ;base 0-15 dw 0 ;base 0-15
db 0 ;base 16-23 db 0 ;base 16-23
db cpl0 ;type db cpl0 ;type
db D32 ;lim 16-19+props db D32 ;lim 16-19+props
db 0 ;base 24-31 db 0 ;base 24-31
pci_data_32: pci_data_32:
dw 0 ;lim 0-15 dw 0 ;lim 0-15
dw 0 ;base 0-15 dw 0 ;base 0-15
db 0 ;base 16-23 db 0 ;base 16-23
db dpl0 ;type db dpl0 ;type
db D32 ;lim 16-19+props db D32 ;lim 16-19+props
db 0 ;base 24-31 db 0 ;base 24-31
; --------------- APM --------------------- ; --------------- APM ---------------------
apm_code_32: apm_code_32:
dw 0x0f ; limit 64kb dw 0x0f ; limit 64kb
db 0, 0, 0 db 0, 0, 0
dw 11010000b *256 +10011010b dw 11010000b *256 +10011010b
db 0x00 db 0x00
apm_code_16: apm_code_16:
dw 0x0f dw 0x0f
db 0, 0, 0 db 0, 0, 0
dw 10010000b *256 +10011010b dw 10010000b *256 +10011010b
db 0x00 db 0x00
apm_data_16: apm_data_16:
dw 0x0f dw 0x0f
db 0, 0, 0 db 0, 0, 0
dw 10010000b *256 +10010010b dw 10010000b *256 +10010010b
db 0x00 db 0x00
; ----------------------------------------- ; -----------------------------------------
graph_data_l: graph_data_l:
dw 0x7ff dw 0x7ff
dw 0x0000 dw 0x0000
db 0x00 db 0x00
dw 11010000b *256 +11110010b dw 11010000b *256 +11110010b
db 0x00 db 0x00
tss0_l: tss0_l:
dw TSS_SIZE-1 dw TSS_SIZE-1
dw tss and 0xFFFF dw tss and 0xFFFF
db (tss shr 16) and 0xFF db (tss shr 16) and 0xFF
db 10001001b db 10001001b
dw (tss shr 16) and 0xFF00 dw (tss shr 16) and 0xFF00
tls_data_l: tls_data_l:
dw 0x0FFF dw 0x0FFF
dw 0 dw 0
db 0 db 0
db drw3 db drw3
dw D32 dw D32
endofcode: endofcode:
gdte: gdte:
align 16 align 16
cur_saved_data rb 4096 cur_saved_data rb 4096
fpu_data: rb 512 fpu_data: rb 512
; device irq owners ; device irq owners
irq_owner rd 16 ; process id irq_owner rd 16 ; process id
; on irq read ports ; on irq read ports
irq00read rd 16 irq00read rd 16
irq01read rd 16 irq01read rd 16
irq02read rd 16 irq02read rd 16
irq03read rd 16 irq03read rd 16
irq04read rd 16 irq04read rd 16
irq05read rd 16 irq05read rd 16
irq06read rd 16 irq06read rd 16
irq07read rd 16 irq07read rd 16
irq08read rd 16 irq08read rd 16
irq09read rd 16 irq09read rd 16
irq10read rd 16 irq10read rd 16
irq11read rd 16 irq11read rd 16
irq12read rd 16 irq12read rd 16
irq13read rd 16 irq13read rd 16
irq14read rd 16 irq14read rd 16
irq15read rd 16 irq15read rd 16
irq_tab rd 16 irq_tab rd 16
mem_block_map rb 512 mem_block_map rb 512
mem_block_list rd 64 mem_block_list rd 64
large_block_list rd 31 large_block_list rd 31
mem_block_mask rd 2 mem_block_mask rd 2
large_block_mask rd 1 large_block_mask rd 1
mem_used.fd rd 1 mem_used.fd rd 1
mem_used.bk rd 1 mem_used.bk rd 1
mem_block_arr rd 1 mem_block_arr rd 1
mem_block_start rd 1 mem_block_start rd 1
mem_block_end rd 1 mem_block_end rd 1
heap_mutex rd 1 heap_mutex rd 1
heap_size rd 1 heap_size rd 1
heap_free rd 1 heap_free rd 1
heap_blocks rd 1 heap_blocks rd 1
free_blocks rd 1 free_blocks rd 1
mst MEM_STATE mst MEM_STATE
page_start rd 1 page_start rd 1
page_end rd 1 page_end rd 1
sys_page_map rd 1 sys_page_map rd 1
os_stack_seg rd 1 os_stack_seg rd 1
srv.fd rd 1 srv.fd rd 1
srv.bk rd 1 srv.bk rd 1
align 16 align 16
_display display_t _display display_t
_WinMapAddress rd 1 _WinMapAddress rd 1
_WinMapSize rd 1 _WinMapSize rd 1
def_cursor rd 1 def_cursor rd 1
current_cursor rd 1 current_cursor rd 1
hw_cursor rd 1 hw_cursor rd 1
cur_saved_base rd 1 cur_saved_base rd 1
cur.lock rd 1 ;1 - lock update, 2- hide cur.lock rd 1 ;1 - lock update, 2- hide
cur.left rd 1 ;cursor clip box cur.left rd 1 ;cursor clip box
cur.top rd 1 cur.top rd 1
cur.right rd 1 cur.right rd 1
cur.bottom rd 1 cur.bottom rd 1
cur.w rd 1 cur.w rd 1
cur.h rd 1 cur.h rd 1
ipc_tmp rd 1 ipc_tmp rd 1
ipc_pdir rd 1 ipc_pdir rd 1
ipc_ptab rd 1 ipc_ptab rd 1
proc_mem_map rd 1 proc_mem_map rd 1
proc_mem_pdir rd 1 proc_mem_pdir rd 1
proc_mem_tab rd 1 proc_mem_tab rd 1
tmp_task_pdir rd 1 tmp_task_pdir rd 1
tmp_task_ptab rd 1 tmp_task_ptab rd 1
default_io_map rd 1 default_io_map rd 1
LFBSize rd 1 LFBSize rd 1
stall_mcs rd 1 stall_mcs rd 1
current_slot rd 1 current_slot rd 1
; status ; status
hd1_status rd 1 ; 0 - free : other - pid hd1_status rd 1 ; 0 - free : other - pid
application_table_status rd 1 ; 0 - free : other - pid application_table_status rd 1 ; 0 - free : other - pid
; device addresses ; device addresses
mididp rd 1 mididp rd 1
midisp rd 1 midisp rd 1
cdbase rd 1 cdbase rd 1
cdid rd 1 cdid rd 1
hdbase rd 1 ; for boot 0x1f0 hdbase rd 1 ; for boot 0x1f0
hdid rd 1 hdid rd 1
hdpos rd 1 ; for boot 0x1 hdpos rd 1 ; for boot 0x1
label known_part dword label known_part dword
fat32part rd 1 ; for boot 0x1 fat32part rd 1 ; for boot 0x1
cdpos rd 1 cdpos rd 1
;CPUID information ;CPUID information
cpu_vendor rd 3 cpu_vendor rd 3
cpu_sign rd 1 cpu_sign rd 1
cpu_info rd 1 cpu_info rd 1
cpu_caps rd 4 cpu_caps rd 4
pg_data PG_DATA pg_data PG_DATA
heap_test rd 1 heap_test rd 1
buttontype rd 1 buttontype rd 1
windowtypechanged rd 1 windowtypechanged rd 1
hd_entries rd 1 ;unused ? 0xfe10 hd_entries rd 1 ;unused ? 0xfe10
;* start code - Mario79 ;* start code - Mario79
mouse_active rd 1 mouse_active rd 1
mouse_pause rd 1 mouse_pause rd 1
MouseTickCounter rd 1 MouseTickCounter rd 1
;* end code - Mario79 ;* end code - Mario79
img_background rd 1 img_background rd 1
mem_BACKGROUND rd 1 mem_BACKGROUND rd 1
static_background_data rd 1 static_background_data rd 1
cache_ide0: cache_ide0:
cache_ide0_pointer rd 1 cache_ide0_pointer rd 1
cache_ide0_size rd 1 ; not use cache_ide0_size rd 1 ; not use
cache_ide0_data_pointer rd 1 cache_ide0_data_pointer rd 1
cache_ide0_system_data_size rd 1 ; not use cache_ide0_system_data_size rd 1 ; not use
cache_ide0_appl_data_size rd 1 ; not use cache_ide0_appl_data_size rd 1 ; not use
cache_ide0_system_data rd 1 cache_ide0_system_data rd 1
cache_ide0_appl_data rd 1 cache_ide0_appl_data rd 1
cache_ide0_system_sad_size rd 1 cache_ide0_system_sad_size rd 1
cache_ide0_appl_sad_size rd 1 cache_ide0_appl_sad_size rd 1
cache_ide0_search_start rd 1 cache_ide0_search_start rd 1
cache_ide0_appl_search_start rd 1 cache_ide0_appl_search_start rd 1
cache_ide1: cache_ide1:
cache_ide1_pointer rd 1 cache_ide1_pointer rd 1
cache_ide1_size rd 1 ; not use cache_ide1_size rd 1 ; not use
cache_ide1_data_pointer rd 1 cache_ide1_data_pointer rd 1
cache_ide1_system_data_size rd 1 ; not use cache_ide1_system_data_size rd 1 ; not use
cache_ide1_appl_data_size rd 1 ; not use cache_ide1_appl_data_size rd 1 ; not use
cache_ide1_system_data rd 1 cache_ide1_system_data rd 1
cache_ide1_appl_data rd 1 cache_ide1_appl_data rd 1
cache_ide1_system_sad_size rd 1 cache_ide1_system_sad_size rd 1
cache_ide1_appl_sad_size rd 1 cache_ide1_appl_sad_size rd 1
cache_ide1_search_start rd 1 cache_ide1_search_start rd 1
cache_ide1_appl_search_start rd 1 cache_ide1_appl_search_start rd 1
cache_ide2: cache_ide2:
cache_ide2_pointer rd 1 cache_ide2_pointer rd 1
cache_ide2_size rd 1 ; not use cache_ide2_size rd 1 ; not use
cache_ide2_data_pointer rd 1 cache_ide2_data_pointer rd 1
cache_ide2_system_data_size rd 1 ; not use cache_ide2_system_data_size rd 1 ; not use
cache_ide2_appl_data_size rd 1 ; not use cache_ide2_appl_data_size rd 1 ; not use
cache_ide2_system_data rd 1 cache_ide2_system_data rd 1
cache_ide2_appl_data rd 1 cache_ide2_appl_data rd 1
cache_ide2_system_sad_size rd 1 cache_ide2_system_sad_size rd 1
cache_ide2_appl_sad_size rd 1 cache_ide2_appl_sad_size rd 1
cache_ide2_search_start rd 1 cache_ide2_search_start rd 1
cache_ide2_appl_search_start rd 1 cache_ide2_appl_search_start rd 1
cache_ide3: cache_ide3:
cache_ide3_pointer rd 1 cache_ide3_pointer rd 1
cache_ide3_size rd 1 ; not use cache_ide3_size rd 1 ; not use
cache_ide3_data_pointer rd 1 cache_ide3_data_pointer rd 1
cache_ide3_system_data_size rd 1 ; not use cache_ide3_system_data_size rd 1 ; not use
cache_ide3_appl_data_size rd 1 ; not use cache_ide3_appl_data_size rd 1 ; not use
cache_ide3_system_data rd 1 cache_ide3_system_data rd 1
cache_ide3_appl_data rd 1 cache_ide3_appl_data rd 1
cache_ide3_system_sad_size rd 1 cache_ide3_system_sad_size rd 1
cache_ide3_appl_sad_size rd 1 cache_ide3_appl_sad_size rd 1
cache_ide3_search_start rd 1 cache_ide3_search_start rd 1
@ -462,11 +462,11 @@ cd_appl_data rb 1 ; 0 = system cache, 1 - application cache
lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled
pci_access_enabled rd 1 ; 0 = disabled , 1 = enabled pci_access_enabled rd 1 ; 0 = disabled , 1 = enabled
timer_ticks_enable rb 1 ; for cd driver timer_ticks_enable rb 1 ; for cd driver
NumBiosDisks rd 1 NumBiosDisks rd 1
BiosDisksData rb 200h BiosDisksData rb 200h
BiosDiskCaches rb 80h*(cache_ide1-cache_ide0) BiosDiskCaches rb 80h*(cache_ide1-cache_ide0)
BiosDiskPartitions rd 80h BiosDiskPartitions rd 80h
IncludeUGlobals IncludeUGlobals

View File

@ -4253,11 +4253,11 @@ sys_gs: ; direct screen access
;align 4 ; PCI functions ;align 4 ; PCI functions
; ;
;sys_pci: sys_pci:
;
; call pci_api call pci_api
; mov [esp+36],eax mov [esp+36],eax
; ret ret
align 4 ; system functions align 4 ; system functions

View File

@ -0,0 +1,345 @@
;; ZiS test -- Art J ;;
use32 ;
org 0x0 ;
db 'MENUET01' ;
dd 0x01 ;
dd START ;
dd I_END ;
dd 0x1000 ;
dd 0x1000 ;
dd 0x0 ;
dd 0x0 ;
include 'MACROS.INC' ;
PCIE_SPACE equ 0xF0000000
PCIE_ADDR equ 0xF00A3000 ; bdf0:20.3 = SB7xx LPC Config Registers
BOX_COLOR equ 0xE0D8D0
START:
mov edx, 0x88
add edx, PCIE_ADDR
mov eax, 0x00010101
mov [edx], eax
red:
call draw_window
still:
mcall 10 ; event waiting
cmp eax,1 ; redraw window
je red ;
cmp eax,2 ; key pressed?
je key ;
cmp eax,3 ; button hit?
je button ;
jmp still ; none of that
;---------------------------------------------------------------------
key: ; key pressed
jmp red
;---------------------------------------------------------------------
button:
mcall 17 ; get the button ID
cmp ah, 1
jne .bt2
mcall -1
.bt2:
cmp ah, 2
jne .bt3
sub [Reg],4 ; Rg# decrement
jmp red
.bt3:
cmp ah, 3
jne .bt4
add [Reg],4 ; Rg# increment
jmp red
.bt4:
cmp ah, 4
jne .bt5
add [Reg],4*16 ; PgDn
jmp red
.bt5:
cmp ah, 5
jne .bt6
mov edx, [Reg]
cmp edx, 4*16
jb @f
sub edx, 4*16
mov [Reg],edx ; PgUp
jmp red
@@:
xor edx, edx
mov [Reg], edx
jmp red
.bt6:
cmp ah, 6
jne still
mcall 37, 1 ; get the mouse pointer
shr eax, 16 ; only X needed
sub eax, 124 ; check the left border
jb red
xor edx, edx
mov ebx, 12
div ebx
cmp eax, 32 ; check the right border
jnb red
mov ecx, 31
sub ecx, eax ; reverse the bit order
mov ebx, [Rct]
btc ebx, ecx ; invert the bit
mov eax, [Reg]
add eax, PCIE_ADDR
mov [Rct], ebx
mov [eax], ebx
jmp red
;------------------------------------------------
print_config_reg:
;------------------------------------------------
mov eax, [reg]
and eax, 0x0FFC
mov ebx, 4*65536+256 ; 4 hex digits
mov ecx, eax
mov dx,[stX]
shl edx,16 ; = X*65536
mov dx,[stY] ; = edx + Y
mov esi,0
mcall 47 ; print reg#
mov eax, [reg]
add eax, PCIE_ADDR
mov ecx, [eax]
add edx, 36*65536 ; right column
mov ebx, 8*65536+256 ; 8 hex digits
mcall 47 ; print config data
ret
;------------------------------------------------
read_nbconfig:
; in: dl = reg# | out: eax = data
;------------------------------------------------
mov ebx, 0xF0000000
and edx, 0x0FC
mov eax, dword [ebx+edx]
ret
;------------------------------------------------
write_nbconfig:
; in: dl = reg#; eax = data
;------------------------------------------------
mov ebx, 0xF0000000
and edx, 0x0FC
mov dword [ebx+edx], eax
ret
;------------------------------------------------
;read_htiunbind:
; in: [HTr] = reg# | out: eax = data
;------------------------------------------------
; mov dl, 0x94
; mov al, byte[HTr]
; and eax, 0x07C
; call write_nbconfig
; add dl, 4
; call read_nbconfig
; ret
;------------------------------------------------
;write_htiunbind:
; in: [HTr] = reg#; ecx = data
;------------------------------------------------
; mov dl, 0x94
; mov al, byte[Reg]
; and eax, 0x017C
; call write_nbconfig
; add dl, 4
; mov ecx, eax
; call write_nbconfig
; sub dl, 4
; mov eax, 0x0
; call write_nbconfig
; ret
;------------------------------------------------
draw_window:
;------------------------------------------------
mcall 12, 1
mcall 0, 600*65536+530, 120*65536+290, 0x1499AAA0,,title
; -----------------------------------------------------------------
; BUTTONS: Xleft Xwid, Ytop Yheig
mcall 8, 370*65536+ 40, 26*65536+ 18, 2, 0x99AABB ; <<
mcall , , 51*65536+ 18, 3, ; >>
mcall , 425*65536+ 90, 26*65536+ 18, 4, ; PCIe Cfg
mcall , , 51*65536+ 18, 5, ; NB config
mcall , 117*65536+400, 97*65536+ 40, 6, ; Bits
mov edx, [Reg]
add edx, PCIE_ADDR ; reading the current reg content
mov ecx, [edx]
mov [Rct], ecx
mov ebx, bitstr2
inc ebx
mov edx, [Rct]
mov ecx, 0x80000000
xor eax, eax
.stringtest:
test edx, ecx
jz @f
mov byte [ebx+eax*2],'I' ; bit dump
jmp .nextbit
@@:
mov byte [ebx+eax*2],'0'
.nextbit:
inc eax
shr ecx, 1
jnz .stringtest
; button txt: X *65536+ Y
mcall 4, 378*65536+32 ,0x10000000, butstr2,3
mcall , 378*65536+57 , , butstr3,
mcall , 436*65536+32 , , butstr4,9
mcall , 436*65536+57 , , butstr5,
mcall 4, 122*65536+101,0 , bitstr0,65
mcall , 122*65536+110,0 , bitstr1,65
mcall , 122*65536+117,0 , bitstr2,65
mcall , 122*65536+126,0 , bitstr3,65
; -----------------------------------------------------------------
; draw the reg-value box
mov ebx, 10*65536+100 ; Xleft | Xwidth
mov ecx, 26*65536+250 ; Ytop | Yheight
mov edx, BOX_COLOR
mcall 13
; draw the reg-address box
mov ebx, 206*65536+146 ; Xleft | Xwidth
mov cx, 44 ; Yheight only
mcall 13
; draw ZiS status box
; mov ebx, 206*65536+274 ; Xleft | Xwidth
; mov ecx, 84*65536+ 64 ; Ytop | Yheight
; mcall 13
; draw the dump box
; mov ebx, 206*65536+274 ; Xleft | Xwidth
; mov ecx, 190*65536+232 ; Ytop | Yheight
; mcall 13
; fill the data box
mov ebx, [Reg]
mov [reg],ebx
mov bx, 40 ; upper position
mov [stY],bx
.print_reg_names:
call print_config_reg
add [stY],14
add [reg], 4
mov edx,[Reg]
add edx,16*4
cmp edx,[reg]
ja .print_reg_names
; fill the status box
mcall 4, 210*65536+30,0,str1,12
mcall , 210*65536+44, ,str2,
mcall , 210*65536+56, ,str3,
mov ecx, PCIE_ADDR
mov edx, 300*65536+30
mov ebx, 8*65536+256
mcall 47
add dx, 14
mov ecx,[Reg]
mov esi, 0
mcall 47
add dx,14
mov ecx, [Rct]
mcall 47
; print extra info
mov ebx, 120*65536+180
xor ecx, ecx
mov edx, info1
@@:
mcall 4,,,,66
add edx, 66
add ebx, 14
cmp edx, info_end
jb @b
mcall 12, 2 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
ret
align 4
;-------------------------------------------------
pix dd 0x55AACC33
pxX dd 200
pxY dd 160
stX dw 18
stY dw 0
reg dd 0
Rct dd 0 ; reg content
Reg dd 0x00 ; reg number
title db ' SB710 LPC Config Registers - LPC_Reg ',0
;------------------------------------------------------------------------------------
reg_str db 'Reg#| hex.Value '
;------------------------------------------------------------------------------------
str1 db 'bdf address:'
str2 db 'Reg. number:'
str3 db 'Reg.content:'
butstr2 db ' << '
butstr3 db ' >> '
butstr4 db 'Next Page'
butstr5 db 'Prev Page'
bitstr0 db '31',209,205,209,205,209,205,209,205,209,205,209,205,'24',\
209,205,209,205,209,205,209,205,209,205,209,205,209,205,'16',\
209,'15',205,209,205,209,205,209,205,209,205,209,205,209,'8',\
205,'7',209,205,209,205,209,205,209,205,209,205,209,205,209,'0',184
bitstr1 db 179,' | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ',179
bitstr2 db 179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179,'9 8 7 6',\
179,'5 4 3 2',179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179
bitstr3 db 212,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,190
info1 db '--------------------------- extra info ---------------------------'
info2 db '| reg 00[31:16] (DeviceID): 439D = SB7100/710/750 LPC bus |'
db '| reg |'
db '| reg |'
db '| reg |'
db '------------------------------------------------------------------'
info_end:
I_END: ; end of program
rd 256
align 256
st_0:

View File

@ -0,0 +1,344 @@
$Revision: 1598 $
use32 ;
org 0x0 ;
db 'MENUET01' ;
dd 0x01 ;
dd START ;
dd I_END ;
dd 0x1000 ;
dd 0x1000 ;
dd 0x0 ;
dd 0x0 ;
include 'MACROS.INC' ;
PCIE_SPACE equ 0xF0000000
PCIE_ADDR equ 0xF00A0000 ; bdf0:20.0 = SB7xx PCI Config Registers
BOX_COLOR equ 0xE0D8D0
START:
mov edx, 0x88
add edx, PCIE_ADDR
mov eax, 0x00010101
mov [edx], eax
red:
call draw_window
still:
mcall 10 ; event waiting
cmp eax,1 ; redraw window
je red ;
cmp eax,2 ; key pressed?
je key ;
cmp eax,3 ; button hit?
je button ;
jmp still ; none of that
;---------------------------------------------------------------------
key: ; key pressed
jmp red
;---------------------------------------------------------------------
button:
mcall 17 ; get the button ID
cmp ah, 1
jne .bt2
mcall -1
.bt2:
cmp ah, 2
jne .bt3
sub [Reg],4 ; Rg# decrement
jmp red
.bt3:
cmp ah, 3
jne .bt4
add [Reg],4 ; Rg# increment
jmp red
.bt4:
cmp ah, 4
jne .bt5
add [Reg],4*16 ; PgDn
jmp red
.bt5:
cmp ah, 5
jne .bt6
mov edx, [Reg]
cmp edx, 4*16
jb @f
sub edx, 4*16
mov [Reg],edx ; PgUp
jmp red
@@:
xor edx, edx
mov [Reg], edx
jmp red
.bt6:
cmp ah, 6
jne still
mcall 37, 1 ; get the mouse pointer
shr eax, 16 ; only X needed
sub eax, 124 ; check the left border
jb red
xor edx, edx
mov ebx, 12
div ebx
cmp eax, 32 ; check the right border
jnb red
mov ecx, 31
sub ecx, eax ; reverse the bit order
mov ebx, [Rct]
btc ebx, ecx ; invert the bit
mov eax, [Reg]
add eax, PCIE_ADDR
mov [Rct], ebx
mov [eax], ebx
jmp red
;------------------------------------------------
print_config_reg:
;------------------------------------------------
mov eax, [reg]
and eax, 0x0FFC
mov ebx, 4*65536+256 ; 4 hex digits
mov ecx, eax
mov dx,[stX]
shl edx,16 ; = X*65536
mov dx,[stY] ; = edx + Y
mov esi,0
mcall 47 ; print reg#
mov eax, [reg]
add eax, PCIE_ADDR
mov ecx, [eax]
add edx, 36*65536 ; right column
mov ebx, 8*65536+256 ; 8 hex digits
mcall 47 ; print config data
ret
;------------------------------------------------
read_nbconfig:
; in: dl = reg# | out: eax = data
;------------------------------------------------
mov ebx, 0xF0000000
and edx, 0x0FC
mov eax, dword [ebx+edx]
ret
;------------------------------------------------
write_nbconfig:
; in: dl = reg#; eax = data
;------------------------------------------------
mov ebx, 0xF0000000
and edx, 0x0FC
mov dword [ebx+edx], eax
ret
;------------------------------------------------
;read_htiunbind:
; in: [HTr] = reg# | out: eax = data
;------------------------------------------------
; mov dl, 0x94
; mov al, byte[HTr]
; and eax, 0x07C
; call write_nbconfig
; add dl, 4
; call read_nbconfig
; ret
;------------------------------------------------
;write_htiunbind:
; in: [HTr] = reg#; ecx = data
;------------------------------------------------
; mov dl, 0x94
; mov al, byte[Reg]
; and eax, 0x017C
; call write_nbconfig
; add dl, 4
; mov ecx, eax
; call write_nbconfig
; sub dl, 4
; mov eax, 0x0
; call write_nbconfig
; ret
;------------------------------------------------
draw_window:
;------------------------------------------------
mcall 12, 1
mcall 0, 600*65536+530, 120*65536+290, 0x1499AABB,,title
; -----------------------------------------------------------------
; BUTTONS: Xleft Xwid, Ytop Yheig
mcall 8, 370*65536+ 40, 26*65536+ 18, 2, 0x99AABB ; <<
mcall , , 51*65536+ 18, 3, ; >>
mcall , 425*65536+ 90, 26*65536+ 18, 4, ; PCIe Cfg
mcall , , 51*65536+ 18, 5, ; NB config
mcall , 117*65536+400, 97*65536+ 40, 6, ; Bits
mov edx, [Reg]
add edx, PCIE_ADDR ; reading the current reg content
mov ecx, [edx]
mov [Rct], ecx
mov ebx, bitstr2
inc ebx
mov edx, [Rct]
mov ecx, 0x80000000
xor eax, eax
.stringtest:
test edx, ecx
jz @f
mov byte [ebx+eax*2],'I' ; bit dump
jmp .nextbit
@@:
mov byte [ebx+eax*2],'0'
.nextbit:
inc eax
shr ecx, 1
jnz .stringtest
; button txt: X *65536+ Y
mcall 4, 378*65536+32 ,0x10000000, butstr2,3
mcall , 378*65536+57 , , butstr3,
mcall , 436*65536+32 , , butstr4,9
mcall , 436*65536+57 , , butstr5,
mcall 4, 122*65536+101,0 , bitstr0,65
mcall , 122*65536+110,0 , bitstr1,65
mcall , 122*65536+117,0 , bitstr2,65
mcall , 122*65536+126,0 , bitstr3,65
; -----------------------------------------------------------------
; draw the reg-value box
mov ebx, 10*65536+100 ; Xleft | Xwidth
mov ecx, 26*65536+250 ; Ytop | Yheight
mov edx, BOX_COLOR
mcall 13
; draw the reg-address box
mov ebx, 206*65536+146 ; Xleft | Xwidth
mov cx, 44 ; Yheight only
mcall 13
; draw ZiS status box
; mov ebx, 206*65536+274 ; Xleft | Xwidth
; mov ecx, 84*65536+ 64 ; Ytop | Yheight
; mcall 13
; draw the dump box
; mov ebx, 206*65536+274 ; Xleft | Xwidth
; mov ecx, 190*65536+232 ; Ytop | Yheight
; mcall 13
; fill the data box
mov ebx, [Reg]
mov [reg],ebx
mov bx, 40 ; upper position
mov [stY],bx
.print_reg_names:
call print_config_reg
add [stY],14
add [reg], 4
mov edx,[Reg]
add edx,16*4
cmp edx,[reg]
ja .print_reg_names
; fill the status box
mcall 4, 210*65536+30,0,str1,12
mcall , 210*65536+44, ,str2,
mcall , 210*65536+56, ,str3,
mov ecx, PCIE_ADDR
mov edx, 300*65536+30
mov ebx, 8*65536+256
mcall 47
add dx, 14
mov ecx,[Reg]
mov esi, 0
mcall 47
add dx,14
mov ecx, [Rct]
mcall 47
; print extra info
mov ebx, 120*65536+180
xor ecx, ecx
mov edx, info1
@@:
mcall 4,,,,66
add edx, 66
add ebx, 14
cmp edx, info_end
jb @b
mcall 12, 2 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
ret
align 4
;-------------------------------------------------
pix dd 0x55AACC33
pxX dd 200
pxY dd 160
stX dw 18
stY dw 0
reg dd 0
Rct dd 0 ; reg content
Reg dd 0x00 ; reg number
title db ' SB710 PCI Config Registers - PCI_Reg ',0
;------------------------------------------------------------------------------------
reg_str db 'Reg#| hex.Value '
;------------------------------------------------------------------------------------
str1 db 'bdf address:'
str2 db 'Reg. number:'
str3 db 'Reg.content:'
butstr2 db ' << '
butstr3 db ' >> '
butstr4 db 'Next Page'
butstr5 db 'Prev Page'
bitstr0 db '31',209,205,209,205,209,205,209,205,209,205,209,205,'24',\
209,205,209,205,209,205,209,205,209,205,209,205,209,205,'16',\
209,'15',205,209,205,209,205,209,205,209,205,209,205,209,'8',\
205,'7',209,205,209,205,209,205,209,205,209,205,209,205,209,'0',184
bitstr1 db 179,' | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ',179
bitstr2 db 179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179,'9 8 7 6',\
179,'5 4 3 2',179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179
bitstr3 db 212,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,190
info1 db '--------------------------- extra info ---------------------------'
info2 db '| reg 00[31:16] (DeviceID): 4385=SB7100/710/750 SMBus module |'
db '| reg |'
db '| reg |'
db '| reg |'
db '------------------------------------------------------------------'
info_end:
I_END: ; end of program
rd 256
align 256
st_0:

View File

@ -0,0 +1,314 @@
$Revision: 1598 $
use32 ;
org 0x0 ;
db 'MENUET01' ;
dd 0x01 ;
dd START ;
dd I_END ;
dd 0x1000 ;
dd 0x1000 ;
dd 0x0 ;
dd 0x0 ;
include 'MACROS.INC' ;
SB_PM_INDEX equ 0xC50
SB_PM_DATA equ 0xC51
BOX_COLOR equ 0xD0C8C0
START:
red:
call draw_window
still:
mcall 10 ; event waiting
cmp eax,1 ; redraw window
je red ;
cmp eax,2 ; key pressed?
je key ;
cmp eax,3 ; button hit?
je button ;
jmp still ; none of that
;---------------------------------------------------------------------
key: ; key pressed
jmp red
;---------------------------------------------------------------------
button:
mcall 17 ; get the button ID
cmp ah, 1
jne .bt2
mcall -1
.bt2:
cmp ah, 2
jne .bt3
dec [Reg] ; Rg# decrement
jmp red
.bt3:
cmp ah, 3
jne .bt4
inc [Reg] ; Rg# increment
jmp red
.bt4:
cmp ah, 4
jne .bt5
add [Reg],16 ; PgDn
jmp red
.bt5:
cmp ah, 5
jne .bt6
mov edx, [Reg]
cmp edx, 16
jb @f
sub edx, 16
mov [Reg],edx ; PgUp
jmp red
@@:
xor edx, edx
mov [Reg], edx
jmp red
.bt6:
cmp ah, 6
jne still
mcall 37, 1 ; get the mouse pointer
shr eax, 16 ; only X needed
sub eax, 124 ; check the left border
jb red
xor edx, edx
mov ebx, 12
div ebx
cmp eax, 32 ; check the right border
jnb red
mov ecx, 31
sub ecx, eax ; reverse the bit order
mov ebx, [Rct]
btc ebx, ecx ; invert the bit
mov eax, [Reg]
mov [Rct], ebx
call write_sb_pm_reg
jmp red
;------------------------------------------------
print_config_reg:
;------------------------------------------------
mov eax, [Reg]
; and eax, 0x0FF
mov ebx, 3*65536+256 ; 3 hex digits
mov ecx, eax
mov dx,[stX]
shl edx,16 ; = X*65536
mov dx,[stY] ; = edx + Y
mov esi,0
mcall 47 ; print reg#
mov ecx, edx
call read_sb_pm_reg
mov edx, ecx
mov ecx, eax
add edx, 36*65536 ; right column
mov ebx, 8*65536+256 ; 8 hex digits
mcall 47 ; print config data
ret
;------------------------------------------------
read_sb_pm_reg:
; in: [Reg] = reg# | out: eax = [Rct] = data
;------------------------------------------------
mov dx, SB_PM_INDEX
xor eax, eax
mov al, byte [Reg]
out dx, al
inc dl
in al, dx
mov [Rct], eax
ret
;------------------------------------------------
write_sb_pm_reg:
; in: [Reg] = reg#; [Rct] = data
;------------------------------------------------
mov dx, SB_PM_INDEX
xor eax, eax
mov al, byte [Reg]
out dx, al
inc dl
mov eax, [Rct]
out dx, al
ret
;------------------------------------------------
draw_window:
;------------------------------------------------
mcall 12, 1
mcall 0, 600*65536+530, 410*65536+290, 0x14748090,,title
; -----------------------------------------------------------------
; BUTTONS: Xleft Xwid, Ytop Yheig
mcall 8, 370*65536+ 40, 26*65536+ 18, 2, 0x94A0B0 ; <<
mcall , , 51*65536+ 18, 3, ; >>
mcall , 425*65536+ 90, 26*65536+ 18, 4, ; Next Page
mcall , , 51*65536+ 18, 5, ; Prev Page
mcall , 117*65536+400, 97*65536+ 40, 6, ; Bits
call read_sb_pm_reg
mov ebx, bitstr2
inc ebx
mov edx, [Rct]
mov ecx, 0x80000000
xor eax, eax
.stringtest:
test edx, ecx
jz @f
mov byte [ebx+eax*2],'I' ; bit dump
jmp .nextbit
@@:
mov byte [ebx+eax*2],'0'
.nextbit:
inc eax
shr ecx, 1
jnz .stringtest
; button txt: X *65536+ Y
mcall 4, 378*65536+32 ,0x10000000, butstr2,3
mcall , 378*65536+57 , , butstr3,
mcall , 436*65536+32 , , butstr4,9
mcall , 436*65536+57 , , butstr5,
mcall 4, 122*65536+101,0 , bitstr0,65
mcall , 122*65536+110,0 , bitstr1,65
mcall , 122*65536+117,0 , bitstr2,65
mcall , 122*65536+126,0 , bitstr3,65
; -----------------------------------------------------------------
; draw the reg-value box
mov ebx, 10*65536+100 ; Xleft | Xwidth
mov ecx, 26*65536+250 ; Ytop | Yheight
mov edx, BOX_COLOR
mcall 13
; draw the reg-address box
mov ebx, 206*65536+146 ; Xleft | Xwidth
mov cx, 44 ; Yheight only
mcall 13
; fill the data box
mov bx, 40 ; upper position
mov [stY],bx
mov eax, [Reg]
mov [reg], eax ; store original#
.print_reg_names:
call print_config_reg
add [stY],14
inc [Reg]
mov edx,[reg]
mov eax, 16
add eax, edx
cmp eax,[Reg]
ja .print_reg_names
mov [Reg], edx ; restore original#
; fill the status box
mcall 4, 210*65536+30,0,str1,12
mcall , 210*65536+44, ,str2,
mcall , 210*65536+56, ,str3,
call read_sb_pm_reg
mov ecx, SB_PM_DATA
mov edx, 300*65536+30
mov ebx, 8*65536+256
mcall 47
add dx, 14
mov ecx,[Reg]
mov esi, 0
mcall 47
add dx,14
mov ecx, [Rct]
mcall 47
; print extra info
mov ebx, 120*65536+170
xor ecx, ecx
mov edx, info1
@@:
mcall 4,,,,66
add edx, 66
add ebx, 14
cmp edx, info_end
jb @b
mcall 12, 2 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
ret
align 4
;-------------------------------------------------
pix dd 0x55AACC33
pxX dd 200
pxY dd 160
stX dw 18
stY dw 0
reg dd 0
Rct dd 0 ; reg content
Reg dd 0x00 ; reg number
title db ' SB710 Client Management Registers - IO_CM_Reg',0
;------------------------------------------------------------------------------------
reg_str db 'Reg#| hex.Value '
;------------------------------------------------------------------------------------
str1 db 'bdf address:'
str2 db 'Reg. number:'
str3 db 'Reg.content:'
butstr2 db ' << '
butstr3 db ' >> '
butstr4 db 'Next Page'
butstr5 db 'Prev Page'
bitstr0 db '31',209,205,209,205,209,205,209,205,209,205,209,205,'24',\
209,205,209,205,209,205,209,205,209,205,209,205,209,205,'16',\
209,'15',205,209,205,209,205,209,205,209,205,209,205,209,'8',\
205,'7',209,205,209,205,209,205,209,205,209,205,209,205,209,'0',184
bitstr1 db 179,' | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ',179
bitstr2 db 179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179,'9 8 7 6',\
179,'5 4 3 2',179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179
bitstr3 db 212,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,190
info1 db '------------- PM REG -------------'
db '| see AMD SB700/710/750 Register Reference Guide, pp.172-173 |'
info2 db '| reg 00 - IdRegister |'
db '| reg 02 [0]: logical status of TALERT/GPIO64 input (read-clears)|'
db '| reg 03 [1]: generate SMI# ipon TALERT |'
db '| reg 12 - I2C Control |'
db '| reg 13 [7:6]: GpmPortStatus (00=read; 01=OE; 10=output) |'
db '------------------------------------------------------------------'
info_end:
I_END: ; end of program
rd 256
align 256
st_0:

View File

@ -0,0 +1,331 @@
$Revision: 1598 $
use32 ;
org 0x0 ;
db 'MENUET01' ;
dd 0x01 ;
dd START ;
dd I_END ;
dd 0x1000 ;
dd 0x1000 ;
dd 0x0 ;
dd 0x0 ;
include 'MACROS.INC' ;
SB_SIO_INDEX equ 0x2e
SB_SIO_DATA equ 0x2f
BOX_COLOR equ 0xD0C8C0
START:
call enter_cfg_mode ; call this once
red:
call draw_window
still:
mcall 10 ; event waiting
cmp eax,1 ; redraw window
je red ;
cmp eax,2 ; key pressed?
je key ;
cmp eax,3 ; button hit?
je button ;
jmp still ; none of that
;---------------------------------------------------------------------
key: ; key pressed
jmp red
;---------------------------------------------------------------------
button:
mcall 17 ; get the button ID
cmp ah, 1
jne .bt2
mov byte[Reg], 2
mov byte[Rct], 2
call write_sio_cfg ; exit config-mode on exit
mcall -1
; --------------
.bt2:
cmp ah, 2
jne .bt3
dec [Reg] ; Rg# decrement
jmp red
.bt3:
cmp ah, 3
jne .bt4
inc [Reg] ; Rg# increment
jmp red
.bt4:
cmp ah, 4
jne .bt5
add [Reg],16 ; PgDn
jmp red
.bt5:
cmp ah, 5
jne .bt6
mov edx, [Reg]
cmp edx, 16
jb @f
sub edx, 16
mov [Reg],edx ; PgUp
jmp red
@@:
xor edx, edx
mov [Reg], edx
jmp red
.bt6:
cmp ah, 6
jne still
mcall 37, 1 ; get the mouse pointer
shr eax, 16 ; only X needed
sub eax, 124 ; check the left border
jb red
xor edx, edx
mov ebx, 12
div ebx
cmp eax, 32 ; check the right border
jnb red
mov ecx, 31
sub ecx, eax ; reverse the bit order
mov ebx, [Rct]
btc ebx, ecx ; invert the bit
mov eax, [Reg]
mov [Rct], ebx
call write_sio_cfg
jmp red
;------------------------------------------------
print_config_reg:
;------------------------------------------------
mov eax, [Reg]
; and eax, 0x0FF
mov ebx, 3*65536+256 ; 3 hex digits
mov ecx, eax
mov dx,[stX]
shl edx,16 ; = X*65536
mov dx,[stY] ; = edx + Y
mov esi,0
mcall 47 ; print reg#
mov ecx, edx
call read_sio_cfg
mov edx, ecx
mov ecx, eax
add edx, 36*65536 ; right column
mov ebx, 8*65536+256 ; 8 hex digits
mcall 47 ; print config data
ret
;------------------------------------------------
read_sio_cfg:
; in: [Reg] = reg# | out: eax = [Rct] = data
;------------------------------------------------
mov dx, SB_SIO_INDEX
xor eax, eax
mov al, byte [Reg]
out dx, al
inc dl
in al, dx
mov [Rct], eax
ret
;------------------------------------------------
write_sio_cfg:
; in: [Reg] = reg#; [Rct] = data
;------------------------------------------------
mov dx, SB_SIO_INDEX
mov eax, [Reg]
out dx, al
inc dl
mov eax, [Rct]
out dx, al
ret
;------------------------------------------------
enter_cfg_mode:
; the magic sequence to unlock the port
;------------------------------------------------
mov dx, SB_SIO_INDEX
mov eax, 0x55550187 ; low byte first
out dx, al
shr eax, 8
out dx, al
shr eax, 8
out dx, al
shr eax, 8
out dx, al
ret
;------------------------------------------------
draw_window:
;------------------------------------------------
mcall 12, 1
mcall 0, 600*65536+530, 410*65536+290, 0x14748090,,title
; -----------------------------------------------------------------
; BUTTONS: Xleft Xwid, Ytop Yheig
mcall 8, 370*65536+ 40, 26*65536+ 18, 2, 0x94A0B0 ; <<
mcall , , 51*65536+ 18, 3, ; >>
mcall , 425*65536+ 90, 26*65536+ 18, 4, ; Next Page
mcall , , 51*65536+ 18, 5, ; Prev Page
mcall , 117*65536+400, 97*65536+ 40, 6, ; Bits
call read_sio_cfg
mov ebx, bitstr2
inc ebx
mov edx, [Rct]
mov ecx, 0x80000000
xor eax, eax
.stringtest:
test edx, ecx
jz @f
mov byte [ebx+eax*2],'I' ; bit dump
jmp .nextbit
@@:
mov byte [ebx+eax*2],'0'
.nextbit:
inc eax
shr ecx, 1
jnz .stringtest
; button txt: X *65536+ Y
mcall 4, 378*65536+32 ,0x10000000, butstr2,3
mcall , 378*65536+57 , , butstr3,
mcall , 436*65536+32 , , butstr4,9
mcall , 436*65536+57 , , butstr5,
mcall 4, 122*65536+101,0 , bitstr0,65
mcall , 122*65536+110,0 , bitstr1,65
mcall , 122*65536+117,0 , bitstr2,65
mcall , 122*65536+126,0 , bitstr3,65
; -----------------------------------------------------------------
; draw the reg-value box
mov ebx, 10*65536+100 ; Xleft | Xwidth
mov ecx, 26*65536+250 ; Ytop | Yheight
mov edx, BOX_COLOR
mcall 13
; draw the reg-address box
mov ebx, 206*65536+146 ; Xleft | Xwidth
mov cx, 44 ; Yheight only
mcall 13
; fill the data box
mov bx, 40 ; upper position
mov [stY],bx
mov eax, [Reg]
mov [reg], eax ; store original#
.print_reg_names:
call print_config_reg
add [stY],14
inc [Reg]
mov edx,[reg]
mov eax, 16
add eax, edx
cmp eax,[Reg]
ja .print_reg_names
mov [Reg], edx ; restore original#
; fill the status box
mcall 4, 210*65536+30,0,str1,12
mcall , 210*65536+44, ,str2,
mcall , 210*65536+56, ,str3,
call read_sio_cfg
mov ecx, SB_SIO_DATA
mov edx, 300*65536+30
mov ebx, 8*65536+256
mcall 47
add dx, 14
mov ecx,[Reg]
mov esi, 0
mcall 47
add dx,14
mov ecx, [Rct]
mcall 47
; print extra info
mov ebx, 120*65536+170
xor ecx, ecx
mov edx, info1
@@:
mcall 4,,,,66
add edx, 66
add ebx, 14
cmp edx, info_end
jb @b
mcall 12, 2 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
ret
align 4
;-------------------------------------------------
pix dd 0x55AACC33
pxX dd 200
pxY dd 160
stX dw 18
stY dw 0
reg dd 0
Rct dd 0 ; reg content
Reg dd 0x00 ; reg number
title db ' IT8712F -- Super IO control - SIO_Reg',0
;------------------------------------------------------------------------------------
reg_str db 'Reg#| hex.Value '
;------------------------------------------------------------------------------------
str1 db 'bdf address:'
str2 db 'Reg. number:'
str3 db 'Reg.content:'
butstr2 db ' << '
butstr3 db ' >> '
butstr4 db 'Next Page'
butstr5 db 'Prev Page'
bitstr0 db '31',209,205,209,205,209,205,209,205,209,205,209,205,'24',\
209,205,209,205,209,205,209,205,209,205,209,205,209,205,'16',\
209,'15',205,209,205,209,205,209,205,209,205,209,205,209,'8',\
205,'7',209,205,209,205,209,205,209,205,209,205,209,205,209,'0',184
bitstr1 db 179,' | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ',179
bitstr2 db 179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179,'9 8 7 6',\
179,'5 4 3 2',179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179
bitstr3 db 212,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,190
info1 db '------------- SIO REG -------------'
db '| see AMD SB700/710/750 Register Reference Guide, pp. |'
info2 db '| |'
db '| reg |'
db '| reg |'
db '| reg |'
db '| reg |'
db '------------------------------------------------------------------'
info_end:
I_END: ; end of program
rd 256
align 256
st_0:

View File

@ -0,0 +1,314 @@
$Revision: 1598 $
use32 ;
org 0x0 ;
db 'MENUET01' ;
dd 0x01 ;
dd START ;
dd I_END ;
dd 0x1000 ;
dd 0x1000 ;
dd 0x0 ;
dd 0x0 ;
include 'MACROS.INC' ;
SB_PM2_INDEX equ 0xCD0
SB_PM2_DATA equ 0xCD1
BOX_COLOR equ 0xD0C8C0
START:
red:
call draw_window
still:
mcall 10 ; event waiting
cmp eax,1 ; redraw window
je red ;
cmp eax,2 ; key pressed?
je key ;
cmp eax,3 ; button hit?
je button ;
jmp still ; none of that
;---------------------------------------------------------------------
key: ; key pressed
jmp red
;---------------------------------------------------------------------
button:
mcall 17 ; get the button ID
cmp ah, 1
jne .bt2
mcall -1
.bt2:
cmp ah, 2
jne .bt3
dec [Reg] ; Rg# decrement
jmp red
.bt3:
cmp ah, 3
jne .bt4
inc [Reg] ; Rg# increment
jmp red
.bt4:
cmp ah, 4
jne .bt5
add [Reg],16 ; PgDn
jmp red
.bt5:
cmp ah, 5
jne .bt6
mov edx, [Reg]
cmp edx, 16
jb @f
sub edx, 16
mov [Reg],edx ; PgUp
jmp red
@@:
xor edx, edx
mov [Reg], edx
jmp red
.bt6:
cmp ah, 6
jne still
mcall 37, 1 ; get the mouse pointer
shr eax, 16 ; only X needed
sub eax, 124 ; check the left border
jb red
xor edx, edx
mov ebx, 12
div ebx
cmp eax, 32 ; check the right border
jnb red
mov ecx, 31
sub ecx, eax ; reverse the bit order
mov ebx, [Rct]
btc ebx, ecx ; invert the bit
mov eax, [Reg]
mov [Rct], ebx
call write_sb_pm2_reg
jmp red
;------------------------------------------------
print_config_reg:
;------------------------------------------------
mov eax, [Reg]
; and eax, 0x0FF
mov ebx, 3*65536+256 ; 3 hex digits
mov ecx, eax
mov dx,[stX]
shl edx,16 ; = X*65536
mov dx,[stY] ; = edx + Y
mov esi,0
mcall 47 ; print reg#
mov ecx, edx
call read_sb_pm2_reg
mov edx, ecx
mov ecx, eax
add edx, 36*65536 ; right column
mov ebx, 8*65536+256 ; 8 hex digits
mcall 47 ; print config data
ret
;------------------------------------------------
read_sb_pm2_reg:
; in: [Reg] = reg# | out: eax = [Rct] = data
;------------------------------------------------
mov dx, SB_PM2_INDEX
xor eax, eax
mov al, byte [Reg]
out dx, al
inc dl
in al, dx
mov [Rct], eax
ret
;------------------------------------------------
write_sb_pm2_reg:
; in: [Reg] = reg#; [Rct] = data
;------------------------------------------------
mov dx, SB_PM2_INDEX
xor eax, eax
mov al, byte [Reg]
out dx, al
inc dl
mov eax, [Rct]
out dx, al
ret
;------------------------------------------------
draw_window:
;------------------------------------------------
mcall 12, 1
mcall 0, 600*65536+530, 410*65536+290, 0x14848090,,title
; -----------------------------------------------------------------
; BUTTONS: Xleft Xwid, Ytop Yheig
mcall 8, 370*65536+ 40, 26*65536+ 18, 2, 0x94A0B0 ; <<
mcall , , 51*65536+ 18, 3, ; >>
mcall , 425*65536+ 90, 26*65536+ 18, 4, ; Next Page
mcall , , 51*65536+ 18, 5, ; Prev Page
mcall , 117*65536+400, 97*65536+ 40, 6, ; Bits
call read_sb_pm2_reg
mov ebx, bitstr2
inc ebx
mov edx, [Rct]
mov ecx, 0x80000000
xor eax, eax
.stringtest:
test edx, ecx
jz @f
mov byte [ebx+eax*2],'I' ; bit dump
jmp .nextbit
@@:
mov byte [ebx+eax*2],'0'
.nextbit:
inc eax
shr ecx, 1
jnz .stringtest
; button txt: X *65536+ Y
mcall 4, 378*65536+32 ,0x10000000, butstr2,3
mcall , 378*65536+57 , , butstr3,
mcall , 436*65536+32 , , butstr4,9
mcall , 436*65536+57 , , butstr5,
mcall 4, 122*65536+101,0 , bitstr0,65
mcall , 122*65536+110,0 , bitstr1,65
mcall , 122*65536+117,0 , bitstr2,65
mcall , 122*65536+126,0 , bitstr3,65
; -----------------------------------------------------------------
; draw the reg-value box
mov ebx, 10*65536+100 ; Xleft | Xwidth
mov ecx, 26*65536+250 ; Ytop | Yheight
mov edx, BOX_COLOR
mcall 13
; draw the reg-address box
mov ebx, 206*65536+146 ; Xleft | Xwidth
mov cx, 44 ; Yheight only
mcall 13
; fill the data box
mov bx, 40 ; upper position
mov [stY],bx
mov eax, [Reg]
mov [reg], eax ; store original#
.print_reg_names:
call print_config_reg
add [stY],14
inc [Reg]
mov edx,[reg]
mov eax, 16
add eax, edx
cmp eax,[Reg]
ja .print_reg_names
mov [Reg], edx ; restore original#
; fill the status box
mcall 4, 210*65536+30,0,str1,12
mcall , 210*65536+44, ,str2,
mcall , 210*65536+56, ,str3,
call read_sb_pm2_reg
mov ecx, SB_PM2_DATA
mov edx, 300*65536+30
mov ebx, 8*65536+256
mcall 47
add dx, 14
mov ecx,[Reg]
mov esi, 0
mcall 47
add dx,14
mov ecx, [Rct]
mcall 47
; print extra info
mov ebx, 120*65536+170
xor ecx, ecx
mov edx, info1
@@:
mcall 4,,,,66
add edx, 66
add ebx, 14
cmp edx, info_end
jb @b
mcall 12, 2 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
ret
align 4
;-------------------------------------------------
pix dd 0x55AACC33
pxX dd 200
pxY dd 160
stX dw 18
stY dw 0
reg dd 0
Rct dd 0 ; reg content
Reg dd 0x00 ; reg number
title db ' SB710 PowerManagement (Block2) registers - PM2_Reg',0
;------------------------------------------------------------------------------------
reg_str db 'Reg#| hex.Value '
;------------------------------------------------------------------------------------
str1 db 'bdf address:'
str2 db 'Reg. number:'
str3 db 'Reg.content:'
butstr2 db ' << '
butstr3 db ' >> '
butstr4 db 'Next Page'
butstr5 db 'Prev Page'
bitstr0 db '31',209,205,209,205,209,205,209,205,209,205,209,205,'24',\
209,205,209,205,209,205,209,205,209,205,209,205,209,205,'16',\
209,'15',205,209,205,209,205,209,205,209,205,209,205,209,'8',\
205,'7',209,205,209,205,209,205,209,205,209,205,209,205,209,'0',184
bitstr1 db 179,' | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ',179
bitstr2 db 179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179,'9 8 7 6',\
179,'5 4 3 2',179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179
bitstr3 db 212,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,190
info1 db '------------- PM2 REG ------------'
db '| see AMD SB700/710/750 Register Reference Guide, pp.228-258 |'
info2 db '| reg |'
db '| reg |'
db '| reg |'
db '| reg |'
db '| reg F6: Gpm3-0pull; F7: Gpm7-4pull; F8: Gpm9-8pull |'
db '------------------------------------------------------------------'
info_end:
I_END: ; end of program
rd 256
align 256
st_0:

View File

@ -0,0 +1,314 @@
$Revision: 1598 $
use32 ;
org 0x0 ;
db 'MENUET01' ;
dd 0x01 ;
dd START ;
dd I_END ;
dd 0x1000 ;
dd 0x1000 ;
dd 0x0 ;
dd 0x0 ;
include 'MACROS.INC' ;
SB_PM_INDEX equ 0xCD6
SB_PM_DATA equ 0xCD7
BOX_COLOR equ 0xD0C8C0
START:
red:
call draw_window
still:
mcall 10 ; event waiting
cmp eax,1 ; redraw window
je red ;
cmp eax,2 ; key pressed?
je key ;
cmp eax,3 ; button hit?
je button ;
jmp still ; none of that
;---------------------------------------------------------------------
key: ; key pressed
jmp red
;---------------------------------------------------------------------
button:
mcall 17 ; get the button ID
cmp ah, 1
jne .bt2
mcall -1
.bt2:
cmp ah, 2
jne .bt3
dec [Reg] ; Rg# decrement
jmp red
.bt3:
cmp ah, 3
jne .bt4
inc [Reg] ; Rg# increment
jmp red
.bt4:
cmp ah, 4
jne .bt5
add [Reg],16 ; PgDn
jmp red
.bt5:
cmp ah, 5
jne .bt6
mov edx, [Reg]
cmp edx, 16
jb @f
sub edx, 16
mov [Reg],edx ; PgUp
jmp red
@@:
xor edx, edx
mov [Reg], edx
jmp red
.bt6:
cmp ah, 6
jne still
mcall 37, 1 ; get the mouse pointer
shr eax, 16 ; only X needed
sub eax, 124 ; check the left border
jb red
xor edx, edx
mov ebx, 12
div ebx
cmp eax, 32 ; check the right border
jnb red
mov ecx, 31
sub ecx, eax ; reverse the bit order
mov ebx, [Rct]
btc ebx, ecx ; invert the bit
mov eax, [Reg]
mov [Rct], ebx
call write_sb_pm_reg
jmp red
;------------------------------------------------
print_config_reg:
;------------------------------------------------
mov eax, [Reg]
; and eax, 0x0FF
mov ebx, 3*65536+256 ; 3 hex digits
mov ecx, eax
mov dx,[stX]
shl edx,16 ; = X*65536
mov dx,[stY] ; = edx + Y
mov esi,0
mcall 47 ; print reg#
mov ecx, edx
call read_sb_pm_reg
mov edx, ecx
mov ecx, eax
add edx, 36*65536 ; right column
mov ebx, 8*65536+256 ; 8 hex digits
mcall 47 ; print config data
ret
;------------------------------------------------
read_sb_pm_reg:
; in: [Reg] = reg# | out: eax = [Rct] = data
;------------------------------------------------
mov dx, SB_PM_INDEX
xor eax, eax
mov al, byte [Reg]
out dx, al
inc dl
in al, dx
mov [Rct], eax
ret
;------------------------------------------------
write_sb_pm_reg:
; in: [Reg] = reg#; [Rct] = data
;------------------------------------------------
mov dx, SB_PM_INDEX
xor eax, eax
mov al, byte [Reg]
out dx, al
inc dl
mov eax, [Rct]
out dx, al
ret
;------------------------------------------------
draw_window:
;------------------------------------------------
mcall 12, 1
mcall 0, 600*65536+530, 410*65536+290, 0x14748090,,title
; -----------------------------------------------------------------
; BUTTONS: Xleft Xwid, Ytop Yheig
mcall 8, 370*65536+ 40, 26*65536+ 18, 2, 0x94A0B0 ; <<
mcall , , 51*65536+ 18, 3, ; >>
mcall , 425*65536+ 90, 26*65536+ 18, 4, ; Next Page
mcall , , 51*65536+ 18, 5, ; Prev Page
mcall , 117*65536+400, 97*65536+ 40, 6, ; Bits
call read_sb_pm_reg
mov ebx, bitstr2
inc ebx
mov edx, [Rct]
mov ecx, 0x80000000
xor eax, eax
.stringtest:
test edx, ecx
jz @f
mov byte [ebx+eax*2],'I' ; bit dump
jmp .nextbit
@@:
mov byte [ebx+eax*2],'0'
.nextbit:
inc eax
shr ecx, 1
jnz .stringtest
; button txt: X *65536+ Y
mcall 4, 378*65536+32 ,0x10000000, butstr2,3
mcall , 378*65536+57 , , butstr3,
mcall , 436*65536+32 , , butstr4,9
mcall , 436*65536+57 , , butstr5,
mcall 4, 122*65536+101,0 , bitstr0,65
mcall , 122*65536+110,0 , bitstr1,65
mcall , 122*65536+117,0 , bitstr2,65
mcall , 122*65536+126,0 , bitstr3,65
; -----------------------------------------------------------------
; draw the reg-value box
mov ebx, 10*65536+100 ; Xleft | Xwidth
mov ecx, 26*65536+250 ; Ytop | Yheight
mov edx, BOX_COLOR
mcall 13
; draw the reg-address box
mov ebx, 206*65536+146 ; Xleft | Xwidth
mov cx, 44 ; Yheight only
mcall 13
; fill the data box
mov bx, 40 ; upper position
mov [stY],bx
mov eax, [Reg]
mov [reg], eax ; store original#
.print_reg_names:
call print_config_reg
add [stY],14
inc [Reg]
mov edx,[reg]
mov eax, 16
add eax, edx
cmp eax,[Reg]
ja .print_reg_names
mov [Reg], edx ; restore original#
; fill the status box
mcall 4, 210*65536+30,0,str1,12
mcall , 210*65536+44, ,str2,
mcall , 210*65536+56, ,str3,
call read_sb_pm_reg
mov ecx, SB_PM_DATA
mov edx, 300*65536+30
mov ebx, 8*65536+256
mcall 47
add dx, 14
mov ecx,[Reg]
mov esi, 0
mcall 47
add dx,14
mov ecx, [Rct]
mcall 47
; print extra info
mov ebx, 120*65536+170
xor ecx, ecx
mov edx, info1
@@:
mcall 4,,,,66
add edx, 66
add ebx, 14
cmp edx, info_end
jb @b
mcall 12, 2 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
ret
align 4
;-------------------------------------------------
pix dd 0x55AACC33
pxX dd 200
pxY dd 160
stX dw 18
stY dw 0
reg dd 0
Rct dd 0 ; reg content
Reg dd 0x00 ; reg number
title db ' SB710 PowerManagement registers - PM_Reg',0
;------------------------------------------------------------------------------------
reg_str db 'Reg#| hex.Value '
;------------------------------------------------------------------------------------
str1 db 'bdf address:'
str2 db 'Reg. number:'
str3 db 'Reg.content:'
butstr2 db ' << '
butstr3 db ' >> '
butstr4 db 'Next Page'
butstr5 db 'Prev Page'
bitstr0 db '31',209,205,209,205,209,205,209,205,209,205,209,205,'24',\
209,205,209,205,209,205,209,205,209,205,209,205,209,205,'16',\
209,'15',205,209,205,209,205,209,205,209,205,209,205,209,'8',\
205,'7',209,205,209,205,209,205,209,205,209,205,209,205,209,'0',184
bitstr1 db 179,' | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ',179
bitstr2 db 179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179,'9 8 7 6',\
179,'5 4 3 2',179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179
bitstr3 db 212,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\
205,207,205,207,205,207,205,207,205,207,205,190
info1 db '------------- PM REG -------------'
db '| see AMD SB700/710/750 Register Reference Guide, pp.174-223 |'
info2 db '| |'
db '| reg |'
db '| reg |'
db '| reg |'
db '| reg |'
db '------------------------------------------------------------------'
info_end:
I_END: ; end of program
rd 256
align 256
st_0: