Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1564 → Rev 1565

/kernel/branches/Kolibri-A/utilities/RS780/HTIU_TST.ASM
0,0 → 1,316
;; rs780 HTUI test
;; (C) art_zh 2010
;; <kolibri@jerdev.co.uk>
 
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 0xF0000000 ; bus 0, dev 0 fn 0 -- don't change!
HTIU_NB_INDEX equ 0xF0000094 ; index reg for inderect space access
HTIU_NB_DAT equ 0xF0000098 ; inderect space data register
BOX_COLOR equ 0xE0D8D0
 
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 - general case
jmp red
@@:
xor edx, edx
mov [Reg], edx ; PgUp - the upper page
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 [Rct], ebx
call write_htiu
 
jmp red
 
 
;------------------------------------------------
print_config_reg:
;------------------------------------------------
mov eax, [Reg]
and eax, 0x07F
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 ; store edx
call read_htiu ; get content
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_htiu:
; in: [Reg] = reg# | out: eax = [Rct] = data
;------------------------------------------------
mov edx, HTIU_NB_INDEX
mov al, byte[Reg]
and eax, 0x07F
mov [edx], eax
add dl, 4
mov eax, [edx]
mov [Rct], eax
ret
;------------------------------------------------
write_htiu:
; in: [Reg] = reg#; [Rct] = data
;------------------------------------------------
mov edx, HTIU_NB_INDEX
mov al, byte[Reg]
and eax, 0x07F
or eax, 0x100
mov [edx], eax
add dl, 4
mov eax, [Rct]
mov [edx], eax
sub dl, 4
xor eax, eax
mov [edx], eax
ret
 
 
;------------------------------------------------
draw_window:
;------------------------------------------------
 
 
mcall 12, 1
mcall 0, 72*65536+530, 700*65536+290, 0x14A0B8A0,,title
; -----------------------------------------------------------------
; BUTTONS: Xleft Xwid, Ytop Yheig
mcall 8, 370*65536+ 40, 26*65536+ 18, 2, 0xA0B8A0 ; <<
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
 
call read_htiu ; read the current 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] ; store original#
mov [reg], eax
.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_htiu ; refresh the content
mov ecx, HTIU_NB_DAT
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
 
ret
 
 
align 4
;-------------------------------------------------
 
pix dd 0x55AACC33
pxX dd 200
pxY dd 160
stX dw 18
stY dw 0
reg dd 0 ; reg-storage
 
Rct dd 0 ; reg content
Reg dd 0x00 ; reg number
 
 
title db ' RS780 HT Indirect Registers ',0
;------------------------------------------------------------------------------------
reg_str db 'Reg#| hex.Value '
;------------------------------------------------------------------------------------
str1 db 'access addr:'
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 '---------------- Indirect registers shortlist --------------------'
info2 db ' '
db ' '
db ' '
db ' '
db '------------------------------------------------------------------'
info_end:
 
I_END: ; end of program
 
rd 256
 
align 256
st_0:
/kernel/branches/Kolibri-A/utilities/RS780/MACROS.INC
0,0 → 1,519
@^ fix macro comment {
^@ fix }
 
; -------------------------
macro library [lname,fname]
{
forward
dd __#lname#_library_table__,__#lname#_library_name__
common
dd 0
forward
align 4
__#lname#_library_name__ db fname,0
}
 
macro import lname,[name,sname]
{
common
align 4
__#lname#_library_table__:
forward
if used name
name dd __#name#_import_name__
end if
common
dd 0
forward
if used name
align 4
__#name#_import_name__ db sname,0
end if
}
 
macro export [name,sname]
{
forward
dd __#name#_export_name__,name
common
dd 0
forward
align 4
__#name#_export_name__ db sname,0
}
; -------------------------
 
macro m2m dest,src {
push src
pop dest
}
 
 
macro iglobal {
IGlobals equ IGlobals,
macro __IGlobalBlock { }
 
macro uglobal {
UGlobals equ UGlobals,
macro __UGlobalBlock { }
 
endg fix } ; Use endg for ending iglobal and uglobal blocks.
 
 
macro IncludeIGlobals{
macro IGlobals dummy,[n] \{ __IGlobalBlock
purge __IGlobalBlock \}
match I, IGlobals \{ I \} }
 
macro IncludeUGlobals{
macro UGlobals dummy,[n] \{
\common
\local begin, size
begin = $
virtual at $
\forward
__UGlobalBlock
purge __UGlobalBlock
\common
size = $ - begin
end virtual
rb size
\}
match U, UGlobals \{ U \} }
 
uglobal
endg
 
iglobal
endg
 
 
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
IncludeIGlobals
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
IncludeUGlobals
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
; macro for defining multiline text data
struc mls [sstring]
{
forward
local ssize
virtual at 0
db sstring ; mod
ssize = $
end virtual
db ssize
db sstring
common
db -1 ; mod
}
 
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
name db data
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
forward
if lang eq lng
db data
end if
common
.size = $-name
end if
}
 
macro szc name,elsz,[data] { ; from MFAR [mike.dld]
common
local s,m
m = 0
if used name
label name
forward
virtual at 0
db data
s = $
end virtual
d#elsz s
if m < s
m = s
end if
db data
common
.size = $-name
.maxl = m
end if
}
 
macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld]
common
local s,m,c
m = 0
c = 0
if used name
label name
forward
if lang eq lng
virtual at 0
db data
s = $
end virtual
d#elsz s
if m < s
m = s
end if
db data
c = c+1
end if
common
.size = $-name
.maxl = m
.count = c
end if
}
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
 
;include 'config.inc'
;__CPU_type equ p5
SYSENTER_VAR equ 0
 
macro mcall a,b,c,d,e,f { ; mike.dld, updated by Ghost for Fast System Calls
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
 
int 0x40
}
 
 
; -------------------------
macro header a,[b] {
common
use32
org 0
db 'MENUET',a
forward
if b eq
dd 0
else
dd b
end if }
macro section name { align 16
label name }
macro func name {
if ~used name
display 'FUNC NOT USED: ',`name,13,10
else
align 4
name:
;diff16 `name,0,name
;pushad
;pushfd
;dps `name
;newline
;mcall 5,1
;popfd
;popad
}
macro endf { end if }
 
macro diff16 title,l1,l2
{
local s,d
s = l2-l1
display title,': 0x'
repeat 8
d = '0' + s shr ((8-%) shl 2) and $0F
if d > '9'
d = d + 'A'-'9'-1
end if
display d
end repeat
display 13,10
}
 
macro diff10 title,l1,l2
{
local s,d,z,m
s = l2-l1
z = 0
m = 1000000000
display title,': '
repeat 10
d = '0' + s / m
s = s - (s/m)*m
m = m / 10
if d <> '0'
z = 1
end if
if z <> 0
display d
end if
end repeat
display 13,10
}
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0'))
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro RGB [a] {
common
match (r=,g=,b),a \{
\dd ((r) shl 16) or ((g) shl 8) or (b)
\}
}
 
 
struc POINT _t,_dx,_dy {
.x _t _dx
.y _t _dy
}
 
; structure definition helper
include 'struct.inc'
 
struct RECT
left dd ?
top dd ?
right dd ?
bottom dd ?
ends
 
struct BOX
left dd ?
top dd ?
width dd ?
height dd ?
ends
 
; structures used in MeOS
struct process_information
cpu_usage dd ? ; +0
window_stack_position dw ? ; +4
window_stack_value dw ? ; +6
dw ? ; +8
process_name rb 12 ; +10
memory_start dd ? ; +22
used_memory dd ? ; +26
PID dd ? ; +30
box BOX ; +34
slot_state dw ? ; +50
dw ? ; +52
client_box BOX ; +54
wnd_state db ? ; +70
rb (1024-71)
ends
 
struct system_colors
frame dd ?
grab dd ?
grab_button dd ?
grab_button_text dd ?
grab_text dd ?
work dd ?
work_button dd ?
work_button_text dd ?
work_text dd ?
work_graph dd ?
ends
 
struct FILEDATE
Second db ?
Minute db ?
Hour db ?
db ?
Day db ?
Month db ?
Year dw ?
ends
 
struct FILEINFO
Attributes dd ?
IsUnicode db ?
db 3 dup(?)
DateCreate FILEDATE
DateAccess FILEDATE
DateModify FILEDATE
Size dq ?
ends
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
/kernel/branches/Kolibri-A/utilities/RS780/MISC_TST.ASM
0,0 → 1,320
;; rs780 HT misc registers test
;; (C) art_zh 2010
;; <kolibri@jerdev.co.uk>
 
 
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 0xF0000000 ; bus 0, dev 0 fn 0 -- don't change!
MISC_NB_INDEX equ 0xF0000060 ; index reg for inderect space access
MISC_NB_DAT equ 0xF0000064 ; inderect space data register
BOX_COLOR equ 0xE0D8D0
 
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 - general case
jmp red
@@:
xor edx, edx
mov [Reg], edx ; PgUp - the upper page
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 [Rct], ebx
call write_misc
 
jmp red
 
 
;------------------------------------------------
print_config_reg:
;------------------------------------------------
mov eax, [Reg]
and eax, 0x07F
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 ; store edx
call read_misc ; get content
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_misc:
; in: [Reg] = reg# | out: eax = [Rct] = data
;------------------------------------------------
mov edx, MISC_NB_INDEX
mov al, byte[Reg]
and eax, 0x07F
mov [edx], eax
add dl, 4
mov eax, [edx]
mov [Rct], eax
ret
;------------------------------------------------
write_misc:
; in: [Reg] = reg#; [Rct] = data
;------------------------------------------------
mov edx, MISC_NB_INDEX
mov al, byte[Reg]
and eax, 0x07F
or eax, 0x080 ; WriteEnable bit
mov [edx], eax
add dl, 4
mov eax, [Rct]
mov [edx], eax
sub dl, 4
xor eax, eax
mov [edx], eax ; safety precaution
ret
 
 
;------------------------------------------------
draw_window:
;------------------------------------------------
 
 
mcall 12, 1
mcall 0, 72*65536+530, 410*65536+290, 0x14A0B8A0,,title
; -----------------------------------------------------------------
; BUTTONS: Xleft Xwid, Ytop Yheig
mcall 8, 370*65536+ 40, 26*65536+ 18, 2, 0xA0B8A0 ; <<
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_misc ; read the current 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] ; store original#
mov [reg], eax
.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_misc ; refresh the content
mov ecx, MISC_NB_DAT
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+160
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 ; reg-storage
 
Rct dd 0 ; reg content
Reg dd 0x00 ; reg number
 
 
title db ' RS780 NB MISC Indirect Registers ',0
;------------------------------------------------------------------------------------
reg_str db 'Reg#| hex.Value '
;------------------------------------------------------------------------------------
str1 db 'access addr:'
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 '---------------- Indirect registers shortlist --------------------'
db ' '
info2 db ' reg00: hides acces to pcie config registers and some hardware '
db ' reg08,0B : PCIe link config & IOC control '
db ' reg0C : select/disable bridges '
db ' reg32-39, 22-26 : PCIE_NBCONFIG bits '
db ' reg40-43 : GPIO pads | regs74-79 : SCRATCH '
db '------------------------------------------------------------------'
info_end:
 
I_END: ; end of program
 
rd 256
 
align 256
st_0:
/kernel/branches/Kolibri-A/utilities/RS780/NB_TST.ASM
0,0 → 1,344
;; rs780 NB config regs test
;; (C) art_zh 2010
;; <kolibri@jerdev.co.uk>
 
 
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 0xF0000000 ; bus 0, dev 0 fn 0 -- don't change!
BOX_COLOR equ 0xE0D8D0
 
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
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, 72*65536+530, 120*65536+290, 0x14A0B0A0,,title
; -----------------------------------------------------------------
; BUTTONS: Xleft Xwid, Ytop Yheig
mcall 8, 370*65536+ 40, 26*65536+ 18, 2, 0xA0B0A0 ; <<
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
 
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 ' RS780 NB config registers ',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 '------------------------------------------------------------------'
info2 db ' '
db ' AMD RS780 NorthBridge Monitor '
db ' '
db ' (C) A.Jerdev 2010 <kolibri@jerdev.co.uk> '
db '------------------------------------------------------------------'
info_end:
 
I_END: ; end of program
 
rd 256
 
align 256
st_0:
/kernel/branches/Kolibri-A/utilities/RS780/PCIEINDC.ASM
0,0 → 1,324
;; rs780 PCIe Core indirect regs test
;; (C) art_zh 2010
;; <kolibri@jerdev.co.uk>
 
 
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
PCIEIND_INDEX equ 0xF00000E0
PCIEIND_DATA equ 0xF00000E4
BOX_COLOR equ 0xE0D8D0
 
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_pcieind
 
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_pcieind
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_pcieind:
; in: [Reg] = reg# | out: eax = [Rct] = data
;------------------------------------------------
mov edx, PCIEIND_INDEX
xor eax, eax
mov al, byte [Reg]
; or eax, 0x00020000 ; 2=translate to GPP; 1 = to SB; 0 = GFX (default)
mov [edx], eax
add dl, 4
mov eax, [edx]
mov [Rct], eax
ret
 
;------------------------------------------------
write_pcieind:
; in: [Reg] = reg#; [Rct] = data
;------------------------------------------------
mov edx, PCIEIND_INDEX
xor eax, eax
mov al, byte [Reg]
; set bits [18:16] as shown above^ to access GPP os SB bridges ^
mov [edx], eax
add dl, 4
mov eax, [Rct]
mov [edx], eax
sub dl, 4
xor eax, eax ; reg#1 = SCRATCH
inc al
mov [edx], eax ; safely switch the index
ret
 
 
;------------------------------------------------
draw_window:
;------------------------------------------------
 
 
mcall 12, 1
mcall 0, 600*65536+530, 410*65536+290, 0x1494A0B0,,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_pcieind
 
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_pcieind
mov ecx, PCIEIND_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
 
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 ' RS780 PCIe Core indirect registers ',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 '------------- PCIe Core indirect registers shortlist -------------'
db '| |'
info2 db '| reg 13 - timeout status; 28,29 - line control |'
db '| reg 41 - buffer status; 42 - decoder errors |'
db '| reg 46 - symbol control; 60-62 impedance/strength control |'
db '| reg 71-78 latency control; 82-8F ??? |'
db '| reg EF - ERROR RESET; F0-FF error counters |'
db '------------------------------------------------------------------'
info_end:
 
I_END: ; end of program
 
rd 256
 
align 256
st_0:
/kernel/branches/Kolibri-A/utilities/RS780/PCIEINDP.ASM
0,0 → 1,322
;; rs780 PCIe Port indirect regs test
;; (C) art_zh 2010
;; <kolibri@jerdev.co.uk>
 
 
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
PCIEINDP_INDEX equ 0xF00100E0
PCIEINDP_DATA equ 0xF00100E4 ; bus 0, dev 2
BOX_COLOR equ 0xE0D8D0
 
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_pcieind_p
 
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_pcieind_p
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_pcieind_p:
; in: [Reg] = reg# | out: eax = [Rct] = data
;------------------------------------------------
mov edx, PCIEINDP_INDEX
xor eax, eax
mov ax, word [Reg]
mov [edx], eax
add dl, 4
mov eax, [edx]
mov [Rct], eax
ret
 
;------------------------------------------------
write_pcieind_p:
; in: [Reg] = reg#; [Rct] = data
;------------------------------------------------
mov edx, PCIEINDP_INDEX
xor eax, eax
mov ax, word [Reg]
mov [edx], eax
add dl, 4
mov eax, [Rct]
mov [edx], eax
sub dl, 4
xor eax, eax ; reg#1 = SCRATCH
inc al
mov [edx], eax ; safely switch the index
ret
 
 
;------------------------------------------------
draw_window:
;------------------------------------------------
 
 
mcall 12, 1
mcall 0, 1128*65536+530, 410*65536+290, 0x14B4A0A0,,title
; -----------------------------------------------------------------
; BUTTONS: Xleft Xwid, Ytop Yheig
mcall 8, 370*65536+ 40, 26*65536+ 18, 2, 0xB4A0A0 ; <<
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_pcieind_p
 
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_pcieind_p
mov ecx, PCIEINDP_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
 
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 ' RS780 PCIe GFX Port indirect registers ',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 '----------- PCIe GFX port indirect registers shortlist -----------'
db '| |'
info2 db '| reg 10 - port control; 20-25 - Tx control |'
db '| reg 30-36 - Tx credits; 50 - line status |'
db '| reg 60-62 - flow control; 70-72 Rx control |'
db '| reg 80-84 - Rx credits; A0,B1-B5 line control |'
db '| reg A1-A6 - lane training; A4 - speed control |'
db '------------------------------------------------------------------'
info_end:
 
I_END: ; end of program
 
rd 256
 
align 256
st_0:
/kernel/branches/Kolibri-A/utilities/RS780/PCIETST.ASM
0,0 → 1,346
;; rs780 PCIe config space test
;; (C) art_zh 2010
;; <kolibri@jerdev.co.uk>
 
 
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 0xF0008000 ; bdf0:1.0 = internal GFX P2P bridge
PCIE_ADDR equ 0xF0010000 ; bdf0:2.0 = PCIE P2P bridge
BOX_COLOR equ 0xE0D8D0
 
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
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
 
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 ' RS780 PCIe registers ',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): 9602=int. GFX; 9603=PCIE GFX bridge |'
db '| reg |'
db '| reg |'
db '| reg |'
db '------------------------------------------------------------------'
info_end:
 
I_END: ; end of program
 
rd 256
 
align 256
st_0:
/kernel/branches/Kolibri-A/utilities/RS780/XLX_TST.ASM
0,0 → 1,345
;; ZiS-3 board test
;; (C) art_zh 2010
;; <artem@jerdev.co.uk>
 
 
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 0xF0200000 ; bus 2, dev 0 fn 0
BOX_COLOR equ 0xE0D8D0
 
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
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, 1128*65536+530, 120*65536+290, 0x14B6A0A0,,title
; -----------------------------------------------------------------
; BUTTONS: Xleft Xwid, Ytop Yheig
mcall 8, 370*65536+ 40, 26*65536+ 18, 2, 0xB6A0A0 ; <<
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
 
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 ' ZiS-3 monitor (C) A.Jerdev 2010',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 68: Device Status + Device Control register |'
db '| reg 6C: PCIe Capability register. |'
db '| reg 70: PCIe Status register. |'
db '| reg 00: Vendor = 10EE, Device = 0007 |'
db '------------------------------------------------------------------'
info_end:
 
I_END: ; end of program
 
rd 256
 
align 256
st_0: